Files
Genarrative/server-rs/crates/platform-agent/src/output_parser.rs
2026-05-08 11:44:42 +08:00

13 lines
338 B
Rust

use serde::de::DeserializeOwned;
use crate::error::PlatformAgentError;
pub fn parse_json_output<T>(raw_text: &str) -> Result<T, PlatformAgentError>
where
T: DeserializeOwned,
{
serde_json::from_str(raw_text).map_err(|error| {
PlatformAgentError::OutputParse(format!("解析 Agent JSON 输出失败:{error}"))
})
}