瀏覽代碼

feat: refactor base_prompt.py and run.py for code clarity

XingYu-Zhong 1 年之前
父節點
當前提交
ce9bd7c36a
共有 2 個文件被更改,包括 10 次插入37 次删除
  1. 8 35
      repodemo/prompts/base_prompt.py
  2. 2 2
      repodemo/run.py

+ 8 - 35
repodemo/prompts/base_prompt.py

@@ -1,7 +1,5 @@
 base_system_prompt = """<|system|>\n你是一位智能编程助手,你叫CodeGeeX。你会为用户回答关于编程、代码、计算机方面的任何问题,并提供格式规范、可以执行、准确安全的代码,并在必要时提供详细的解释。"""
 
-repo_system_prompt = """<|system|>\n你是一位智能编程助手,你叫CodeGeeX。你会为用户回答关于编程、代码、计算机方面的任何问题,并提供格式规范、可以执行、准确安全的代码。请根据用户给出的项目仓库中的代码,以及用户提出的需求,生成新的代码或者更改已有代码。输出格式:\n\n###PATH:{PATH}\n{CODE}"""
-
 web_search_prompy = """你将接收到一个用户提出的问题,并请撰写清晰、简洁且准确的答案。
 
 # Note
@@ -37,8 +35,7 @@ Here is some examples about tools choosing:
 Input:
 tools_summary: {
     "online_query": "Questions need to be queried on the Internet to ensure accurate answers",
-    "project_qa": "Questions need to be answered specific to the project",
-    "project_modify": "The problem is that we need to modify the project"
+    "project_qa": "Questions need to be answered specific to the project"
 }
 input_text: "今天星期几"
 
@@ -56,33 +53,12 @@ Output:
 }
 
 
-Input:
-tools_summary: {
-    "online_query": "Questions need to be queried on the Internet to ensure accurate answers",
-    "project_qa": "Questions need to be answered specific to the project",
-    "project_modify": "The problem is that we need to modify the project"
-}
-input_text: "请你帮我把项目的readme改成韩文"
-
-Output:
-{
-    "thoughts": {
-        "text": "用户需要将项目的readme文件翻译成韩文。",
-        "reasoning": "根据工具概要,project_modify专用于项目修改,这与用户的需求相符。",
-        "criticism": "需要确保用户对翻译后的韩文内容满意,因为翻译质量可能影响项目的整体感受。",
-        "speak": "我们将使用project_modify来修改项目的readme文件。请确认您希望使用的韩文翻译内容。"
-    },
-    "tool": {
-        "name": ["project_modify"]
-    }
-}
 
 
 Input:
 tools_summary: {
     "online_query": "Questions need to be queried on the Internet to ensure accurate answers",
-    "project_qa": "Questions need to be answered specific to the project",
-    "project_modify": "The problem is that we need to modify the project"
+    "project_qa": "Questions need to be answered specific to the project"
 }
 input_text: "你是谁"
 
@@ -102,8 +78,7 @@ Output:
 Input:
 tools_summary: {
     "online_query": "Questions need to be queried on the Internet to ensure accurate answers",
-    "project_qa": "Questions need to be answered specific to the project",
-    "project_modify": "The problem is that we need to modify the project"
+    "project_qa": "Questions need to be answered specific to the project"
 }
 input_text: "解释一下项目"
 
@@ -148,8 +123,7 @@ Don't output in markdown format, something like ```json or ```,just output in th
 Input:
 tools_summary: {
     "online_query": "Questions need to be queried on the Internet to ensure accurate answers",
-    "project_qa": "Questions need to be answered specific to the project",
-    "project_modify": "The problem is that we need to modify the project"
+    "project_qa": "Questions need to be answered specific to the project"
 }
 """
 tools_input_prompt = """
@@ -172,7 +146,7 @@ def build_message_list(result):
 
     return message_list
 
-def get_cur_base_user_prompt(message_history, index_prompt=None, judge_context=""):
+def get_cur_base_user_prompt(message_history, index_prompt=None):
     user_prompt_tmp = """<|user|>\n{user_input}"""
     assistant_prompt_tmp = """<|assistant|>\n{assistant_input}"""
     history_prompt = ""
@@ -188,10 +162,9 @@ def get_cur_base_user_prompt(message_history, index_prompt=None, judge_context="
             )
 
 
-    if "project_modify" not in judge_context:
-        result = base_system_prompt + history_prompt + """<|assistant|>\n"""
-    else:
-        result = repo_system_prompt + history_prompt + """<|assistant|>\n"""
+
+    result = base_system_prompt + history_prompt + """<|assistant|>\n"""
+   
     
     message_list = build_message_list(result)
     # print(message_list)

+ 2 - 2
repodemo/run.py

@@ -128,10 +128,11 @@ async def start():
                 cl.Action(name="url", value="url", label="上传GitHub链接"),
             ],
         ).send()
+  
         if res.get("value") == "url":
             repo_path =None
             while repo_path == None:
-                res = await cl.AskUserMessage(content="请你在下面消息框中提供GitHub仓库URL? ex:https://github.com/THUDM/CodeGeeX4", timeout=3600).send()
+                res = await cl.AskUserMessage(content="请你在下面消息框中提供GitHub仓库URL? ex:https://github.com/THUDM/CodeGeeX2", timeout=3600).send()
                 if res:
                     repo_path = clone_repo(res['output'],extract_dir)
                     if repo_path is None:
@@ -201,7 +202,6 @@ async def main(message: cl.Message):
             prompt_content = get_cur_base_user_prompt(
                     message_history=message_history,
                     index_prompt=index_prompt,
-                    judge_context=tool_name[0],
                 )
             
         else: