Skip to content

Commit 89bed1a

Browse files
committed
Update the Vertex Tool calling docs
1 parent 52feb77 commit 89bed1a

File tree

5 files changed

+53
-222
lines changed

5 files changed

+53
-222
lines changed

spring-ai-docs/src/main/antora/modules/ROOT/nav.adoc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
*** xref:api/chat/deepseek-chat.adoc[DeepSeek AI]
1515
*** xref:api/chat/google-vertexai.adoc[Google VertexAI]
1616
**** xref:api/chat/vertexai-gemini-chat.adoc[VertexAI Gemini]
17-
***** xref:api/chat/functions/vertexai-gemini-chat-functions.adoc[Gemini Function Calling]
1817
*** xref:api/chat/groq-chat.adoc[Groq]
1918
*** xref:api/chat/huggingface.adoc[Hugging Face]
2019
*** xref:api/chat/mistralai-chat.adoc[Mistral AI]

spring-ai-docs/src/main/antora/modules/ROOT/pages/api/chat/bedrock-converse.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ String response = ChatClient.create(this.chatModel)
115115
.content();
116116
----
117117

118-
== Tool/Function Calling
118+
== Tool Calling
119119

120120
The Bedrock Converse API supports tool calling capabilities, allowing models to use tools during conversations.
121121
Here's an example of how to define and use @Tool based tools:

spring-ai-docs/src/main/antora/modules/ROOT/pages/api/chat/functions/vertexai-gemini-chat-functions.adoc

Lines changed: 0 additions & 207 deletions
This file was deleted.

spring-ai-docs/src/main/antora/modules/ROOT/pages/api/chat/vertexai-gemini-chat.adoc

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,49 @@ ChatResponse response = chatModel.call(
113113
TIP: In addition to the model specific `VertexAiGeminiChatOptions` you can use a portable https://github.com/spring-projects/spring-ai/blob/main/spring-ai-core/src/main/java/org/springframework/ai/chat/prompt/ChatOptions.java[ChatOptions] instance, created with the
114114
https://github.com/spring-projects/spring-ai/blob/main/spring-ai-core/src/main/java/org/springframework/ai/chat/prompt/ChatOptionsBuilder.java[ChatOptionsBuilder#builder()].
115115

116-
== Function Calling
116+
== Tool Calling
117+
118+
The Vertex AI Gemini supports tool calling capabilities, allowing models to use tools during conversations.
119+
Here's an example of how to define and use @Tool based tools:
120+
121+
[source,java]
122+
----
123+
124+
public class WeatherService {
125+
126+
@Tool(description = "Get the weather in location")
127+
public String weatherByLocation(@ToolParam(description= "City or state name") String location) {
128+
...
129+
}
130+
}
131+
132+
String response = ChatClient.create(this.chatModel)
133+
.prompt("What's the weather like in Boston?")
134+
.tools(new WeatherService())
135+
.call()
136+
.content();
137+
----
138+
139+
You can use the java.util.function beans as tools as well:
140+
141+
[source,java]
142+
----
143+
@Bean
144+
@Description("Get the weather in location. Return temperature in 36°F or 36°C format.")
145+
public Function<Request, Response> weatherFunction() {
146+
return new MockWeatherService();
147+
}
148+
149+
String response = ChatClient.create(this.chatModel)
150+
.prompt("What's the weather like in Boston?")
151+
.tools("weatherFunction")
152+
.inputType(Request.class)
153+
.call()
154+
.content();
155+
----
156+
157+
Find more in xref:api/tools.adoc[Tools] documentation.
117158

118-
You can register custom Java functions with the VertexAiGeminiChatModel and have the Gemini Pro model intelligently choose to output a JSON object containing arguments to call one or many of the registered functions.
119-
This is a powerful technique to connect the LLM capabilities with external tools and APIs.
120-
Read more about xref:api/chat/functions/vertexai-gemini-chat-functions.adoc[Vertex AI Gemini Function Calling].
121159

122160
== Multimodal
123161

spring-ai-docs/src/main/antora/modules/ROOT/pages/api/functions.adoc

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,17 @@ WARNING: This page describes the previous version of the Function Calling API, w
55

66
The integration of function support in AI models, permits the model to request the execution of client-side functions, thereby accessing necessary information or performing tasks dynamically as required.
77

8-
Spring AI currently supports function invocation for the following AI Models:
9-
10-
* Anthropic Claude: Refer to the xref:api/chat/functions/anthropic-chat-functions.adoc[Anthropic Claude function invocation docs].
11-
* Azure OpenAI: Refer to the xref:api/chat/functions/azure-open-ai-chat-functions.adoc[Azure OpenAI function invocation docs].
12-
* Google VertexAI Gemini: Refer to the xref:api/chat/functions/vertexai-gemini-chat-functions.adoc[Vertex AI Gemini function invocation docs].
13-
* Groq: Refer to the xref:api/chat/groq-chat.adoc#_function_calling[Groq function invocation docs].
14-
* Mistral AI: Refer to the xref:api/chat/functions/mistralai-chat-functions.adoc[Mistral AI function invocation docs].
8+
Spring AI currently supports tool/function calling for the following AI Models:
9+
10+
* Anthropic Claude: Refer to the xref:api/chat/functions/anthropic-chat-functions.adoc[Anthropic Claude tool/function calling].
11+
* Azure OpenAI: Refer to the xref:api/chat/functions/azure-open-ai-chat-functions.adoc[Azure OpenAI tool/function calling].
12+
* Amazon Bedrock Converse: Refer to the xref:api/chat/bedrock-converse.adoc#_tool_calling[Amazon Bedrock Converse tool/function calling].
13+
* Google VertexAI Gemini: Refer to the xref:api/chat/vertexai-gemini-chat.adoc#_tool_calling[Vertex AI Gemini tool/function calling].
14+
* Groq: Refer to the xref:api/chat/groq-chat.adoc#_function_calling[Groq tool/function calling].
15+
* Mistral AI: Refer to the xref:api/chat/functions/mistralai-chat-functions.adoc[Mistral AI tool/function calling].
1516
// * MiniMax : Refer to the xref:api/chat/functions/minimax-chat-functions.adoc[MiniMax function invocation docs].
16-
* Ollama: Refer to the xref:api/chat/functions/ollama-chat-functions.adoc[Ollama function invocation docs] (streaming not supported yet).
17-
* OpenAI: Refer to the xref:api/chat/functions/openai-chat-functions.adoc[OpenAI function invocation docs].
17+
* Ollama: Refer to the xref:api/chat/functions/ollama-chat-functions.adoc[Ollama tool/function calling]
18+
* OpenAI: Refer to the xref:api/chat/functions/openai-chat-functions.adoc[OpenAI tool/function calling].
1819
// * ZhiPu AI : Refer to the xref:api/chat/functions/zhipuai-chat-functions.adoc[ZhiPu AI function invocation docs].
1920

2021
image::function-calling-basic-flow.jpg[Function calling, width=700, align="center"]

0 commit comments

Comments
 (0)