Documentation

ML Agent

The ML Agent is an intelligent component that processes inputs and generates responses based on configured language models and tools. It provides a flexible interface for natural language interactions with customizable behaviors and capabilities.

ML Agent Component

ML Agent interface and configuration options

Configuration Note: Ensure proper configuration of all required fields including Template, Language Model, and Agent Instructions for optimal performance.

Component Configuration

  • Template: Message template configuration

    Format: {{sender_name}}: {{text}}

  • Language Model: The AI model to use for processing

    Select from available language models

  • Agent Instructions: Behavioral guidelines for the agent

    Detailed instructions for agent behavior and responses

  • Tools: Available tools and capabilities

    Configure tools the agent can use

Advanced Settings

  • Handle Parse Errors: Error handling configuration
  • Verbose: Detailed logging options
  • Max Iterations: Maximum number of processing iterations (default: 15)
  • External Memory: Configuration for persistent memory
  • Sender Type: Type of sender (Machine and User)
  • Number of Messages: Message history limit (default: 100)
  • Session ID: Unique identifier for conversation sessions
  • Order: Message ordering preference (Ascending)

Implementation Example

const mlAgent = new MLAgent({ template: "{sender_name}: {text}", languageModel: "gpt-4", agentInstructions: "You are a helpful assistant...", tools: ["search", "calculate", "fetch"], maxIterations: 15, senderType: "Machine and User", numberOfMessages: 100, order: "Ascending" }); const response = await mlAgent.process({ input: "Hello, can you help me?", sessionId: "user-session-123" }); // Output: // { // response: "Hello! Of course, I'd be happy to help...", // metadata: { // toolsUsed: [], // processingTime: "0.5s", // confidence: 0.95 // } // }

Best Practices

  • Provide clear and specific agent instructions
  • Configure appropriate error handling
  • Monitor and limit iterations
  • Maintain session context appropriately
  • Regular performance monitoring