52 lines
1.4 KiB
Rust
52 lines
1.4 KiB
Rust
//! llm-worker - LLMワーカーライブラリ
|
|
//!
|
|
//! LLMとの対話を管理するコンポーネントを提供します。
|
|
//!
|
|
//! # 主要なコンポーネント
|
|
//!
|
|
//! - [`Worker`] - LLMとの対話を管理する中心コンポーネント
|
|
//! - [`tool::Tool`] - LLMから呼び出し可能なツール
|
|
//! - [`hook::Hook`] - ターン進行への介入
|
|
//! - [`subscriber::WorkerSubscriber`] - ストリーミングイベントの購読
|
|
//!
|
|
//! # Quick Start
|
|
//!
|
|
//! ```ignore
|
|
//! use llm_worker::{Worker, Message};
|
|
//!
|
|
//! // Workerを作成
|
|
//! let mut worker = Worker::new(client)
|
|
//! .system_prompt("You are a helpful assistant.");
|
|
//!
|
|
//! // ツールを登録(オプション)
|
|
//! // worker.register_tool(my_tool_definition)?;
|
|
//!
|
|
//! // 対話を実行
|
|
//! let history = worker.run("Hello!").await?;
|
|
//! ```
|
|
//!
|
|
//! # キャッシュ保護
|
|
//!
|
|
//! KVキャッシュのヒット率を最大化するには、[`Worker::lock()`]で
|
|
//! ロック状態に遷移してから実行してください。
|
|
//!
|
|
//! ```ignore
|
|
//! let mut locked = worker.lock();
|
|
//! locked.run("user input").await?;
|
|
//! ```
|
|
|
|
mod handler;
|
|
mod message;
|
|
mod worker;
|
|
|
|
pub mod event;
|
|
pub mod hook;
|
|
pub mod llm_client;
|
|
pub mod state;
|
|
pub mod subscriber;
|
|
pub mod timeline;
|
|
pub mod tool;
|
|
|
|
pub use message::{ContentPart, Message, MessageContent, Role};
|
|
pub use worker::{ToolRegistryError, Worker, WorkerConfig, WorkerError, WorkerResult};
|