Added `response_format` capabilities to chat completion request
Would also love to see the support for 'seed' in the request (as the latest OpenAI adds support for adding a random generator seed)
I wonder when this PR code will be released.
I also need this PR merged, let me know if I can help with anything for the review.
Also interested in this, are there any updates?
We need this module very much, please merge this PR as soon as possible 😭
Hey @TheoKanning , is there anything we can do to speed up this process?
alternative way
public class JsonChatCompletionRequest {
@JsonProperty("response_format")
String responseFormat = "json_object";
}
OpenAiService getClient(String key, boolean jsonMode) {
ObjectMapper mapper = defaultObjectMapper();
if (jsonMode) {
mapper.addMixIn(ChatCompletionRequest.class, JsonChatCompletionRequest.class);
}
OkHttpClient client = defaultClient(key, Duration.ofMillis(5 * 60 * 1000))
.newBuilder()
.build();
Retrofit retrofit = defaultRetrofit(client, mapper);
OpenAiApi api = retrofit.create(OpenAiApi.class);
return new OpenAiService(api);
}
I just used this way
class ChatCompletionJsonRequest(target: ChatCompletionRequest) : ChatCompletionRequest(
target.model, target.messages, target.temperature, target.topP, target.n, target.stream, target.stop,
target.maxTokens, target.presencePenalty, target.frequencyPenalty, target.logitBias, target.user, target.functions, target.functionCall
) {
@JsonProperty("response_format")
val responseFormat: ResponseFormat = ResponseFormat("json_object")
}
data class ResponseFormat(val type: String)
@TheoKanning please let us know how we can help to speed it up. Might be interesting to look into having some community admin that could approve those PR and merge them.