|
8 | 8 | from agno.tools.duckduckgo import DuckDuckGoTools |
9 | 9 | from agno.vectordb.pgvector import PgVector, SearchType |
10 | 10 |
|
11 | | -from db.session import db_url |
12 | | - |
13 | | - |
14 | | -def get_agno_assist( |
15 | | - model_id: str = "gpt-5", |
16 | | - debug_mode: bool = False, |
17 | | -) -> Agent: |
18 | | - return Agent( |
19 | | - id="agno-assist", |
20 | | - name="Agno Assist", |
21 | | - model=OpenAIChat(id=model_id), |
22 | | - # Tools available to the agent |
23 | | - tools=[DuckDuckGoTools()], |
24 | | - # Description of the agent |
25 | | - description=dedent("""\ |
26 | | - You are AgnoAssist, an advanced AI Agent specializing in Agno: a lightweight framework for building multi-modal, reasoning Agents. |
27 | | -
|
28 | | - Your goal is to help developers understand and use Agno by providing clear explanations, functional code examples, and best-practice guidance for using Agno. |
29 | | - """), |
30 | | - # Instructions for the agent |
31 | | - instructions=dedent("""\ |
32 | | - Your mission is to provide comprehensive and actionable support for developers working with the Agno framework. Follow these steps to deliver high-quality assistance: |
33 | | -
|
34 | | - 1. **Understand the request** |
35 | | - - Analyze the request to determine if it requires a knowledge search, creating an Agent, or both. |
36 | | - - If you need to search the knowledge base, identify 1-3 key search terms related to Agno concepts. |
37 | | - - If you need to create an Agent, search the knowledge base for relevant concepts and use the example code as a guide. |
38 | | - - When the user asks for an Agent, they mean an Agno Agent. |
39 | | - - All concepts are related to Agno, so you can search the knowledge base for relevant information |
40 | | -
|
41 | | - After Analysis, always start the iterative search process. No need to wait for approval from the user. |
42 | | -
|
43 | | - 2. **Iterative Knowledge Base Search:** |
44 | | - - Use the `search_knowledge_base` tool to iteratively gather information. |
45 | | - - Focus on retrieving Agno concepts, illustrative code examples, and specific implementation details relevant to the user's request. |
46 | | - - Continue searching until you have sufficient information to comprehensively address the query or have explored all relevant search terms. |
47 | | -
|
48 | | - After the iterative search process, determine if you need to create an Agent. |
49 | | -
|
50 | | - 3. **Code Creation** |
51 | | - - Create complete, working code examples that users can run. For example: |
52 | | - ```python |
53 | | - from agno.agent import Agent |
54 | | - from agno.tools.duckduckgo import DuckDuckGoTools |
55 | | -
|
56 | | - agent = Agent(tools=[DuckDuckGoTools()]) |
57 | | -
|
58 | | - # Perform a web search and capture the response |
59 | | - response = agent.run("What's happening in France?") |
60 | | - ``` |
61 | | - - Remember to: |
62 | | - * Build the complete agent implementation |
63 | | - * Includes all necessary imports and setup |
64 | | - * Add comprehensive comments explaining the implementation |
65 | | - * Ensure all dependencies are listed |
66 | | - * Include error handling and best practices |
67 | | - * Add type hints and documentation |
68 | | -
|
69 | | - Key topics to cover: |
70 | | - - Agent architecture, levels, and capabilities. |
71 | | - - Knowledge base integration and memory management strategies. |
72 | | - - Tool creation, integration, and usage. |
73 | | - - Supported models and their configuration. |
74 | | - - Common development patterns and best practices within Agno. |
75 | | -
|
76 | | - Additional Information: |
77 | | - - You are interacting with the user_id: {current_user_id} |
78 | | - - The user's name might be different from the user_id, you may ask for it if needed and add it to your memory if they share it with you.\ |
79 | | - """), |
80 | | - # -*- Knowledge -*- |
81 | | - # Add the knowledge base to the agent |
82 | | - knowledge=Knowledge( |
83 | | - contents_db=PostgresDb(id="agno-storage", db_url=db_url), |
84 | | - vector_db=PgVector( |
85 | | - db_url=db_url, |
86 | | - table_name="agno_assist_knowledge", |
87 | | - search_type=SearchType.hybrid, |
88 | | - embedder=OpenAIEmbedder(id="text-embedding-3-small"), |
89 | | - ), |
| 11 | +from app.models import OPENAI_MODEL_ID |
| 12 | +from db.session import get_session_db, db_url |
| 13 | + |
| 14 | +agno_assist = Agent( |
| 15 | + id="agno-assist", |
| 16 | + name="Agno Assist", |
| 17 | + model=OpenAIChat(id=OPENAI_MODEL_ID), |
| 18 | + # Tools available to the agent |
| 19 | + tools=[DuckDuckGoTools()], |
| 20 | + # Description of the agent |
| 21 | + description=dedent("""\ |
| 22 | + You are AgnoAssist, an advanced AI Agent specializing in Agno: a lightweight framework for building multi-modal, reasoning Agents. |
| 23 | +
|
| 24 | + Your goal is to help developers understand and use Agno by providing clear explanations, functional code examples, and best-practice guidance for using Agno. |
| 25 | + """), |
| 26 | + # Instructions for the agent |
| 27 | + instructions=dedent("""\ |
| 28 | + Your mission is to provide comprehensive and actionable support for developers working with the Agno framework. Follow these steps to deliver high-quality assistance: |
| 29 | +
|
| 30 | + 1. **Understand the request** |
| 31 | + - Analyze the request to determine if it requires a knowledge search, creating an Agent, or both. |
| 32 | + - If you need to search the knowledge base, identify 1-3 key search terms related to Agno concepts. |
| 33 | + - If you need to create an Agent, search the knowledge base for relevant concepts and use the example code as a guide. |
| 34 | + - When the user asks for an Agent, they mean an Agno Agent. |
| 35 | + - All concepts are related to Agno, so you can search the knowledge base for relevant information |
| 36 | +
|
| 37 | + After Analysis, always start the iterative search process. No need to wait for approval from the user. |
| 38 | +
|
| 39 | + 2. **Iterative Knowledge Base Search:** |
| 40 | + - Use the `search_knowledge_base` tool to iteratively gather information. |
| 41 | + - Focus on retrieving Agno concepts, illustrative code examples, and specific implementation details relevant to the user's request. |
| 42 | + - Continue searching until you have sufficient information to comprehensively address the query or have explored all relevant search terms. |
| 43 | +
|
| 44 | + After the iterative search process, determine if you need to create an Agent. |
| 45 | +
|
| 46 | + 3. **Code Creation** |
| 47 | + - Create complete, working code examples that users can run. For example: |
| 48 | + ```python |
| 49 | + from agno.agent import Agent |
| 50 | + from agno.tools.duckduckgo import DuckDuckGoTools |
| 51 | +
|
| 52 | + agent = Agent(tools=[DuckDuckGoTools()]) |
| 53 | +
|
| 54 | + # Perform a web search and capture the response |
| 55 | + response = agent.run("What's happening in France?") |
| 56 | + ``` |
| 57 | + - Remember to: |
| 58 | + * Build the complete agent implementation |
| 59 | + * Includes all necessary imports and setup |
| 60 | + * Add comprehensive comments explaining the implementation |
| 61 | + * Ensure all dependencies are listed |
| 62 | + * Include error handling and best practices |
| 63 | + * Add type hints and documentation |
| 64 | +
|
| 65 | + Key topics to cover: |
| 66 | + - Agent architecture, levels, and capabilities. |
| 67 | + - Knowledge base integration and memory management strategies. |
| 68 | + - Tool creation, integration, and usage. |
| 69 | + - Supported models and their configuration. |
| 70 | + - Common development patterns and best practices within Agno. |
| 71 | +
|
| 72 | + Additional Information: |
| 73 | + - You are interacting with the user_id: {current_user_id} |
| 74 | + - The user's name might be different from the user_id, you may ask for it if needed and add it to your memory if they share it with you.\ |
| 75 | + """), |
| 76 | + # -*- Knowledge -*- |
| 77 | + # Add the knowledge base to the agent |
| 78 | + knowledge=Knowledge( |
| 79 | + contents_db=get_session_db(), |
| 80 | + vector_db=PgVector( |
| 81 | + db_url=db_url, |
| 82 | + table_name="agno_assist_knowledge", |
| 83 | + search_type=SearchType.hybrid, |
| 84 | + embedder=OpenAIEmbedder(id=OPENAI_MODEL_ID), |
90 | 85 | ), |
91 | | - # Give the agent a tool to search the knowledge base (this is True by default but set here for clarity) |
92 | | - search_knowledge=True, |
93 | | - # -*- Storage -*- |
94 | | - # Storage chat history and session state in a Postgres table |
95 | | - db=PostgresDb(id="agno-storage", db_url=db_url), |
96 | | - # -*- History -*- |
97 | | - # Send the last 3 messages from the chat history |
98 | | - add_history_to_context=True, |
99 | | - num_history_runs=3, |
100 | | - # Add a tool to read the chat history if needed |
101 | | - read_chat_history=True, |
102 | | - # -*- Memory -*- |
103 | | - # Enable agentic memory where the Agent can personalize responses to the user |
104 | | - enable_agentic_memory=True, |
105 | | - # -*- Other settings -*- |
106 | | - # Format responses using markdown |
107 | | - markdown=True, |
108 | | - # Add the current date and time to the instructions |
109 | | - add_datetime_to_context=True, |
110 | | - # Show debug logs |
111 | | - debug_mode=debug_mode, |
112 | | - ) |
113 | | - |
114 | | - |
115 | | -# Create the agno assist agent instance for direct import |
116 | | -agno_assist = get_agno_assist() |
| 86 | + ), |
| 87 | + # Give the agent a tool to search the knowledge base (this is True by default but set here for clarity) |
| 88 | + search_knowledge=True, |
| 89 | + # -*- Storage -*- |
| 90 | + # Storage chat history and session state in a Postgres table |
| 91 | + db=get_session_db(), |
| 92 | + # -*- History -*- |
| 93 | + # Send the last 3 messages from the chat history |
| 94 | + add_history_to_context=True, |
| 95 | + num_history_runs=3, |
| 96 | + # Add a tool to read the chat history if needed |
| 97 | + read_chat_history=True, |
| 98 | + # -*- Memory -*- |
| 99 | + # Enable agentic memory where the Agent can personalize responses to the user |
| 100 | + enable_agentic_memory=True, |
| 101 | + # -*- Other settings -*- |
| 102 | + # Format responses using markdown |
| 103 | + markdown=True, |
| 104 | + # Add the current date and time to the instructions |
| 105 | + add_datetime_to_context=True, |
| 106 | +) |
0 commit comments