From d4f866ed3acff1e0e20f88fbe35e003709671023 Mon Sep 17 00:00:00 2001 From: Philipp Zehnder Date: Thu, 11 Apr 2024 19:10:51 +0200 Subject: [PATCH] Update documentation for azure open ai chat --- .../pages/api/chat/azure-openai-chat.adoc | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/spring-ai-docs/src/main/antora/modules/ROOT/pages/api/chat/azure-openai-chat.adoc b/spring-ai-docs/src/main/antora/modules/ROOT/pages/api/chat/azure-openai-chat.adoc index 063fb6ba2..000d7f4c4 100644 --- a/spring-ai-docs/src/main/antora/modules/ROOT/pages/api/chat/azure-openai-chat.adoc +++ b/spring-ai-docs/src/main/antora/modules/ROOT/pages/api/chat/azure-openai-chat.adoc @@ -216,24 +216,25 @@ Next, create an `AzureOpenAiChatClient` instance and use it to generate text res [source,java] ---- -var openAIClient = OpenAIClientBuilder() - .credential(new AzureKeyCredential(System.getenv("AZURE_OPENAI_API_KEY"))) - .endpoint(System.getenv("AZURE_OPENAI_ENDPOINT")) - .buildClient(); +var openAIClient = new OpenAIClientBuilder() + .credential(new AzureKeyCredential(System.getenv("AZURE_OPENAI_API_KEY"))) + .endpoint(System.getenv("AZURE_OPENAI_ENDPOINT")) + .buildClient(); -var chatClient = new AzureOpenAiChatClient(openAIClient).withDefaultOptions( - AzureOpenAiChatOptions.builder() - .withModel("gpt-35-turbo") - .withTemperature(0.4) - .withMaxTokens(200) - .build()); +var openAIChatOptions = AzureOpenAiChatOptions.builder() + .withDeploymentName("gpt-35-turbo") + .withTemperature(0.4f) + .withMaxTokens(200) + .build(); + +var chatClient = new AzureOpenAiChatClient(openAIClient, openAIChatOptions); ChatResponse response = chatClient.call( - new Prompt("Generate the names of 5 famous pirates.")); + new Prompt("Generate the names of 5 famous pirates.")); // Or with streaming responses Flux response = chatClient.stream( - new Prompt("Generate the names of 5 famous pirates.")); + new Prompt("Generate the names of 5 famous pirates.")); ----