Expand description
AISDK language models for Sova — app.install(Ai::…) / req.ai().
Thin shell over aisdk: install a default
model into app state, call it from handlers, or drop down to the full
LanguageModelRequest builder. FakeAi records prompts for tests.
ⓘ
use sova_ai::{Ai, AiExt, FakeAi};
let fake = FakeAi::new().stub_text("pong");
app.install(Ai::fake(fake.clone()));
// in a handler:
let out = req.ai().prompt("ping").generate().await?;
assert_eq!(out.text().as_deref(), Some("pong"));Re-exports§
pub use aisdk;
Modules§
- prelude
- Common AISDK imports for handlers and agents.
Structs§
- Ai
- Plugin builder — install with
app.install(Ai::…). - AiBound
- Fluent call builder (
prompt/system/generate/stream_response). - AiClient
- Shared AI client in app state (
req.state::<AiClient>()/req.ai()). - FakeAi
- Laravel-style fake model: stub replies, assert prompts.
- Shared
Model - Cloneable model handle used as the default for
LanguageModelRequest.
Enums§
- AiError
- Plugin / call errors (maps AISDK failures and missing install config).
Traits§
Functions§
- stream_
to_ response - Convert
StreamTextResponseinto an SSE HTTP response (data:lines = text deltas).