Compare commits

...

1 Commits

Author SHA1 Message Date
xxm
9cf81a1200 优化了第二次对用户问题的提示词 2025-12-05 09:12:44 +00:00
3 changed files with 13 additions and 7 deletions

Binary file not shown.

View File

@@ -239,18 +239,24 @@ def message(req: MessageReq):
class QueryFromMsgReq(BaseModel):
session_id: str
message: str | None = None
@app.post("/query_from_message", tags=["opro"])
def query_from_message(req: QueryFromMsgReq):
s = get_session(req.session_id)
if not s:
raise AppException(404, "session not found", "SESSION_NOT_FOUND")
last_user = None
for m in reversed(s.get("chat_history", [])):
if m.get("role") == "user" and m.get("content"):
last_user = m["content"]
break
base = last_user or s["original_query"]
base = None
if req.message:
log_chat_message(req.session_id, "user", req.message)
base = req.message
else:
for m in reversed(s.get("chat_history", [])):
if m.get("role") == "user" and m.get("content"):
base = m["content"]
break
base = base or s["original_query"]
cands = generate_candidates(base, s["history_candidates"], model_name=s.get("model_name"))
update_session_add_candidates(req.session_id, cands)
return ok({"session_id": req.session_id, "round": s["round"], "candidates": cands})

View File

@@ -272,7 +272,7 @@
const candRes = await fetch(API_BASE + '/query_from_message', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ session_id: currentSession })
body: JSON.stringify({ session_id: currentSession, message: msg })
});
const candData = await candRes.json();
const payload = candData && candData.data ? candData.data : {};