Refactor MistralAiChatOptions builder methods
- Refactor the builder methods to remove `with` as the prefix. - Introduce new methods with updated naming conventions. - Deprecate the existing `with*` methods to maintain backward compatibility. - Update MistralAiChatOptions builder documentation
This commit is contained in:
committed by
Ilayaperumal Gopinathan
parent
48bcbd1555
commit
de29df7c58
@@ -153,7 +153,7 @@ MistralAiChatModel chatModel = ...
|
||||
UserMessage userMessage = new UserMessage("What's the weather like in Paris?");
|
||||
|
||||
ChatResponse response = this.chatModel.call(new Prompt(this.userMessage,
|
||||
MistralAiChatOptions.builder().withFunction("CurrentWeather").build())); // Enable the function
|
||||
MistralAiChatOptions.builder().function("CurrentWeather").build())); // Enable the function
|
||||
|
||||
logger.info("Response: {}", response);
|
||||
----
|
||||
@@ -173,7 +173,7 @@ MistralAiChatModel chatModel = ...
|
||||
UserMessage userMessage = new UserMessage("What's the weather like in Paris?");
|
||||
|
||||
var promptOptions = MistralAiChatOptions.builder()
|
||||
.withFunctionCallbacks(List.of(FunctionCallback.builder()
|
||||
.functionCallbacks(List.of(FunctionCallback.builder()
|
||||
.function("CurrentWeather", new MockWeatherService()) // (1) function name and instance
|
||||
.description("Get the weather in location") // (2) function description
|
||||
.inputType(MockWeatherService.Request.class) // (3) function signature
|
||||
|
||||
@@ -126,8 +126,8 @@ ChatResponse response = chatModel.call(
|
||||
new Prompt(
|
||||
"Generate the names of 5 famous pirates.",
|
||||
MistralAiChatOptions.builder()
|
||||
.withModel(MistralAiApi.ChatModel.LARGE.getValue())
|
||||
.withTemperature(0.5)
|
||||
.model(MistralAiApi.ChatModel.LARGE.getValue())
|
||||
.temperature(0.5)
|
||||
.build()
|
||||
));
|
||||
----
|
||||
@@ -222,9 +222,9 @@ Next, create a `MistralAiChatModel` and use it for text generations:
|
||||
var mistralAiApi = new MistralAiApi(System.getenv("MISTRAL_AI_API_KEY"));
|
||||
|
||||
var chatModel = new MistralAiChatModel(this.mistralAiApi, MistralAiChatOptions.builder()
|
||||
.withModel(MistralAiApi.ChatModel.LARGE.getValue())
|
||||
.withTemperature(0.4)
|
||||
.withMaxTokens(200)
|
||||
.model(MistralAiApi.ChatModel.LARGE.getValue())
|
||||
.temperature(0.4)
|
||||
.maxTokens(200)
|
||||
.build());
|
||||
|
||||
ChatResponse response = this.chatModel.call(
|
||||
|
||||
Reference in New Issue
Block a user