Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions ai-agent/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Qdrant will be available on `http://localhost:6333`.

* `camel-spring-ai-chat-starter` - Camel Spring AI chat integration
* `camel-spring-ai-vector-store-starter` - Camel Spring AI vector store integration
* `camel-spring-ai-tools-starter` - Camel Spring AI tools/function calling
* `camel-ai-tool-starter` - Camel AI tools/function calling
* `spring-ai-starter-model-ollama` - Spring AI Ollama model support
* `spring-ai-starter-vector-store-qdrant` - Qdrant vector store integration

Expand All @@ -70,7 +70,7 @@ NOTE: The routes use timer delays to ensure proper startup sequence. The chat ro
Demonstrates basic chat functionality. Sends questions to the AI model and logs the responses. Executes immediately on startup.

==== ToolRoute
Shows how to define tools (functions) that the AI can call. The example includes a weather tool that the AI can invoke when asked about weather information. The tool is defined using the `spring-ai-tools` component with parameters. The tool chat route executes after a 20 second delay to ensure all services are ready.
Shows how to define tools (functions) that the AI can call. The example includes a weather tool that the AI can invoke when asked about weather information. The tool is defined using the `ai-tool` component with parameters. The tool chat route executes after a 20 second delay to ensure all services are ready.

==== VectorStoreRoute
Demonstrates semantic search using vector embeddings with Qdrant:
Expand Down Expand Up @@ -128,7 +128,7 @@ The example will continue running and watching the `input` directory for new doc


2025-11-25T17:51:41.445+01:00 INFO 54308 --- [imer://toolChat] toolChatRoute : Sending question with tool capability to AI: What is the weather like in Rome, Italy? Answer with English slang
2025-11-25T17:51:43.520+01:00 INFO 54308 --- [imer://toolChat] weatherTool : Weather tool called for location: Rome
2025-11-25T17:51:43.520+01:00 INFO 54308 --- [imer://toolChat] weatherTool : Weather tool called for city: Rome
2025-11-25T17:51:43.739+01:00 INFO 54308 --- [imer://toolChat] weatherTool : Geocoding result - Latitude: 41.89193, Longitude: 12.51133
2025-11-25T17:51:43.858+01:00 INFO 54308 --- [imer://toolChat] weatherTool : Weather tool response: The weather in is 12.4 degrees Celsius with 87% humidity, 100% cloud cover, wind speed 2.9 km/h from 7 degrees, and 0.2 mm precipitation.
2025-11-25T17:51:47.786+01:00 INFO 54308 --- [imer://toolChat] toolChatRoute : AI Response with tool usage: So, Rome's got it pretty mild out there right now – about **12.4°C**, feels like a cool breeze with that high humidity hanging around at **87%**. No rain in sight (just **0.2mm**), and the sky’s practically overcast (**100% cloud cover**) thanks to those gentle winds from the north‑west at **7°** – perfect for grabbing an espresso outside while you ponder life, love, or just how many more layers you need before it gets chilly again!
Expand Down
4 changes: 2 additions & 2 deletions ai-agent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<spring-ai-version>2.0.0-M2</spring-ai-version>
<spring-ai-version>2.0.0</spring-ai-version>
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -91,7 +91,7 @@
</dependency>
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-spring-ai-tools-starter</artifactId>
<artifactId>camel-ai-tool-starter</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.springboot</groupId>
Expand Down
22 changes: 10 additions & 12 deletions ai-agent/src/main/java/sample/camel/ToolRoute.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import org.springframework.stereotype.Component;

/**
* Route that demonstrates Spring AI tool/function calling capabilities.
* Route that demonstrates AI tool/function calling capabilities.
* The AI can invoke the weather tool to get current weather information.
*/
@Component
Expand All @@ -29,31 +29,29 @@ public class ToolRoute extends RouteBuilder {
@Override
public void configure() throws Exception {
// Define the weather tool that can be called by the AI
from("spring-ai-tools:weatherTool?tags=weather&description=Get the current weather for a location"
+ "&parameter.location=string"
+ "&parameter.location.description=The city, e.g. Rome"
+ "&parameter.location.required=true")
from("ai-tool:weatherTool?tags=weather&description=Get the current weather for a city"
+ "&parameter.city=string"
+ "&parameter.city.description=The city, e.g. Rome"
+ "&parameter.city.required=true")
.routeId("weatherTool")
.log("Weather tool called for location: ${header.location}")
.log("Weather tool called for city: ${header.city}")
.to("direct:geocode")
.log("Geocoding result - Latitude: ${header.latitude}, Longitude: ${header.longitude}")
.to("direct:fetchWeather")
.log("Weather tool response: ${body}");

// Geocoding route - convert location name to coordinates
// Geocoding route - convert city name to coordinates
from("direct:geocode")
.routeId("geocodeRoute")
.setHeader("savedLocation", simple("${header.location}"))
.toD("https://geocoding-api.open-meteo.com/v1/search?name=${header.location}&count=1&language=en&format=json")
.toD("https://geocoding-api.open-meteo.com/v1/search?name=${header.city}&count=1&language=en&format=json")
.setHeader("latitude", jq(".results[0].latitude"))
.setHeader("longitude", jq(".results[0].longitude"))
.setHeader("location", simple("${header.savedLocation}"));
.setHeader("longitude", jq(".results[0].longitude"));

// Weather fetching route - get current weather for coordinates
from("direct:fetchWeather")
.routeId("fetchWeatherRoute")
.toD("https://api.open-meteo.com/v1/forecast?latitude=${header.latitude}&longitude=${header.longitude}&current=temperature_2m,weather_code,precipitation,wind_speed_10m,wind_direction_10m,relative_humidity_2m,cloud_cover&temperature_unit=celsius&wind_speed_unit=kmh")
.setBody(simple("The weather in ${header.location} is ${jq(.current.temperature_2m)} degrees Celsius with ${jq(.current.relative_humidity_2m)}% humidity, ${jq(.current.cloud_cover)}% cloud cover, wind speed ${jq(.current.wind_speed_10m)} km/h from ${jq(.current.wind_direction_10m)} degrees, and ${jq(.current.precipitation)} mm precipitation."));
.setBody(simple("The weather in ${header.city} is ${jq(.current.temperature_2m)} degrees Celsius with ${jq(.current.relative_humidity_2m)}% humidity, ${jq(.current.cloud_cover)}% cloud cover, wind speed ${jq(.current.wind_speed_10m)} km/h from ${jq(.current.wind_direction_10m)} degrees, and ${jq(.current.precipitation)} mm precipitation."));

// Route that uses AI with function calling
from("timer:toolChat?repeatCount=1&delay=20000")
Expand Down
Loading