From db3a7b6ec2dee82df74fa055ab83b5a140cf49f0 Mon Sep 17 00:00:00 2001 From: sigoden Date: Thu, 17 Oct 2024 19:36:00 +0800 Subject: refactor: improve RAG search (#931) --- src/config/mod.rs | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'src/config') diff --git a/src/config/mod.rs b/src/config/mod.rs index 34da912..0f3f89e 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -65,19 +65,24 @@ const SUMMARIZE_PROMPT: &str = "Summarize the discussion briefly in 200 words or less to use as a prompt for future context."; const SUMMARY_PROMPT: &str = "This is a summary of the chat history as a recap: "; -const RAG_TEMPLATE: &str = r#"Use the following context as your learned knowledge, inside XML tags. +const RAG_TEMPLATE: &str = r#"Answer the query based on the context while respecting the rules. (user query, some textual context and rules, all inside xml tags) + __CONTEXT__ -When answer to user: -- If you don't know, just say that you don't know. -- If you don't know when you are not sure, ask for clarification. -Avoid mentioning that you obtained the information from the context. -And answer according to the language of the user's question. - -Given the context information, answer the query. -Query: __INPUT__"#; + +- If you don't know, just say so. +- If you are not sure, ask for clarification. +- Answer in the same language as the user query. +- If the context appears unreadable or of poor quality, tell the user then answer as best as you can. +- If the answer is not in the context but you think you know the answer, explain that to the user then answer with your own knowledge. +- Answer directly and without using xml tags. + + + +__INPUT__ +"#; const LEFT_PROMPT: &str = "{color.green}{?session {?agent {agent}>}{session}{?role /}}{!session {?agent {agent}>}}{role}{?rag @{rag}}{color.cyan}{?session )}{!session >}{color.reset} "; const RIGHT_PROMPT: &str = "{color.purple}{?session {?consume_tokens {consume_tokens}({consume_percent}%)}{!consume_tokens {consume_tokens}}}{color.reset}"; -- cgit v1.2.3