Skip to content

[BUG] react error handling #62

Description

@bkj

If there are no tool calls, this checks if there is parsable JSON:

  • If parsable json AND looks like tool call, record as tool call
  • If NOT not parsable JSON, record as final answer

But .. if parsable json AND doesn't look like tool call, then nothing happens and the loop continues.

https://github.com/jataware/archytas/blob/main/archytas/react.py#L282

I think needs to be changed to:

try:
    # Check to ensure the content isn't an tool call in the wrong place.
    action_json = json.loads(action.text)
    if isinstance(action_json, dict) and "id" in action_json and "name" in action_json and "args" in action_json:
        action.tool_calls.append(action_json)
    else:
        action.tool_calls.append({
            "id": uuid.uuid4().hex,
            "name": "final_answer",
            "args": {
                "response": action.text
            }
        })
        
except json.JSONDecodeError:
    # Presume content to be a final answer
    action.tool_calls.append({
        "id": uuid.uuid4().hex,
        "name": "final_answer",
        "args": {
            "response": action.text
        }
    })

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions