weavegraph 0.7.0

Graph-driven, concurrent agent workflow framework with versioned state, deterministic barrier merges, and rich diagnostics.
Documentation
//! Framework-agnostic traits for LLM providers.
use crate::message::Message;
use async_trait::async_trait;
use futures_util::stream::BoxStream;

/// Boxed error type for LLM provider operations.
pub type LlmError = Box<dyn std::error::Error + Send + Sync + 'static>;

/// Completed response from an LLM provider.
#[derive(Clone, Debug, Default)]
pub struct LlmResponse {
    /// Generated text content.
    pub content: String,
    /// Provider metadata (token counts, finish reason, etc.).
    pub metadata: serde_json::Value,
}

/// Non-streaming LLM provider.
#[async_trait]
pub trait LlmProvider: Send + Sync {
    /// Run a chat completion over `messages`.
    async fn chat(&self, messages: &[Message]) -> Result<LlmResponse, LlmError>;
}

/// Streaming LLM provider.
#[async_trait]
pub trait LlmStreamProvider: LlmProvider {
    /// Token chunk type produced during streaming.
    type Chunk: Send + 'static;

    /// Stream a chat completion over `messages`.
    async fn chat_stream(
        &self,
        messages: &[Message],
    ) -> Result<BoxStream<'static, Result<Self::Chunk, LlmError>>, LlmError>;
}