-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into build-platform-matrix
- Loading branch information
Showing
68 changed files
with
1,092 additions
and
830 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 8 additions & 28 deletions
36
core/src/commonMain/kotlin/com/xebia/functional/xef/auto/AIRuntime.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,12 @@ | ||
package com.xebia.functional.xef.auto | ||
|
||
import com.xebia.functional.xef.embeddings.OpenAIEmbeddings | ||
import com.xebia.functional.xef.env.OpenAIConfig | ||
import com.xebia.functional.xef.llm.openai.KtorOpenAIClient | ||
import com.xebia.functional.xef.llm.openai.LLMModel | ||
import com.xebia.functional.xef.vectorstores.LocalVectorStore | ||
import kotlin.jvm.JvmStatic | ||
import kotlin.time.ExperimentalTime | ||
import com.xebia.functional.xef.embeddings.Embeddings | ||
import com.xebia.functional.xef.llm.AIClient | ||
|
||
data class AIRuntime<A>(val runtime: suspend (block: AI<A>) -> A) { | ||
companion object { | ||
@OptIn(ExperimentalTime::class) | ||
@JvmStatic | ||
fun <A> openAI(): AIRuntime<A> = AIRuntime { block -> | ||
val openAIConfig = OpenAIConfig() | ||
KtorOpenAIClient(openAIConfig).use { openAiClient -> | ||
val embeddings = OpenAIEmbeddings(openAIConfig, openAiClient) | ||
val vectorStore = LocalVectorStore(embeddings) | ||
val scope = | ||
CoreAIScope( | ||
defaultModel = LLMModel.GPT_3_5_TURBO_16K, | ||
defaultSerializationModel = LLMModel.GPT_3_5_TURBO_FUNCTIONS, | ||
aiClient = openAiClient, | ||
context = vectorStore, | ||
embeddings = embeddings | ||
) | ||
block(scope) | ||
} | ||
} | ||
} | ||
data class AIRuntime<A>( | ||
val client: AIClient, | ||
val embeddings: Embeddings, | ||
val runtime: suspend (block: AI<A>) -> A | ||
) { | ||
companion object | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 0 additions & 31 deletions
31
core/src/commonMain/kotlin/com/xebia/functional/xef/auto/Solution.kt
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
core/src/commonMain/kotlin/com/xebia/functional/xef/embeddings/Embeddings.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 0 additions & 21 deletions
21
core/src/commonMain/kotlin/com/xebia/functional/xef/env/config.kt
This file was deleted.
Oops, something went wrong.
28 changes: 28 additions & 0 deletions
28
core/src/commonMain/kotlin/com/xebia/functional/xef/llm/AIClient.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.xebia.functional.xef.llm | ||
|
||
import com.xebia.functional.xef.llm.models.chat.ChatCompletionRequest | ||
import com.xebia.functional.xef.llm.models.chat.ChatCompletionRequestWithFunctions | ||
import com.xebia.functional.xef.llm.models.chat.ChatCompletionResponse | ||
import com.xebia.functional.xef.llm.models.chat.ChatCompletionResponseWithFunctions | ||
import com.xebia.functional.xef.llm.models.embeddings.EmbeddingRequest | ||
import com.xebia.functional.xef.llm.models.embeddings.EmbeddingResult | ||
import com.xebia.functional.xef.llm.models.images.ImagesGenerationRequest | ||
import com.xebia.functional.xef.llm.models.images.ImagesGenerationResponse | ||
import com.xebia.functional.xef.llm.models.text.CompletionRequest | ||
import com.xebia.functional.xef.llm.models.text.CompletionResult | ||
|
||
interface AIClient : AutoCloseable { | ||
suspend fun createCompletion(request: CompletionRequest): CompletionResult | ||
|
||
suspend fun createChatCompletion(request: ChatCompletionRequest): ChatCompletionResponse | ||
|
||
suspend fun createChatCompletionWithFunctions( | ||
request: ChatCompletionRequestWithFunctions | ||
): ChatCompletionResponseWithFunctions | ||
|
||
suspend fun createEmbeddings(request: EmbeddingRequest): EmbeddingResult | ||
|
||
suspend fun createImages(request: ImagesGenerationRequest): ImagesGenerationResponse | ||
|
||
override fun close() {} | ||
} |
Oops, something went wrong.