Skip to content

Commit

Permalink
cleaned up some comments and added some more
Browse files Browse the repository at this point in the history
  • Loading branch information
suryyyansh committed May 22, 2024
1 parent d190c73 commit f8d04f0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 42 deletions.
32 changes: 4 additions & 28 deletions src/backend/ggml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,9 @@ pub(crate) async fn rag_query_handler(
}
};

// get ready for context
let mut context: String = "".to_string();
// handle SEARCH case
if query_text.starts_with("[SEARCH]") {

println!("[SEARCH] query without search: {}", query_text.to_string().strip_prefix("[SEARCH]").unwrap());
Expand Down Expand Up @@ -426,8 +428,6 @@ pub(crate) async fn rag_query_handler(
}
};

//return error::internal_server_error("*********** DEBUGGING **************");

match ro.points {
Some(scored_points) => {
match scored_points.is_empty() {
Expand All @@ -449,29 +449,6 @@ pub(crate) async fn rag_query_handler(
context.push_str("\n\n");
}

// if chat_request.messages.is_empty() {
// return error::internal_server_error("No message in the chat request.");
// }

// let prompt_template = match llama_core::utils::chat_prompt_template(
// chat_request.model.as_deref(),
// ) {
// Ok(prompt_template) => prompt_template,
// Err(e) => {
// return error::internal_server_error(e.to_string());
// }
// };

// insert rag context into chat request
//if let Err(e) = RagPromptBuilder::build(
// &mut chat_request.messages,
// &[context],
// prompt_template.has_system_prompt(),
// server_info.rag_config.policy,
//) {
// return error::internal_server_error(e.to_string());
//}

println!("\n[+] Answer the user query with the context info ...");
}
}
Expand All @@ -495,8 +472,8 @@ pub(crate) async fn rag_query_handler(
}
}
}
//FIXME: aggregate search results

// * build RAG prompt using embeddings or search results
if let Err(e) = RagPromptBuilder::build(
&mut chat_request.messages,
&[context],
Expand Down Expand Up @@ -526,8 +503,7 @@ async fn get_searched_context(query: String) -> String {
Err(_) => "No search results returned".to_string(),
};

//let results: String = serde_json::from_str::<serde_json::Value>(&results_json).unwrap().get("results").unwrap().to_string();

// * extracting content out of json results.
let searched_context: String = serde_json::from_str::<Vec<serde_json::Value>>(&results_json)
.unwrap().into_iter()
.filter_map(|item| item.get("content").and_then(|c: &serde_json::Value| c.as_str()).map(String::from))
Expand Down
2 changes: 0 additions & 2 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,4 @@ pub enum ServerError {
Operation(String),
#[error("{0}")]
NoDatabaseError(String),
#[error("{0}")]
SearchError(String),
}
15 changes: 3 additions & 12 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,24 +214,15 @@ async fn main() -> Result<(), ServerError> {
log(format!("[SEARCH] Max results: {}", cli.max_search_results));


//FIXME: TESTING SPACE
//FIXME: TESTING SPACE FOR DEMONSTRATIONAL PURPOSES
let tavily: Arc<dyn Query> = Arc::new(TavilyAPISearch {
api_key: cli.search_api_key,
max_search_results: cli.max_search_results,
});

// can easily implement logic to set this at execution time
let _ = CURRENT_SEARCH_API.set(tavily);

// match CURRENT_SEARCH_API.get().expect("CURRENT_SEARCH_API is unset.").search("nintendo3ds".to_string()).await {
// Ok(body) => {
// log(format!("[SEARCH] Output: {}", body));
// },
// Err(e) => return Err(ServerError::SearchError(format!(
// "[SEARCH] Search error: {}",
// e
// ))),
// }


log(format!(
"[INFO] Qdrant collection name: {}",
&cli.qdrant_collection_name
Expand Down

0 comments on commit f8d04f0

Please sign in to comment.