Download schemas/ai-stream.schema.json from deepstack-ml/deepstack-api-v2-contracts: direct link, hf CLI and curl.
- Browser
- Download file 9.33 kB
-
https://huggingface.co/datasets/deepstack-ml/deepstack-api-v2-contracts/resolve/main/schemas/ai-stream.schema.json
- Command line
-
hf download hf://datasets/deepstack-ml/deepstack-api-v2-contracts/schemas/ai-stream.schema.json
-
curl -L -o ai-stream.schema.json https://huggingface.co/datasets/deepstack-ml/deepstack-api-v2-contracts/resolve/main/schemas/ai-stream.schema.json
9.33 kB
| { | |
| "$schema": "https://json-schema.org/draft/2020-12/schema", | |
| "$id": "ai-stream.schema.json", | |
| "title": "AiStreamEvent", | |
| "description": "One event of the v2 answer stream, shared by the ML service, the edge and the app (POST /api/ai with Accept: text/event-stream). seq starts at 0 and grows by one; exactly one terminal event (done or error) closes the stream. claim_delta only carries a block whose references and checkable numbers were validated; error is never a finished answer. Transport-level names (token, chunk, complete) are internal and are translated, never exposed. The shape of `data` depends on `event` and is fixed by the $defs of the same name: the validators of both languages (semantic.check_stream / errors_of_stream_event in Python, stream.ts errorsOfStreamEvent in TypeScript) pick the $defs by `event` and check `data` against it, since the shared subset has no conditional keyword.", | |
| "type": "object", | |
| "additionalProperties": false, | |
| "required": [ | |
| "schema_version", | |
| "request_id", | |
| "seq", | |
| "event", | |
| "data" | |
| ], | |
| "properties": { | |
| "schema_version": { | |
| "$ref": "common.schema.json#/$defs/schema_version" | |
| }, | |
| "request_id": { | |
| "$ref": "common.schema.json#/$defs/id" | |
| }, | |
| "seq": { | |
| "type": "integer", | |
| "minimum": 0, | |
| "maximum": 9007199254740991 | |
| }, | |
| "event": { | |
| "enum": [ | |
| "meta", | |
| "status", | |
| "evidence", | |
| "claim_delta", | |
| "tool_result", | |
| "warning", | |
| "done", | |
| "error" | |
| ] | |
| }, | |
| "data": { | |
| "type": "object" | |
| } | |
| }, | |
| "$defs": { | |
| "code": { | |
| "description": "A stable machine word: a warning or error code, a status word, a degradation code.", | |
| "type": "string", | |
| "pattern": "^[a-z][a-z0-9_]{0,63}$" | |
| }, | |
| "meta": { | |
| "description": "The first event. The phase is the server's; environment says where the answer really runs ('fake' is a fixture, never a real answer). The app's bridge sends its own meta (phase and origin 'app') when the service cannot be reached, so only the phase is required.", | |
| "type": "object", | |
| "additionalProperties": false, | |
| "required": [ | |
| "phase" | |
| ], | |
| "properties": { | |
| "environment": { | |
| "$ref": "common.schema.json#/$defs/environment" | |
| }, | |
| "phase": { | |
| "$ref": "common.schema.json#/$defs/phase" | |
| }, | |
| "purpose": { | |
| "$ref": "common.schema.json#/$defs/purpose" | |
| }, | |
| "pack_id": { | |
| "$ref": "common.schema.json#/$defs/id" | |
| }, | |
| "question_id": { | |
| "$ref": "common.schema.json#/$defs/question_id" | |
| }, | |
| "origin": { | |
| "description": "Who produced the stream: the ML service ('ml') or the app's bridge standing in for it ('app').", | |
| "enum": [ | |
| "ml", | |
| "app" | |
| ] | |
| } | |
| } | |
| }, | |
| "status": { | |
| "type": "object", | |
| "additionalProperties": false, | |
| "required": [ | |
| "state" | |
| ], | |
| "properties": { | |
| "state": { | |
| "$ref": "#/$defs/code" | |
| } | |
| } | |
| }, | |
| "evidence": { | |
| "description": "The pack the answer may cite and the items its content_hash binds (evidence-pack-items), exactly as the retrieval produced them; the only source of the app's sources drawer.", | |
| "type": "object", | |
| "additionalProperties": false, | |
| "required": [ | |
| "pack", | |
| "items", | |
| "degradations" | |
| ], | |
| "properties": { | |
| "pack": { | |
| "$ref": "evidence-pack-ref.schema.json" | |
| }, | |
| "items": { | |
| "type": "array", | |
| "items": { | |
| "$ref": "evidence-pack-items.schema.json#/$defs/item" | |
| } | |
| }, | |
| "degradations": { | |
| "type": "array", | |
| "items": { | |
| "type": "object", | |
| "additionalProperties": false, | |
| "required": [ | |
| "code" | |
| ], | |
| "properties": { | |
| "code": { | |
| "$ref": "#/$defs/code" | |
| }, | |
| "detail": { | |
| "type": [ | |
| "string", | |
| "null" | |
| ], | |
| "maxLength": 300 | |
| } | |
| } | |
| } | |
| } | |
| } | |
| }, | |
| "claim_delta": { | |
| "description": "One validated block: the claim as it will appear in the answer's claim_refs and the citations it points at (citation_refs of grounded-answer). validated is always true; an unvalidated block is never sent.", | |
| "type": "object", | |
| "additionalProperties": false, | |
| "required": [ | |
| "validated", | |
| "claim", | |
| "citations" | |
| ], | |
| "properties": { | |
| "validated": { | |
| "const": true | |
| }, | |
| "claim": { | |
| "$ref": "grounded-answer.schema.json#/properties/claim_refs/items" | |
| }, | |
| "citations": { | |
| "type": "array", | |
| "items": { | |
| "$ref": "grounded-answer.schema.json#/properties/citation_refs/items" | |
| } | |
| } | |
| } | |
| }, | |
| "tool_result": { | |
| "description": "A tool the model called, by its receipt: id, status and error class. The output stays on the server; the full receipts travel in done.", | |
| "type": "object", | |
| "additionalProperties": false, | |
| "required": [ | |
| "tool_receipt_id", | |
| "tool_id", | |
| "status", | |
| "error_class" | |
| ], | |
| "properties": { | |
| "tool_receipt_id": { | |
| "$ref": "common.schema.json#/$defs/id" | |
| }, | |
| "tool_id": { | |
| "$ref": "common.schema.json#/$defs/id" | |
| }, | |
| "status": { | |
| "enum": [ | |
| "ok", | |
| "error" | |
| ] | |
| }, | |
| "error_class": { | |
| "type": [ | |
| "string", | |
| "null" | |
| ], | |
| "pattern": "^[a-z][a-z0-9_]{0,63}$" | |
| } | |
| } | |
| }, | |
| "warning": { | |
| "type": "object", | |
| "additionalProperties": false, | |
| "required": [ | |
| "code" | |
| ], | |
| "properties": { | |
| "code": { | |
| "$ref": "#/$defs/code" | |
| }, | |
| "reason": { | |
| "$ref": "#/$defs/code" | |
| }, | |
| "detail": { | |
| "type": "string", | |
| "maxLength": 600 | |
| } | |
| } | |
| }, | |
| "error": { | |
| "description": "The terminal that is never an answer. code 'cancelled' (service) and 'interrupted' (bridge, browser) mean the reader or the connection stopped it; the rest are failures.", | |
| "type": "object", | |
| "additionalProperties": false, | |
| "required": [ | |
| "code" | |
| ], | |
| "properties": { | |
| "code": { | |
| "$ref": "#/$defs/code" | |
| }, | |
| "reason": { | |
| "$ref": "#/$defs/code" | |
| }, | |
| "detail": { | |
| "type": "string", | |
| "maxLength": 600 | |
| }, | |
| "environment": { | |
| "$ref": "common.schema.json#/$defs/environment" | |
| }, | |
| "execution_receipt_id": { | |
| "type": [ | |
| "string", | |
| "null" | |
| ], | |
| "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$" | |
| }, | |
| "execution_receipt": { | |
| "$ref": "model-execution-receipt.schema.json" | |
| }, | |
| "execution_receipt_ids": { | |
| "type": "array", | |
| "items": { | |
| "$ref": "common.schema.json#/$defs/id" | |
| } | |
| } | |
| } | |
| }, | |
| "done": { | |
| "description": "The finished answer (grounded-answer) with every receipt of the run and the claims the validation rejected, with their reasons.", | |
| "type": "object", | |
| "additionalProperties": false, | |
| "required": [ | |
| "environment", | |
| "answer", | |
| "execution_receipts", | |
| "tool_receipts", | |
| "rejected" | |
| ], | |
| "properties": { | |
| "environment": { | |
| "$ref": "common.schema.json#/$defs/environment" | |
| }, | |
| "answer": { | |
| "$ref": "grounded-answer.schema.json" | |
| }, | |
| "execution_receipts": { | |
| "type": "array", | |
| "items": { | |
| "$ref": "model-execution-receipt.schema.json" | |
| } | |
| }, | |
| "tool_receipts": { | |
| "type": "array", | |
| "items": { | |
| "type": "object", | |
| "required": [ | |
| "receipt_id", | |
| "tool_id", | |
| "status" | |
| ], | |
| "properties": { | |
| "receipt_id": { | |
| "$ref": "common.schema.json#/$defs/id" | |
| }, | |
| "tool_id": { | |
| "$ref": "common.schema.json#/$defs/id" | |
| }, | |
| "status": { | |
| "enum": [ | |
| "ok", | |
| "error" | |
| ] | |
| } | |
| } | |
| } | |
| }, | |
| "rejected": { | |
| "type": "array", | |
| "items": { | |
| "type": "object", | |
| "additionalProperties": false, | |
| "required": [ | |
| "claim_text", | |
| "reason", | |
| "detail" | |
| ], | |
| "properties": { | |
| "claim_text": { | |
| "type": "string", | |
| "maxLength": 200 | |
| }, | |
| "reason": { | |
| "$ref": "#/$defs/code" | |
| }, | |
| "detail": { | |
| "type": "string", | |
| "maxLength": 600 | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |