Crate ceylon_next

Crate ceylon_next 

Source
Expand description

§Ceylon - AI Agent Framework

Ceylon is a powerful and flexible framework for building AI agents with goal-oriented capabilities, memory management, and tool integration.

§Features

  • Goal-Oriented Agents: Agents that can analyze tasks, break them into sub-goals, and track progress
  • Memory Management: Built-in conversation history and context management
  • Tool Integration: Extensible tool system for adding custom capabilities
  • Multiple LLM Support: Works with OpenAI, Anthropic, Ollama, and other LLM providers
  • Async-First: Built on Tokio for efficient async/await support

§Quick Start

use ceylon_next::agent::Agent;
use ceylon_next::tasks::TaskRequest;

#[tokio::main]
async fn main() {
    // Create a new agent
    let mut agent = Agent::new("MyAssistant", "openai::gpt-4");

    // Create a task
    let task = TaskRequest::new("What is the capital of France?");

    // Run the agent
    let response = agent.run(task).await;
    println!("Response: {:?}", response.result());
}

§Working with Tools

use ceylon_next::agent::Agent;
use ceylon_next::tools::ToolTrait;
use serde_json::json;

// Define a custom tool
struct CalculatorTool;

impl ToolTrait for CalculatorTool {
    fn name(&self) -> String {
        "calculator".to_string()
    }

    fn description(&self) -> String {
        "Performs basic arithmetic operations".to_string()
    }

    fn input_schema(&self) -> serde_json::Value {
        json!({
            "type": "object",
            "properties": {
                "operation": {"type": "string"},
                "a": {"type": "number"},
                "b": {"type": "number"}
            }
        })
    }

    fn execute(&self, input: serde_json::Value) -> serde_json::Value {
        // Implementation details...
        json!({"result": 42})
    }
}

#[tokio::main]
async fn main() {
    let mut agent = Agent::new("Calculator Agent", "openai::gpt-4");
    agent.add_tool(CalculatorTool);
    // Now the agent can use the calculator tool
}

§Working with Memory

use ceylon_next::agent::Agent;
use ceylon_next::tasks::TaskRequest;

#[tokio::main]
async fn main() {
    let mut agent = Agent::new("MemoryAgent", "openai::gpt-4");

    // First conversation
    let task1 = TaskRequest::new("My name is Alice");
    agent.run(task1).await;

    // Second conversation - agent remembers context
    let task2 = TaskRequest::new("What is my name?");
    let response = agent.run(task2).await;
    // Agent should respond with "Alice"

    // Search memory
    let memories = agent.search_memory("Alice").await;
    println!("Found {} relevant conversations", memories.len());
}

§Working with Goals

use ceylon_next::agent::{Agent, AgentConfig};
use ceylon_next::tasks::TaskRequest;

#[tokio::main]
async fn main() {
    let mut agent = Agent::new("GoalAgent", "openai::gpt-4");

    // Enable goal analysis (enabled by default)
    let mut config = AgentConfig::default();
    config.with_goal_analysis(true);
    agent.with_config(config);

    // The agent will automatically analyze and break down complex tasks
    let task = TaskRequest::new("Create a web server with user authentication");
    let response = agent.run(task).await;

    // Check the goal that was created
    if let Some(goal) = agent.get_current_goal() {
        println!("{}", goal.get_summary());
    }
}

Modules§

agent
Agent module providing the core Agent functionality.
goal
Goal-oriented task planning and tracking system.
llm
LLM (Large Language Model) integration layer.
memory
Memory system for storing and retrieving agent conversation history.
runner
Agent runner with TOML configuration support
tasks
Task management types for agent execution.
tools
Tool system for extending agent capabilities.