.f0rge/wiki/docs/capabilities/extract.v1.md 3.9 KiB 113 lines Raw

extract.v1

Status: v1. A published shape is frozen by spec.md section 20.1. Capability key: extract Route: POST /extract

Parts in

One row for each part kind that this capability accepts. A kind that is not in this table is invalid_part.

kindrolerequiredmeaning
textsourceyes, exactly onethe text that the plugin reads.
jsonfieldsyes, exactly one{"fields": [{"name": "...", "type": "string", "description": "..."}]}.

Parameters

This capability has no parameters. A value in params is ignored (R26). The fields part carries the whole output schema.

Channels out

One row for each channel that this capability can emit.

channelmimepayload
decisionapplication/json{"fields": {"<name>": "<value>"}}

Terminal metadata

done.meta is vocabulary-defined. The core stores it and never reads it. done without meta means {}.

keytypemeaning
modelstringthe served name that ran the job

model is present when outcome is completed. It is absent when the outcome is cancelled or expired.

Request

POST /extract
{
  "model": "<served-name>",
  "input": [
    {"kind": "text", "role": "source", "text": "The queue held 12 jobs for 400 ms, then drained."},
    {"kind": "json", "role": "fields", "json": {"fields": [
      {"name": "jobs", "type": "number", "description": "How many jobs the queue held."},
      {"name": "drained", "type": "boolean", "description": "Whether the queue emptied."},
      {"name": "devices", "type": "string[]", "description": "Device names that ran the jobs."}
    ]}}
  ],
  "params": {},
  "stream": false
}

Response, no stream

{"job": "019...", "outcome": "completed",
 "decision": {"mime": "application/json", "inline": {"fields": {
   "jobs": 12, "drained": true, "devices": ["gpu-0"]}}},
 "usage": {"tokens_in": 41, "tokens_out": 9},
 "meta": {"model": "<served-name>"}}

Stream

extract emits one decision event, then the done frame. No other event appears.

event  ch=decision application/json {"fields":{"jobs":12,"drained":true,"devices":["gpu-0"]}}
done   outcome=completed meta={"model": "<served-name>"}

Rules

  1. Exactly one text part with role source is required. A request without it is invalid_part.
  2. Exactly one json part with role fields is required. A request without it is invalid_part.
  3. An image, audio, video, or tokens part is invalid_part.
  4. Every entry of the fields array names name, type, and description. A missing key gives a refusal that names fields.
  5. The fields array is not empty. An empty array gives a refusal that names fields.
  6. A type value is string, number, boolean, or string[]. Any other value gives a refusal that names fields.
  7. Every name in the fields array is unique. A repeated name gives a refusal that names fields.
  8. The payload fields object has one entry per requested name. Its key set equals the requested name set.
  9. A string value is a JSON string. A number value is a JSON number, not a string.
  10. A boolean value is true or false. A string[] value is an array of JSON strings.
  11. A field that the source cannot answer carries null. The plugin never omits a requested key.
  12. The payload carries no type and no description. Those strings never appear in the output.
  13. The plugin emits one decision event and nothing else for this job. A second decision event is a protocol error.
  14. A value in params does not change the extracted fields.
  15. usage.tokens_in counts the source and the field schema. usage.tokens_out counts the emitted answer tokens. Both are present when outcome is completed.
  16. No event follows a cancel. The terminal frame is done with outcome = cancelled, and it carries no metadata keys.

view raw