pub struct HTTPLlmService<M: ModelInfo> { /* private fields */ }Expand description
An LLM service implementation that sends requests over HTTP.
This implementation of LLMService uses HTTP to communicate with language model providers. It replaces the previous SingleRequestExecutor, providing the same functionality but with a more flexible trait-based design.
§Examples
use language_barrier_core::{Chat, Message, model::Claude};
use language_barrier_core::llm_service::{HTTPLlmService, LLMService};
use language_barrier_core::provider::anthropic::AnthropicProvider;
use std::sync::Arc;
#[tokio::main]
async fn main() -> language_barrier_core::Result<()> {
// Create a provider
let provider = AnthropicProvider::new();
// Create a service with the model and provider
let service = HTTPLlmService::new(
Claude::Opus3,
Arc::new(provider)
);
// Create a chat and generate a response
let chat = Chat::default()
.with_system_prompt("You are a helpful assistant.")
.add_message(Message::user("Hello, how are you?"));
let response = service.generate_next_message(&chat).await?;
Ok(())
}Implementations§
Source§impl<M: ModelInfo> HTTPLlmService<M>
impl<M: ModelInfo> HTTPLlmService<M>
pub fn new(model: M, provider: Arc<dyn HTTPProvider<M>>) -> Self
Trait Implementations§
Source§impl<M: ModelInfo> LLMService<M> for HTTPLlmService<M>
impl<M: ModelInfo> LLMService<M> for HTTPLlmService<M>
Auto Trait Implementations§
impl<M> Freeze for HTTPLlmService<M>where
M: Freeze,
impl<M> !RefUnwindSafe for HTTPLlmService<M>
impl<M> Send for HTTPLlmService<M>
impl<M> Sync for HTTPLlmService<M>
impl<M> Unpin for HTTPLlmService<M>where
M: Unpin,
impl<M> !UnwindSafe for HTTPLlmService<M>
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
Mutably borrows from an owned value. Read more