[ 
https://issues.apache.org/jira/browse/CAMEL-22260?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Luis Sergio Faria Carneiro updated CAMEL-22260:
-----------------------------------------------
    Description: 
The langchain4j-tools component has a parameter name *description* which is 
used to generate a tool name to be registered at the LLM.

The tool name is the simple description defined 
[here|https://github.com/apache/camel/blob/main/components/camel-ai/camel-langchain4j-tools/src/main/java/org/apache/camel/component/langchain4j/tools/LangChain4jToolsEndpoint.java#L125].

However, LLMs might have restrictions on the tool names. For example, Gemini 
function names length must not exceed 64 characters and have some limitations 
on what characters can be used. And those restrictions are reflected on the 
description.

So If I create a route like this:
{code:java}
- from:
    uri: "langchain4j-tools:demo"
    parameters:
        tags: demo
        description: Returns the address for a given zip code (city, state and 
neighborhood)
        parameter.zipcode: string
    steps:
    - log:
        message: Querying zip code ${headers.zipcode} {code}
and try to use it with gemini-1.5-flash I get the error:
{code:java}
error": {
    "code": 400,
    "message": "* 
GenerateContentRequest.tools[0].function_declarations[0].name: Invalid function 
name. Must start with a letter or an underscore. Must be alphameric (a-z, A-Z, 
0-9), underscores (_), dots (.) or dashes (-), with a maximum length of 64.\n",
    "status": "INVALID_ARGUMENT"
  }
 {code}
So this forces me to change the description.

The goal here is to support a new parameter, {*}name{*}, which could be used as 
follows:
{code:java}
- from:
    uri: "langchain4j-tools:demo"
    parameters:
        tags: demo
        description: Returns the address for a given zip code (city, state and 
neighborhood)
        name: ReturnAddressForZipCode
        parameter.zipcode: string
    steps:
    - log:
        message: Querying zip code ${headers.zipcode} 
{code}
If no name is provided, we would still generate one from the description.

Some other cases where this fails are descriptions in languages that have 
non-ascii characters, like é, á, ã, ñ.

  was:
The langchain4j-tools component has a parameter name *description* which is 
used to generate a tool name to be registered at the LLM.

The tool name is the simple description defined 
[here|https://github.com/lsergio/camel/blob/main/components/camel-ai/camel-langchain4j-tools/src/main/java/org/apache/camel/component/langchain4j/tools/LangChain4jToolsEndpoint.java#L125].

However, LLMs might have restrictions on the tool names. For example, Gemini 
function names length must not exceed 64 characters and have some limitations 
on what characters can be used. And those restrictions are reflected on the 
description.

So If I create a route like this:
{code:java}
- from:
    uri: "langchain4j-tools:demo"
    parameters:
        tags: demo
        description: Returns the address for a given zip code (city, state and 
neighborhood)
        parameter.zipcode: string
    steps:
    - log:
        message: Querying zip code ${headers.zipcode} {code}
and try to use it with gemini-1.5-flash I get the error:
{code:java}
error": {
    "code": 400,
    "message": "* 
GenerateContentRequest.tools[0].function_declarations[0].name: Invalid function 
name. Must start with a letter or an underscore. Must be alphameric (a-z, A-Z, 
0-9), underscores (_), dots (.) or dashes (-), with a maximum length of 64.\n",
    "status": "INVALID_ARGUMENT"
  }
 {code}
So this forces me to change the description.

The goal here is to support a new parameter, {*}name{*}, which could be used as 
follows:
{code:java}
- from:
    uri: "langchain4j-tools:demo"
    parameters:
        tags: demo
        description: Returns the address for a given zip code (city, state and 
neighborhood)
        name: ReturnAddressForZipCode
        parameter.zipcode: string
    steps:
    - log:
        message: Querying zip code ${headers.zipcode} 
{code}
If no name is provided, we would still generate one from the description.

Some other cases where this fails are descriptions in languages that have 
non-ascii characters, like é, á, ã, ñ.


> [camel-langchain4j-tools] Support for defining the tool names
> -------------------------------------------------------------
>
>                 Key: CAMEL-22260
>                 URL: https://issues.apache.org/jira/browse/CAMEL-22260
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-langchain4j-tools
>            Reporter: Luis Sergio Faria Carneiro
>            Priority: Minor
>
> The langchain4j-tools component has a parameter name *description* which is 
> used to generate a tool name to be registered at the LLM.
> The tool name is the simple description defined 
> [here|https://github.com/apache/camel/blob/main/components/camel-ai/camel-langchain4j-tools/src/main/java/org/apache/camel/component/langchain4j/tools/LangChain4jToolsEndpoint.java#L125].
> However, LLMs might have restrictions on the tool names. For example, Gemini 
> function names length must not exceed 64 characters and have some limitations 
> on what characters can be used. And those restrictions are reflected on the 
> description.
> So If I create a route like this:
> {code:java}
> - from:
>     uri: "langchain4j-tools:demo"
>     parameters:
>         tags: demo
>         description: Returns the address for a given zip code (city, state 
> and neighborhood)
>         parameter.zipcode: string
>     steps:
>     - log:
>         message: Querying zip code ${headers.zipcode} {code}
> and try to use it with gemini-1.5-flash I get the error:
> {code:java}
> error": {
>     "code": 400,
>     "message": "* 
> GenerateContentRequest.tools[0].function_declarations[0].name: Invalid 
> function name. Must start with a letter or an underscore. Must be alphameric 
> (a-z, A-Z, 0-9), underscores (_), dots (.) or dashes (-), with a maximum 
> length of 64.\n",
>     "status": "INVALID_ARGUMENT"
>   }
>  {code}
> So this forces me to change the description.
> The goal here is to support a new parameter, {*}name{*}, which could be used 
> as follows:
> {code:java}
> - from:
>     uri: "langchain4j-tools:demo"
>     parameters:
>         tags: demo
>         description: Returns the address for a given zip code (city, state 
> and neighborhood)
>         name: ReturnAddressForZipCode
>         parameter.zipcode: string
>     steps:
>     - log:
>         message: Querying zip code ${headers.zipcode} 
> {code}
> If no name is provided, we would still generate one from the description.
> Some other cases where this fails are descriptions in languages that have 
> non-ascii characters, like é, á, ã, ñ.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to