Skip to content

Commit 471497a

Browse files
committed
add token as parameter to openAI fn falling back to env variable
1 parent a629d15 commit 471497a

File tree

1 file changed

+2
-2
lines changed
  • core/src/commonMain/kotlin/com/xebia/functional/xef/auto

1 file changed

+2
-2
lines changed

core/src/commonMain/kotlin/com/xebia/functional/xef/auto/AIRuntime.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ data class AIRuntime<A>(val runtime: suspend (block: AI<A>) -> A) {
1414
companion object {
1515
@OptIn(ExperimentalTime::class)
1616
@JvmStatic
17-
fun <A> openAI(): AIRuntime<A> = AIRuntime { block ->
17+
fun <A> openAI(token: String? = null): AIRuntime<A> = AIRuntime { block ->
1818
val openAIConfig =
1919
OpenAIConfig(
20-
token =
20+
token = token ?:
2121
requireNotNull(getenv("OPENAI_TOKEN")) { "OpenAI Token missing from environment." },
2222
)
2323
val openAI = OpenAI(openAIConfig)

0 commit comments

Comments
 (0)