Replies: 2 comments
-
Sounds like a useful utility idea. Would it make sense to turn this into an issue? I'd be happy to help implement it, just need to double check the OpenAI docs for the calculation logic. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Relevant PR that somewhat handles image cost calculation #8341 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Checked
Feature request
OpenAI provides a method for estimating the number of tokens associated with image inputs. This calculation can be implemented based on OpenAI's official documentation:
We've implemented this logic in our production environment and would like to contribute it to LangChain to make it easier for others to reuse.
Would
libs/langchain-openai/src/utils/tools.ts
be the correct place to add this utility function?Motivation
Developers working with image inputs currently need to implement cost calculations themselves. Adding this utility would save time and ensure consistency.
Proposal (If applicable)
Add a method like this that returns the number of tokens for a given image size.
Beta Was this translation helpful? Give feedback.
All reactions