committed by
Ilayaperumal Gopinathan
parent
49209d1d76
commit
7aa440e6bc
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2023-2024 the original author or authors.
|
||||
* Copyright 2023-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -65,7 +65,7 @@ class FunctionCallWithFunctionBeanIT {
|
||||
var userMessage = new UserMessage("""
|
||||
What's the weather like in San Francisco, Paris and in Tokyo?
|
||||
Return the temperature in Celsius.
|
||||
Perform multiple funciton execution if necessary.
|
||||
Perform multiple function execution if necessary.
|
||||
""");
|
||||
|
||||
ChatResponse response = chatModel.call(new Prompt(List.of(userMessage),
|
||||
@@ -105,7 +105,7 @@ class FunctionCallWithFunctionBeanIT {
|
||||
var userMessage = new UserMessage("""
|
||||
What's the weather like in San Francisco, Paris and in Tokyo?
|
||||
Return the temperature in Celsius.
|
||||
Perform multiple funciton execution if necessary.
|
||||
Perform multiple function execution if necessary.
|
||||
""");
|
||||
|
||||
ChatResponse response = chatModel.call(new Prompt(List.of(userMessage),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2023-2024 the original author or authors.
|
||||
* Copyright 2023-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -335,7 +335,7 @@ class AnthropicChatClientMethodInvokingFunctionCallbackIT {
|
||||
public void changeRoomLightColor(String roomName, LightColor color) {
|
||||
arguments.put("roomName", roomName);
|
||||
arguments.put("color", color);
|
||||
logger.info("Change light colur in room: {} to color: {}", roomName, color);
|
||||
logger.info("Change light color in room: {} to color: {}", roomName, color);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2023-2024 the original author or authors.
|
||||
* Copyright 2023-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -59,8 +59,8 @@ class ChatClientToolsWithGenericArgumentTypesIT {
|
||||
void toolWithGenericArgumentTypes() {
|
||||
// @formatter:off
|
||||
String response = ChatClient.create(this.chatModel).prompt()
|
||||
.user("Turn light red in the living room and the kitchen. Please group the romms with the same color in a single tool call.")
|
||||
.tools(new TestToolProvider())
|
||||
.user("Turn light red in the living room and the kitchen. Please group the rooms with the same color in a single tool call.")
|
||||
.tools(new TestToolProvider())
|
||||
.call()
|
||||
.content();
|
||||
// @formatter:on
|
||||
@@ -86,7 +86,7 @@ class ChatClientToolsWithGenericArgumentTypesIT {
|
||||
|
||||
@Tool(description = "Change the lamp color in a room.")
|
||||
public void changeRoomLightColor(
|
||||
@ToolParam(description = "List of rooms to change the ligth color for") List<Room> rooms,
|
||||
@ToolParam(description = "List of rooms to change the light color for") List<Room> rooms,
|
||||
@ToolParam(description = "light color to change to") LightColor color) {
|
||||
|
||||
logger.info("Change light color in rooms: {} to color: {}", rooms, color);
|
||||
|
||||
@@ -184,7 +184,7 @@ public class BedrockNovaChatClientIT {
|
||||
ChatClient chatClient = ChatClient.builder(this.chatModel).build();
|
||||
|
||||
String response = chatClient.prompt()
|
||||
.tools(new DummyWeatherForcastTools())
|
||||
.tools(new DummyWeatherForecastTools())
|
||||
.user("Get current weather in Amsterdam")
|
||||
.call()
|
||||
.content();
|
||||
@@ -199,7 +199,7 @@ public class BedrockNovaChatClientIT {
|
||||
ChatClient chatClient = ChatClient.builder(this.chatModel).build();
|
||||
|
||||
Flux<ChatResponse> responses = chatClient.prompt()
|
||||
.tools(new DummyWeatherForcastTools())
|
||||
.tools(new DummyWeatherForecastTools())
|
||||
.user("Get current weather in Amsterdam")
|
||||
.stream()
|
||||
.chatResponse();
|
||||
@@ -214,11 +214,11 @@ public class BedrockNovaChatClientIT {
|
||||
assertThat(content).contains("20 degrees");
|
||||
}
|
||||
|
||||
public static class DummyWeatherForcastTools {
|
||||
public static class DummyWeatherForecastTools {
|
||||
|
||||
@Tool(description = "Get the current weather forcast in Amsterdam")
|
||||
@Tool(description = "Get the current weather forecast in Amsterdam")
|
||||
String getCurrentDateTime() {
|
||||
return "Weahter is hot and sunny wiht a temperature of 20 degrees";
|
||||
return "Weather is hot and sunny with a temperature of 20 degrees";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2023-2024 the original author or authors.
|
||||
* Copyright 2023-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -61,7 +61,7 @@ class ChatClientToolsWithGenericArgumentTypesIT {
|
||||
void toolWithGenericArgumentTypes() {
|
||||
// @formatter:off
|
||||
String response = ChatClient.create(this.chatModel).prompt()
|
||||
.user("Turn light red in the living room and the kitchen. Please group the romms with the same color in a single tool call.")
|
||||
.user("Turn light red in the living room and the kitchen. Please group the rooms with the same color in a single tool call.")
|
||||
.tools(new TestToolProvider())
|
||||
.call()
|
||||
.content();
|
||||
@@ -88,7 +88,7 @@ class ChatClientToolsWithGenericArgumentTypesIT {
|
||||
|
||||
@Tool(description = "Change the lamp color in a room.")
|
||||
public void changeRoomLightColor(
|
||||
@ToolParam(description = "List of rooms to change the ligth color for") List<Room> rooms,
|
||||
@ToolParam(description = "List of rooms to change the light color for") List<Room> rooms,
|
||||
@ToolParam(description = "light color to change to") LightColor color) {
|
||||
|
||||
logger.info("Change light color in rooms: {} to color: {}", rooms, color);
|
||||
|
||||
@@ -10,12 +10,12 @@ The Bedrock Converse API has the following high-level features:
|
||||
* System Messages: Support for system-level instructions and context setting
|
||||
|
||||
TIP: The Bedrock Converse API provides a unified interface across multiple model providers while handling AWS-specific authentication and infrastructure concerns.
|
||||
Currently, the Converse API link:https://docs.aws.amazon.com/bedrock/latest/userguide/conversation-inference-supported-models-features.html[Supported Models] inlcude:
|
||||
Currently, the Converse API link:https://docs.aws.amazon.com/bedrock/latest/userguide/conversation-inference-supported-models-features.html[Supported Models] include:
|
||||
`Amazon Titan`, `Amazon Nova`, `AI21 Labs`, `Anthropic Claude`, `Cohere Command`, `Meta Llama`, `Mistral AI`.
|
||||
|
||||
[NOTE]
|
||||
====
|
||||
Following the Bedrock recommendations, Spring AI is transitioning to using Amazon Bedrock's Converse API for all chat conversation implementations in Spring AI.
|
||||
Following the Bedrock recommendations, Spring AI is transitioning to using Amazon Bedrock's Converse API for all chat conversation implementations in Spring AI.
|
||||
While the existing xref:api/bedrock-chat.adoc[InvokeModel API] supports conversation applications, we strongly recommend adopting the Converse API for all Chat conversation models.
|
||||
|
||||
The Converse API does not support embedding operations, so these will remain in the current API and the embedding model functionality in the existing `InvokeModel API` will be maintained
|
||||
@@ -135,7 +135,7 @@ String response = ChatClient.create(this.chatModel)
|
||||
|
||||
== Tool Calling
|
||||
|
||||
The Bedrock Converse API supports tool calling capabilities, allowing models to use tools during conversations.
|
||||
The Bedrock Converse API supports tool calling capabilities, allowing models to use tools during conversations.
|
||||
Here's an example of how to define and use @Tool based tools:
|
||||
|
||||
[source,java]
|
||||
@@ -150,7 +150,7 @@ public class WeatherService {
|
||||
}
|
||||
|
||||
String response = ChatClient.create(this.chatModel)
|
||||
.prompt("What's the weather like in Boston?")
|
||||
.prompt("What's the weather like in Boston?")
|
||||
.tools(new WeatherService())
|
||||
.call()
|
||||
.content();
|
||||
@@ -167,7 +167,7 @@ public Function<Request, Response> weatherFunction() {
|
||||
}
|
||||
|
||||
String response = ChatClient.create(this.chatModel)
|
||||
.prompt("What's the weather like in Boston?")
|
||||
.prompt("What's the weather like in Boston?")
|
||||
.tools("weatherFunction")
|
||||
.inputType(Request.class)
|
||||
.call()
|
||||
@@ -178,7 +178,7 @@ Find more in xref:api/tools.adoc[Tools] documentation.
|
||||
|
||||
== Multimodal
|
||||
|
||||
Multimodality refers to a model's ability to simultaneously understand and process information from various sources, including text, images, video, pdf, doc, html, md and more data formats.
|
||||
Multimodality refers to a model's ability to simultaneously understand and process information from various sources, including text, images, video, pdf, doc, html, md and more data formats.
|
||||
|
||||
The Bedrock Converse API supports multimodal inputs, including text and image inputs, and can generate a text response based on the combined input.
|
||||
|
||||
@@ -248,13 +248,13 @@ image::test.video.jpeg[Multimodal Test Video, 200, 200, align="left"]
|
||||
along with the text message "Explain what do you see in this video?", and generates a response something like:
|
||||
|
||||
----
|
||||
The video shows a group of baby chickens, also known as chicks, huddled together on a surface
|
||||
The video shows a group of baby chickens, also known as chicks, huddled together on a surface
|
||||
...
|
||||
----
|
||||
|
||||
=== Documents
|
||||
|
||||
For some models, Bedrock allows you to include documents in the payload through Converse API document support, which can be provided in bytes.
|
||||
For some models, Bedrock allows you to include documents in the payload through Converse API document support, which can be provided in bytes.
|
||||
The document support has two different variants as explained below:
|
||||
|
||||
- **Text document types** (txt, csv, html, md, and so on), where the emphasis is on text understanding. These use case include answering based on textual elements of the document.
|
||||
|
||||
@@ -293,7 +293,7 @@ public class CouchbaseSearchVectorStoreIT {
|
||||
CouchbaseSearchVectorStore.Builder builder = CouchbaseSearchVectorStore.builder(cluster, embeddingModel)
|
||||
.bucketName("springBucket")
|
||||
.scopeName("springScope")
|
||||
.collectionName("sprtingcollection");
|
||||
.collectionName("springCollection");
|
||||
|
||||
return builder.initializeSchema(true).build();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user