pub struct GenericSchemaAdapter;Expand description
Default schema adapter for providers with no specific requirements (Ollama, etc.).
Applies a conservative set of shared utility transforms:
- Strip
$schemakeyword - Strip conditional keywords (
if/then/else) - Convert
constto single-elementenum - Add implicit
"type": "object"whenpropertiesexists - Strip unsupported
formatvalues
This adapter does not resolve $ref, collapse combiners, or enforce nesting
depth limits. It is suitable for providers that accept most JSON Schema features
but reject the meta-keywords and conditional constructs.
Used as the default return value of Llm::schema_adapter()
for providers that do not override it.
§Example
use adk_core::{GenericSchemaAdapter, SchemaAdapter};
use serde_json::json;
let adapter = GenericSchemaAdapter;
let schema = json!({
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"name": { "type": "string", "const": "fixed" }
},
"if": { "properties": { "x": { "type": "number" } } },
"then": { "required": ["x"] }
});
let normalized = adapter.normalize_schema(schema);
assert!(normalized.get("$schema").is_none());
assert!(normalized.get("if").is_none());
assert!(normalized.get("then").is_none());
assert_eq!(normalized["type"], "object");
assert_eq!(normalized["properties"]["name"]["enum"], json!(["fixed"]));Trait Implementations§
Source§impl Debug for GenericSchemaAdapter
impl Debug for GenericSchemaAdapter
Source§impl SchemaAdapter for GenericSchemaAdapter
impl SchemaAdapter for GenericSchemaAdapter
Source§fn normalize_schema(&self, schema: Value) -> Value
fn normalize_schema(&self, schema: Value) -> Value
Normalize a raw JSON Schema for this provider. Read more
Source§fn normalize_tool_name<'a>(&self, name: &'a str) -> Cow<'a, str>
fn normalize_tool_name<'a>(&self, name: &'a str) -> Cow<'a, str>
Normalize a tool name for this provider’s limits. Read more
Source§fn empty_schema(&self) -> Value
fn empty_schema(&self) -> Value
Fallback schema when a tool provides no
parameters_schema. Read moreAuto Trait Implementations§
impl Freeze for GenericSchemaAdapter
impl RefUnwindSafe for GenericSchemaAdapter
impl Send for GenericSchemaAdapter
impl Sync for GenericSchemaAdapter
impl Unpin for GenericSchemaAdapter
impl UnsafeUnpin for GenericSchemaAdapter
impl UnwindSafe for GenericSchemaAdapter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more