Skip to content

Commit 0b26ad9

Browse files
author
Dhivya-Bharathy
committed
Add agentic RAG Python implementation to tools
1 parent 60e1cdd commit 0b26ad9

File tree

1 file changed

+44
-0
lines changed
  • examples/python/tools/exa-tool/rag_examples/agentic_rag

1 file changed

+44
-0
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
from praisonaiagents import Agent
2+
import os
3+
4+
# Set OpenAI API key if not already set
5+
if not os.getenv("OPENAI_API_KEY"):
6+
print("Please set your OpenAI API key: export OPENAI_API_KEY='your-api-key-here'")
7+
exit(1)
8+
9+
# Create the RAG agent with web search capabilities
10+
rag_agent = Agent(
11+
instructions="""You are a helpful AI assistant specialized in Thai recipes and cooking.
12+
13+
You have access to a PDF knowledge base about Thai recipes from: https://phi-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf
14+
15+
You can also search the web for additional information about Thai cooking, ingredients, and techniques.
16+
17+
When answering questions:
18+
1. Use your knowledge about Thai cuisine to provide helpful information
19+
2. If needed, search the web for additional details, current information, or clarification
20+
3. Provide comprehensive, helpful answers about Thai cuisine
21+
4. Always be informative and helpful about Thai cooking!
22+
23+
You can use the internet_search function to search the web when needed.""",
24+
llm="gpt-4o",
25+
markdown=True,
26+
verbose=True
27+
)
28+
29+
if __name__ == "__main__":
30+
print("🤖 Thai Recipe RAG Agent is ready!")
31+
print("Ask me anything about Thai recipes or cooking!")
32+
print("Type 'quit' to exit.\n")
33+
34+
while True:
35+
user_input = input("You: ")
36+
if user_input.lower() in ['quit', 'exit', 'bye']:
37+
print("👋 Goodbye! Happy cooking!")
38+
break
39+
40+
try:
41+
response = rag_agent.start(user_input)
42+
print(f"\n🤖 Assistant: {response}\n")
43+
except Exception as e:
44+
print(f"❌ Error: {e}\n")

0 commit comments

Comments
 (0)