Spaces:
Paused
Paused
Update app/main.py
Browse files81 unmodified lines82838485868788899091929381 unmodified linesreturn {"reply": random.choice(npc["fallback"]), "in_tok": 0, "out_tok": 0}try:window = store.get_window(req.session_id)summary = store.get_summary(req.session_id)profile = store.get_profile(req.player_id)messages = build(npc, profile=profile, summary=summary, mems=None,window=window, ctx=req.ctx, user_text=user_text)r = await chat(messages)reply = clean(r["text"], npc)81 unmodified lines82838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913081 unmodified linesreturn {"reply": random.choice(npc["fallback"]), "in_tok": 0, "out_tok": 0}try:window = store.get_window(req.session_id)summary = store.get_summary(req.session_id)profile = store.get_profile(req.player_id)messages = build(npc=npc,profile=profile,summary=summary,mems=None,window=window,ctx=req.ctx,user_text=user_text,)# ตรวจเฉพาะจำนวนและสถานะ ไม่พิมพ์บทสนทนาลง logmessage_texts = [message.get("content", "")for message in messages]previous_user_present = Falseprevious_npc_present = Falseif window:previous_user = window[-1].get("u", "")previous_npc = window[-1].get("a", "")previous_user_present = bool(previous_user) and any(previous_user in contentfor content in message_texts)previous_npc_present = bool(previous_npc) and any(previous_npc in contentfor content in message_texts)print(f"[memory] loaded_turns={len(window)} "f"previous_user_present={previous_user_present} "f"previous_npc_present={previous_npc_present} "f"prompt_chars={sum(len(content) for content in message_texts)}",flush=True,)r = await chat(messages)reply = clean(r["text"], npc)
app/main.py+40-3