mirror of
https://github.com/AstrBotDevs/AstrBot.git
synced 2026-10-16 06:58:51 +08:00
fix: refresh queued conversation history under the session lock (#10238)
* fix: refresh queued conversation history under the session lock * style: format queued conversation history refresh * Delete tests/unit/test_queued_conversation_history.py --------- Co-authored-by: Soulter <37870767+Soulter@users.noreply.github.com>
This commit is contained in:
@@ -1440,7 +1440,22 @@ async def collect_initial_request(
|
||||
list(req.contexts) if isinstance(req.contexts, list) else req.contexts
|
||||
)
|
||||
if req.conversation:
|
||||
req.contexts = json.loads(req.conversation.history)
|
||||
# Handler requests can be prepared before the pipeline acquires
|
||||
# the session lock. Reload the bound conversation here so queued
|
||||
# turns include replies saved while they were waiting.
|
||||
conversation = (
|
||||
await plugin_context.conversation_manager.get_conversation(
|
||||
event.unified_msg_origin, req.conversation.cid
|
||||
)
|
||||
)
|
||||
if conversation is None:
|
||||
_set_llm_error_message(
|
||||
event,
|
||||
"The requested conversation no longer exists. Please send a new message.",
|
||||
)
|
||||
return None, None
|
||||
req.conversation = conversation
|
||||
req.contexts = json.loads(conversation.history)
|
||||
else:
|
||||
req = ProviderRequest()
|
||||
req.prompt = ""
|
||||
|
||||
Reference in New Issue
Block a user