Skip to content

Commit

Permalink
Update azure-openai-chat.adoc
Browse files Browse the repository at this point in the history
Signed-off-by: jaeyeonling <[email protected]>
  • Loading branch information
jaeyeonling authored and ilayaperumalg committed Feb 27, 2025
1 parent 6be3d0a commit 6cb15e4
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -335,24 +335,26 @@ 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")
.temperature(0.4)
.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."));
----
Expand Down

0 comments on commit 6cb15e4

Please sign in to comment.