story-kit: merge 351_story_bot_reset_command_to_clear_conversation_context
This commit is contained in:
@@ -928,6 +928,32 @@ async fn on_room_message(
|
||||
return;
|
||||
}
|
||||
|
||||
// Check for the reset command, which requires async access to the shared
|
||||
// conversation history and cannot be handled by the sync command registry.
|
||||
if super::reset::extract_reset_command(
|
||||
&user_message,
|
||||
&ctx.bot_name,
|
||||
ctx.bot_user_id.as_str(),
|
||||
)
|
||||
.is_some()
|
||||
{
|
||||
slog!("[matrix-bot] Handling reset command from {sender}");
|
||||
let response = super::reset::handle_reset(
|
||||
&ctx.bot_name,
|
||||
&incoming_room_id,
|
||||
&ctx.history,
|
||||
&ctx.project_root,
|
||||
)
|
||||
.await;
|
||||
let html = markdown_to_html(&response);
|
||||
if let Ok(msg_id) = ctx.transport.send_message(&room_id_str, &response, &html).await
|
||||
&& let Ok(event_id) = msg_id.parse()
|
||||
{
|
||||
ctx.bot_sent_event_ids.lock().await.insert(event_id);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Spawn a separate task so the Matrix sync loop is not blocked while we
|
||||
// wait for the LLM response (which can take several seconds).
|
||||
tokio::spawn(async move {
|
||||
|
||||
Reference in New Issue
Block a user