openai-java icon indicating copy to clipboard operation
openai-java copied to clipboard

Provide statically typed model selection

Open yeikel opened this issue 1 year ago • 1 comments

It would be a nice-to-have to provide a mechanism to access models in a statically typed fashion rather than using the hard coded Strings.

From the onboarding example, rather than :



CompletionRequest completionRequest = CompletionRequest.builder()
        .prompt("Somebody once told me the world is gonna roll me")
        .model("ada")
        .echo(true)
        .build();

It would be nice to be able to do something like :



CompletionRequest completionRequest = CompletionRequest.builder()
        .prompt("Somebody once told me the world is gonna roll me")
        .model(Model.ada)
        .echo(true)
        .build();

With the current setup, it fails at runtime with a 404 when the model is invalid


Exception in thread "main" retrofit2.adapter.rxjava2.HttpException: HTTP 404 
	at retrofit2.adapter.rxjava2.BodyObservable$BodyObserver.onNext(BodyObservable.java:57)
	at retrofit2.adapter.rxjava2.BodyObservable$BodyObserver.onNext(BodyObservable.java:38)
	at retrofit2.adapter.rxjava2.CallExecuteObservable.subscribeActual(CallExecuteObservable.java:48)
	at io.reactivex.Observable.subscribe(Observable.java:10151)

yeikel avatar Jan 26 '23 00:01 yeikel