|
| 1 | +import os |
| 2 | + |
| 3 | +from llama_index.core.agent.workflow import AgentWorkflow |
| 4 | +from llama_index.llms.openai import OpenAI |
| 5 | +from llama_index.tools.tavily_research import TavilyToolSpec |
| 6 | + |
| 7 | +llm = OpenAI(model="gpt-4o-mini") |
| 8 | +tavily_tool = TavilyToolSpec(api_key=os.environ["TAVILY_API_KEY"]) |
| 9 | + |
| 10 | +SYSTEM_PROMPT = ( |
| 11 | + "You are an advanced AI assistant specializing in book research and literature analysis. " |
| 12 | + "Your primary functions are:\n\n" |
| 13 | + "1. Book Information Research: Gather comprehensive information about books, including plot summaries, " |
| 14 | + "themes, publishing details, sales performance, critical reception, and awards.\n" |
| 15 | + "2. Author Research: Provide detailed information about authors, translators, editors, and other " |
| 16 | + "publishing industry professionals.\n" |
| 17 | + "3. Book Recommendations: Suggest books based on user preferences, genres, themes, or similar books " |
| 18 | + "they have enjoyed.\n" |
| 19 | + "4. Publishing Industry Analysis: Analyze trends, bestseller data, genre popularity, and insights " |
| 20 | + "from the literary world.\n" |
| 21 | + "5. Book Trivia and Facts: Share interesting facts, behind-the-scenes stories, and trivia about " |
| 22 | + "books, authors, and the publishing industry.\n\n" |
| 23 | + "Use the search tool for recent or factual information. " |
| 24 | + "Remember previous messages and maintain context across the discussion." |
| 25 | +) |
| 26 | + |
| 27 | +agent = AgentWorkflow.from_tools_or_functions( |
| 28 | + tools_or_functions=tavily_tool.to_tool_list(), llm=llm, system_prompt=SYSTEM_PROMPT |
| 29 | +) |
0 commit comments