Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

Added response_format capabilities to chat completion request #402

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

Conversation

PrimosK
Copy link

@PrimosK PrimosK commented Nov 14, 2023

Added response_format capabilities including integration test.

@PrimosK PrimosK changed the title Added response_format capabilities for chat completion response format Added response_format capabilities to chat completion request Nov 14, 2023
@n-saw
Copy link

n-saw commented Nov 17, 2023

Would also love to see the support for 'seed' in the request (as the latest OpenAI adds support for adding a random generator seed)

fallbackwjj added a commit to fallbackwjj/openai-java that referenced this pull request Nov 22, 2023
@Be-poz
Copy link

Be-poz commented Nov 29, 2023

I wonder when this PR code will be released.

@LTMenezes
Copy link

I also need this PR merged, let me know if I can help with anything for the review.

@YanWittmann
Copy link

Also interested in this, are there any updates?

@MrDalili
Copy link

MrDalili commented Dec 6, 2023

We need this module very much, please merge this PR as soon as possible 😭

@gorkemblm
Copy link

Hey @TheoKanning , is there anything we can do to speed up this process?

@KevinGu
Copy link

KevinGu commented Dec 8, 2023

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);
    }

@Be-poz
Copy link

Be-poz commented Dec 22, 2023

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)

Ran-Mewo added a commit to Ran-Mewo/openai-java that referenced this pull request Jan 3, 2024
@mbayou
Copy link

mbayou commented Jan 12, 2024

@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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants