Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
- Replace doom-loop string history with content hash comparison (#645)
- Return &'static str from detect_image_mime with case-insensitive matching (#646)
- Replace block_on in history persist with fire-and-forget async spawn (#647)
- Change `LlmProvider::name()` from `&'static str` to `&str`, eliminating `Box::leak` memory leak in CompatibleProvider (#633)
- Extract rate-limit retry helper `send_with_retry()` in zeph-llm, deduplicating 3 retry loops (#634)
- Extract `sse_to_chat_stream()` helpers shared by Claude and OpenAI providers (#635)
- Replace double `AnyProvider::clone()` in `embed_fn()` with single `Arc` clone (#636)
- Add `with_client()` builder to ClaudeProvider and OpenAiProvider for shared `reqwest::Client` (#637)
- Cache `JsonSchema` per `TypeId` in `chat_typed` to avoid per-call schema generation (#638)

### Fixed
- False positive: "sudoku" no longer matched by "sudo" blocked pattern (word-boundary matching)
Expand Down
10 changes: 5 additions & 5 deletions crates/zeph-llm/src/any.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ pub enum AnyProvider {

impl AnyProvider {
/// Return a cloneable closure that calls `embed()` on this provider.
pub fn embed_fn(&self) -> impl Fn(&str) -> crate::provider::EmbedFuture {
let provider = self.clone();
pub fn embed_fn(&self) -> impl Fn(&str) -> crate::provider::EmbedFuture + Send + Sync {
let provider = std::sync::Arc::new(self.clone());
move |text: &str| -> crate::provider::EmbedFuture {
let p = std::sync::Arc::clone(&provider);
let owned = text.to_owned();
let p = provider.clone();
Box::pin(async move { p.embed(&owned).await })
}
}
Expand All @@ -62,7 +62,7 @@ impl AnyProvider {
/// Returns an error if the provider fails or the response cannot be parsed.
pub async fn chat_typed_erased<T>(&self, messages: &[Message]) -> Result<T, crate::LlmError>
where
T: DeserializeOwned + JsonSchema,
T: DeserializeOwned + JsonSchema + 'static,
{
delegate_provider!(self, |p| p.chat_typed::<T>(messages).await)
}
Expand Down Expand Up @@ -119,7 +119,7 @@ impl LlmProvider for AnyProvider {
delegate_provider!(self, |p| p.supports_embeddings())
}

fn name(&self) -> &'static str {
fn name(&self) -> &str {
delegate_provider!(self, |p| p.name())
}

Expand Down
6 changes: 4 additions & 2 deletions crates/zeph-llm/src/candle_provider/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,9 @@ impl LlmProvider for CandleProvider {

async fn embed(&self, text: &str) -> Result<Vec<f32>, LlmError> {
let Some(ref embed_model) = self.embed_model else {
return Err(LlmError::EmbedUnsupported { provider: "candle" });
return Err(LlmError::EmbedUnsupported {
provider: "candle".into(),
});
};
let model = embed_model.clone();
let text = text.to_owned();
Expand All @@ -176,7 +178,7 @@ impl LlmProvider for CandleProvider {
self.embed_model.is_some()
}

fn name(&self) -> &'static str {
fn name(&self) -> &str {
"candle"
}
}
Loading
Loading