Skip to content

Commit

Permalink
endpoint now works
Browse files Browse the repository at this point in the history
  • Loading branch information
Endle committed Aug 26, 2024
1 parent ec610aa commit e99f2db
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
5 changes: 5 additions & 0 deletions fire_seq_search_server/src/local_llm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,11 @@ impl LlmEngine{

}

pub async fn quick_fetch(&self, title: &str) -> Option<String> {
let jcache = self.job_cache.lock().await;
return jcache.done_job.get(title).cloned();
}

pub async fn health(&self) -> Result<(), Box<dyn std::error::Error>> {
info!("Calling health check");
let resp = reqwest::get(self.endpoint.to_owned() + "/health")
Expand Down
17 changes: 15 additions & 2 deletions fire_seq_search_server/src/query_engine/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,24 @@ impl QueryEngine {
}

impl QueryEngine {
async fn wait_for_summarize(&self, title: String) -> String {
let llm = self.llm.as_ref().unwrap();
let wait_llm = tokio::time::Duration::from_millis(50);
// TODO maybe add a guard to make sure don't wait too long?
loop {
let result = llm.quick_fetch(&title).await;
match result {
Some(s) => { return s; },
None => { }
};
tokio::time::sleep(wait_llm).await;
}
// llm.summarize(&title).await
}
pub async fn summarize(&self, title: String) -> String {
info!("Called summarize on {}", &title);
if cfg!(feature="llm") {
let llm = self.llm.as_ref().unwrap();
llm.summarize(&title).await
self.wait_for_summarize(title).await
} else {
"LLM turned off".to_owned()
}
Expand Down

0 comments on commit e99f2db

Please sign in to comment.