1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
//! LLM provider abstraction for clawft.
//!
//! This crate provides a unified interface for calling LLM APIs via
//! OpenAI-compatible endpoints. It is a standalone library with no
//! dependencies on other clawft crates.
//!
//! # Architecture
//!
//! - [`Provider`] trait defines the chat completion interface
//! - [`OpenAiCompatProvider`] implements it for any OpenAI-compatible API
//! - [`ProviderRouter`] routes model names (e.g. "openai/gpt-4o") to providers
//! - [`LlmProviderConfig`] describes how to connect to a provider
//!
//! # Quick Start
//!
//! ```rust,ignore
//! use clawft_llm::{ProviderRouter, ChatRequest, ChatMessage};
//!
//! let router = ProviderRouter::with_builtins();
//! let (provider, model_name) = router.route("openai/gpt-4o").unwrap();
//!
//! let request = ChatRequest::new(model_name, vec![
//! ChatMessage::system("You are a helpful assistant."),
//! ChatMessage::user("What is Rust?"),
//! ]);
//!
//! let response = provider.complete(&request).await?;
//! println!("{}", response.choices[0].message.content);
//! ```
//!
//! ## Crate Ecosystem
//!
//! WeftOS is built from these crates:
//!
//! | Crate | Role |
//! |-------|------|
//! | [`weftos`](https://crates.io/crates/weftos) | Product facade -- re-exports kernel, core, types |
//! | [`clawft-kernel`](https://crates.io/crates/clawft-kernel) | Kernel: processes, services, governance, mesh, ExoChain |
//! | [`clawft-core`](https://crates.io/crates/clawft-core) | Agent framework: pipeline, context, tools, skills |
//! | [`clawft-types`](https://crates.io/crates/clawft-types) | Shared type definitions |
//! | [`clawft-platform`](https://crates.io/crates/clawft-platform) | Platform abstraction (native/WASM/browser) |
//! | [`clawft-plugin`](https://crates.io/crates/clawft-plugin) | Plugin SDK for tools, channels, and extensions |
//! | [`clawft-llm`](https://crates.io/crates/clawft-llm) | LLM provider abstraction (11 providers + local) |
//! | [`exo-resource-tree`](https://crates.io/crates/exo-resource-tree) | Hierarchical resource namespace with Merkle integrity |
//!
//! Source: <https://github.com/weave-logic-ai/weftos>
pub use RetryModel;
pub use LlmProviderConfig;
/// Backward-compatible alias for [`LlmProviderConfig`].
pub type ProviderConfig = LlmProviderConfig;
pub use ;
pub use parse_sse_line;
pub use ;
pub use FailoverChain;
pub use LocalProvider;
pub use OpenAiCompatProvider;
pub use Provider;
pub use ;
pub use ProviderRouter;
pub use BrowserLlmClient;