[
https://issues.apache.org/jira/browse/CAMEL-21816?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Otavio Rodolfo Piske resolved CAMEL-21816.
------------------------------------------
Resolution: Fixed
This was resolved with the linked PRs.
> camel-ai - Missing tool information when returning function call response
> -------------------------------------------------------------------------
>
> Key: CAMEL-21816
> URL: https://issues.apache.org/jira/browse/CAMEL-21816
> Project: Camel
> Issue Type: Bug
> Components: camel-ai, camel-langchain4j-tools
> Affects Versions: 4.10.0
> Reporter: Bruno Meseguer
> Assignee: Otavio Rodolfo Piske
> Priority: Major
> Fix For: 4.12.0
>
>
> When a Camel route uses the LangChain4J-tools component, it calls the LLM,
> providing metadata about the tools (tool routes) available the LLM can use.
> The LLM computes the request and decides if a tool call is necessary or not.
> If the LLM performs a tool call, Camel executes the tool and returns the
> result to the LLM.
> However, the current implementation does not provide the Tools metadata
> (tools available) when returning the tool result.
> The consequence of Camel not including Tools metadata when returning the tool
> response is that the LLM understands there are no more Tools available, and
> concludes that subsequent tool calls are not allowed, forcing the LLM to
> compose a final response.
> The expected behaviour from Camel is to always provide a full history of tool
> calls and results, including the metadata of available tools the LLM can use
> at all times.
> Let's assume Camel asks the LLM the following question:
> * "what is the weather in London?"
> Camel calls the LLM and provides metadata listing the tools available to the
> LLM. In this example, it would provide:
> * Tool to find the geo-coordinates for a given city
> * Tool to obtain weather information for a given longitude and latitude
> The LLM needs to first obtain from Camel the geo-coordinates for London, and
> in a subsequent call, invoke the second tool to obtain the weather passing
> the geo-coordinates obtained in the first call.
> When Camel returns the result of the geo-coordinates tool call, the current
> implementation is missing to provide tools metadata. The sample below shows
> all the data Camel needs to provide to allow the LLM to call a second time:
> {code:java}
> Request:
> - method: POST
> - url: http://localhost:11434/api/chat
> - headers: [Accept: application/json], [Content-Type: application/json],
> [User-Agent: Apache Camel], [content-length: 2257]
> - body: {
> "model" : "qwen2.5:7b-instruct",
> "messages" : [ {
> "role" : "system",
> "content" : " You are a meteorologist, and you need to answer
> questions asked by the user about weather using at most 3 lines.\n\n The
> weather information is a JSON object and has the following fields:\n\n
> maxTemperature is the maximum temperature of the day in Celsius degrees\n
> minTemperature is the minimum temperature of the day in Celsius degrees\n
> precipitation is the amount of water in mm\n windSpeed is the speed of
> wind in kilometers per hour\n weather is the overall weather.\n"
> }, {
> "role" : "user",
> "content" : "What is the weather in london ?"
> }, {
> "role" : "assistant",
> "tool_calls" : [ {
> "function" : {
> "name" : "findCity",
> "arguments" : {
> "name" : "london"
> }
> }
> } ]
> }, {
> "role" : "tool",
> "content" : "{\n \"results\" : [ {\n \"latitude\" : 51.50853,\n
> \"longitude\" : -0.12574\n } ]\n}"
> } ],
>
> "tools" : [ {
> "type" : "function",
> "function" : {
> "name" : "forecast",
> "description" : "Forecasts the weather for the given latitude and
> longitude",
> "parameters" : {
> "type" : "object",
> "properties" : {
> "latitude" : {
> "type" : "number"
> },
> "longitude" : {
> "type" : "number"
> }
> },
> "required" : [ "latitude", "longitude" ]
> }
> }
> }, {
> "type" : "function",
> "function" : {
> "name" : "findCity",
> "description" : "Finds the latitude and longitude of a given city",
> "parameters" : {
> "type" : "object",
> "properties" : {
> "name" : {
> "type" : "string"
> }
> },
> "required" : [ "name" ]
> }
> }
> } ],
> "options" : {
> "temperature" : 0.0,
> "top_k" : 40,
> "top_p" : 0.9
> },
> "stream" : false
> } {code}
> Note in the JSON data above that Camel provides both the result of the tool
> call (provides latitude and longitude for the city of London), and also
> provides (again) the list of available tools the LLM can use at all times if
> it decides to call again.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)