Skip to content

Commit 042db73

Browse files
sbrunkraulraja
andauthored
Add static apply method to enable creating RequestConfig from Scala (#285)
* Add static apply method to enable creating RequestConfig from Scala Fixes #275 * `./gradlew spotlessApply` --------- Co-authored-by: Raúl Raja Martínez <[email protected]>
1 parent 84960ca commit 042db73

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
package com.xebia.functional.xef.llm.models.embeddings
22

33
import kotlin.jvm.JvmInline
4+
import kotlin.jvm.JvmStatic
45

56
data class RequestConfig(val model: EmbeddingModel, val user: User) {
67
companion object {
8+
@JvmStatic
9+
fun apply(model: EmbeddingModel, userId: String): RequestConfig {
10+
return RequestConfig(model, User(userId))
11+
}
12+
713
@JvmInline value class User(val id: String)
814
}
915
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.xebia.functional.xef.llm.models.embeddings
2+
3+
import munit.FunSuite
4+
5+
class RequestConfigSpec extends FunSuite:
6+
7+
test("Should create a RequestConfig through the static apply method") {
8+
val requestConfig = RequestConfig(EmbeddingModel.TEXT_EMBEDDING_ADA_002, "user")
9+
10+
assertEquals(requestConfig.getModel, EmbeddingModel.TEXT_EMBEDDING_ADA_002)
11+
}

0 commit comments

Comments
 (0)