orpiske commented on code in PR #15396:
URL: https://github.com/apache/camel/pull/15396#discussion_r1741686944
##########
components/camel-ai/camel-langchain4j-tools/src/main/docs/langchain4j-tools-component.adoc:
##########
@@ -0,0 +1,187 @@
+= LangChain4j Tools Component
+:doctitle: LangChain4j Tools
+:shortname: langchain4j-tools
+:artifactid: camel-langchain4j-tools
+:description: LangChain4j Tools and Function Calling Features
+:since: 4.8
+:supportlevel: Experimental
+:tabs-sync-option:
+:component-header: Only producer is supported
+//Manually maintained attributes
+:group: AI
+:camel-spring-boot-name: langchain4j-tools
+
+*Since Camel {since}*
+
+*{component-header}*
+
+The LangChain4j Tools Component allows you to use function calling features
from Large Language Models (LLMs) supported by
https://github.com/langchain4j/langchain4j[LangChain4j].
+
+Maven users will need to add the following dependency to their `pom.xml`
+for this component:
+
+[source,xml]
+----
+<dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-langchain4j-tools</artifactId>
+ <version>x.x.x</version>
+ <!-- use the same version as your Camel core version -->
+</dependency>
+----
+
+== URI format
+
+.Producer
+----
+langchain4j-tools:toolSet[?options]
+----
+
+.Consumer
+----
+langchain4j-tools:toolSet[?options]
+----
+
+Where *toolSet* can be any string to uniquely identify the endpoint
+
+
+// component-configure options: START
+
+// component-configure options: END
+
+// component options: START
+include::partial$component-configure-options.adoc[]
+include::partial$component-endpoint-options.adoc[]
+// component options: END
+
+// endpoint options: START
+
+// endpoint options: END
+
+// component headers: START
+include::partial$component-endpoint-headers.adoc[]
+// component headers: END
+
+include::spring-boot:partial$starter.adoc[]
+
+== Usage
+
+This component helps to use function-calling features from LLMs so that models
can decide what functions (routes, in case of Camel)
+can be called (i.e.; routed).
+
+Consider, for instance, two consumer routes capable of query an user database
by user ID or by social security number (SSN).
+
+.Queries user by ID
+[source, java]
+----
+from("langchain4j-tool:userInfo?tags=users&description=Query database by user
ID")
+ .to("sql:SELECT name FROM users WHERE id = :#number");
+----
+
+.Queries user by SSN
+[source, java]
+----
+from("langchain4j-tool:userInfo?tags=users&description=Query database by user
social security ID")
+ .to("sql:SELECT name FROM users WHERE ssn = :#ssn");
+----
+
+Now, consider a producer route that receives unstructured data as input. Such
a route could consume
+this data, pass it to a LLM with function-calling capabilities (such as
https://huggingface.co/meta-llama/Meta-Llama-3.1-8B[llama3.1],
+https://huggingface.co/ibm-granite/granite-20b-functioncalling[Granite Code
20b function calling, etc]) and have
+the model decide which route to call.
+
+Such a route could receive questions in english such as:
+
+- _"What is the name of the user with user ID 1?"_
+- _"What is the name of the user with SSN 34.400.96?"_
+
+.Produce
+[source, java]
+----
+from(source)
+ .to("langchain4j-tool:userInfo?tags=users");
+----
+
+=== Tool Tags
+
+Consumer routes must define tags that groups
https://en.wikipedia.org/wiki/Set_theory[together]. The aforementioned routes
would be
+part have the `users` tag. The `users` tag has two routes: `queryById` and
`queryBySSN`
+
+=== Parameters
+
+The Tool Input parameter can be defined as an Endpoint multiValue option in
the form of `parameter.<name>=<type>`,
+or via the endpoint option `camelToolParameter` for a programmatic approach.
+The parameters can be found as headers in the consumer route, in particular,
if you define `parameter.userId=5`,
+in the consumer route `${header.userId}` can be used.
+
+.Producer and consumer example:
+[source, java]
+----
+from("direct:test")
+ .to("langchain4j-tools:test1?tags=users");
+
+from("langchain4j-chat:test1?tags=users&description=Query user database by
number¶meter.number=integer")
Review Comment:
Thanks for pointing this!
This should work as well, but I think it's better to use the same parameter
/ header name described above. I'll adjust the documentation.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]