1
This commit is contained in:
12
server-rs/crates/platform-agent/src/output_parser.rs
Normal file
12
server-rs/crates/platform-agent/src/output_parser.rs
Normal file
@@ -0,0 +1,12 @@
|
||||
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}"))
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user