Use child model classes as factories instead #301
+244
−238
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 commit bricks several instanceof checks. Other changes needs to be done as well. See the other pull requests:
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.
This is pull request is about to suggest a way to reflector the usage of the model classes to only use the model class as a struct without using inheritance. I stick to the previous classes to simplify code changes and the current effects of different types of models being grouped in a class. The class hierarchy has been broken up, so the previously sub classes of the model class are no longer extending the model class, and the model of the class has been made final to prevent changes like this in the future. Right now, it will break instanceof checks in several classes and can only be merged if the linked requests merged. It is not part of the others, as the approach how to solve this particular issue can be discussed separately.