Skip to main content

Crate af_llm

Crate af_llm 

Source
Expand description

af-llm — unified async LLM access for the Agent Factory platform.

Provider-neutral model transport and request types. Provides:

§Example

use af_llm::{LlmClient, LlmConfig, CompletionRequest, ChatMessage};

let client = LlmClient::new(LlmConfig::new("http://localhost:4000/v1", ""))?;
let req = CompletionRequest::new(
    "deepseek/deepseek-chat",
    vec![ChatMessage::user("Say hi in one word.")],
);
let resp = client.complete_stream_single_attempt(&req, |_, _| {}).await?;
println!("{:?}", resp.first_content());

Re-exports§

pub use circuit_breaker::CircuitBreaker;
pub use circuit_breaker::State as CircuitState;
pub use circuit_breaker::Status as CircuitStatus;
pub use client::LlmClient;
pub use client::LlmConfig;
pub use client::DEFAULT_TIMEOUT;
pub use error::LlmError;
pub use error::Result;
pub use json::parse_json;
pub use json::strip_code_fence;
pub use stream::StreamDelta;
pub use types::AssistantBlock;
pub use types::ChatMessage;
pub use types::Choice;
pub use types::CompletionRequest;
pub use types::CompletionResponse;
pub use types::FinishReason;
pub use types::FunctionCall;
pub use types::FunctionDef;
pub use types::InputImage;
pub use types::ReasoningEffort;
pub use types::Role;
pub use types::StreamOptions;
pub use types::Tool;
pub use types::ToolCall;
pub use types::ToolChoice;
pub use types::Usage;

Modules§

circuit_breaker
In-process circuit breaker for LLM calls.
client
Async LLM client — port of agent_core/llm/client.py::llm_completion.
error
Error type for the LLM client.
images
Governed binary resource resolution at the provider boundary. Image references remain durable; signed projections exist only for one request.
json
Helpers for coaxing structured JSON out of free-form LLM text.
stream
OpenAI-compatible SSE parsing for streaming chat completions.
types
Strongly-typed OpenAI-compatible chat-completion request/response shapes.