Skip to main content

tiy_core/
lib.rs

1//! # tiy-core
2//!
3//! A unified LLM API and stateful Agent runtime in Rust.
4//!
5//! This library provides:
6//! - Unified API for multiple LLM providers (OpenAI, Anthropic, Google, Ollama, etc.)
7//! - Streaming event-based responses
8//! - Tool/function calling support
9//! - Stateful agent with tool execution
10//!
11//! ## Example
12//!
13//! ```rust,no_run
14//! use tiy_core::{provider::openai::OpenAIProvider, types::*};
15//!
16//! #[tokio::main]
17//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
18//!     // Create a model
19//!     let model = Model {
20//!         id: "gpt-4o-mini".to_string(),
21//!         name: "GPT-4o Mini".to_string(),
22//!         api: None,
23//!         provider: Provider::OpenAI,
24//!         base_url: Some("https://api.openai.com/v1".to_string()),
25//!         reasoning: false,
26//!         input: vec![InputType::Text, InputType::Image],
27//!         cost: Cost::default(),
28//!         context_window: 128000,
29//!         max_tokens: 16384,
30//!         headers: None,
31//!         compat: None,
32//!     };
33//!
34//!     // Create context
35//!     let context = Context {
36//!         system_prompt: Some("You are a helpful assistant.".to_string()),
37//!         messages: vec![Message::User(UserMessage {
38//!             role: Role::User,
39//!             content: UserContent::Text("Hello!".to_string()),
40//!             timestamp: chrono::Utc::now().timestamp_millis(),
41//!         })],
42//!         tools: None,
43//!     };
44//!
45//!     Ok(())
46//! }
47//! ```
48
49pub mod agent;
50pub mod catalog;
51pub mod models;
52pub mod protocol;
53pub mod provider;
54pub mod stream;
55pub mod thinking;
56pub mod transform;
57pub mod types;
58pub mod validation;
59
60// Re-export commonly used types
61pub use types::{
62    AgentLimits, Api, AssistantMessage, ContentBlock, Context, Cost, HeaderPolicy, HttpLimits,
63    ImageContent, InputType, Message, Model, Provider, Role, SecurityConfig, StopReason,
64    StreamLimits, TextContent, ThinkingContent, Tool, ToolCall, ToolResultMessage, UrlPolicy,
65    Usage, UserMessage,
66};
67
68pub use stream::EventStream;
69
70pub use agent::{Agent, AgentStateSnapshot};
71pub use catalog::{
72    build_catalog_snapshot, build_catalog_snapshot_manifest, catalog_manifest_sidecar_path,
73    enrich_manual_model, list_models, list_models_with_enrichment, load_catalog_metadata_store,
74    refresh_catalog_snapshot, save_catalog_snapshot, CatalogMetadataStore, CatalogModelMatch,
75    CatalogModelMetadata, CatalogRefreshResult, CatalogRemoteConfig, CatalogSnapshot,
76    CatalogSnapshotError, CatalogSnapshotManifest, EmptyCatalogMetadataStore, FetchModelsRequest,
77    FileCatalogMetadataStore, InMemoryCatalogMetadataStore, ListModelsResult, ModelCatalogError,
78    ProviderExtractedModel, UnifiedModelInfo,
79};