feat: unify creation agent chat fill

This commit is contained in:
2026-04-25 10:50:19 +08:00
parent c06bf84d0a
commit 31f350d499
26 changed files with 540 additions and 153 deletions

View File

@@ -508,7 +508,7 @@ pub async fn get_custom_world_works(
pub async fn delete_custom_world_agent_session(
State(state): State<AppState>,
AxumPath(session_id): AxumPath<String>,
Path(session_id): Path<String>,
Extension(request_context): Extension<RequestContext>,
Extension(authenticated): Extension<AuthenticatedAccessToken>,
) -> Result<Json<Value>, Response> {
@@ -516,10 +516,7 @@ pub async fn delete_custom_world_agent_session(
let items = state
.spacetime_client()
.delete_custom_world_agent_session(
session_id,
authenticated.claims().user_id().to_string(),
)
.delete_custom_world_agent_session(session_id, authenticated.claims().user_id().to_string())
.await
.map_err(|error| {
custom_world_error_response(&request_context, map_custom_world_client_error(error))
@@ -1121,7 +1118,7 @@ fn spawn_custom_world_draft_foundation_job(
"底稿生成失败",
message.clone().as_str(),
100,
Some(message),
Some(message.clone()),
)
.await;
return;
@@ -1142,7 +1139,7 @@ fn spawn_custom_world_draft_foundation_job(
"底稿素材生成失败",
message.as_str(),
100,
Some(message),
Some(message.clone()),
)
.await;
return;
@@ -1158,7 +1155,7 @@ fn spawn_custom_world_draft_foundation_job(
"底稿素材生成失败",
message.as_str(),
100,
Some(message),
Some(message.clone()),
)
.await;
return;
@@ -1183,7 +1180,7 @@ fn spawn_custom_world_draft_foundation_job(
"生成角色主形象失败",
message.as_str(),
100,
Some(message),
Some(message.clone()),
)
.await;
return;
@@ -1207,7 +1204,7 @@ fn spawn_custom_world_draft_foundation_job(
"生成幕背景图失败",
message.as_str(),
100,
Some(message),
Some(message.clone()),
)
.await;
return;
@@ -1226,7 +1223,7 @@ fn spawn_custom_world_draft_foundation_job(
"底稿素材写回失败",
message.as_str(),
100,
Some(message),
Some(message.clone()),
)
.await;
return;
@@ -1916,6 +1913,24 @@ fn custom_world_error_response(request_context: &RequestContext, error: AppError
error.into_response_with_context(Some(request_context))
}
fn ensure_non_empty(
request_context: &RequestContext,
value: &str,
field_name: &str,
) -> Result<(), Response> {
if value.trim().is_empty() {
return Err(custom_world_error_response(
request_context,
AppError::from_status(StatusCode::BAD_REQUEST).with_details(json!({
"provider": "custom-world",
"message": format!("{field_name} is required"),
})),
));
}
Ok(())
}
fn custom_world_sse_json_event(event_name: &str, payload: Value) -> Result<Event, AppError> {
Event::default()
.event(event_name)