This commit is contained in:
2026-04-30 17:49:07 +08:00
parent 805d6f8cae
commit 9d684cb7b3
615 changed files with 15368 additions and 6172 deletions

View File

@@ -11,6 +11,8 @@ use serde_json::{Map as JsonMap, Value as JsonValue, json};
use shared_contracts::runtime::ExecuteCustomWorldAgentActionRequest;
use spacetime_client::CustomWorldAgentSessionRecord;
use crate::llm_model_routing::CREATION_TEMPLATE_LLM_MODEL;
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct CustomWorldFoundationDraftResult {
pub draft_profile_json: String,
@@ -174,10 +176,15 @@ where
F: Fn(&str) -> String,
{
let response = llm_client
.request_text(LlmTextRequest::new(vec![
LlmMessage::system(FOUNDATION_JSON_ONLY_SYSTEM_PROMPT),
LlmMessage::user(user_prompt),
]))
.request_text(
LlmTextRequest::new(vec![
LlmMessage::system(FOUNDATION_JSON_ONLY_SYSTEM_PROMPT),
LlmMessage::user(user_prompt),
])
.with_model(CREATION_TEMPLATE_LLM_MODEL)
.with_responses_api()
.with_web_search(true),
)
.await
.map_err(|error| format!("{debug_label} LLM 请求失败:{error}"))?;
let text = response.content.trim();
@@ -188,10 +195,14 @@ where
Ok(value) => Ok(value),
Err(_) => {
let repaired = llm_client
.request_text(LlmTextRequest::new(vec![
LlmMessage::system(FOUNDATION_JSON_REPAIR_SYSTEM_PROMPT),
LlmMessage::user(repair_prompt_builder(text)),
]))
.request_text(
LlmTextRequest::new(vec![
LlmMessage::system(FOUNDATION_JSON_REPAIR_SYSTEM_PROMPT),
LlmMessage::user(repair_prompt_builder(text)),
])
.with_model(CREATION_TEMPLATE_LLM_MODEL)
.with_responses_api(),
)
.await
.map_err(|error| format!("{repair_debug_label} LLM 请求失败:{error}"))?;
parse_json_response_text(repaired.content.as_str())