Skip to content

Tool call throws NPE when LLM tried to call non existing function #117

@jesuino

Description

@jesuino

I am constantly having NPE because it is common for small LLMs hallucinate and try to call non existing function.

java.lang.NullPointerException: Cannot invoke "io.github.ollama4j.tools.ToolFunction.apply(java.util.Map)" because "toolFunction" is null
        at io.github.ollama4j.OllamaAPI.chatStreaming(OllamaAPI.java:921)

A suggestion is to avoid these NPEs by telling the LLM that the function it tried to call is not registered.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions