Update azure-openai-chat.adoc

Signed-off-by: jaeyeonling <jaeyeonling@gmail.com>
This commit is contained in:
Jaeyeon Kim
2025-02-20 02:17:58 +09:00
committed by Ilayaperumal Gopinathan
parent 6be3d0a809
commit 6cb15e4727

View File

@@ -335,10 +335,9 @@ Next, create an `AzureOpenAiChatModel` instance and use it to generate text resp
[source,java]
----
var openAIClient = new OpenAIClientBuilder()
var openAIClientBuilder = new OpenAIClientBuilder()
.credential(new AzureKeyCredential(System.getenv("AZURE_OPENAI_API_KEY")))
.endpoint(System.getenv("AZURE_OPENAI_ENDPOINT"))
.buildClient();
.endpoint(System.getenv("AZURE_OPENAI_ENDPOINT"));
var openAIChatOptions = AzureOpenAiChatOptions.builder()
.deploymentName("gpt-4o")
@@ -346,13 +345,16 @@ var openAIChatOptions = AzureOpenAiChatOptions.builder()
.maxTokens(200)
.build();
var chatModel = new AzureOpenAiChatModel(this.openAIClient, this.openAIChatOptions);
var chatModel = AzureOpenAiChatModel.builder()
.openAIClientBuilder(openAIClientBuilder)
.defaultOptions(openAIChatOptions)
.build();
ChatResponse response = this.chatModel.call(
ChatResponse response = chatModel.call(
new Prompt("Generate the names of 5 famous pirates."));
// Or with streaming responses
Flux<ChatResponse> response = this.chatModel.stream(
Flux<ChatResponse> streamingResponses = chatModel.stream(
new Prompt("Generate the names of 5 famous pirates."));
----