Skip to content

Use capabilities instead of instanceof checks #299

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

JoshuaBehrens
Copy link
Contributor

@JoshuaBehrens JoshuaBehrens commented Aug 11, 2025

This commit bricks some code flows. Other changes needs to be done as well. See #300

Q A
Bug fix? "yes"
New feature? no
Docs? no
Issues Fix #114
License MIT

In other issues and pull requests the model class should be used as a simple struct, only holding scalar values and should not have any business logic effect by inheritance. This has been the case for embeddings, completions and other API calls like Whisper audio, and Dall-e images. Right now this makes it difficult to share different instances of the model class with various providers, although a lot of providers share the same models, and therefore likely the same capabilities. This eventually will reduce the amount of code you have to write to establish new providers that replicate existing API's with a well-known subset of models or add better support for custom models like OpenAI fine-tuned models or ollamas self-built models.

To stop this, I have changed all instanceof checks matching a specific model subclass to refer to the expected input or output capabilities of the model, that were implemented in the specific messagenormalizer, resultconverter or modelclient. It was sometimes not easy to decide, which approach to go as not every input has a corresponding output capability. Some are merged behind a helpful name like tool calling or but when you are not familiar with the underlying decisions the name input_multiple is not easily relatable to a vector calculations done by embeddings features. So either this could need a refreshing rename, new capability or some documentation around it on the capability enum.

…ring pre-request situations to reduce dependency on specific model class
…ace during pre-request situations to reduce dependency on specific model class
…e during response situations to reduce dependency on specific model class
@JoshuaBehrens JoshuaBehrens marked this pull request as ready for review August 11, 2025 03:15
@carsonbot carsonbot changed the title Use capabilities instead of instanceof checks Use capabilities instead of instanceof checks Aug 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Custom URL ability or generic bridges?
2 participants