这是indexloc提供的服务,不要输入任何密码
Skip to content

Method to set the image processing quality #76

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

Closed
wants to merge 1 commit into from

Conversation

MightyElemental
Copy link

OpenAI vision can either use low res or high res. Low res is cheaper and uses only 85 tokens. High res uses 85 tokens + 170 * tile_count, where tile_count is the number of 512x512 tiles the image is split into. High res scales the image down so that the longest edge is <=2000px, and the short edge is <=768px.

To save on token cost or to improve quality, this change allows the users to choose processing quality.

https://platform.openai.com/docs/guides/vision#low-or-high-fidelity-image-understanding

OpenAI vision can either use low res or high res. Low res is cheaper and
uses only 85 tokens. High res uses 85 tokens + 170 * tileCount, where
tileCount is the number of 512x512 tiles the image is split into. High
res scales the image down so that the longest edge is <=2000px, and the
short edge is <=768px.
@Lambdua
Copy link
Owner

Lambdua commented Nov 28, 2024

You can directly call setDetail() by obtaining the ImageUrl object. I think it would be too bulky to put too many static methods at the top level of UserMessage

@MightyElemental
Copy link
Author

You can directly call setDetail() by obtaining the ImageUrl object. I think it would be too bulky to put too many static methods at the top level of UserMessage

Though it's possible to do this, you still need to cast the content object, then go through each ImageContent object and set the detail. If there were an easier way to build the ImageContent object, it wouldn't be an issue, but the method used to build it in the UserMessage class doesn't give an ImageContent object.

What would you think about adding a new builder function to include the detail level? I did consider it, but I thought it'd be too bulky to have two more methods with similar names to the existing ones.

@Lambdua
Copy link
Owner

Lambdua commented Nov 28, 2024

I am thinking whether it is necessary to create a UserMessageBuilder class to help construct UserMessage, remove some static methods, and construct UserMessage through the builder. Is this more appropriate?

@MightyElemental
Copy link
Author

It probably would be beneficial to create a builder class.

@Lambdua
Copy link
Owner

Lambdua commented Nov 28, 2024

Tomorrow, I will add this feature

@Lambdua Lambdua closed this Nov 29, 2024
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