ai_lib_rust/types/mod.rs
1//! 类型系统模块:定义基于 AI-Protocol 规范的核心数据类型。
2//!
3//! # Types Module
4//!
5//! This module defines the core type system based on the AI-Protocol standard schema,
6//! providing strongly-typed representations for all AI interaction primitives.
7//!
8//! ## Overview
9//!
10//! The type system ensures:
11//! - Type-safe message construction and handling
12//! - Consistent event representation across providers
13//! - Standardized tool/function calling interfaces
14//! - Serialization compatibility with AI-Protocol specification
15//!
16//! ## Key Types
17//!
18//! | Type | Description |
19//! |------|-------------|
20//! | [`Message`] | Chat message with role and content |
21//! | [`MessageRole`] | Message role (user, assistant, system, tool) |
22//! | [`StreamingEvent`] | Unified streaming event representation |
23//! | [`ToolCall`] | Function/tool call from model response |
24//! | [`ToolDefinition`] | Tool definition for model context |
25//!
26//! ## Submodules
27//!
28//! | Module | Description |
29//! |--------|-------------|
30//! | [`events`] | Streaming event types and variants |
31//! | [`message`] | Message types with multi-modal content support |
32//! | [`tool`] | Tool/function calling types |
33//!
34//! ## Example
35//!
36//! ```rust
37//! use ai_lib_rust::types::{Message, MessageRole, ToolDefinition};
38//!
39//! // Create messages
40//! let system = Message::system("You are a helpful assistant");
41//! let user = Message::user("What's the weather?");
42//!
43//! // Define a tool
44//! let tool = ToolDefinition {
45//! name: "get_weather".to_string(),
46//! description: Some("Get current weather for a location".to_string()),
47//! parameters: serde_json::json!({
48//! "type": "object",
49//! "properties": {
50//! "location": {"type": "string"}
51//! }
52//! }),
53//! strict: None,
54//! };
55//! ```
56
57pub mod events;
58pub mod message;
59pub mod tool;
60
61pub use events::StreamingEvent;
62pub use message::{Message, MessageRole};
63pub use tool::{ToolCall, ToolDefinition};