Skip to content

Commit 21152b8

Browse files
Mustafa-EsoofallyLockeysama
authored andcommitted
An agent that uses RAG to get recipes and generates images (agno-agi#3058)
## Summary Describe key changes, mention related issues or motivation for the changes. (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.)
1 parent e95ef5d commit 21152b8

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
"""Example: Multi-Modal RAG & Image Agent
2+
3+
An agent that uses Llama 4 for multi-modal RAG and OpenAITools to create a visual, step-by-step image manual for a recipe.
4+
5+
Run: `pip install openai agno groq cohere` to install the dependencies
6+
"""
7+
8+
from pathlib import Path
9+
10+
from agno.agent import Agent
11+
from agno.embedder.cohere import CohereEmbedder
12+
from agno.knowledge.pdf_url import PDFUrlKnowledgeBase
13+
from agno.models.groq import Groq
14+
from agno.tools.openai import OpenAITools
15+
from agno.utils.media import download_image
16+
from agno.vectordb.pgvector import PgVector
17+
18+
knowledge_base = PDFUrlKnowledgeBase(
19+
urls=["https://agno-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf"],
20+
vector_db=PgVector(
21+
db_url="postgresql+psycopg://ai:ai@localhost:5532/ai",
22+
table_name="embed_vision_documents",
23+
embedder=CohereEmbedder(
24+
id="embed-v4.0",
25+
),
26+
),
27+
)
28+
29+
knowledge_base.load()
30+
31+
agent = Agent(
32+
name="EmbedVisionRAGAgent",
33+
model=Groq(id="meta-llama/llama-4-scout-17b-16e-instruct"),
34+
tools=[OpenAITools()],
35+
knowledge=knowledge_base,
36+
instructions=[
37+
"You are a specialized recipe assistant.",
38+
"When asked for a recipe:",
39+
"1. Search the knowledge base to retrieve the relevant recipe details.",
40+
"2. Analyze the retrieved recipe steps carefully.",
41+
"3. Use the `generate_image` tool to create a visual, step-by-step image manual for the recipe.",
42+
"4. Present the recipe text clearly and mention that you have generated an accompanying image manual. Add instructions while generating the image.",
43+
],
44+
markdown=True,
45+
debug_mode=True,
46+
)
47+
48+
agent.print_response(
49+
"What is the recipe for a Thai curry?",
50+
)
51+
52+
response = agent.run_response
53+
if response.images:
54+
download_image(response.images[0].url, Path("tmp/recipe_image.png"))

0 commit comments

Comments
 (0)