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