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(llm-observability): flatten langchain's additional_kwargs #166

Merged
merged 2 commits into from
Jan 17, 2025

Conversation

skoob13
Copy link
Contributor

@skoob13 skoob13 commented Jan 17, 2025

Problem

OpenAI wrappers send data as:

{
    "role": "assistant",
    "content": "",
    "tool_calls": [
        {
            "type": "function",
            "id": "123",
            "function": {
                "name": "test",
                "args": "{\"a\": 1}",
            },
        }
    ]
}

But the Langchain integration adds the tool calls into the additional_kwargs field:

{
    "role": "assistant",
    "content": "",
    "additional_kwargs": {
        "tool_calls": [
            {
                "type": "function",
                "id": "123",
                "function": {
                    "name": "test",
                    "args": "{\"a\": 1}"
                }
            }
        ]
    }
}

Changes

Flatten additional_kwargs to mirror the OpenAI wrapper to remove the discrepancies.

@skoob13 skoob13 requested review from Twixes and k11kirky January 17, 2025 12:52
Copy link
Member

@Twixes Twixes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, this makes sense – will need to update PostHog/posthog#27626 too

@skoob13 skoob13 merged commit 9b42349 into master Jan 17, 2025
2 checks passed
@skoob13 skoob13 deleted the fix/flatten-additional-kwargs-in-langchain branch January 17, 2025 16:59
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