Commit 048f0b5
Changed files (2)
src
src/llm/contexts.py
@@ -99,7 +99,7 @@ async def single_context(client: Client, message: Message) -> dict:
contexts.append(
{
"type": "text",
- "text": f"[from user]: {info['full_name']}\n[file name]: {info['file_name']}\n[file content begin]\n{res['value'].strip()}\n[file content end]",
+ "text": f"[username]: {info['full_name']}\n[filename]: {info['file_name']}\n[file content]:\n{res['value'].strip()}",
}
)
else:
@@ -113,13 +113,13 @@ async def single_context(client: Client, message: Message) -> dict:
contexts.append(
{
"type": "text",
- "text": f"[from user]: {info['full_name']}\n[file name]: {info['file_name']}\n[file content begin]\n{Path(path).read_text().strip()}\n[file content end]",
+ "text": f"[username]: {info['full_name']}\n[filename]: {info['file_name']}\n[file content]:\n{Path(path).read_text().strip()}",
}
)
Path(path).unlink(missing_ok=True)
if msg_text:
if role == "user":
- contexts.append({"type": "text", "text": f"[from user]: {info['full_name']}\n[message begin]\n{msg_text}\n[message end]"})
+ contexts.append({"type": "text", "text": f"[username]: {info['full_name']}\n[message]:\n{msg_text}"})
else:
contexts.append({"type": "text", "text": msg_text})
except Exception as e:
src/llm/utils.py
@@ -100,9 +100,9 @@ def beautify_llm_response(text: str) -> str:
# remove tags. should align with the tags in `contexts.py`
clean_text = ""
for line in text.split("\n"):
- if line.strip().startswith(("[from user]:", "[file name]:")):
+ if line.strip().startswith(("[username]:", "[filename]:")):
continue
- if line.strip() in ["[message begin]", "[message end]", "[file content begin]", "[file content end]"]:
+ if line.strip() in ["[message]:", "[file content]:"]:
continue
clean_text += line + "\n"
clean_text = clean_text.removesuffix("\n") # remove the last newline