Skip to main content

tea_model/
lib.rs

1#![forbid(unsafe_code)]
2#![deny(missing_docs)]
3
4//! Provider-neutral model port for `tea-rs`.
5//!
6//! This crate defines model contracts but does not contain a live provider
7//! adapter or network transport.
8//!
9//! # Example
10//!
11//! ```
12//! use std::str::FromStr;
13//!
14//! use tea_model::{
15//!     ModelCapabilities, ModelDisplayName, ModelSpec, ProviderId,
16//! };
17//! use tea_protocol::{ModelId, TokenCount};
18//!
19//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
20//! let model = ModelSpec::new(
21//!     ModelId::from_str("example/model")?,
22//!     ProviderId::from_str("example")?,
23//!     ModelDisplayName::from_str("Example Model")?,
24//!     TokenCount::new(32_000)?,
25//!     TokenCount::new(8_000)?,
26//!     ModelCapabilities::text().with_reasoning().with_tools(true),
27//! )?;
28//!
29//! assert!(model.capabilities().supports_parallel_tool_calls());
30//! # Ok(())
31//! # }
32//! ```
33
34mod failure;
35mod hosted;
36mod provider;
37mod request;
38mod router;
39mod spec;
40mod stream;
41
42pub use failure::{ModelFailure, ModelFailureCode};
43pub use hosted::{
44    HostedToolKind, HostedToolOptions, MAX_WEB_SEARCH_DOMAIN_BYTES, MAX_WEB_SEARCH_DOMAINS,
45    MAX_WEB_SEARCH_LOCATION_FIELD_BYTES, WebSearchLocation, WebSearchOptions,
46};
47pub use provider::{BoxModelStream, ModelProvider, ModelStream};
48pub use request::{
49    FunctionToolDefinition, HostedToolDefinition, MAX_MODEL_TOOLS, MAX_REQUEST_MESSAGES,
50    MAX_SYSTEM_PROMPT_BYTES, MAX_TOOL_DESCRIPTION_BYTES, MAX_TOOL_SCHEMA_BYTES,
51    MAX_TOOL_SCHEMA_DEPTH, ModelRequest, ModelRequestError, ModelToolDefinition, ReasoningOptions,
52};
53pub use router::{ModelRegistry, ModelRegistryError, ModelRouter};
54pub use spec::{
55    ModelCapabilities, ModelDisplayName, ModelSpec, ModelSpecError, ModelTextParseError,
56    ReasoningProfile, ReasoningResolution,
57};
58pub use stream::{
59    HostedToolCompleted, HostedToolStarted, MAX_MODEL_DELTA_BYTES, MAX_MODEL_STREAM_INDEX,
60    MAX_PROVIDER_OPAQUE_ID_BYTES, ModelCompletion, ModelEvent, ModelResponseInfo,
61    ModelSourceCitation, ModelStreamIndex, ModelStreamSummary, ModelStreamValidator,
62    ModelStreamValueError, ModelStreamViolation, ProviderResponseId, ProviderToolCallId,
63    ToolArgumentsDelta, ToolCallCompleted, ToolCallStarted, Utf8Delta,
64};
65pub use tea_control::CancellationScope as ModelCancellation;
66pub use tea_protocol::{ModelRef, ProviderId, ReasoningEffort};