lutum_protocol/
structured.rs1use std::{any::type_name, borrow::Cow};
2
3use schemars::{JsonSchema, Schema, schema_for};
4use serde::{Serialize, de::DeserializeOwned};
5
6pub trait StructuredOutput:
7 Serialize + DeserializeOwned + JsonSchema + Clone + Send + Sync + 'static
8{
9 fn schema_name() -> Cow<'static, str> {
10 Cow::Owned(type_name::<Self>().to_string())
11 }
12
13 fn json_schema() -> Schema {
14 schema_for!(Self)
15 }
16}
17
18impl<T> StructuredOutput for T where
19 T: Serialize + DeserializeOwned + JsonSchema + Clone + Send + Sync + 'static
20{
21}