Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added responseFormat to Azure OpenAi Chat Model #483

Merged
merged 1 commit into from
Apr 22, 2024

Conversation

UnvirtualHH
Copy link

@UnvirtualHH UnvirtualHH commented Apr 22, 2024

@@ -116,7 +120,8 @@ private Response<AiMessage> generate(List<ChatMessage> messages,
.topP(topP)
.maxTokens(maxTokens)
.presencePenalty(presencePenalty)
.frequencyPenalty(frequencyPenalty);
.frequencyPenalty(frequencyPenalty)
.responseFormat(responseFormat);
Copy link

@Plawn Plawn Apr 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the Lang4Chain documentation, I see

AzureOpenAiChatModel.builder()
        ...
        .responseFormat(new ChatCompletionsJsonResponseFormat())
        .build();

I don't see, how the correct item is injected in the builder here, is it actually working as expected ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, yes, it works as Expected. ChatCompletionsJsonResponseFormat is also possible, but you lose the flexibility of changing it over the application properties. It is now implemented the same way as for the open ai part directly.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks !

@@ -205,6 +205,11 @@ public Double frequencyPenalty() {
return null;
}

@Override
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't a test case for the JSON use be added as well ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testing is for beginners, expert just do it ;) Well, without joking, for sure a test could be added, but I needed a quick working version and I'm pretty sure that the impact from this change is minimal to the rest of the code.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I'm sure it won't break the rest of the code :)
Just in case, this changes, the code won't be protected :)
If I have the time, I'll try to add a test

@geoand geoand self-requested a review April 22, 2024 12:16
Copy link
Collaborator

@geoand geoand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@geoand geoand merged commit 8287330 into quarkiverse:main Apr 22, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

How to enable JSON mode for azure-openai ?
4 participants