Refactor AnthropicChatOptions 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 AnthropicChatOptions builder documentation
This commit is contained in:
committed by
Ilayaperumal Gopinathan
parent
de29df7c58
commit
1d38fd11fd
@@ -130,8 +130,8 @@ ChatResponse response = chatModel.call(
|
||||
new Prompt(
|
||||
"Generate the names of 5 famous pirates.",
|
||||
AnthropicChatOptions.builder()
|
||||
.withModel("claude-2.1")
|
||||
.withTemperature(0.4)
|
||||
.model("claude-2.1")
|
||||
.temperature(0.4)
|
||||
.build()
|
||||
));
|
||||
----
|
||||
@@ -274,9 +274,9 @@ var anthropicApi = new AnthropicApi(System.getenv("ANTHROPIC_API_KEY"));
|
||||
|
||||
var chatModel = new AnthropicChatModel(this.anthropicApi,
|
||||
AnthropicChatOptions.builder()
|
||||
.withModel("claude-3-opus-20240229")
|
||||
.withTemperature(0.4)
|
||||
.withMaxTokens(200)
|
||||
.model("claude-3-opus-20240229")
|
||||
.temperature(0.4)
|
||||
.maxTokens(200)
|
||||
.build());
|
||||
|
||||
ChatResponse response = this.chatModel.call(
|
||||
|
||||
@@ -155,7 +155,7 @@ AnthropicChatModel chatModel = ...
|
||||
UserMessage userMessage = new UserMessage("What's the weather like in Paris?");
|
||||
|
||||
ChatResponse response = this.chatModel.call(new Prompt(List.of(this.userMessage),
|
||||
AnthropicChatOptions.builder().withFunction("CurrentWeather").build())); // (1) Enable the function
|
||||
AnthropicChatOptions.builder().function("CurrentWeather").build())); // (1) Enable the function
|
||||
|
||||
logger.info("Response: {}", response);
|
||||
----
|
||||
@@ -175,7 +175,7 @@ AnthropicChatModel chatModel = ...
|
||||
UserMessage userMessage = new UserMessage("What's the weather like in Paris?");
|
||||
|
||||
var promptOptions = AnthropicChatOptions.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
|
||||
|
||||
Reference in New Issue
Block a user