Proc macros for the Cognis framework.
Macros
- [
tool] —#[cognis::tool]attribute that generates acognis_core::tools::BaseToolimplementation from anasync fn(or from animplblock containing one). Uses [schemars] under the hood for parameter schema generation. - [
GraphState] — derive macro for graph state schemas with per-field reducers (see attributes#[reducer(append|last_value|add|merge)]).
JSON Schema generation
For #[derive(JsonSchema)] on your own structs/enums, use the re-export
at cognis_core::JsonSchema (which is schemars::JsonSchema). The legacy
hand-rolled JsonSchema / ToolSchema derives in this crate were removed
in favor of the upstream schemars crate, which supports recursive types,
$ref/definitions, doc-comment → description, and richer attribute
syntax.
use cognis_core::JsonSchema;
use serde::{Deserialize, Serialize};
#[derive(JsonSchema, Serialize, Deserialize)]
struct SearchFilter {
/// Minimum relevance score
min_score: f64,
/// Categories to include
categories: Vec<String>,
}
let schema = serde_json::to_value(schemars::schema_for!(SearchFilter)).unwrap();