Table kit command
table.ai.prepare
Prepare an AI field run
Builds the prompts an AI field's run needs for one record or several, for the host to send to a model; changes nothing.
- Kit
- Table 0.4.0 (.ktable)
- Changes the document
- no
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
action | string | no | The AI action (summarize, translate, extract, improve, customize, classify, text_generation, image_generation, image_customization); when given, it must be the field's own. |
config | object | no | Overrides of the field's AI configuration for this run. |
fieldId | integer | string | yes | The AI field's id. |
limit | integer | no | How many records to prepare at most. |
recordId | integer | string | no | One record to run on. |
record_ids | (integer | string)[] | no | The records to run on, instead of recordId. |
tableId | integer | string | yes | The table's id. |
Call through table_run
text
table_run {
"path": "<file>.ktable",
"steps": [{ "command": "table.ai.prepare", "params": { "tableId": <integer | string>, "fieldId": <integer | string> } }]
}The required parameters, with placeholders for their types: not a tested example. Optional: action, config, limit, recordId, record_ids. table_run answers the step’s result in completed[i].result.
Result
| Name | Type | Required | Description |
|---|---|---|---|
change | object | null | no | What the call changed, or null. |
error | object | no | Why the call failed (A18); the file is as it was. |
result | object | no | The model requests of the run, for the host to generate and answer with table.ai.apply. |
Result JSON Schema
json
{
"additionalProperties": false,
"description": "The request's own answer is in `result`, beside `change`: what the call changed in the document (null when nothing changed). A failed call answers `error` instead (A18).",
"properties": {
"change": {
"description": "What the call changed, or null.",
"oneOf": [
{
"additionalProperties": false,
"description": "What one projection changed in the relational tables, by integer id. Every list is sorted and\nholds no repeats.",
"properties": {
"dashboards": {
"description": "A dashboard, or the base's list of them, changed.",
"type": "boolean"
},
"documentId": {
"type": "string"
},
"origin": {
"description": "Who wrote it: kind:principal, or a system origin's label.",
"type": "string"
},
"recordsDeleted": {
"description": "[tableId, rowKey] pairs.",
"items": {
"items": {},
"type": "array"
},
"type": "array"
},
"recordsReordered": {
"description": "Tables whose records' positions changed.",
"items": {
"type": "integer"
},
"type": "array"
},
"recordsUpserted": {
"description": "[tableId, rowKey] pairs.",
"items": {
"items": {},
"type": "array"
},
"type": "array"
},
"schema": {
"description": "Tables whose fields were added, removed, updated, or reordered.",
"items": {
"type": "integer"
},
"type": "array"
},
"tables": {
"description": "Tables whose own row changed: created, deleted, renamed, moved, or given a new primary\nfield.",
"items": {
"type": "integer"
},
"type": "array"
},
"views": {
"description": "Views created, deleted, updated, or reordered, or whose column widths or visibility\nchanged.",
"items": {
"type": "integer"
},
"type": "array"
}
},
"required": [
"tables",
"schema",
"views",
"recordsReordered",
"dashboards"
],
"type": "object"
},
{
"type": "null"
}
]
},
"error": {
"additionalProperties": false,
"description": "Why the call failed (A18); the file is as it was.",
"properties": {
"code": {
"enum": [
"invalid-params",
"invalid-op",
"invalid-value",
"not-found",
"read-only",
"unknown-command",
"command-failed",
"not-open",
"draft-required",
"not-allowed",
"unsupported",
"unavailable",
"failed"
],
"type": "string"
},
"index": {
"description": "The failing step or operation.",
"type": "integer"
},
"message": {
"type": "string"
},
"retryable": {
"type": "boolean"
}
},
"required": [
"code",
"message"
],
"type": "object"
},
"result": {
"additionalProperties": true,
"description": "The model requests of the run, for the host to generate and answer with table.ai.apply.",
"properties": {
"fieldId": {
"description": "The AI field's id.",
"type": "integer"
},
"model": {
"description": "The model the field asks for, when it names one.",
"type": "string"
},
"output": {
"description": "What the model makes.",
"enum": [
"text",
"image"
],
"type": "string"
},
"requests": {
"items": {
"additionalProperties": true,
"description": "One record's request.",
"properties": {
"messages": {
"items": {
"additionalProperties": true,
"description": "A message to the model.",
"properties": {
"parts": {
"items": {
"additionalProperties": true,
"description": "A part: {type: text, text} or {type: image, mime, hash?, url?}.",
"type": "object"
},
"type": "array"
},
"role": {
"description": "user.",
"type": "string"
}
},
"type": "object"
},
"type": "array"
},
"options": {
"additionalProperties": true,
"description": "An image request's count, size, width, height, quality and useCase.",
"type": "object"
},
"recordId": {
"description": "The record's id.",
"type": "integer"
}
},
"type": "object"
},
"type": "array"
},
"skipped": {
"items": {
"additionalProperties": true,
"description": "A record left out of a batch.",
"properties": {
"reason": {
"description": "Why.",
"type": "string"
},
"recordId": {
"description": "The record's id.",
"type": "integer"
}
},
"type": "object"
},
"type": "array"
}
},
"type": "object"
}
},
"type": "object"
}Parameter schema
json
{
"additionalProperties": false,
"properties": {
"action": {
"description": "The AI action (summarize, translate, extract, improve, customize, classify, text_generation, image_generation, image_customization); when given, it must be the field's own.",
"type": "string"
},
"config": {
"additionalProperties": true,
"description": "Overrides of the field's AI configuration for this run.",
"type": "object"
},
"fieldId": {
"description": "The AI field's id.",
"oneOf": [
{
"type": "integer"
},
{
"type": "string"
}
],
"x-khp-types": [
"Field"
]
},
"limit": {
"description": "How many records to prepare at most.",
"type": "integer"
},
"recordId": {
"description": "One record to run on.",
"oneOf": [
{
"type": "integer"
},
{
"type": "string"
}
],
"x-khp-types": [
"Record"
]
},
"record_ids": {
"description": "The records to run on, instead of recordId.",
"items": {
"oneOf": [
{
"type": "integer"
},
{
"type": "string"
}
]
},
"type": "array",
"x-khp-types": [
"Record"
]
},
"tableId": {
"description": "The table's id.",
"oneOf": [
{
"type": "integer"
},
{
"type": "string"
}
],
"x-khp-types": [
"Table"
]
}
},
"required": [
"tableId",
"fieldId"
],
"type": "object"
}Generated from kition-sdk packages/script/kits/table.ts and the kit itself (kition-table@ee73209). As data: commands.jsonl.