-
Notifications
You must be signed in to change notification settings - Fork 205
Add dynamic model discovery and fix tool call IDs for Ollama client #144
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
Conversation
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.
Hello @Kashif-E! Thank you for your contribution!
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.
That's far better than what I did in my PR.
In my opinion, we have to use the real model name advertised by Ollama, without any prefix added.
...ama-client/src/commonMain/kotlin/ai/koog/prompt/executor/ollama/client/OllamaModelManager.kt
Show resolved
Hide resolved
...ama-client/src/commonMain/kotlin/ai/koog/prompt/executor/ollama/client/OllamaModelManager.kt
Show resolved
Hide resolved
...a-client/src/commonMain/kotlin/ai/koog/prompt/executor/ollama/client/dto/OllamaConverters.kt
Show resolved
Hide resolved
...or-ollama-client/src/commonMain/kotlin/ai/koog/prompt/executor/ollama/client/OllamaClient.kt
Show resolved
Hide resolved
@Rizzen wow, you merged really fast. Can I do a PR with the changes that I propose above? |
@ptitjes Yeah, I merged it pretty fast because we're working on actual ollama integration tests right now, and these changes are very useful. I suggest to wait for PR with these tests and then make PR with your proposals. What do you think about it? |
resoling conversations for now |
This pull request introduces significant enhancements to the
OllamaClient
and its associated components, enabling dynamic model management and improving the flexibility of interacting with the Ollama API. The most notable changes include adding support for dynamic model resolution, introducing a newOllamaModelFactory
for creating models, and implementing aOllamaModelManager
for managing model discovery and capabilities. These changes collectively enhance the modularity and extensibility of the Ollama client.Enhancements to
OllamaClient
:enableDynamicModels
property, allowing models to be resolved dynamically using theOllamaModelResolver
. This impacts methods likeexecute
,stream
, andembed
, which now use dynamically resolved model names.getAvailableModels
,resolveModel
,createDynamicModel
,pullModel
, andsuggestSimilarModels
, providing extended functionality for model management.Introduction of
OllamaModelFactory
:OllamaModelFactory
class to create and manage Ollama models dynamically. This includes methods for creating models from names, listing available models, grouping models by family, and finding models by patterns.Introduction of
OllamaModelManager
:OllamaModelManager
class to handle model discovery, caching, and capability detection. It includes features like retrieving available models, resolving models, pulling models from the registry, and invalidating the model cache.Code Examples
Basic Agent with Dynamic Model Selection
Model Discovery and Management
Automatic Model Creation with Fallbacks
Temperature Control with Dynamic Models
These changes lay the groundwork for a more robust and flexible integration with the Ollama API, enabling dynamic and efficient model management without maintaining hardcoded model lists.
fixes #140
Type of the change
Checklist for all pull requests
develop
as the base branchAdditional steps for pull requests adding a new feature