pub struct LlmPool { /* private fields */ }Expand description
Pool of LLM clients for different purposes.
This provides a centralized way to access LLM clients configured for specific tasks:
- Summary — Document summarization (fast, cheap model)
- Retrieval — Document navigation (capable model)
- TOC — Table of contents processing (fast, cheap model)
§Example
use vectorless::llm::LlmPool;
let pool = LlmPool::from_defaults();
// Use summary client for summarization
let summary = pool.summary().complete(
"You summarize text concisely.",
"Long text to summarize..."
).await?;
// Use retrieval client for navigation
let nav = pool.retrieval().complete(
"You navigate documents.",
"Find information about X..."
).await?;
Implementations§
Source§impl LlmPool
impl LlmPool
Sourcepub fn new(configs: LlmConfigs) -> Self
pub fn new(configs: LlmConfigs) -> Self
Create a new LLM pool from configurations.
Sourcepub fn from_defaults() -> Self
pub fn from_defaults() -> Self
Create a pool with default configurations.
Uses auto-detected models based on available API keys:
- OpenAI: gpt-4o-mini for summary/toc, gpt-4o for retrieval
- Anthropic: claude-3-haiku for summary/toc, claude-3-sonnet for retrieval
- Default: glm-4-flash for summary/toc, glm-4 for retrieval
Sourcepub fn with_concurrency(self, controller: ConcurrencyController) -> Self
pub fn with_concurrency(self, controller: ConcurrencyController) -> Self
Add concurrency control to all clients in the pool.
All clients share the same ConcurrencyController, which means rate limiting and concurrency limits are applied globally across all LLM operations.
§Example
use vectorless::llm::LlmPool;
use vectorless::throttle::{ConcurrencyController, ConcurrencyConfig};
let config = ConcurrencyConfig::new()
.with_max_concurrent_requests(10)
.with_requests_per_minute(500);
let pool = LlmPool::from_defaults()
.with_concurrency(ConcurrencyController::new(config));Add concurrency control from an existing Arc.
Sourcepub fn concurrency(&self) -> Option<&ConcurrencyController>
pub fn concurrency(&self) -> Option<&ConcurrencyController>
Get the concurrency controller (if any).
Sourcepub fn summary(&self) -> &LlmClient
pub fn summary(&self) -> &LlmClient
Get the summary client.
Used for generating summaries of document sections. Typically uses a fast, cost-effective model.
Sourcepub fn retrieval(&self) -> &LlmClient
pub fn retrieval(&self) -> &LlmClient
Get the retrieval client.
Used for document navigation and retrieval. Typically uses a more capable model for better navigation decisions.
Sourcepub fn toc(&self) -> &LlmClient
pub fn toc(&self) -> &LlmClient
Get the TOC client.
Used for TOC detection, parsing, and page assignment. Typically uses a fast, cost-effective model.
Sourcepub fn single_model(model: impl Into<String>) -> Self
pub fn single_model(model: impl Into<String>) -> Self
Create a pool with a single model for all purposes.
Useful for testing or simple deployments.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for LlmPool
impl !RefUnwindSafe for LlmPool
impl Send for LlmPool
impl Sync for LlmPool
impl Unpin for LlmPool
impl UnsafeUnpin for LlmPool
impl !UnwindSafe for LlmPool
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more