-
Notifications
You must be signed in to change notification settings - Fork 93
Generated image support #86
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
Conversation
d169b14 to
ba6e07a
Compare
ba6e07a to
51e0454
Compare
…s input to url generation
chatkit/agents.py
Outdated
| elif event.type == "response.image_generation_call.partial_image": | ||
| if not ctx.generated_image_item: | ||
| continue | ||
|
|
||
| url = await converter.base64_image_to_url( | ||
| event.item_id, | ||
| event.partial_image_b64, | ||
| event.partial_image_index, | ||
| ) | ||
| progress = converter.partial_image_index_to_progress( | ||
| event.partial_image_index | ||
| ) | ||
|
|
||
| ctx.generated_image_item.image = GeneratedImage( | ||
| id=event.item_id, url=url | ||
| ) | ||
|
|
||
| yield ThreadItemUpdatedEvent( | ||
| item_id=ctx.generated_image_item.id, | ||
| update=GeneratedImageUpdated( | ||
| image=ctx.generated_image_item.image, progress=progress | ||
| ), | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for readability should this block be above the done handlers?
| """ | ||
| Convert a GeneratedImageItem into input item(s) to send to the model. | ||
| Required when generated images are enabled. | ||
| """ | ||
| raise NotImplementedError( | ||
| "A GeneratedImageItem was included in a UserMessageItem but Converter.generated_image_to_message_content was not implemented" | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm is there no way for us to represent images in a response? I'm not actually sure what the right thing to do here is, but can you just add image content by URL which we have?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, I'll add a default that returns a ResponseInputImageParam
876c31b to
f3a2b1f
Compare
Changes:
GeneratedImageItem(thread item),GeneratedImage,GeneratedImageUpdated(thread item update)stream_agent_responsesupports Agents SDK'sImageGenerationTooloutputResponseStreamConverterto handle base64 image data string -> url conversion and partial image index -> progress conversion.