Skip to content

AzureOpenAiChatModel and issues with Structured JSON schema output #1953

@henkka14

Description

@henkka14

Is there currently any option for io.quarkiverse.langchain4j.azure.openai.AzureOpenAiChatModel to support structured JSON output?

https://techcommunity.microsoft.com/blog/azure-ai-foundry-blog/introducing-gpt-4o-2024-08-06-api-with-structured-outputs-on-azure/4232684

Based on my testing the jsonSchema argument for ResponseFormat is not utilized by AzureOpenAiChatModel.

ResponseFormat format = ResponseFormat.builder()
        .type(ResponseFormatType.JSON)
        .jsonSchema(getSchema())
        .build();

ChatRequest chatRequest = ChatRequest.builder()
        .responseFormat(format)
        .messages(messages)
        .build();

ChatResponse response = model.chat(chatRequest); // will not use the schema

However, I have been able to receive structured JSON outputs for my gpt-4o model using the dev.langchain4j.model.azure.AzureOpenAiChatModel implementation.
https://github.com/langchain4j/langchain4j/blob/main/docs/docs/integrations/language-models/azure-open-ai.md#structured-outputs

Perhaps similar supportedCapabilities(Set.of(RESPONSE_FORMAT_JSON_SCHEMA)) option is needed for io.quarkiverse model? Or has anyone successfully received structed JSON output with the current io.quarkiverse implementation from Azure OpenAI model deployment?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions