-
-
Notifications
You must be signed in to change notification settings - Fork 103
[Platform][Ollama] FallbackModelCatalog
for custom platform
#766
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
base: main
Are you sure you want to change the base?
Conversation
Another approach would be to define a catalog for each platform when needed (Ollama requires a custom one, it's probably the only one with ElevenLabs) and inject it as the default implementation for the platform. |
I think it's better to open up the FallbackModelCatalog to be able to receive additional models configured from the outside (like for the real ModelCatalog's), check these first and if not go with the Model::class as default. WDYT? |
Not sure about the implementation but I get the idea of accepting additional models 🤔 My main concern is about the capability to add those models at runtime, my issue here is that if I'm using models stored in Ollama but not in the catalog (so I can't configure them / add them in the catalog directly), the catalog is returning a |
Another approach would be to build the catalog from the Ollama API directly, something similar to what we're doing in the |
Yes, but not all models are available and in the end you cannot be up to date in the end always, so we need to have the option to be able to provide custom models. Take Azure for example, you need to deploy some models, so no model catalog for azure will look the same for a user... |
What if we're building the catalog directly from the API for specific platform? What I mean is that in the catalog, we can query the API (when available) and build the model list from it then if a list of models is provided in the constructor, we can merge both at the end of the method, WDYT? 🤔 |
I am not convinced about doing this on runtime, it can be costly, we would need to introduce caches etc. WDYT @chr-hertel |
I pushed a POC, the idea is to move the code that we already have in the |
], | ||
]); | ||
|
||
$payload = $response->toArray(); |
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.
now you would need to implement the option handling etc here as well
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.
Hum, maybe we can do parent::getModel()
to retrieve an object with its options then transform it into the correct model 🤔
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.
Something like:
public function getModel(string $modelName): Model
{
$model = parent::getModel($modelName);
$response = $this->httpClient->request('POST', \sprintf('%s/api/show', $this->host), [
'json' => [
'model' => $model->getName(),
],
]);
$payload = $response->toArray();
if ([] === $payload['capabilities'] ?? []) {
throw new InvalidArgumentException('The model information could not be retrieved from the Ollama API. Your Ollama server might be too old. Try upgrade it.');
}
return new Ollama($modelName, $payload['capabilities']);
}
a00950d
to
8431479
Compare
I don't think it's an issue here. The first call is a fraction of the time compared to the main call later, and we're talking local execution only anyways. but i agree that at least the |
@chr-hertel What about using the |
same like PSR cache. sugar on top & introducing new concerns. not needed from my side for a first PR |
FallbackModelCatalog
for custom platform
For reference: I already updated the PR header and title with the new term I will come up with a proposal shortly |
Hi 👋🏻
It looks like when we're dealing with platforms that can list / detain multiple models at once, the default catalog is "a fixed one", when trying to add a
FallbackModelCatalog
, the platform fails to retrieve the model as most of them use a customModel
class, this PR aims to introduce / fix the issue with an extra argument.I know that the solution is not perfect, my main concern is the problem we're facing as we have custom models classes, that's the only way I found to prevent the error:
This approach allows to use any model stored in the platform (especially as the ones listed in the default catalog are not up-to-date).