Agents

Agents are a combination of a single model and a single directive. An agent can be given a task to pursue. During task execution, the agent may request command execution through the AGiXT server. If this occurs, the command result is passed back to the agent, and execution continues until the agent determines the task is complete.

Agent Traits

The core functionality of agents is defined in the AgentTrait trait. This trait provides a standardized interface for all agents, ensuring consistency across implementations.

Trait Definition

use async_trait::async_trait;
use std::error::Error;
use models::message::Message;

#[async_trait]
pub trait AgentTrait {
    fn get_name(&self) -> &str;
    fn is_coder_agent(&self) -> bool;
    fn is_twitter_agent(&self) -> bool;
    fn convert_to_coder(&mut self);
    fn convert_to_chat(&mut self);
    fn convert_to_twitter(&mut self);
    async fn send_message(&mut self, input: &str) -> Result<String, Box<dyn Error>>;
    fn export_to_file(&self, file_path: &str) -> Result<(), Box<dyn Error>>;
    fn import_from_file(file_path: &str) -> Result<Self, Box<dyn Error>>
    where
        Self: Sized;

    fn set_custom_provider(&mut self, provider: &str);
    fn get_provider(&self) -> Option<&str>;

    fn set_model(&mut self, model: &str);
    fn get_model(&self) -> &str;

    fn set_temperature(&mut self, temperature: f64);
    fn get_temperature(&self) -> Option<f64>;

    fn set_max_tokens(&mut self, max_tokens: u64);
    fn get_max_tokens(&self) -> Option<u64>;

    fn add_system_msg(&mut self, sys_msg: &str);
    fn get_system_messages(&self) -> Vec<&Message>;
}

Base Agent

The BaseAgent struct serves as the foundation for all agents, providing core functionalities such as message handling, model interaction, and API request management. Derived agent types should use this base to ensure consistency.

Agent Settings

Agent settings allow users to manage and configure their agents. This includes adding, updating, and deleting agents. Users can customize the provider, model, and various other parameters to control agent behavior.

If agent settings are not specified, default values are used:

Default Settings

Setting Value Description
provider gpt4free The language model provider.
embedder default The embedder for generating embeddings.
AI_MODEL gpt-3.5-turbo The language model used.
AI_TEMPERATURE 0.7 Temperature setting for response generation.
AI_TOP_P 1 Top p value used.
MAX_TOKENS 4000 Maximum tokens allowed.
helper_agent_name gpt4free Name of the helper agent.
WEBSEARCH_TIMEOUT 0 Timeout for web searches.
WAIT_BETWEEN_REQUESTS 1 Delay between requests.
WAIT_AFTER_FAILURE 3 Delay after failure before retrying.
stream False Whether to stream responses.
WORKING_DIRECTORY ./WORKSPACE Directory for agent operations.
WORKING_DIRECTORY_RESTRICTED True Restricts agent operations to the working directory.
agent_type base64 The agent type must be in base64 format.

Configuration Files

Agents can be configured using JSON or YAML configuration files. These files allow users to predefine settings, making it easier to manage multiple agents across different environments.

Example JSON configuration:

{
  "provider": "gpt4free",
  "AI_MODEL": "gpt-3.5-turbo",
  "AI_TEMPERATURE": 0.7,
  "MAX_TOKENS": 4000,
  "WORKING_DIRECTORY": "./WORKSPACE",
  "agent_type": "coder"
}

Remember to set the file base64 and save as ".agent"

Customization

Users can customize agent behavior by modifying the configuration file or programmatically adjusting parameters using API calls or command-line options. This flexibility ensures that agents can be tailored to specific needs and use cases.

By leveraging these settings and configurations, users can optimize their agents for performance, accuracy, and efficiency.

results matching ""

    No results matching ""