Skip to content

Commit

Permalink
ChatOptions migrated from Float to Double
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasVitale committed Sep 16, 2024
1 parent 0d5ca47 commit 7a26efb
Show file tree
Hide file tree
Showing 13 changed files with 32 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class StructuredDataExtractionService {
StructuredDataExtractionService(ChatClient.Builder chatClientBuilder) {
this.chatClient = chatClientBuilder
.defaultOptions(ChatOptionsBuilder.builder()
.withTemperature(0.0f)
.withTemperature(0.0)
.build())
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class TextClassifier {
TextClassifier(ChatClient.Builder chatClientBuilder) {
this.chatClient = chatClientBuilder
.defaultOptions(ChatOptionsBuilder.builder()
.withTemperature(0.0f)
.withTemperature(0.0)
.build())
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ String chatWithGenericOptions(@RequestParam(defaultValue = "What did Gandalf say
return chatClient.prompt()
.user(question)
.options(ChatOptionsBuilder.builder()
.withTemperature(0.9f)
.withTemperature(0.9)
.build())
.call()
.content();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ String chat(@RequestParam(defaultValue = "What did Gandalf say to the Balrog?")
@GetMapping("/chat/generic-options")
String chatWithGenericOptions(@RequestParam(defaultValue = "What did Gandalf say to the Balrog?") String question) {
return chatModel.call(new Prompt(question, ChatOptionsBuilder.builder()
.withTemperature(0.9f)
.withTemperature(0.9)
.build()))
.getResult().getOutput().getContent();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ String chatWithMistralAiOptions(@RequestParam(defaultValue = "What did Gandalf s
.user(question)
.options(MistralAiChatOptions.builder()
.withModel("open-mixtral-8x7b")
.withTemperature(1.0f)
.withTemperature(1.0)
.build())
.call()
.content();
Expand All @@ -57,7 +57,7 @@ String chatWithOpenAiOptions(@RequestParam(defaultValue = "What did Gandalf say
.user(question)
.options(OpenAiChatOptions.builder()
.withModel("gpt-4o-mini")
.withTemperature(1.0f)
.withTemperature(1.0)
.build())
.call()
.content();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ String chatOpenAi(@RequestParam(defaultValue = "What did Gandalf say to the Balr
String chatWithMistralAiOptions(@RequestParam(defaultValue = "What did Gandalf say to the Balrog?") String question) {
return mistralAiChatModel.call(new Prompt(question, MistralAiChatOptions.builder()
.withModel("open-mixtral-8x7b")
.withTemperature(1.0f)
.withTemperature(1.0)
.build()))
.getResult().getOutput().getContent();
}
Expand All @@ -48,7 +48,7 @@ String chatWithMistralAiOptions(@RequestParam(defaultValue = "What did Gandalf s
String chatWithOpenAiOptions(@RequestParam(defaultValue = "What did Gandalf say to the Balrog?") String question) {
return openAiChatModel.call(new Prompt(question, OpenAiChatOptions.builder()
.withModel("gpt-4o-mini")
.withTemperature(1.0f)
.withTemperature(1.0)
.build()))
.getResult().getOutput().getContent();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ String chatWithGenericOptions(@RequestParam(defaultValue = "What did Gandalf say
return chatClient.prompt()
.user(question)
.options(ChatOptionsBuilder.builder()
.withTemperature(0.9f)
.withTemperature(0.9)
.build())
.call()
.content();
Expand All @@ -45,7 +45,7 @@ String chatWithProviderOptions(@RequestParam(defaultValue = "What did Gandalf sa
.user(question)
.options(OllamaOptions.create()
.withModel("mistral")
.withRepeatPenalty(1.5f))
.withRepeatPenalty(1.5))
.call()
.content();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ String chat(@RequestParam(defaultValue = "What did Gandalf say to the Balrog?")
@GetMapping("/chat/generic-options")
String chatWithGenericOptions(@RequestParam(defaultValue = "What did Gandalf say to the Balrog?") String question) {
return chatModel.call(new Prompt(question, ChatOptionsBuilder.builder()
.withTemperature(0.9f)
.withTemperature(0.9)
.build()))
.getResult().getOutput().getContent();
}
Expand All @@ -40,7 +40,7 @@ String chatWithGenericOptions(@RequestParam(defaultValue = "What did Gandalf say
String chatWithProviderOptions(@RequestParam(defaultValue = "What did Gandalf say to the Balrog?") String question) {
return chatModel.call(new Prompt(question, OllamaOptions.create()
.withModel("mistral")
.withRepeatPenalty(1.5f)))
.withRepeatPenalty(1.5)))
.getResult().getOutput().getContent();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ String chatWithGenericOptions(@RequestParam(defaultValue = "What did Gandalf say
return chatClient.prompt()
.user(question)
.options(ChatOptionsBuilder.builder()
.withTemperature(0.9f)
.withTemperature(0.9)
.build())
.call()
.content();
Expand All @@ -45,7 +45,7 @@ String chatWithProviderOptions(@RequestParam(defaultValue = "What did Gandalf sa
.user(question)
.options(OpenAiChatOptions.builder()
.withModel("gpt-4o-mini")
.withTemperature(0.9f)
.withTemperature(0.9)
.withUser("jon.snow")
.build())
.call()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ String chat(@RequestParam(defaultValue = "What did Gandalf say to the Balrog?")
@GetMapping("/chat/generic-options")
String chatWithGenericOptions(@RequestParam(defaultValue = "What did Gandalf say to the Balrog?") String question) {
return chatModel.call(new Prompt(question, ChatOptionsBuilder.builder()
.withTemperature(0.9f)
.withTemperature(0.9)
.build()))
.getResult().getOutput().getContent();
}
Expand All @@ -40,7 +40,7 @@ String chatWithGenericOptions(@RequestParam(defaultValue = "What did Gandalf say
String chatWithProviderOptions(@RequestParam(defaultValue = "What did Gandalf say to the Balrog?") String question) {
return chatModel.call(new Prompt(question, OpenAiChatOptions.builder()
.withModel("gpt-4o-mini")
.withTemperature(0.9f)
.withTemperature(0.9)
.withUser("jon.snow")
.build()))
.getResult().getOutput().getContent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ String chat(@RequestParam(defaultValue = "What did Gandalf say to the Balrog?")
@GetMapping("/chat/generic-options")
String chatWithGenericOptions(@RequestParam(defaultValue = "What did Gandalf say to the Balrog?") String message) {
return chatModel.call(new Prompt(message, ChatOptionsBuilder.builder()
.withTemperature(1.3f)
.withTemperature(1.3)
.build()))
.getResult().getOutput().getContent();
}
Expand All @@ -43,8 +43,8 @@ String chatWithMistralAiOptions(@RequestParam(defaultValue = "What did Gandalf s
return chatModel.call(new Prompt(message, MistralAiChatOptions.builder()
.withMaxTokens(1500)
.withStop(List.of("this-is-the-end", "addio"))
.withTemperature(0.7f)
.withTopP(0.1f)
.withTemperature(0.7)
.withTopP(0.1)
.build()))
.getResult().getOutput().getContent();
}
Expand All @@ -53,7 +53,7 @@ String chatWithMistralAiOptions(@RequestParam(defaultValue = "What did Gandalf s
String chatWithFunctions(@RequestParam(defaultValue = "Philip Pullman") String author) {
return chatModel.call(new Prompt("What books written by %s are available to read and what is their bestseller?".formatted(author),
MistralAiChatOptions.builder()
.withTemperature(0.3f)
.withTemperature(0.3)
.withFunctions(Set.of("booksByAuthor", "bestsellerBookByAuthor"))
.build()))
.getResult().getOutput().getContent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,21 @@ String chat(@RequestParam(defaultValue = "What did Gandalf say to the Balrog?")
@GetMapping("/chat/generic-options")
String chatWithGenericOptions(@RequestParam(defaultValue = "What did Gandalf say to the Balrog?") String message) {
return chatModel.call(new Prompt(message, ChatOptionsBuilder.builder()
.withTemperature(1.3f)
.withTemperature(1.3)
.build()))
.getResult().getOutput().getContent();
}

@GetMapping("/chat/ollama-options")
String chatWithOllamaOptions(@RequestParam(defaultValue = "What did Gandalf say to the Balrog?") String message) {
return chatModel.call(new Prompt(message, OllamaOptions.builder()
.withFrequencyPenalty(1.3f)
.withFrequencyPenalty(1.3)
.withNumPredict(1500)
.withPresencePenalty(1.0f)
.withPresencePenalty(1.0)
.withStop(List.of("this-is-the-end", "addio"))
.withTemperature(0.7f)
.withTemperature(0.7)
.withTopK(1)
.withTopP(0f)
.withTopP(0.0)
.build()))
.getResult().getOutput().getContent();
}
Expand All @@ -56,7 +56,7 @@ String chatWithOllamaOptions(@RequestParam(defaultValue = "What did Gandalf say
String chatWithFunctions(@RequestParam(defaultValue = "Philip Pullman") String author) {
return chatModel.call(new Prompt("What books written by %s are available to read and what is their bestseller?".formatted(author),
OllamaOptions.builder()
.withTemperature(0.3f)
.withTemperature(0.3)
.withFunctions(Set.of("booksByAuthor", "bestsellerBookByAuthor"))
.build()))
.getResult().getOutput().getContent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,20 @@ String chat(@RequestParam(defaultValue = "What did Gandalf say to the Balrog?")
@GetMapping("/chat/generic-options")
String chatWithGenericOptions(@RequestParam(defaultValue = "What did Gandalf say to the Balrog?") String message) {
return chatModel.call(new Prompt(message, ChatOptionsBuilder.builder()
.withTemperature(1.3f)
.withTemperature(1.3)
.build()))
.getResult().getOutput().getContent();
}

@GetMapping("/chat/openai-options")
String chatWithOpenAiOptions(@RequestParam(defaultValue = "What did Gandalf say to the Balrog?") String message) {
return chatModel.call(new Prompt(message, OpenAiChatOptions.builder()
.withFrequencyPenalty(1.3f)
.withFrequencyPenalty(1.3)
.withMaxTokens(1500)
.withPresencePenalty(1.0f)
.withPresencePenalty(1.0)
.withStop(List.of("this-is-the-end", "addio"))
.withTemperature(0.7f)
.withTopP(0f)
.withTemperature(0.7)
.withTopP(0.0)
.withUser("jon.snow")
.build()))
.getResult().getOutput().getContent();
Expand All @@ -56,7 +56,7 @@ String chatWithOpenAiOptions(@RequestParam(defaultValue = "What did Gandalf say
String chatWithFunctions(@RequestParam(defaultValue = "Philip Pullman") String author) {
return chatModel.call(new Prompt("What books written by %s are available to read and what is their bestseller?".formatted(author),
OpenAiChatOptions.builder()
.withTemperature(0.3f)
.withTemperature(0.3)
.withFunctions(Set.of("booksByAuthor", "bestsellerBookByAuthor"))
.build()))
.getResult().getOutput().getContent();
Expand Down

0 comments on commit 7a26efb

Please sign in to comment.