Crate mecha10_ai_llm

Crate mecha10_ai_llm 

Source
Expand description

Mecha10 AI - Large Language Models

This crate provides LLM integration as BehaviorNode implementations.

§Supported Providers

  • Claude (Anthropic) - Claude 3.5 Sonnet, Claude 3 Opus, etc.
  • OpenAI - GPT-4, GPT-4 Turbo, GPT-3.5
  • Local - Ollama, Llama.cpp (HTTP API)

§Example

use mecha10_ai_llm::prelude::*;

// Create Claude LLM node
let mut llm = LlmNode::claude()
    .with_model("claude-3-5-sonnet-20241022")
    .with_system_prompt("You are a helpful robot assistant.")
    .with_api_key(std::env::var("ANTHROPIC_API_KEY")?)
    .build()?;

// Ask a question
llm.add_message("user", "What should I do next?");
let status = llm.tick(ctx).await?;

if let Some(response) = llm.last_response() {
    println!("LLM: {}", response);
}

Modules§

prelude
Prelude module for convenient imports

Structs§

ClaudeProvider
Claude (Anthropic) provider
LlmConfig
Configuration for an LLM node
LlmMessage
A message in the conversation
LlmNode
LLM node that generates text completions
LlmNodeBuilder
Builder for LLM nodes
LlmResponse
Response from LLM
LlmUsage
Token usage statistics
OpenAIProvider
OpenAI provider

Traits§

LlmProvider
Trait for LLM providers