follow master change, use gpt-5.4-mini max_tokens=1024
This commit is contained in:
Generated
+1
@@ -4447,6 +4447,7 @@ name = "platform-editor-agent"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"hmac",
|
||||
"platform-agent",
|
||||
"platform-llm",
|
||||
"serde",
|
||||
"serde_json",
|
||||
|
||||
@@ -167,9 +167,9 @@ pub async fn editor_agent_message(
|
||||
let tool_context = context::build_tool_context(&document);
|
||||
|
||||
// Build and run agent
|
||||
let llm_client = state.llm_client().ok_or_else(|| {
|
||||
let llm_client = state.creative_agent_gpt5_client().ok_or_else(|| {
|
||||
AppError::from_status(axum::http::StatusCode::SERVICE_UNAVAILABLE)
|
||||
.with_details(json!({ "message": "LLM client not configured" }))
|
||||
.with_details(json!({ "message": "Creative Agent GPT-5 client not configured" }))
|
||||
})?;
|
||||
let llm_client = llm_client.clone();
|
||||
let pricing = state.editor_generation_pricing().await.map_err(|error| {
|
||||
|
||||
@@ -6,6 +6,7 @@ license.workspace = true
|
||||
|
||||
[dependencies]
|
||||
hmac = { workspace = true }
|
||||
platform-agent = { workspace = true }
|
||||
platform-llm = { workspace = true }
|
||||
serde = { workspace = true }
|
||||
serde_json = { workspace = true }
|
||||
|
||||
@@ -4,9 +4,13 @@ use crate::framework::error::PromptError;
|
||||
use crate::framework::hook::Hook;
|
||||
use crate::framework::memory::AgentMemory;
|
||||
use crate::framework::tool::{Tool, ToolDyn};
|
||||
use platform_llm::{LlmClient, LlmMessage};
|
||||
use platform_agent::CREATIVE_AGENT_GPT5_MODEL;
|
||||
use platform_llm::{LlmClient, LlmMessage, LlmTextRequest};
|
||||
use serde_json::Value;
|
||||
|
||||
const EDITOR_AGENT_LLM_MAX_OUTPUT_TOKENS: u32 = 1024;
|
||||
const EDITOR_AGENT_LLM_REQUEST_TIMEOUT_MS: u64 = 60_000;
|
||||
|
||||
pub struct LlmCompletionModel {
|
||||
client: LlmClient,
|
||||
}
|
||||
@@ -16,9 +20,7 @@ impl LlmApiAdaptor<LlmMessage> for LlmCompletionModel {
|
||||
&self,
|
||||
messages: impl Iterator<Item = &'a LlmMessage> + Send,
|
||||
) -> Result<String, PromptError> {
|
||||
use platform_llm::LlmTextRequest;
|
||||
let request =
|
||||
LlmTextRequest::new(messages.cloned().collect()).with_request_timeout_ms(30_000);
|
||||
let request = build_editor_agent_llm_request(messages.cloned().collect());
|
||||
let response = self
|
||||
.client
|
||||
.request_text(request)
|
||||
@@ -36,6 +38,13 @@ impl LlmApiAdaptor<LlmMessage> for LlmCompletionModel {
|
||||
}
|
||||
}
|
||||
|
||||
fn build_editor_agent_llm_request(messages: Vec<LlmMessage>) -> LlmTextRequest {
|
||||
LlmTextRequest::new(messages)
|
||||
.with_model(CREATIVE_AGENT_GPT5_MODEL)
|
||||
.with_max_tokens(EDITOR_AGENT_LLM_MAX_OUTPUT_TOKENS)
|
||||
.with_request_timeout_ms(EDITOR_AGENT_LLM_REQUEST_TIMEOUT_MS)
|
||||
}
|
||||
|
||||
pub struct LlmChatAgentBuilder {
|
||||
client: Option<LlmClient>,
|
||||
system_prompt_parts: Vec<String>,
|
||||
@@ -172,3 +181,24 @@ fn build_tools_system_prompt(base_prompt: &str, tool_specs: &[ToolPromptSpec]) -
|
||||
|
||||
prompt
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn editor_agent_llm_request_keeps_gpt5_contract() {
|
||||
let request = build_editor_agent_llm_request(vec![
|
||||
LlmMessage::system("系统提示"),
|
||||
LlmMessage::user("用户请求"),
|
||||
]);
|
||||
|
||||
assert_eq!(
|
||||
request.model.as_deref(),
|
||||
Some(platform_agent::CREATIVE_AGENT_GPT5_MODEL)
|
||||
);
|
||||
assert_eq!(request.max_tokens, Some(1024));
|
||||
assert_eq!(request.request_timeout_ms, Some(60_000));
|
||||
assert_eq!(request.messages.len(), 2);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user