-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CU-865cn6kqn Model capabilities and AIScope simplification. #214
Merged
Conversation
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
# Conflicts: # core/src/commonMain/kotlin/com/xebia/functional/xef/llm/openai/OpenAIEmbeddings.kt
# Conflicts: # core/src/commonMain/kotlin/com/xebia/functional/xef/auto/CoreAIScope.kt # core/src/commonMain/kotlin/com/xebia/functional/xef/llm/models/functions/CFunction.kt # core/src/commonMain/kotlin/com/xebia/functional/xef/llm/openai/models.kt # kotlin/src/commonMain/kotlin/com/xebia/functional/xef/auto/DeserializerLLMAgent.kt # kotlin/src/commonMain/kotlin/com/xebia/functional/xef/auto/serialization/functions/FunctionSchema.kt # scala/src/main/scala/com/xebia/functional/xef/scala/auto/package.scala
… and java depends on openai module for defaults. xef core does not depend on open ai
# Conflicts: # core/src/commonMain/kotlin/com/xebia/functional/xef/auto/AI.kt # core/src/commonMain/kotlin/com/xebia/functional/xef/auto/AIRuntime.kt # core/src/commonMain/kotlin/com/xebia/functional/xef/auto/AiDsl.kt # core/src/commonMain/kotlin/com/xebia/functional/xef/auto/CoreAIScope.kt # core/src/commonMain/kotlin/com/xebia/functional/xef/llm/models/chat/Message.kt # core/src/commonMain/kotlin/com/xebia/functional/xef/llm/models/chat/Role.kt # core/src/commonMain/kotlin/com/xebia/functional/xef/llm/models/text/CompletionRequest.kt # examples/kotlin/src/main/kotlin/com/xebia/functional/xef/auto/CustomRuntime.kt # java/src/main/java/com/xebia/functional/xef/java/auto/AIScope.java # openai/src/commonMain/kotlin/com/xebia/functional/xef/auto/llm/openai/DeserializerLLMAgent.kt # openai/src/commonMain/kotlin/com/xebia/functional/xef/auto/llm/openai/ImageGenerationAgent.kt # openai/src/commonMain/kotlin/com/xebia/functional/xef/auto/llm/openai/MockAIClient.kt # openai/src/commonMain/kotlin/com/xebia/functional/xef/auto/llm/openai/OpenAIClient.kt # openai/src/commonMain/kotlin/com/xebia/functional/xef/auto/llm/openai/OpenAIEmbeddings.kt # openai/src/commonMain/kotlin/com/xebia/functional/xef/auto/llm/openai/OpenAIRuntime.kt # scala/src/main/scala/com/xebia/functional/xef/scala/auto/package.scala
… local models. Local models can be use in the AI DSL and interleaved with any model.
… block and manual component construction
raulraja
changed the title
Model capabilities and AIScope simplification.
CU-865cn6kqn Model capabilities and AIScope simplification.
Jul 2, 2023
@xebia-functional/team-ai Ready for review |
- Replace blocks with equals / single expressions
diesalbla
force-pushed
the
gpt-4all-aiclient
branch
from
July 3, 2023 16:23
371067f
to
b9b6f05
Compare
diesalbla
approved these changes
Jul 3, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a few suggested changes .
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR aims to enhance the flexibility and robustness of the
ai
dsl by ensuring its compatibility with local models, alongside the existing OpenAI models.The
AIScope
cares about embeddings to index context in the store used in the operators. Still, it does not care about the models themselves or what they do because each model operation is independent of the scope and only uses the scope to retrieve the context in those operations where it's needed.The changes involve a major refactoring of
AIScope
, gets rid of the client dependencies, moving several responsibilities to the individual model implementation, which are now accurately typed based on their capabilities. This ensures that the usage of each model is transparent and explicit in the code, eliminating any hardcoded dependencies on OpenAI models.You can still achieve the same short syntax as before but must import it from the
openai
package defaults.You can also get a hold of default models and build your own without needing a
client
abstraction.Three layers of syntax are now available, including generic functions like
prompt
andpromptMessage
in AIScope that take a model as an argument or use it as the receiver, and similar functions available directly on the model and vendor defaults such as OpenAI. The syntax requests the VectorStore context or not as needed.Additionally, I added a way to have local embeddings computed in memory without calls to openAI and added it by default used in the GPT4ALL impl which now can do all Xef can do without Open AI except function serialization.
We use the AI DJL library to load a
Tokenizer
from huggingface and one of their embedding models. This is, for now, JVM only and lives in the GPT4All module, but it can be generalized if we find it works and we want to stop using the paid embeddings.Examples
New manual style without the AI block
We pass manually what otherwise is provided by the scope in an
ai
block:Explicit OpenAI imports:
Mixing local text models with image models in the same
ai
scope:This is all done locally, embeddings, context search and prompt: