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

  1. Receives Prompt Input – The agent processes user messages and commands.

  2. Queries Data from APIs – The system retrieves data from external sources like Dexscreener and Solana RPC.

  3. Applies AI-Based Analysis – The agent uses predefined prompt templates and market analysis tools to structure responses.

  4. Outputs a Detailed Market Report – Generates insights, including price trends, volatility analysis, and contract evaluations.

  5. 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

  1. Model Selection

    • Use OpenAI for accuracy

    • Use Deepseek for cost-efficiency

  2. Memory Management

    • Clear history periodically

    • Monitor memory usage

  3. Error Handling

    • Implement proper try-except blocks

    • Log errors appropriately

  4. Performance

    • Use streaming for long responses

    • Batch similar queries

Common Issues

  1. Rate Limiting

  2. Context Management

  3. Model Switching

Extension Points

Custom Tools

Add custom tools to the agent:

Custom Prompts

Modify system prompts:

Performance Optimization

  1. Streaming Optimization

  2. Batch Processing

Security Considerations

  1. API Key Management

    • Use environment variables

    • Rotate keys regularly

  2. Input Validation

  3. Rate Limiting

Last updated