Skip to content

Commit

Permalink
Xhxag persona fixes (BasedHardware#1855)
Browse files Browse the repository at this point in the history
  • Loading branch information
beastoin authored Feb 21, 2025
2 parents 5b7a621 + ee143c3 commit 37694c1
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions backend/utils/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -645,15 +645,14 @@ def answer_omi_question_stream(messages: List[Message], context: str, callbacks:


def answer_persona_question_stream(app: App, messages: List[Message], callbacks: []) -> str:
prompt = f"""
{app.persona_prompt}
chat_messages = [{"role": "system", "content": app.persona_prompt}]
for msg in messages:
if msg.sender == "ai":
chat_messages.append({"role": "ai", "content": msg.text})
else:
chat_messages.append({"role": "user", "content": msg.text})

---
CHAT MESSAGES:
{Message.get_messages_as_string(messages)}
"""
return llm_medium_stream.invoke(prompt, {'callbacks':callbacks}).content
return llm_medium_stream.invoke(chat_messages, {'callbacks':callbacks}).content

def _get_qa_rag_prompt(uid: str, question: str, context: str, plugin: Optional[Plugin] = None,
cited: Optional[bool] = False,
Expand Down Expand Up @@ -2131,6 +2130,6 @@ def generate_persona_intro_message(prompt: str, name: str):
{"role": "system", "content": prompt},
{"role": "user", "content": f"Generate a short, funny 5-8 word message that would make someone want to chat with you. Be casual and witty, but don't mention being AI or a clone. Just be {name}. The message should feel natural and make people curious to chat with you."}
]

response = llm_medium.invoke(messages)
return response.content.strip('"').strip()
return response.content.strip('"').strip()

0 comments on commit 37694c1

Please sign in to comment.