quarkiverse / quarkus-langchain4j

Quarkus Langchain4j extension
https://docs.quarkiverse.io/quarkus-langchain4j/dev/index.html
Apache License 2.0
116 stars 65 forks source link

Introduce a way to configure tools per method of an AiService #613

Closed geoand closed 1 month ago

geoand commented 1 month ago

This is done using the new @ToolBox annotation

geoand commented 1 month ago

@cescoffier can you give this a try with the example you had in mind for the @ToolBox use case?

cescoffier commented 1 month ago

@geoand I will try it tomorrow.

geoand commented 1 month ago

🙏

geoand commented 1 month ago

I'll fix the conflict if we decide we want this

geoand commented 1 month ago

@cescoffier can you have a look at this one?

cescoffier commented 1 month ago

@geoand Yes, I will try to use it on the demo we did last week.

geoand commented 1 month ago

🙏🏼

cescoffier commented 1 month ago

Works!


    @UserMessage("""
            Extract the policy number from the given claim.
            Only return the policy number.

            {text}
            """)
    String extractPolicyNumber(String text);

    @UserMessage("""
            Check if there is an existing claim related to the given claim.
            Return the claim id, null if none.

            The existing claim can be found by identifying the policy number from the given claim.

            If no claim is found, return -1.

            {text}

             """)
    @ToolBox(ClaimService.class)
    Long findRelatedClaims(String text);
geoand commented 1 month ago

Thanks for checking!

I will add some documentation while also fixing the conflict

geoand commented 1 month ago

Done