Agent
Overview
The Agents
component is the core of the Tempus framework, providing AI-powered market analysis capabilities. It uses LangChain and various LLM providers to create intelligent agents that can analyze cryptocurrency markets, understand market trends, and provide insights.
Capabilities
Processes user prompts and queries related to cryptocurrency analysis.
Analyzes live token data from the Solana blockchain.
Leverages AI-driven tools for contract analysis, market trend evaluation, and ticker monitoring.
Supports multiple AI models, including OpenAI's GPT-4 and DeepSeek models.
Generates structured reports with trading recommendations and market trend analysis.
Agent Workflow
Receives Prompt Input – The agent processes user messages and commands.
Queries Data from APIs – The system retrieves data from external sources like Dexscreener and Solana RPC.
Applies AI-Based Analysis – The agent uses predefined prompt templates and market analysis tools to structure responses.
Outputs a Detailed Market Report – Generates insights, including price trends, volatility analysis, and contract evaluations.
Memory Management – Maintains conversation history and context for continuous engagement.
Basic Concepts
QuantAIAgent
The main agent class that provides:
Market analysis capabilities
LLM integration
Conversation management
Tool orchestration
Chatbot
A helper class that manages:
LLM interactions
Response processing
Error handling
Stream management
State Management
The agent maintains:
Conversation history
Tool states
LLM configuration
Memory checkpoints
Architecture
Basic Usage
Advanced Features
Conversation Management
The agent maintains conversation history for context:
Tool Integration
The agent automatically manages market analysis tools:
Error Handling
The agent includes robust error handling:
Configuration
LLM Providers
Currently supported LLM providers:
OpenAI (default: gpt-4)
Deepseek (default: deepseek-chat)
Memory Management
The agent uses LangChain's memory system:
Internal Components
StateGraph
The agent uses LangChain's StateGraph for workflow:
Message Handling
The agent processes different message types:
HumanMessage: User inputs
AIMessage: Agent responses
ToolMessage: Tool outputs
SystemMessage: System prompts
Best Practices
Model Selection
Use OpenAI for accuracy
Use Deepseek for cost-efficiency
Memory Management
Clear history periodically
Monitor memory usage
Error Handling
Implement proper try-except blocks
Log errors appropriately
Performance
Use streaming for long responses
Batch similar queries
Common Issues
Rate Limiting
Context Management
Model Switching
Extension Points
Custom Tools
Add custom tools to the agent:
Custom Prompts
Modify system prompts:
Performance Optimization
Streaming Optimization
Batch Processing
Security Considerations
API Key Management
Use environment variables
Rotate keys regularly
Input Validation
Rate Limiting
Last updated