Skip to content

General Agent Flow

General Agent Flow

Configurable LLM agent for various AI tasks including conversation, analysis, and structured data processing.

How to Use

Input Requirements

To configure the AI agent, you need:

  • Model Selection: Choose any model from the available options
  • System Prompt: Define how the AI should behave and respond
  • Mode: Select Normal or Structured output mode
  • JSON Schema: Required only for Structured mode

Configuration Modes

Normal Mode

Purpose: Get flexible text or JSON responses based on your system prompt

Configuration:

  • Model: Choose any model from dropdown options (GPT-4, GPT-3.5, Claude, etc.)
  • System Prompt: Write instructions for how the AI should behave

Example Setup:

Model: GPT-4
System Prompt: "You are a helpful crypto trading assistant. Provide clear advice about DeFi protocols and market trends."

Output: String or JSON based on what your system prompt requests

Structured Mode (For JSON Structured Output)

Purpose: Get guaranteed JSON output that follows a specific format

Configuration:

  • Model: Choose any model from dropdown options
  • System Prompt: Write instructions for the AI
  • JSON Schema: Define the exact structure you want

Example Setup:

Model: GPT-4
System Prompt: "Analyze crypto prices and provide trading recommendations"
JSON Schema: {
  "type": "object",
  "properties": {
    "recommendation": {"type": "string"},
    "confidence": {"type": "number"},
    "price_target": {"type": "number"}
  }
}

Output: Always returns structured JSON matching your schema

Configuration Examples

Customer Support Agent (Normal Mode)

Input: "Help me understand DeFi yield farming" System Prompt: "You are a friendly DeFi expert. Explain complex concepts in simple terms." Output:

"DeFi yield farming is like earning interest on your crypto by lending it to protocols. You deposit tokens into pools and earn rewards, typically 5-20% annually. Popular platforms include Aave, Compound, and Uniswap. Start small and research risks before investing."

Price Analysis Agent (Structured Mode)

Input: "Analyze Bitcoin price trends" System Prompt: "Analyze crypto market data and provide trading insights" JSON Schema:

{
  "type": "object",
  "properties": {
    "trend": {"type": "string"},
    "confidence": {"type": "number"},
    "recommendation": {"type": "string"},
    "target_price": {"type": "number"}
  }
}

Output:

{
  "trend": "bullish",
  "confidence": 0.75,
  "recommendation": "BUY",
  "target_price": 52000
}

Content Creator Agent (Normal Mode)

Input: "Write a tweet about Ethereum" System Prompt: "You are a crypto content creator. Write engaging, informative social media posts." Output:

"🚀 Ethereum continues to lead DeFi innovation! With over $50B locked in protocols and growing Layer 2 adoption, $ETH remains the backbone of decentralized finance. What's your favorite dApp? #Ethereum #DeFi #Web3"

Data Extraction Agent (Structured Mode)

Input: "Extract key info from this contract: 0x1234..." System Prompt: "Extract blockchain contract information and return structured data" JSON Schema:

{
  "type": "object",
  "properties": {
    "contract_type": {"type": "string"},
    "token_symbol": {"type": "string"},
    "total_supply": {"type": "number"},
    "is_verified": {"type": "boolean"}
  }
}

Output:

{
  "contract_type": "ERC-20",
  "token_symbol": "USDC",
  "total_supply": 1000000000,
  "is_verified": true
}

Mode Selection Guide

Choose Normal Mode When:

  • You want flexible, conversational responses
  • Output format can vary based on the question
  • You need explanations, summaries, or creative content
  • Human-readable text is the primary goal

Choose Structured Mode When:

  • You need consistent JSON output format
  • Data will be processed by other systems
  • You require specific fields every time
  • Building APIs or automated workflows

Input Format

Provide questions or requests in natural language:

Example inputs:
  • "Explain how staking works"
  • "Analyze this wallet address"
  • "Write a summary of today's crypto news"
  • "Compare Uniswap vs SushiSwap"

Output Format

Normal Mode: Returns flexible text or JSON based on system prompt Structured Mode: Returns guaranteed JSON matching your schema

Use Cases

Trading & Analysis

  • Market trend analysis
  • Portfolio recommendations
  • Risk assessments
  • Trading signal generation

Content Creation

  • Social media posts
  • Blog articles
  • Documentation
  • Educational content

Data Processing

  • Contract analysis
  • Wallet research
  • Transaction summaries
  • Protocol comparisons

Customer Support

  • Answer user questions
  • Explain crypto concepts
  • Troubleshoot issues
  • Provide guidance

Technical Details

Overview

LLMAgentFlow is a versatile, configurable flow within the SkynetXBT framework that provides general-purpose AI capabilities. It acts as a flexible wrapper around LLM (Large Language Model) functionality, supporting both structured and unstructured outputs for various AI tasks.

Features

  • Dual Output Modes: Supports both normal text responses and structured JSON outputs
  • Configurable LLM Providers: Works with multiple AI providers (OpenAI, Azure, custom endpoints)
  • Schema Validation: Automatic JSON schema to Zod conversion for structured outputs
  • Customizable System Prompts: Define specific AI behaviors and personas
  • Type Safety: Full TypeScript implementation with proper error handling
  • Flexible Configuration: Extensive LLM configuration options

Implementation Examples

Contract Address Extraction

const contractExtractor = new LLMAgentFlow({
  llmConfig: { /* your config */ },
  settings: {
    type: "structured",
    systemPrompt: "Extract contract addresses from user messages.",
    schema: {
      type: "object",
      properties: {
        addresses: { 
          type: "array",
          items: { type: "string" }
        },
        count: { type: "number" }
      }
    }
  }
});

General Q&A Agent

const qaAgent = new LLMAgentFlow({
  llmConfig: { /* your config */ },
  settings: {
    type: "normal",
    systemPrompt: "You are a knowledgeable blockchain expert. Answer questions clearly and concisely."
  }
});

Best Practices

System Prompt Design

// Good: Specific and clear
systemPrompt: "You are a DeFi yield farming expert. Analyze protocols and suggest optimal strategies based on risk tolerance and capital amount."
 
// Avoid: Too vague
systemPrompt: "You are helpful."

Schema Design

// Good: Well-defined schema
schema: {
  type: "object",
  properties: {
    protocol: { type: "string" },
    apy: { type: "number", minimum: 0 },
    riskLevel: { type: "string", enum: ["LOW", "MEDIUM", "HIGH"] },
    tvl: { type: "number", minimum: 0 }
  },
  required: ["protocol", "apy", "riskLevel"]
}

Troubleshooting

Common Issues

"Invalid API key" errors
  • Verify your API key is correct and has sufficient permissions
  • Check if the key is properly set in environment variables
"Rate limit exceeded" errors
  • Implement exponential backoff retry logic
  • Consider upgrading your API plan
Schema validation failures
  • Simplify your schema
  • Add more specific instructions in the system prompt
  • Use examples in the prompt to guide the model
Inconsistent responses
  • Lower the temperature for more consistent outputs
  • Use more specific system prompts
  • Consider using structured outputs for critical data

Next Steps: