StefanBratanov / jvm-openai

A minimalistic OpenAI API client for the JVM, written in Java 🤖
Apache License 2.0
58 stars 11 forks source link

Add CompletionModel class - narrower scope #5

Closed maciej-cz closed 5 months ago

maciej-cz commented 6 months ago

First of all, thanks for your effort of creating this project @StefanBratanov . It makes OpenAI usage much more convenient.

Now, to the point, the purpose of this change is to replace completion model parameter (currently String) with a value object with predefined values available.

I created 2 versions of this change (the other one is #4). This one is a bit narrower:

Please suggest, which version you prefer (if any).

In case of positive feedback, I can spread this change to other APIs' models.

maciej-cz commented 6 months ago

I am thinking CompletionModel can be renamed to OpenAIModel and then all models can be put there and used by the different builders in future PRs. This way there would be no need to maintain several classes and would keep the library easier to maintain and to reason about

My intention was to only allow suitable models per endpoint (e.g. to not be able to use dall-e model for completion). But this approach has the maintenance overhead drawback you mentioned.

I'll apply your suggestions (hopefully today) and propagate OpenAIModel to other places.

StefanBratanov commented 5 months ago

Thanks for the fix. The failing tests are because pull request builds don't get access to secrets. Will merge this one and figure out how to do this for any future PRs.

StefanBratanov commented 5 months ago

Fixed it in https://github.com/StefanBratanov/jvm-openai/commit/fe3239249f83dfa2c06f21304fb593c55304fbed. Future PRs should be able to have green builds and don't run the integration tests. Thanks again for this change. Will include it in the next release. Just need to finish off the Assistants streaming functionality first.