群聊回复剥离【角色名】学舌前缀
This commit is contained in:
@@ -102,6 +102,8 @@ async def send_group(sid: int, body: dict, user: User = Depends(current_user),
|
|||||||
reply = await client.chat(models.get("narrative") or "step-3.5-flash",
|
reply = await client.chat(models.get("narrative") or "step-3.5-flash",
|
||||||
[{"role": "system", "content": sysmsg}] + msgs,
|
[{"role": "system", "content": sysmsg}] + msgs,
|
||||||
temperature=0.95)
|
temperature=0.95)
|
||||||
|
import re as _re
|
||||||
|
reply = _re.sub(r"^【[^】]*】\s*", "", reply) # 剥掉模型学舌的【角色名】前缀
|
||||||
m = Message(session_id=sid, user_id=user.id, role="assistant",
|
m = Message(session_id=sid, user_id=user.id, role="assistant",
|
||||||
speaker=c.name, content_enc=_enc(user, reply),
|
speaker=c.name, content_enc=_enc(user, reply),
|
||||||
swipes_enc=_enc(user, json.dumps([reply])))
|
swipes_enc=_enc(user, json.dumps([reply])))
|
||||||
|
|||||||
Reference in New Issue
Block a user