Kevin Hu commited on
Commit
21c33f6
·
1 Parent(s): 198acce

Revert the chat history for rewrite. (#4579)

Browse files

### What problem does this PR solve?


### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)

agent/component/base.py CHANGED
@@ -483,7 +483,7 @@ class ComponentBase(ABC):
483
 
484
  if q["component_id"].lower().find("answer") == 0:
485
  txt = []
486
- for r, c in self._canvas.history[::-1][:self._param.message_history_window_size]:
487
  txt.append(f"{r.upper()}: {c}")
488
  txt = "\n".join(txt)
489
  self._param.inputs.append({"content": txt, "component_id": q["component_id"]})
 
483
 
484
  if q["component_id"].lower().find("answer") == 0:
485
  txt = []
486
+ for r, c in self._canvas.history[::-1][:self._param.message_history_window_size][::-1]:
487
  txt.append(f"{r.upper()}: {c}")
488
  txt = "\n".join(txt)
489
  self._param.inputs.append({"content": txt, "component_id": q["component_id"]})
agent/component/rewrite.py CHANGED
@@ -84,7 +84,7 @@ class RewriteQuestion(Generate, ABC):
84
  component_name = "RewriteQuestion"
85
 
86
  def _run(self, history, **kwargs):
87
- hist = self._canvas.get_history(4)
88
  conv = []
89
  for m in hist:
90
  if m["role"] not in ["user", "assistant"]:
 
84
  component_name = "RewriteQuestion"
85
 
86
  def _run(self, history, **kwargs):
87
+ hist = self._canvas.get_history(self._param.message_history_window_size)
88
  conv = []
89
  for m in hist:
90
  if m["role"] not in ["user", "assistant"]:
agent/templates/research_report.json CHANGED
@@ -717,7 +717,7 @@
717
  ]
718
  },
719
  "label": "Template",
720
- "name": "Artical"
721
  },
722
  "dragging": false,
723
  "height": 160,
 
717
  ]
718
  },
719
  "label": "Template",
720
+ "name": "Article"
721
  },
722
  "dragging": false,
723
  "height": 160,
agent/templates/seo_blog.json CHANGED
@@ -1153,7 +1153,7 @@
1153
  ],
1154
  "presencePenaltyEnabled": true,
1155
  "presence_penalty": 0.4,
1156
- "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<article_outline>\n{outline}\n\n<article_body>",
1157
  "temperature": 0.1,
1158
  "temperatureEnabled": true,
1159
  "topPEnabled": true,
@@ -1293,7 +1293,7 @@
1293
  {
1294
  "data": {
1295
  "form": {
1296
- "text": "Let LLM to generate keywords to search. \nBased on the search result, the outline of the artical will be generated."
1297
  },
1298
  "label": "Note",
1299
  "name": "N: Words to search"
 
1153
  ],
1154
  "presencePenaltyEnabled": true,
1155
  "presence_penalty": 0.4,
1156
+ "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<article_outline>\n{outline}\n\n<article_body>",
1157
  "temperature": 0.1,
1158
  "temperatureEnabled": true,
1159
  "topPEnabled": true,
 
1293
  {
1294
  "data": {
1295
  "form": {
1296
+ "text": "Let LLM to generate keywords to search. \nBased on the search result, the outline of the article will be generated."
1297
  },
1298
  "label": "Note",
1299
  "name": "N: Words to search"