from agno.agent import Agentfrom agno.models.openai import OpenAILikefrom tools.history_tools import HistoryToolscontext_qna_agent = Agent( id="context-qna-agent", name="Chat Context Q&A", role="Answering questions about users, topics, and past conversations", model=OpenAILike( id="gpt-4-turbo", max_tokens=8000, temperature=0.3, base_url="https://your-api.com", api_key="your-key", ), tools=[HistoryTools()], instructions=""" You specialize in answering questions about chat history, users, and topics. Always call `read_chat_history` before answering questions. IMPORTANT: Fetch a minimum of 5000 messages on first try. Use the history to: - Answer "who said what" questions - Summarize discussions on specific topics - Track when topics were last mentioned - Identify user opinions and statements - Provide context about past conversations Be precise with timestamps and attribute statements accurately. """)
from tools.history_tools import HistoryToolsfrom tools.bio_tools import BioTools# Combine with BioTools for comprehensive user contextcontext_agent = Agent( name="Context Agent", model=my_model, tools=[HistoryTools(), BioTools(client=discord_client)], instructions="Use chat history and user details to answer questions.")
context_qna_agent = Agent( id="context-qna-agent", name="Chat Context Q&A", role="Answering questions about users, topics, and past conversations", model=OpenAILike( id=CONTEXT_AGENT_MODEL, max_tokens=8000, temperature=0.3, base_url=PROVIDER, api_key=CUSTOM_PROVIDER_API_KEY, ), tools=[HistoryTools(), BioTools(client=client)], add_datetime_to_context=True, timezone_identifier="Asia/Kolkata", instructions=""" You specialize in answering questions about the chat history, users, and topics discussed. You have access to `read_chat_history`. Call this tool to get the conversation history before answering questions. IMPORTANT: always fetch a minimum of 5000 messages on first try. Use the history to: - Answer "who said what" questions - Summarize discussions on specific topics - Track when topics were last mentioned - Identify user opinions and statements - Provide context about past conversations Be precise with timestamps and attribute statements accurately to users. """)
import logginglogger = logging.getLogger(__name__)# Log levels used:logger.info(f"Fetching history for channel {channel.id} with limit {limit}")logger.warning(f"Channel object missing, falling back to DB-only for ID {channel_id}")logger.error(f"Error fetching history: {e}", exc_info=True)