fix: keep generation progress out of chat history
This commit is contained in:
@@ -112,13 +112,6 @@ pub(crate) fn generate_big_fish_asset_tx(
|
||||
updated_at,
|
||||
};
|
||||
replace_big_fish_session(ctx, &session, next_session);
|
||||
append_big_fish_system_message(
|
||||
ctx,
|
||||
&input.session_id,
|
||||
format!("big-fish-message-asset-{}", input.generated_at_micros),
|
||||
reply,
|
||||
input.generated_at_micros,
|
||||
);
|
||||
|
||||
get_big_fish_session_tx(
|
||||
ctx,
|
||||
|
||||
@@ -538,13 +538,6 @@ pub(crate) fn compile_big_fish_draft_tx(
|
||||
updated_at: compiled_at,
|
||||
};
|
||||
replace_big_fish_session(ctx, &session, next_session);
|
||||
append_big_fish_system_message(
|
||||
ctx,
|
||||
&input.session_id,
|
||||
format!("big-fish-message-compile-{}", input.compiled_at_micros),
|
||||
reply,
|
||||
input.compiled_at_micros,
|
||||
);
|
||||
|
||||
get_big_fish_session_tx(
|
||||
ctx,
|
||||
@@ -682,32 +675,6 @@ pub(crate) fn replace_big_fish_session(
|
||||
ctx.db.big_fish_creation_session().insert(next);
|
||||
}
|
||||
|
||||
pub(crate) fn append_big_fish_system_message(
|
||||
ctx: &ReducerContext,
|
||||
session_id: &str,
|
||||
message_id: String,
|
||||
text: String,
|
||||
created_at_micros: i64,
|
||||
) {
|
||||
if ctx
|
||||
.db
|
||||
.big_fish_agent_message()
|
||||
.message_id()
|
||||
.find(&message_id)
|
||||
.is_some()
|
||||
{
|
||||
return;
|
||||
}
|
||||
ctx.db.big_fish_agent_message().insert(BigFishAgentMessage {
|
||||
message_id,
|
||||
session_id: session_id.to_string(),
|
||||
role: BigFishAgentMessageRole::Assistant,
|
||||
kind: BigFishAgentMessageKind::ActionResult,
|
||||
text,
|
||||
created_at: Timestamp::from_micros_since_unix_epoch(created_at_micros),
|
||||
});
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
@@ -659,12 +659,6 @@ fn compile_puzzle_agent_draft_tx(
|
||||
updated_at: compiled_at,
|
||||
},
|
||||
);
|
||||
append_system_message(
|
||||
ctx,
|
||||
&row.session_id,
|
||||
input.compiled_at_micros,
|
||||
"拼图结果页草稿已生成。",
|
||||
)?;
|
||||
get_puzzle_agent_session_tx(
|
||||
ctx,
|
||||
PuzzleAgentSessionGetInput {
|
||||
@@ -1260,25 +1254,6 @@ fn build_puzzle_suggested_actions(
|
||||
}
|
||||
}
|
||||
|
||||
fn append_system_message(
|
||||
ctx: &TxContext,
|
||||
session_id: &str,
|
||||
created_at_micros: i64,
|
||||
text: &str,
|
||||
) -> Result<(), String> {
|
||||
let message_id = format!("{session_id}-system-{created_at_micros}");
|
||||
ensure_message_missing(ctx, &message_id)?;
|
||||
ctx.db.puzzle_agent_message().insert(PuzzleAgentMessageRow {
|
||||
message_id,
|
||||
session_id: session_id.to_string(),
|
||||
role: PuzzleAgentMessageRole::Assistant,
|
||||
kind: PuzzleAgentMessageKind::ActionResult,
|
||||
text: text.to_string(),
|
||||
created_at: Timestamp::from_micros_since_unix_epoch(created_at_micros),
|
||||
});
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn ensure_session_missing(ctx: &TxContext, session_id: &str) -> Result<(), String> {
|
||||
if ctx
|
||||
.db
|
||||
|
||||
Reference in New Issue
Block a user