上下文加载 · 逻辑属性求值 API (0.1.4)

Download OpenAPI specification:

批量求一批对象实例的逻辑属性值。逻辑属性是对象类上的一条只读 Cypher 语句,按实例主键起算,返回单个标量值,所有版本都可用,不依赖执行工厂。

逻辑属性不直接存在于数据源里,需要带参数计算,而参数往往藏在用户的自然语言里 (「最近一年」→ 时间窗、「按省份」→ 分析维度)。本接口先用大模型把 query 翻译成各属性的 dynamic_params,再批量取值,省掉调用方自己拼参数的工作。 调用方也可以在请求里直接给出 dynamic_params:给了的值原样使用,只有缺的才由 大模型生成。

对象类有哪些逻辑属性、各自需要什么参数,看 kn-explore.yaml 的 get_object_types 返回的 logic_properties[].parameters。

认证:Authorization: Bearer <token>(OAuth access token 或 bak_ AppKey)。

LogicProperty

批量求逻辑属性值

query 的质量决定成败:参数由大模型从 query(必要时加 additional_context)里推断。查询里要含时间范围、统计维度等业务上下文, 否则会因缺参失败。

缺参返回 400,不是空结果:模型判定必需的 input 参数无法从查询推出时, 返回 400,details 里是 MISSING_INPUT_PARAMS 及逐属性的缺失说明。补上 上下文重试即可。

与之区分的是 500 DYNAMIC_PARAMS_GENERATION_FAILED:那是大模型或依赖服务 故障,不是调用方少给信息,重试或查服务状态。

结果与入参对齐:datas 与 _instance_identities 顺序一一对应,每项含 主键和本次请求的 properties。

Authorizations:
OAuth2AppKey
query Parameters
response_format
string
Default: "json"
Enum: "json" "toon"

响应格式。toon 返回 application/toon,同构数组压成表格,省 token。

Request Body schema: application/json
required
object (BKNContext)

BKN Trace business-provenance context identifying the business conversation and interaction to which this call belongs.

  • MCP business tools require it: a call without it is refused with conversation_required or interaction_required. This holds even when the verified capture policy is disabled; bkn_start_interaction still issues both IDs then (answering code: capture_disabled), and the business call runs without being recorded.
  • The Context Loader REST routes under /kn/ take it as optional.

Naming it makes the call managed: the service records an Operation under that interaction and attempts to return a receipt and capture evidence. When capture is disabled or Trace Core is unavailable, a managed REST call still runs, unrecorded. Omitting it entirely, or sending an empty object, makes a REST call ad hoc. Only those two shapes are ad hoc — one id without the other, or a misspelt field, is refused rather than quietly downgraded.

Both required child fields are server-issued handles and must not be invented by the caller:

  • conversation_id: obtained from the Context Loader MCP tool bkn_start_interaction on the first turn
  • interaction_id: obtained from the Context Loader MCP tool bkn_start_interaction

These handles are available only through the provenance MCP tool above. The BKN Trace Core session APIs under /api/agent-observability/v1 accept gateway credentials only from trusted in-cluster services. They do not accept OAuth tokens or bak_ AppKeys; direct external calls receive 401 permission_denied. Context Loader derives the Operation idempotency identity on the server from request correlation, tool name, and normalized input. Callers must not submit operation_key. Network retries should reuse bkn-request-id or provide a stable X-OpenBKN-Client-Invocation-Id for the same logical call. This hint is used only for idempotency and has no role in identity, authorization, or data-isolation decisions.

kn_id
required
string

知识网络 ID。

ot_id
required
string

对象类 ID。

query
string

用户查询。需要包含时间范围、统计维度、业务上下文,用于生成 dynamic_params。信息不足会导致 400 缺参。

所请求的逻辑属性有 input 参数时必填;都没有 input 参数时可省略。

required
Array of objects

对象实例标识数组,必须从上游取,不可自拼:先调 query_object_instance 或 query_instance_subgraph,从每个对象的 _instance_identity 取值,按原顺序组成数组。

properties
required
Array of strings

要求值的逻辑属性名列表(cypher)。

object

调用方自己给出的参数值,按逻辑属性名再按参数名分组,形如 {"属性名": {"参数名": 值}}。要填哪些参数看 get_object_types 返回的 logic_properties[].parameters 中 value_from=input 的项。给了的值原样使用, 只有缺的才由服务端生成;某属性的 input 参数全部给齐时不再调用大模型, 同一问题因此可复现。

additional_context
string

补充上下文,如 timezone、instant、step 或对象属性,帮助模型生成更准的 dynamic_params。

llm_model
string

覆盖用于生成动态参数的大模型;留空走系统默认大模型。

object (ResolveOptions)

高级选项。

Responses

Request samples

Content type
application/json
Example
{
  • "kn_id": "kn_medical",
  • "ot_id": "ot_company",
  • "query": "计算这些药企的经营健康度",
  • "_instance_identities": [
    ],
  • "properties": [
    ]
}

Response samples

Content type
{
  • "datas": [
    ],
  • "effective_permissions": {
    },
  • "dynamic_params": { },
  • "dynamic_params_source": {
    },
  • "debug": {
    }
}