Skip to main content

Crate simple_agent_type

Crate simple_agent_type 

Source
Expand description

Core type definitions, async provider traits, and configuration types for SimpleAgents.

No HTTP client or networking code — but includes async-trait for provider interfaces and config types that read from the environment (e.g. TelemetryConfig::from_env).

§Architecture

SimpleAgents follows a trait-based architecture:

  • Provider: Async trait for LLM provider implementations

§Main Types

  • [Message]: Role-based conversation messages
  • [CompletionRequest]: Unified request format
  • [CompletionResponse]: Unified response format
  • [ApiKey]: Secure API key handling

§Example

use simple_agent_type::prelude::*;

// Create a request
let request = CompletionRequest::builder()
    .model("gpt-4")
    .message(Message::user("Hello!"))
    .temperature(0.7)
    .build()
    .unwrap();

// Access request properties
assert_eq!(request.model, "gpt-4");
assert_eq!(request.messages.len(), 1);

§Features

  • Type Safety: Strong types prevent common errors
  • Transparency: All transformations tracked via [CoercionFlag]
  • Security: API keys never logged ([ApiKey])
  • Validation: Early validation with clear errors
  • Async: All traits use async_trait

Re-exports§

pub use error::HealingError;
pub use error::ProviderError;
pub use error::Result;
pub use error::SimpleAgentsError;
pub use error::ValidationError;
pub use telemetry::ApiFormat;
pub use telemetry::OtelProtocol;
pub use telemetry::TelemetryConfig;
pub use telemetry::TraceContext;

Modules§

coercion
Coercion types for tracking response healing.
error
Error types for SimpleAgents.
message
Message types for LLM interactions.
prelude
Prelude module for convenient imports.
provider
Provider trait and types.
request
Request types for LLM completions.
response
Response types for LLM completions.
telemetry
Telemetry and tracing configuration types. Telemetry and tracing configuration types for OpenTelemetry integration.
tool
Tool calling types for function/tool integrations.
validation
Validation types for sensitive data.