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

support nested dicts #26414

Merged
merged 6 commits into from
Sep 13, 2024
Merged

support nested dicts #26414

merged 6 commits into from
Sep 13, 2024

Conversation

hwchase17
Copy link
Contributor

needed for thinking tokens

@efriis efriis added the partner label Sep 13, 2024
Copy link

vercel bot commented Sep 13, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
langchain ⬜️ Ignored (Inspect) Visit Preview Sep 13, 2024 4:37am

@efriis efriis self-assigned this Sep 13, 2024
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. community Related to langchain-community labels Sep 13, 2024
@dosubot dosubot bot added the lgtm PR looks good. Use to confirm that a PR is ready for merging. label Sep 13, 2024
Comment on lines +357 to +358
k: _update_token_usage(overall_token_usage.get(k, 0), v)
for k, v in new_usage.items()

Choose a reason for hiding this comment

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

I would suggest inspecting the value to ensure it's an integer. The OpenAI API may add additional fields within usage that are not integers in the future.

Copy link
Member

Choose a reason for hiding this comment

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

Believe this actually handles what you're asking for! Recursively calls the same function, the adding only happens if it's an int. Otherwise hits the warning "else" case at the bottom

Choose a reason for hiding this comment

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

Agreed with @efriis , The best way to handle this by checking the instance types programmatically for int and dict. And the else case will then take care of warnings.

Choose a reason for hiding this comment

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

Makes sense, thanks! I don't think you need to warn in the else condition though — we may add non-integer fields in usage in the future, and that's not a breaking change or unexpected.

@efriis efriis merged commit 28ad244 into master Sep 13, 2024
38 of 42 checks passed
@efriis efriis deleted the harrison/update-openai branch September 13, 2024 04:47
@efriis
Copy link
Member

efriis commented Sep 13, 2024

released in langchain-openai==0.1.24

community release will wait til tomorrow - github having some issues with actions, and there are some dependency failures in experimental that we'll debug before releasing

Sheepsta300 pushed a commit to Sheepsta300/langchain that referenced this pull request Oct 1, 2024
needed for thinking tokens

---------

Co-authored-by: Erick Friis <erick@langchain.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community Related to langchain-community lgtm PR looks good. Use to confirm that a PR is ready for merging. partner size:M This PR changes 30-99 lines, ignoring generated files.
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

5 participants