Skip to main content

Crate simple_agents_core

Crate simple_agents_core 

Source
Expand description

Core client API for SimpleAgents.

This crate provides the unified SimpleAgentsClient that integrates providers, routing, caching, healing, and middleware in one place.

§Example

use simple_agents_core::{
    CompletionOptions, CompletionOutcome, RoutingMode, SimpleAgentsClient,
    SimpleAgentsClientBuilder,
};
use simple_agent_type::prelude::*;
let client = SimpleAgentsClientBuilder::new()
    .with_provider(Arc::new(MockProvider))
    .with_routing_mode(RoutingMode::RoundRobin)
    .build()?;

let request = CompletionRequest::builder()
    .model("gpt-4")
    .message(Message::user("Hello!"))
    .build()?;

let outcome = client.complete(&request, CompletionOptions::default()).await?;
let response = match outcome {
    CompletionOutcome::Response(response) => response,
    _ => return Ok(()),
};
println!("{}", response.content().unwrap_or_default());

Modules§

prelude
Prelude module for convenient imports.

Structs§

CompletionOptions
Options that control completion behavior.
HealedJsonResponse
JSON healing response wrapper.
HealedSchemaResponse
Schema-aligned healing response wrapper.
HealingSettings
Healing settings for JSON parsing and coercion.
SimpleAgentsClient
Unified SimpleAgents client.
SimpleAgentsClientBuilder
Builder for SimpleAgentsClient.

Enums§

CompletionMode
Mode for completion post-processing.
CompletionOutcome
Result of a unified completion call.
RoutingMode
Routing modes supported by the core client.

Traits§

Middleware
Middleware hooks for request lifecycle events.