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

Error in generating tool call with model #122

Open
manjiler opened this issue Jan 8, 2025 · 1 comment
Open

Error in generating tool call with model #122

manjiler opened this issue Jan 8, 2025 · 1 comment

Comments

@manjiler
Copy link

manjiler commented Jan 8, 2025

I have very simple tool calling agent workflow and I am stuck with this error:

Error in generating tool call with model:
The JSON blob you used is invalid due to the following error: Expecting property name enclosed in double quotes: line 1 column 2 (char 1).
JSON blob was: {'id': '17052', 'type': 'function', 'function': {'name': 'get_weather', 'arguments': {'location': 'Paris'}}}]
@tool
def get_weather(location: str, celsius: Optional[bool] = False) -> str:
    """
    Get weather in the next days at given location.
    Secretly this tool does not care about the location, it hates the weather everywhere.

    Args:
        location: the location
        celsius: the temperature
    """
    return "22"


model = TransformersModel(model_id="meta-llama/Llama-3.2-2B-Instruct")
agent = ToolCallingAgent(tools=[get_weather, get_system_configuration, get_system_performance], model=model)

print(agent.run("What is difference in the configuration of the system ABC123 and XYZ345?"))

Error that is seen

What is weather in Paris?                                                                                                                                                                             TransformersModel - meta-llama/Llama-3.2-2B-Instruct 
 Step 0 
│ Calling tool: 'get_weather' with arguments: {'location': 'Paris'}                                                                                                                                    Observations: 22
[Step 0: Duration 2.43 seconds| Input tokens: 1,103 | Output tokens: 33]
Step 1 
Error in generating tool call with model:
The JSON blob you used is invalid due to the following error: Expecting property name enclosed in double quotes: line 1 column 2 (char 1).
JSON blob was: {'id': '17052', 'type': 'function', 'function': {'name': 'get_weather', 'arguments': {'location': 'Paris'}}}]

Action:
{
  "tool_name": "get_weather",
  "tool_arguments": {"location": "Paris"}
}, decoding failed on that specific part of the blob:
''.

What should I do to get this working?

@ScientistIzaak
Copy link
Contributor

Hi @manjiler,

I think your problem is you are using single quotes in your JSON blob rather than double quotes.

For example:
{'id': '17052', 'type': 'function', 'function': {'name': 'get_weather', 'arguments': {'location': 'Paris'}}}

Should look like:
{ "id": "17052", "type": "function", "function": {"name": "get_weather","arguments": {"location": "Paris"}}}

Hope this helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants