From f48640d7e84db6067718cdada89c30e35b60f7c3 Mon Sep 17 00:00:00 2001 From: Fraser Date: Wed, 29 Mar 2023 00:58:08 -0400 Subject: [PATCH] fix typo accidentally said assistant instead of user --- web/api/chat.py | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/web/api/chat.py b/web/api/chat.py index 3554dcd..dad7e92 100644 --- a/web/api/chat.py +++ b/web/api/chat.py @@ -73,31 +73,16 @@ def generate_prompt(query: str, history: List[Dict[str, str]] = [], blocks: List Returns: List[Dict[str, str]]: The prompt in messages format. """ - # Initialize prompt - prompt = [] - - # Generate system description - if mode == "standard": - prompt.append({"role": "system", "content": "You are a helpful assistant knowledgeable about AI Alignment and Safety."}) - # elif mode == "other": - else: - raise Exception(f"Invalid mode: {mode}") + # Initialize prompt with system description + prompt = [{"role": "system", "content": "You are a helpful assistant knowledgeable about AI Alignment and Safety."}] - # Add previous dialogue - for message in history: - prompt.append(message) - - # Add instruction - if mode == "standard": - instruction_prompt = "Please answer my question (after the Q:) using the provided context." - prompt.append({"role": "assistant", "content": instruction_prompt}) - # elif mode == "other": - else: - raise Exception(f"Invalid mode: {mode}") + prompt.extend(history) # Add previous dialogue + + instruction_prompt = "Please answer my question (after the Q:) using the provided context." + prompt.append({"role": "user", "content": instruction_prompt}) + # Add context from top-k blocks - if blocks is None: - return "Context missing." context_prompt = "Context:\n\n" for i, block in enumerate(blocks): context_prompt += f"[{i}] {block.text}\n\n"