Agents-MCP-Hackathon/NoCoMind-Dynamic-Customizable-AI-Agent-Systems
11
1import os2import traceback3from dotenv import load_dotenv4from agno.agent import Agent5from agno.storage.agent.sqlite import SqliteAgentStorage6from agno.memory.agent import AgentMemory7from agno.models.nebius import Nebius8 9load_dotenv()10NEBIUS_API_KEY = os.getenv("NEBIUS_API_KEY")11DB_NAME = "hackathon.db"12 13storage = SqliteAgentStorage(table_name="hackathon_storage", db_file=DB_NAME)14memory = AgentMemory()15 16class AgentFactory:17 def __init__(self, user_id, thread_id, agent_config: dict, knowledge_base):18 self.user_id = user_id19 self.thread_id = thread_id20 self.agent_config = agent_config21 self.knowledge_base = knowledge_base22 23 async def routing_agent(self):24 try:25 routing_agent = Agent(26 model=Nebius(27 id="meta-llama/Meta-Llama-3.1-405B-Instruct",28 temperature=0,29 api_key=NEBIUS_API_KEY,30 base_url="https://api.studio.nebius.com/v1/"31 ),32 name="Routing Agent",33 description="You are a helpful routing assistant. This agent is responsible for routing the user's message to the appropriate agent. Based on the question it has to provide response. If question relates to 'plot', 'chart', 'graph', 'visualize', 'visualization', 'visual','bar chart', 'line chart', 'pie chart', 'scatter plot', 'histogram', 'heatmap', 'dashboard', 'show me', 'display', 'draw', 'create chart','generate plot', 'make graph', 'data visualization', 'analytics','trends', 'comparison chart', 'infographic'. If the question relates to the visualization like above key points then respond with 'visualization' else respond 'normal'.",34 instructions=[35 "You should only respond with 'normal' or 'visualization'.",36 "DO NOT add any delimiter between the response and the word 'normal' or 'visualization'.",37 "Your response should be one word accordingly.",38 ],39 show_tool_calls=True,40 markdown=True,41 debug_mode=True42 )43 return routing_agent44 except Exception as e:45 print("Error creating routing agent:", traceback.format_exc())46 raise e47 48 async def normal_and_reasoning_agent(self, tools, model_name) -> Agent:49 try:50 agent = Agent(51 model=Nebius(52 id=model_name, #meta-llama/Meta-Llama-3.1-405B-Instruct #Qwen/Qwen3-235B-A22B #Qwen/Qwen3-30B-A3B53 temperature=0,54 api_key=NEBIUS_API_KEY,55 base_url="https://api.studio.nebius.com/v1/"56 ),57 name=self.agent_config["name"],58 description=self.agent_config["description"],59 instructions=self.agent_config["instructions"],60 tools=tools,61 show_tool_calls=True,62 markdown=True,63 debug_mode=True,64 knowledge=self.knowledge_base,65 search_knowledge=True,66 storage=storage,67 memory=memory,68 user_id=self.user_id,69 add_history_to_messages=True,70 session_id=self.thread_id,71 num_history_responses=1072 )73 return agent74 except Exception as e:75 print("Error creating agent:", traceback.format_exc())76 raise e