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

Fix tool calls in chat #764

Merged
merged 4 commits into from
Jan 9, 2025

Conversation

neoxelox
Copy link
Contributor

@neoxelox neoxelox commented Jan 8, 2025

chain-complete was returning tool calls stringified as a content type text instead of content type tool-call

{
  "type": "chain-complete",
  "config": {
    "provider": "OpenAI",
    "model": "gpt-4o-mini",
    "temperature": 0.1,
    "tools": {
      "get_the_weather": {
        "description": "Retrieves the current weather for a specified location.",
        "parameters": {
          "type": "object",
          "properties": {
            "location": { "type": "string", "description": "The city and country, e.g., 'Valencia, Spain'." }
          },
          "required": ["location"],
          "additionalProperties": false
        }
      }
    }
  },
  "response": {
    "streamType": "text",
    "text": "",
    "usage": { "promptTokens": 110, "completionTokens": 17, "totalTokens": 127 },
    "toolCalls": [
      {
        "id": "redacted",
        "name": "get_the_weather",
        "arguments": { "location": "Barcelona, Spain" }
      }
    ]
  },
  "messages": [
    {
      "role": "assistant",
      "toolCalls": [
        {
          "id": "redacted",
          "name": "get_the_weather",
          "arguments": { "location": "Barcelona, Spain" }
        }
      ],
      "content": "[\n  {\n    \"type\": \"tool-call\",\n    \"toolCallId\": \"redacted\",\n    \"toolName\": \"get_the_weather\",\n    \"args\": {\n      \"location\": \"Barcelona, Spain\"\n    }\n  }\n]"
    }
  ],
  "uuid": "redacted"
}

It also seems we were eating away a text message that came along with the tool call request:
image

There was also a bug that made us stuck when there was an error in the streaming chat:
Screenshot 2025-01-08 at 17 33 47

Aaaand also fixed this error that appeared because we have tool calls defined in various fields with different arguments: toolCalls, inside content but with toolArguments and inside content too but with args:

Screenshot 2025-01-08 at 17 31 56

@neoxelox neoxelox added the 🚧 wip Work in progress label Jan 8, 2025
@neoxelox neoxelox changed the title Fix chain-completed event returns tool calls stringified Fix chain-completed event Jan 8, 2025
@neoxelox neoxelox changed the title Fix chain-completed event Fix tool calls in chat Jan 8, 2025
@neoxelox neoxelox requested a review from andresgutgon January 9, 2025 12:28
@neoxelox neoxelox removed the 🚧 wip Work in progress label Jan 9, 2025
@neoxelox neoxelox merged commit 4aa67e0 into main Jan 9, 2025
3 checks passed
@neoxelox neoxelox deleted the fix/chain-completed-returns-tool-calls-stringified branch January 9, 2025 13:09
@github-actions github-actions bot locked and limited conversation to collaborators Jan 9, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants