@ondeinference / ed Mirror · read-only
Fork 0

Read-only mirror of github.com/ondeinference/ed.

Mirrored from https://github.com/ondeinference/ed.git

Synced Nov 23, 01:00 UTC

development
rs 77 lines 2.97 KB
Raw
1 //! Ed: an embeddable, local-LLM-first chat agent.
2 //!
3 //! Ed sits one layer above the [`onde`] inference SDK. `onde` gives you a
4 //! [`ChatEngine`](onde::inference::ChatEngine) you can load a model into and
5 //! send messages to; Ed adds the part every application built on it was
6 //! writing for itself:
7 //!
8 //! - **Lifecycle orchestration.** Loading a model is a sequence of state
9 //! changes, not one call. Ed drives `Loading -> Ready` (or `-> Error`) and
10 //! reports each transition.
11 //! - **Notification.** `onde` exposes status by polling
12 //! [`info()`](onde::inference::ChatEngine::info). A UI needs to be told.
13 //! Ed pushes transitions and replies to a [`StatusSink`] the host implements.
14 //! - **A flattened reply.** Inference returns `Result<InferenceResult, _>`;
15 //! a frontend wants one shape covering both outcomes. That's [`ChatReply`].
16 //!
17 //! Ed deliberately does *not* own sessions, persistence, model catalogues, or
18 //! downloads. Those differ per application and belong to the host. For
19 //! persistence it defines the [`SessionStore`] seam the host implements.
20 //!
21 //! # Platforms
22 //!
23 //! Ed has no `cfg(target_os)` gates. `onde` already splits real and fallback
24 //! implementations internally, so this crate compiles on every platform `onde`
25 //! supports (macOS, iOS, tvOS, visionOS, watchOS, Windows, Linux, Android) and
26 //! simply surfaces `onde`'s error where it can't run inference. On
27 //! `wasm32-unknown-unknown` it builds against `onde`'s web target. Other
28 //! targets outside that list get a stub engine with the same signatures,
29 //! whose calls all return an "unsupported" error.
30 //!
31 //! Do not add platform gates here, and be careful about adding them in a host:
32 //! a gate narrower than `onde`'s own support list silently disables chat on a
33 //! platform that would have worked.
34 //!
35 //! # Example
36 //!
37 //! ```no_run
38 //! use ed_agent::{Ed, GgufModelConfig};
39 //!
40 //! # async fn example() {
41 //! let ed = Ed::new();
42 //! let config = GgufModelConfig::qwen25_1_5b();
43 //! ed.load(config, None, None).await.expect("load");
44 //!
45 //! let reply = ed.send("Summarise this thread.").await;
46 //! println!("{}", reply.reply.unwrap_or_default());
47 //! # }
48 //! ```
49
50 #![forbid(unsafe_code)]
51
52 mod ed;
53 pub mod maybe;
54 mod reply;
55 mod session;
56 mod sink;
57 mod stream;
58 mod tool;
59
60 pub use ed::Ed;
61 pub use reply::ChatReply;
62 pub use session::{SessionError, SessionMeta, SessionStore};
63 pub use sink::{EventSink, NoopSink, StatusSink};
64 pub use stream::TextStream;
65 pub use tool::{
66 AgentConfig, AgentError, AgentReply, AgentToolDefinition, ApprovalDecision, ApprovalHandler,
67 ApprovalRequest, DenyApprovals, RejectingExecutor, ToolCall, ToolExecutionResult, ToolExecutor,
68 ToolRisk,
69 };
70
71 // Re-exported so a host depends on `ed-agent` alone and never has to match a
72 // second `onde` version against this crate's.
73 pub use onde::inference::types::{ChatMessage, ChatRole};
74 pub use onde::inference::{
75 ChatEngine, EngineInfo, EngineStatus, GgufModelConfig, InferenceError, SamplingConfig,
76 ToolCallingSupport, UqffModelConfig,
77 };