From cbc3c5297e681c1f9fe595a397d06674458486e5 Mon Sep 17 00:00:00 2001 From: Kevin Hu Date: Wed, 22 Jan 2025 16:55:11 +0800 Subject: [PATCH] Revert the chat history for rewrite. (#4579) ### What problem does this PR solve? ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --- agent/component/base.py | 2 +- agent/component/rewrite.py | 2 +- agent/templates/research_report.json | 2 +- agent/templates/seo_blog.json | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/agent/component/base.py b/agent/component/base.py index 33410bd08..ed6a511b1 100644 --- a/agent/component/base.py +++ b/agent/component/base.py @@ -483,7 +483,7 @@ class ComponentBase(ABC): if q["component_id"].lower().find("answer") == 0: txt = [] - for r, c in self._canvas.history[::-1][:self._param.message_history_window_size]: + for r, c in self._canvas.history[::-1][:self._param.message_history_window_size][::-1]: txt.append(f"{r.upper()}: {c}") txt = "\n".join(txt) self._param.inputs.append({"content": txt, "component_id": q["component_id"]}) diff --git a/agent/component/rewrite.py b/agent/component/rewrite.py index 06a1f6b23..688664b8a 100644 --- a/agent/component/rewrite.py +++ b/agent/component/rewrite.py @@ -84,7 +84,7 @@ class RewriteQuestion(Generate, ABC): component_name = "RewriteQuestion" def _run(self, history, **kwargs): - hist = self._canvas.get_history(4) + hist = self._canvas.get_history(self._param.message_history_window_size) conv = [] for m in hist: if m["role"] not in ["user", "assistant"]: diff --git a/agent/templates/research_report.json b/agent/templates/research_report.json index 120b151f2..ce6abcfa0 100644 --- a/agent/templates/research_report.json +++ b/agent/templates/research_report.json @@ -717,7 +717,7 @@ ] }, "label": "Template", - "name": "Artical" + "name": "Article" }, "dragging": false, "height": 160, diff --git a/agent/templates/seo_blog.json b/agent/templates/seo_blog.json index b59251b56..f8ac5ffdd 100644 --- a/agent/templates/seo_blog.json +++ b/agent/templates/seo_blog.json @@ -1153,7 +1153,7 @@ ], "presencePenaltyEnabled": true, "presence_penalty": 0.4, - "prompt": "You are an SEO expert who writes in a direct, practical, educational style that is factual rather than storytelling or narrative, focusing on explaining to {audience} the \"how\" and \"what is\" and \u201cwhy\u201d rather than narrating to the audience. \n - Please write at a sixth grade reading level. \n - ONLY output in Markdown format.\n - Use positive, present tense expressions and avoid using complex words and sentence structures that lack narrative, such as \"reveal\" and \"dig deep.\"\n - Next, please continue writing articles related to our topic with a concise title, {title_0}{title} {keywords_0}{keywords}. \n - Please AVOID repeating what has already been written and do not use the same sentence structure. \n - JUST write the body of the article based on the outline.\n - DO NOT include introduction, title.\n - DO NOT miss anything mentioned in artical outline, except introduction and title.\n - Please use the information I provide to create in-depth, interesting and unique content. Also, incorporate the references and data points I provided earlier into the article to increase its value to the reader.\n - MUST be in language of \"{keywords_0} {title_0}\".\n\n\n{outline}\n\n", + "prompt": "You are an SEO expert who writes in a direct, practical, educational style that is factual rather than storytelling or narrative, focusing on explaining to {audience} the \"how\" and \"what is\" and \u201cwhy\u201d rather than narrating to the audience. \n - Please write at a sixth grade reading level. \n - ONLY output in Markdown format.\n - Use positive, present tense expressions and avoid using complex words and sentence structures that lack narrative, such as \"reveal\" and \"dig deep.\"\n - Next, please continue writing articles related to our topic with a concise title, {title_0}{title} {keywords_0}{keywords}. \n - Please AVOID repeating what has already been written and do not use the same sentence structure. \n - JUST write the body of the article based on the outline.\n - DO NOT include introduction, title.\n - DO NOT miss anything mentioned in article outline, except introduction and title.\n - Please use the information I provide to create in-depth, interesting and unique content. Also, incorporate the references and data points I provided earlier into the article to increase its value to the reader.\n - MUST be in language of \"{keywords_0} {title_0}\".\n\n\n{outline}\n\n", "temperature": 0.1, "temperatureEnabled": true, "topPEnabled": true, @@ -1293,7 +1293,7 @@ { "data": { "form": { - "text": "Let LLM to generate keywords to search. \nBased on the search result, the outline of the artical will be generated." + "text": "Let LLM to generate keywords to search. \nBased on the search result, the outline of the article will be generated." }, "label": "Note", "name": "N: Words to search"