拼图候选图改为增加而非替换
This commit is contained in:
@@ -2549,12 +2549,24 @@ mod tests {
|
||||
description: Some("古老礁石上的半沉神殿。".to_string()),
|
||||
};
|
||||
let manual_prompt = build_custom_world_scene_image_prompt(
|
||||
&profile_input,
|
||||
&landmark,
|
||||
user_prompt,
|
||||
false,
|
||||
Some("礁石神殿"),
|
||||
"雾海群岛",
|
||||
SceneImagePromptParams {
|
||||
profile: SceneImagePromptProfile {
|
||||
name: profile_input.name.as_deref().unwrap_or_default(),
|
||||
subtitle: profile_input.subtitle.as_deref().unwrap_or_default(),
|
||||
tone: profile_input.tone.as_deref().unwrap_or_default(),
|
||||
player_goal: profile_input.player_goal.as_deref().unwrap_or_default(),
|
||||
summary: profile_input.summary.as_deref().unwrap_or_default(),
|
||||
setting_text: profile_input.setting_text.as_deref().unwrap_or_default(),
|
||||
},
|
||||
landmark: SceneImagePromptLandmark {
|
||||
name: landmark.name.as_deref().unwrap_or_default(),
|
||||
description: landmark.description.as_deref().unwrap_or_default(),
|
||||
},
|
||||
user_prompt,
|
||||
has_reference_image: false,
|
||||
fallback_landmark_name: Some("礁石神殿"),
|
||||
fallback_world_name: "雾海群岛",
|
||||
},
|
||||
);
|
||||
|
||||
let normalized = normalize_scene_image_request(CustomWorldSceneImageRequest {
|
||||
|
||||
@@ -468,6 +468,7 @@ pub async fn execute_puzzle_agent_action(
|
||||
.filter(|value| !value.trim().is_empty())
|
||||
.unwrap_or_else(|| draft.summary.clone());
|
||||
let candidate_count = payload.candidate_count.unwrap_or(2).clamp(1, 2);
|
||||
let candidate_start_index = draft.candidates.len();
|
||||
let candidates = generate_puzzle_image_candidates(
|
||||
&state,
|
||||
owner_user_id.as_str(),
|
||||
@@ -475,6 +476,7 @@ pub async fn execute_puzzle_agent_action(
|
||||
&draft.level_name,
|
||||
&prompt,
|
||||
candidate_count,
|
||||
candidate_start_index,
|
||||
)
|
||||
.await
|
||||
.map_err(SpacetimeClientError::Runtime);
|
||||
@@ -1474,6 +1476,7 @@ async fn compile_puzzle_draft_with_initial_cover(
|
||||
&draft.level_name,
|
||||
&draft.summary,
|
||||
2,
|
||||
draft.candidates.len(),
|
||||
)
|
||||
.await
|
||||
.map_err(SpacetimeClientError::Runtime)?;
|
||||
@@ -1616,6 +1619,7 @@ async fn generate_puzzle_image_candidates(
|
||||
level_name: &str,
|
||||
prompt: &str,
|
||||
candidate_count: u32,
|
||||
candidate_start_index: usize,
|
||||
) -> Result<Vec<PuzzleGeneratedImageCandidateRecord>, String> {
|
||||
let count = candidate_count.clamp(1, 2);
|
||||
let settings =
|
||||
@@ -1635,7 +1639,7 @@ async fn generate_puzzle_image_candidates(
|
||||
let mut items = Vec::with_capacity(generated.images.len());
|
||||
|
||||
for (index, image) in generated.images.into_iter().enumerate() {
|
||||
let candidate_id = format!("{session_id}-candidate-{}", index + 1);
|
||||
let candidate_id = format!("{session_id}-candidate-{}", candidate_start_index + index + 1);
|
||||
let asset = persist_puzzle_generated_asset(
|
||||
state,
|
||||
owner_user_id,
|
||||
@@ -1655,7 +1659,7 @@ async fn generate_puzzle_image_candidates(
|
||||
prompt: prompt.to_string(),
|
||||
actual_prompt: Some(prompt.to_string()),
|
||||
source_type: "generated".to_string(),
|
||||
selected: index == 0,
|
||||
selected: candidate_start_index == 0 && index == 0,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1729,6 +1733,7 @@ async fn build_local_next_puzzle_run(
|
||||
&draft.level_name,
|
||||
&draft.summary,
|
||||
2,
|
||||
draft.candidates.len(),
|
||||
)
|
||||
.await
|
||||
.map_err(|message| {
|
||||
|
||||
Reference in New Issue
Block a user