mirror of
https://github.com/OpenBMB/ChatDev.git
synced 2026-04-25 11:18:06 +00:00
4.1 KiB
Executable File
4.1 KiB
Executable File
Config Schema API Contract
This reference explains how /api/config/schema and /api/config/schema/validate expose DevAll's dynamic config metadata so IDEs, frontend form builders, and CLI tools can scope schemas with breadcrumbs.
1. Endpoints
| Method & Path | Purpose |
|---|---|
POST /api/config/schema |
Returns the schema for a config node described by breadcrumbs. |
POST /api/config/schema/validate |
Validates a YAML/JSON document and optionally echoes the scoped schema. |
1.1 Request body (shared fields)
{
"breadcrumbs": [
{"node": "DesignConfig", "field": "graph"},
{"node": "GraphConfig", "field": "nodes"},
{"node": "NodeConfig", "value": "model"}
]
}
node(required): class name (DesignConfig,GraphConfig,NodeConfig, etc.) that must match the class reached so far.field(optional): child field to traverse. When omitted, the breadcrumb only asserts you remain onnode.value(optional): use when the child class depends on a discriminator (e.g., nodetype). Supply the value as it would appear in YAML.index(optional int): reserved for list traversal; current configs rely onvalue/fieldfor navigation.
1.2 /schema response
{
"schemaVersion": "0.1.0",
"node": "NodeConfig",
"fields": [
{
"name": "id",
"typeHint": "str",
"required": true,
"description": "Unique node identifier"
},
{
"name": "type",
"typeHint": "str",
"required": true,
"enum": ["model", "python", "agent"],
"enumOptions": [
{"value": "model", "label": "LLM Node", "description": "Runs provider-backed models"}
]
}
],
"constraints": [...],
"breadcrumbs": [...],
"cacheKey": "f90d..."
}
fields: serializedConfigFieldSpecentries; nested targets includechildRoutes.constraints: emitted fromcollect_schema()(mutual exclusivity, required combos, etc.).cacheKey: SHA-1 hash of{node, breadcrumbs}so clients can memoize responses.
1.3 /schema/validate payloads
Add document alongside breadcrumbs:
{
"breadcrumbs": [{"node": "DesignConfig"}],
"document": """
name: demo
version: 0.4.0
workflow:
nodes: []
edges: []
"""
}
Responses:
- Valid document:
{ "valid": true, "schema": { ... } } - Config error:
{ "valid": false, "error": "field 'nodes' must not be empty", "path": ["workflow", "nodes"], "schema": { ... } } - Malformed YAML: HTTP 400 with
{ "message": "invalid_yaml", "error": "..." }.
2. Breadcrumb Tips
- Begin with
{ "node": "DesignConfig" }. - Each hop’s
nodemust match the current config class or the API returns HTTP 422. - Use
fieldto step into nested configs (graph → nodes → config, etc.). - Use
valuefor discriminator-based children (nodetype, toolingtype, etc.). - Non-navigable targets raise
field '<name>' on <node> is not navigable.
3. CLI Helper
python run.py --inspect-schema --schema-breadcrumbs '[{"node":"DesignConfig","field":"graph"}]'
The CLI prints the same JSON as /schema, which is useful while editing FIELD_SPECS or debugging registries before exporting templates.
4. Frontend Pattern
- Fetch base schema with
[{node: 'DesignConfig', field: 'graph'}]to render the workflow form. - When users open nested modals (node config, tooling config, etc.), append breadcrumbs describing the path and refetch.
- Cache responses using
cacheKey+ breadcrumbs. - Before saving, call
/schema/validateto surfaceerror+pathinline.
5. Error Reference
| HTTP Code | Situation | Detail payload |
|---|---|---|
| 400 | YAML parse failure | { "message": "invalid_yaml", "error": "..." } |
| 422 | Breadcrumb resolution failure | { "message": "breadcrumb node 'X'..." } |
200 + valid=false |
Backend ConfigError |
{ "error": "...", "path": ["workflow", ...] } |
200 + valid=true |
Document OK | Schema echoed back for the requested breadcrumbs. |
Pair this contract with FIELD_SPECS to build schema-aware experiences without hardcoding config structures.