Skip to main content

ai_ui_core/
lib.rs

1//! Rust port of [`@assistant-ui/core`](https://github.com/assistant-ui/assistant-ui):
2//! the thread message model, the branching message repository, the model
3//! adapter contract and the local thread runtime.
4//!
5//! ```
6//! use ai_ui_core::{adapter, AppendMessage, ChatModelRunResult, LocalRuntimeOptions, LocalThreadRuntime};
7//!
8//! let runtime = LocalThreadRuntime::new(
9//!     |_options| adapter::from_results([Ok(ChatModelRunResult::text("Hello!"))]),
10//!     LocalRuntimeOptions::default(),
11//! );
12//! let run = runtime.append(AppendMessage::user_text(None, "Hi")).unwrap();
13//! futures_executor::block_on(run).unwrap();
14//! assert_eq!(runtime.messages().last().unwrap().text(), "Hello!");
15//! ```
16#![forbid(unsafe_code)]
17#![warn(missing_docs)]
18
19pub mod abort;
20pub mod adapter;
21pub mod external_store;
22pub mod local;
23pub mod repository;
24pub mod runtime;
25pub mod smooth;
26mod subscribe;
27pub mod thread_list;
28pub mod types;
29
30pub use abort::{AbortController, AbortSignal};
31pub use adapter::{
32    ChatModelAdapter, ChatModelRunOptions, ChatModelRunResult, ModelContext, RunError, RunStream,
33};
34pub use external_store::{ExternalStore, ExternalStoreRuntime, StoreFuture};
35pub use local::{
36    Composer, LocalRuntimeOptions, LocalThreadRuntime, Tool, ToolContext, ToolFuture, ToolRegistry,
37};
38pub use repository::{
39    ExportedMessage, ExportedRepository, MessageChanges, MessageRepository, RepositoryError,
40};
41pub use runtime::{
42    ComposerHost, RunFuture, RuntimeCapabilities, RuntimeError, StartRunConfig, ThreadRuntime,
43    ToolResult,
44};
45pub use smooth::{SmoothOptions, SmoothText};
46pub use subscribe::{Subscribers, Subscription};
47pub use thread_list::{
48    AdapterFuture, RemoteThread, Spawner, ThreadItem, ThreadList, ThreadListAdapter, ThreadStatus,
49};
50pub use types::*;