Skip to content

Commit

Permalink
🚧 added tracing in prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
rathijitpapon committed Jul 2, 2024
1 parent bb85335 commit 6f99048
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 3 additions & 2 deletions server/src/llms/query_rephraser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ pub struct QueryRephraserOutput {
pub rephrased_query: String,
}

fn prepare_prompt(query_rephraser_input: &QueryRephraserInput) -> String {
#[tracing::instrument(level = "info", ret)]
fn prepare_rephrase_query_prompt(query_rephraser_input: &QueryRephraserInput) -> String {
"[INST] Rephrase the input text based on the context and the final sentence. So that it can be understood without the context. Return the rephrased question only\n\n---\n\nFollow the following format.\n\nContext: contains the chat history\n\nQuestion: ${question}\n\nReasoning: Let's think step by step in order to ${produce the answer}. We ...\n\nAnswer: Given a chat history and the latest user question, which might reference the context from the chat history, formulate a standalone question that can be understood from the history without needing the chat history. DO NOT ANSWER THE QUESTION - just reformulate it and return the rephrased question only \n\n---\n\nContext: ".to_string()
+ query_rephraser_input.previous_context.iter().map(|x| format!("{}: {}", x.query, x.result)).collect::<Vec<String>>().join("\n").as_str()
+ "\n\nQuestion: "
Expand All @@ -72,7 +73,7 @@ pub async fn rephrase_query(
HeaderValue::from_str(&settings.api_key.expose())?,
);

let prompt = prepare_prompt(query_rephraser_input);
let prompt = prepare_rephrase_query_prompt(query_rephraser_input);

let response = client
.post(&settings.api_url)
Expand Down
2 changes: 2 additions & 0 deletions server/src/llms/summarizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ pub struct SummarizerStreamOutput {
pub generated_text: Option<String>,
}

#[tracing::instrument(level = "info", ret)]
fn prepare_llm_context_string(
settings: &SummarizerSettings,
summarizer_input: SummarizerInput,
Expand Down Expand Up @@ -121,6 +122,7 @@ pub async fn generate_text_with_llm(
Ok(())
}

#[tracing::instrument(level = "info", ret)]
fn prepare_openai_input(
settings: &OpenAISettings,
summarizer_input: SummarizerInput,
Expand Down

0 comments on commit 6f99048

Please sign in to comment.