[fix] system prompt fit error
This commit is contained in:
@@ -149,14 +149,12 @@ def qa_proposal(chat_mdl, content, topn=3, custom_prompt=None):
|
|||||||
"""
|
"""
|
||||||
if custom_prompt:
|
if custom_prompt:
|
||||||
template = PROMPT_JINJA_ENV.from_string(custom_prompt)
|
template = PROMPT_JINJA_ENV.from_string(custom_prompt)
|
||||||
rendered_user = template.render(content=content, topn=topn)
|
sys_prompt = template.render(topn=topn)
|
||||||
msg = [{"role": "user", "content": rendered_user}]
|
|
||||||
sys_prompt = ""
|
|
||||||
else:
|
else:
|
||||||
sys_prompt = QUESTION_PROMPT_TEMPLATE
|
sys_prompt = QUESTION_PROMPT_TEMPLATE
|
||||||
msg = [{"role": "user", "content": f"## Text Content (topn: {topn})\n\n{content}"}]
|
msg = [{"role": "system", "content": sys_prompt}, {"role": "user", "content": content}]
|
||||||
_, msg = message_fit_in([{"role": "system", "content": sys_prompt}] + msg, getattr(chat_mdl, 'max_length', 8096))
|
_, msg = message_fit_in(msg, getattr(chat_mdl, 'max_length', 8096))
|
||||||
raw = chat_mdl.chat(sys_prompt, msg, {"temperature": 0.2})
|
raw = chat_mdl.chat(sys_prompt, msg[1:], {"temperature": 0.2})
|
||||||
if isinstance(raw, tuple):
|
if isinstance(raw, tuple):
|
||||||
raw = raw[0]
|
raw = raw[0]
|
||||||
raw = re.sub(r"^.*</think>", "", raw, flags=re.DOTALL)
|
raw = re.sub(r"^.*</think>", "", raw, flags=re.DOTALL)
|
||||||
|
|||||||
Reference in New Issue
Block a user