Skip to content

Conversation

@kausmeows
Copy link
Contributor

Summary

passing the user uploaded images in the toolkit

(If applicable, issue number: #____)

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Improvement
  • Model update
  • Other:

Checklist

  • Code complies with style guidelines
  • Ran format/validation scripts (./scripts/format.sh and ./scripts/validate.sh)
  • Self-review completed
  • Documentation updated (comments, docstrings)
  • Examples and guides: Relevant cookbook examples have been included or updated (if applicable)
  • Tested in clean environment
  • Tests added/updated (if applicable)

Additional Notes

Add any important context (deployment instructions, screenshots, security considerations, etc.)

@kausmeows kausmeows marked this pull request as ready for review May 13, 2025 09:32
@kausmeows kausmeows requested a review from a team as a code owner May 13, 2025 09:32
@kausmeows kausmeows changed the title feat: tools structured response feat(WIP): tools structured response May 13, 2025
@kausmeows kausmeows added the WIP work in progress label May 13, 2025
@kausmeows kausmeows changed the title feat(WIP): tools structured response feat: tools structured response May 13, 2025
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
Copy link
Contributor

Choose a reason for hiding this comment

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

?

content=introduction,
messages=[
Message(role=self.model.assistant_message_role, content=introduction) # type: ignore
# type: ignore
Copy link
Contributor

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.
Copy link
Contributor

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:
Copy link
Contributor

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")
Copy link
Contributor

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)
Copy link
Contributor

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)
Copy link
Contributor

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

@kausmeows
Copy link
Contributor Author

closing in favour of- #4286
for v2.0

@kausmeows kausmeows closed this Aug 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

WIP work in progress

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants