mirror of
https://github.com/katanemo/plano.git
synced 2026-05-10 16:22:42 +02:00
retry embeddings fetch (#245)
This commit is contained in:
parent
9a5c5cc3a3
commit
9a6ae2efee
4 changed files with 79 additions and 41 deletions
|
|
@ -61,7 +61,7 @@ pub struct StreamCallContext {
|
|||
|
||||
pub struct StreamContext {
|
||||
system_prompt: Rc<Option<String>>,
|
||||
prompt_targets: Rc<HashMap<String, PromptTarget>>,
|
||||
pub prompt_targets: Rc<HashMap<String, PromptTarget>>,
|
||||
pub embeddings_store: Option<Rc<EmbeddingsStore>>,
|
||||
overrides: Rc<Option<Overrides>>,
|
||||
pub metrics: Rc<WasmMetrics>,
|
||||
|
|
@ -109,10 +109,21 @@ impl StreamContext {
|
|||
request_id: None,
|
||||
}
|
||||
}
|
||||
|
||||
fn embeddings_store(&self) -> &EmbeddingsStore {
|
||||
self.embeddings_store
|
||||
.as_ref()
|
||||
.expect("embeddings store is not set")
|
||||
self.embeddings_store.as_ref().unwrap()
|
||||
}
|
||||
|
||||
pub fn is_embedding_store_initialized(&self) -> bool {
|
||||
if self.embeddings_store.as_ref().is_none() {
|
||||
return false;
|
||||
}
|
||||
|
||||
if self.embeddings_store.as_ref().unwrap().len() == self.prompt_targets.len() {
|
||||
return true;
|
||||
}
|
||||
|
||||
false
|
||||
}
|
||||
|
||||
pub fn send_server_error(&self, error: ServerError, override_status_code: Option<StatusCode>) {
|
||||
|
|
@ -223,7 +234,7 @@ impl StreamContext {
|
|||
"embeddings not found for prompt target name: {}",
|
||||
prompt_name
|
||||
);
|
||||
return (prompt_name.clone(), f64::NAN);
|
||||
return (prompt_name.clone(), 0.0);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -234,7 +245,7 @@ impl StreamContext {
|
|||
"description embeddings not found for prompt target name: {}",
|
||||
prompt_name
|
||||
);
|
||||
return (prompt_name.clone(), f64::NAN);
|
||||
return (prompt_name.clone(), 0.0);
|
||||
}
|
||||
};
|
||||
let similarity_score_description =
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue