Skip to content

add support for extra_content in chat response tool calls returned by Gemini models#768

Open
leonardfischer wants to merge 8 commits into
openai-php:mainfrom
leonardfischer:feature/implement-tool-extra_content
Open

add support for extra_content in chat response tool calls returned by Gemini models#768
leonardfischer wants to merge 8 commits into
openai-php:mainfrom
leonardfischer:feature/implement-tool-extra_content

Conversation

@leonardfischer
Copy link
Copy Markdown
Contributor

What:

  • Bug Fix
  • New Feature

Description:

This is a newer fix, based on #718 in order to fix the Gemini reponse. Gemini sends 'extra_content' when using tools in order to transfer the thought_signature. This is how it looks in the raw response:

{
  "choices": [
    {
      "finish_reason": "tool_calls",
      "index": 0,
      "message": {
        "role": "assistant",
        "tool_calls": [
          {
            "extra_content": {
              "google": {
                "thought_signature": "<token>"
              }
            },
            "function": {
              "arguments": "{}",
              "name": "function-name"
            },
            "id": "<id>",
            "type": "function"
          },
          // ...
        ]
      }
    }
  ],
  // ...

Related:

See other PR #718 - this one should take care of failed checks

@iBotPeaches
Copy link
Copy Markdown
Collaborator

You'll need to type the array shape of this since we are in highest PHPStan mode. Also could we get some tests to confirm OpenAI who doesn't send this doesn't have it returned? Then likewise a test for when its included that it comes back in toArray and other functions.

@leonardfischer
Copy link
Copy Markdown
Contributor Author

Hey @iBotPeaches alright - I'm on it :)

@leonardfischer
Copy link
Copy Markdown
Contributor Author

Sooo... After quite some back- and forth I managed to satisfy all linters and type-checkers (sorry, I noticed to late that this stuff can be checked locally - I'm more used to githooks that do this before committing).

I also added one more test and verified in the existing test that the new "extra_content" would not appear

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

Successfully merging this pull request may close these issues.

2 participants