Skip to content

Commit d4f866e

Browse files
tenthetzolov
authored andcommitted
Update documentation for azure open ai chat
1 parent bc7460b commit d4f866e

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

spring-ai-docs/src/main/antora/modules/ROOT/pages/api/chat/azure-openai-chat.adoc

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -216,24 +216,25 @@ Next, create an `AzureOpenAiChatClient` instance and use it to generate text res
216216

217217
[source,java]
218218
----
219-
var openAIClient = OpenAIClientBuilder()
220-
.credential(new AzureKeyCredential(System.getenv("AZURE_OPENAI_API_KEY")))
221-
.endpoint(System.getenv("AZURE_OPENAI_ENDPOINT"))
222-
.buildClient();
223-
224-
var chatClient = new AzureOpenAiChatClient(openAIClient).withDefaultOptions(
225-
AzureOpenAiChatOptions.builder()
226-
.withModel("gpt-35-turbo")
227-
.withTemperature(0.4)
228-
.withMaxTokens(200)
229-
.build());
219+
var openAIClient = new OpenAIClientBuilder()
220+
.credential(new AzureKeyCredential(System.getenv("AZURE_OPENAI_API_KEY")))
221+
.endpoint(System.getenv("AZURE_OPENAI_ENDPOINT"))
222+
.buildClient();
223+
224+
var openAIChatOptions = AzureOpenAiChatOptions.builder()
225+
.withDeploymentName("gpt-35-turbo")
226+
.withTemperature(0.4f)
227+
.withMaxTokens(200)
228+
.build();
229+
230+
var chatClient = new AzureOpenAiChatClient(openAIClient, openAIChatOptions);
230231
231232
ChatResponse response = chatClient.call(
232-
new Prompt("Generate the names of 5 famous pirates."));
233+
new Prompt("Generate the names of 5 famous pirates."));
233234
234235
// Or with streaming responses
235236
Flux<ChatResponse> response = chatClient.stream(
236-
new Prompt("Generate the names of 5 famous pirates."));
237+
new Prompt("Generate the names of 5 famous pirates."));
237238
238239
----
239240

0 commit comments

Comments
 (0)