-
Notifications
You must be signed in to change notification settings - Fork 4.6k
feat: tools structured response #3165
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
feat: tools structured response #3165
Conversation
libs/agno/agno/agent/agent.py
Outdated
| self.memory.add_run(session_id=session_id, run=run_response) | ||
|
|
||
| await self._amake_memories_and_summaries(run_messages, session_id, user_id, messages) # type: ignore | ||
| # type: ignore |
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.
?
libs/agno/agno/agent/agent.py
Outdated
| content=introduction, | ||
| messages=[ | ||
| Message(role=self.model.assistant_message_role, content=introduction) # type: ignore | ||
| # type: ignore |
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.
?
| # Return the message | ||
| return message | ||
|
|
||
| # This gives the error- agno.exceptions.ModelProviderError: Invalid 'messages[4]'. Image URLs are only allowed for messages with role 'user', but this message with role 'tool' contains an image URL. |
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.
We'll have to create a separate message for "user" with the image, as if the user sent an image after the tool result. Still not sure whether it would work, but worth a try.
| Returns: | ||
| str: str: A message indicating if the image has been generated successfully or an error message. | ||
| """ | ||
| def create_image(self, agent: Union[Agent, Team], prompt: str) -> FunctionCallResult: |
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.
You still need the docstring, for the model
| def create_image(self, agent: Union[Agent, Team], prompt: str) -> FunctionCallResult: | ||
| if not self.api_key: | ||
| return "Please set the OPENAI_API_KEY" | ||
| return FunctionCallResult(content="Please set the OPENAI_API_KEY") |
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.
We don't have to always use the FunctionCallResult, strings and other types should still be allowed.
| image_artifact = ImageArtifact( | ||
| id=str(uuid4()), url=img.url, original_prompt=prompt, revised_prompt=img.revised_prompt | ||
| ) | ||
| agent.add_image(image_artifact) |
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.
Ideally we won't do this anymore but automatically handle it in the model/agent. But yeh for simplicity lets keep it here for now. We can clean up in Agno 2.0
| # Create a more descriptive response that includes details about the image | ||
| content = f"The image shows exactly what was requested - {prompt}. " | ||
|
|
||
| return FunctionCallResult(content=content, images=generated_images if generated_images else None) |
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.
Yeah this is the winner
|
closing in favour of- #4286 |
Summary
passing the user uploaded images in the toolkit
(If applicable, issue number: #____)
Type of change
Checklist
./scripts/format.shand./scripts/validate.sh)Additional Notes
Add any important context (deployment instructions, screenshots, security considerations, etc.)