Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for handling non-existent tools #1207

Open
roguexz opened this issue Jan 9, 2025 · 7 comments
Open

Support for handling non-existent tools #1207

roguexz opened this issue Jan 9, 2025 · 7 comments
Labels
enhancement New feature or request

Comments

@roguexz
Copy link

roguexz commented Jan 9, 2025

It will be nice if we can have custom handling for non-existent tools.

I am playing around with the SystemMessage prompt and tools support. Every now and then the local LLM will hallucinate the tool name, which would result in a runtime error.
e.g,

Tool executor summarizeText not found
java.lang.RuntimeException: Tool executor summarizeText not found
	at dev.langchain4j.internal.Exceptions.runtime(Exceptions.java:32)
	at io.quarkiverse.langchain4j.runtime.aiservice.AiServiceMethodImplementationSupport.doImplement(AiServiceMethodImplementationSupport.java:394)
	at io.quarkiverse.langchain4j.runtime.aiservice.AiServiceMethodImplementationSupport.implement(AiServiceMethodImplementationSupport.java:138)
at DocumentationGenerator$$QuarkusImpl.summarizeDocument(Unknown Source)

Similar to other capabilities within Quarkus, it would be great if there was a way for me to plug in my custom error-handler so that I can remind the LLM about the available list of tools.

e.g.,

 {
    "role" : "tool",
    "content" : "NO SUCH TOOL FOUND: 'summarizeText'.
                 Remember, you only have access to the following tools: {'tool_1', 'tool_2', ...}"
  }
@geoand
Copy link
Collaborator

geoand commented Jan 9, 2025

This is definitely an interesting idea.

@cescoffier @edeandrea I wonder if guardrails could be applicable in this case

@cescoffier
Copy link
Collaborator

Guardrails for tools is definitely something we want to add, and yes, a "pre-tools-invocation" guardrail would detect that it is trying to invoke something that is not there.

@geoand
Copy link
Collaborator

geoand commented Jan 9, 2025

@langchain4j are there any other approaches being discussed in LangChain4j around this topic?

@langchain4j
Copy link

Hi @geoand, yes: langchain4j/langchain4j#1052

@geoand
Copy link
Collaborator

geoand commented Jan 9, 2025

Thanks @langchain4j!

@edeandrea
Copy link
Collaborator

edeandrea commented Jan 9, 2025

This is definitely an interesting idea.

@cescoffier @edeandrea I wonder if guardrails could be applicable in this case

I think this is definitely a great idea! But I also think that this should be handled in upstream LC4j?

What would be another super idea was a guardrail that could prevent the llm from calling a valid/existing tool when it shouldn't :)

@geoand
Copy link
Collaborator

geoand commented Jan 13, 2025

I think this is definitely a great idea! But I also think that this should be handled in upstream LC4j?

Agreed

@geoand geoand added the enhancement New feature or request label Jan 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants