From d7dc69c8a9cbb5bb25c07ae8c05c90419c3716aa Mon Sep 17 00:00:00 2001 From: Ashwin Bharambe Date: Sun, 8 Dec 2024 20:46:22 -0800 Subject: [PATCH] Regenerate openapi --- docs/resources/llama-stack-spec.html | 652 ++++++++++++++++-- docs/resources/llama-stack-spec.yaml | 356 +++++++++- llama_stack/apis/telemetry/telemetry.py | 11 +- .../utils/telemetry/sqlite_trace_store.py | 4 +- 4 files changed, 933 insertions(+), 90 deletions(-) diff --git a/docs/resources/llama-stack-spec.html b/docs/resources/llama-stack-spec.html index 4f220ea1e..d1040f186 100644 --- a/docs/resources/llama-stack-spec.html +++ b/docs/resources/llama-stack-spec.html @@ -21,7 +21,7 @@ "info": { "title": "Llama Stack Specification", "version": "alpha", - "description": "This is the specification of the Llama Stack that provides\n a set of endpoints and their corresponding interfaces that are tailored to\n best leverage Llama Models. Generated at 2024-11-22 17:23:55.034164" + "description": "This is the specification of the Llama Stack that provides\n a set of endpoints and their corresponding interfaces that are tailored to\n best leverage Llama Models." }, "servers": [ { @@ -29,6 +29,39 @@ } ], "paths": { + "/alpha/datasetio/append-rows": { + "post": { + "responses": { + "200": { + "description": "OK" + } + }, + "tags": [ + "DatasetIO" + ], + "parameters": [ + { + "name": "X-LlamaStack-ProviderData", + "in": "header", + "description": "JSON-encoded provider data which will be made available to the adapter servicing the API", + "required": false, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AppendRowsRequest" + } + } + }, + "required": true + } + } + }, "/alpha/batch-inference/chat-completion": { "post": { "responses": { @@ -1026,15 +1059,15 @@ ] } }, - "/alpha/telemetry/get-trace": { - "get": { + "/alpha/telemetry/get-span-tree": { + "post": { "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/Trace" + "$ref": "#/components/schemas/SpanWithChildren" } } } @@ -1045,13 +1078,21 @@ ], "parameters": [ { - "name": "trace_id", + "name": "span_id", "in": "query", "required": true, "schema": { "type": "string" } }, + { + "name": "max_depth", + "in": "query", + "required": false, + "schema": { + "type": "integer" + } + }, { "name": "X-LlamaStack-ProviderData", "in": "header", @@ -1061,7 +1102,17 @@ "type": "string" } } - ] + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GetSpanTreeRequest" + } + } + }, + "required": true + } } }, "/alpha/post-training/job/artifacts": { @@ -1778,6 +1829,86 @@ } } }, + "/alpha/telemetry/query-spans": { + "post": { + "responses": { + "200": { + "description": "OK", + "content": { + "application/jsonl": { + "schema": { + "$ref": "#/components/schemas/Span" + } + } + } + } + }, + "tags": [ + "Telemetry" + ], + "parameters": [ + { + "name": "X-LlamaStack-ProviderData", + "in": "header", + "description": "JSON-encoded provider data which will be made available to the adapter servicing the API", + "required": false, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/QuerySpansRequest" + } + } + }, + "required": true + } + } + }, + "/alpha/telemetry/query-traces": { + "post": { + "responses": { + "200": { + "description": "OK", + "content": { + "application/jsonl": { + "schema": { + "$ref": "#/components/schemas/Trace" + } + } + } + } + }, + "tags": [ + "Telemetry" + ], + "parameters": [ + { + "name": "X-LlamaStack-ProviderData", + "in": "header", + "description": "JSON-encoded provider data which will be made available to the adapter servicing the API", + "required": false, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/QueryTracesRequest" + } + } + }, + "required": true + } + } + }, "/alpha/datasets/register": { "post": { "responses": { @@ -2066,6 +2197,39 @@ } } }, + "/alpha/telemetry/save-spans-to-dataset": { + "post": { + "responses": { + "200": { + "description": "OK" + } + }, + "tags": [ + "Telemetry" + ], + "parameters": [ + { + "name": "X-LlamaStack-ProviderData", + "in": "header", + "description": "JSON-encoded provider data which will be made available to the adapter servicing the API", + "required": false, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SaveSpansToDatasetRequest" + } + } + }, + "required": true + } + } + }, "/alpha/scoring/score": { "post": { "responses": { @@ -2226,6 +2390,39 @@ } } }, + "/alpha/datasets/unregister": { + "post": { + "responses": { + "200": { + "description": "OK" + } + }, + "tags": [ + "Datasets" + ], + "parameters": [ + { + "name": "X-LlamaStack-ProviderData", + "in": "header", + "description": "JSON-encoded provider data which will be made available to the adapter servicing the API", + "required": false, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UnregisterDatasetRequest" + } + } + }, + "required": true + } + } + }, "/alpha/memory-banks/unregister": { "post": { "responses": { @@ -2291,44 +2488,52 @@ "required": true } } - }, - "/alpha/datasets/unregister": { - "post": { - "responses": { - "200": { - "description": "OK" - } - }, - "tags": [ - "Datasets" - ], - "parameters": [ - { - "name": "X-LlamaStack-ProviderData", - "in": "header", - "description": "JSON-encoded provider data which will be made available to the adapter servicing the API", - "required": false, - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/UnregisterDatasetRequest" - } - } - }, - "required": true - } - } } }, "jsonSchemaDialect": "https://json-schema.org/draft/2020-12/schema", "components": { "schemas": { + "AppendRowsRequest": { + "type": "object", + "properties": { + "dataset_id": { + "type": "string" + }, + "rows": { + "type": "array", + "items": { + "type": "object", + "additionalProperties": { + "oneOf": [ + { + "type": "null" + }, + { + "type": "boolean" + }, + { + "type": "number" + }, + { + "type": "string" + }, + { + "type": "array" + }, + { + "type": "object" + } + ] + } + } + } + }, + "additionalProperties": false, + "required": [ + "dataset_id", + "rows" + ] + }, "BuiltinTool": { "type": "string", "enum": [ @@ -5878,13 +6083,38 @@ ], "title": "A safety shield resource that can be used to check content" }, - "Trace": { + "GetSpanTreeRequest": { "type": "object", "properties": { + "attributes_to_return": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "additionalProperties": false + }, + "SpanStatus": { + "type": "string", + "enum": [ + "ok", + "error" + ] + }, + "SpanWithChildren": { + "type": "object", + "properties": { + "span_id": { + "type": "string" + }, "trace_id": { "type": "string" }, - "root_span_id": { + "parent_span_id": { + "type": "string" + }, + "name": { "type": "string" }, "start_time": { @@ -5894,13 +6124,49 @@ "end_time": { "type": "string", "format": "date-time" + }, + "attributes": { + "type": "object", + "additionalProperties": { + "oneOf": [ + { + "type": "null" + }, + { + "type": "boolean" + }, + { + "type": "number" + }, + { + "type": "string" + }, + { + "type": "array" + }, + { + "type": "object" + } + ] + } + }, + "children": { + "type": "array", + "items": { + "$ref": "#/components/schemas/SpanWithChildren" + } + }, + "status": { + "$ref": "#/components/schemas/SpanStatus" } }, "additionalProperties": false, "required": [ + "span_id", "trace_id", - "root_span_id", - "start_time" + "name", + "start_time", + "children" ] }, "Checkpoint": { @@ -6313,13 +6579,6 @@ "name" ] }, - "SpanStatus": { - "type": "string", - "enum": [ - "ok", - "error" - ] - }, "StructuredLogEvent": { "type": "object", "properties": { @@ -6458,11 +6717,15 @@ "$ref": "#/components/schemas/StructuredLogEvent" } ] + }, + "ttl_seconds": { + "type": "integer" } }, "additionalProperties": false, "required": [ - "event" + "event", + "ttl_seconds" ] }, "DPOAlignmentConfig": { @@ -6772,6 +7035,185 @@ "scores" ] }, + "QueryCondition": { + "type": "object", + "properties": { + "key": { + "type": "string" + }, + "op": { + "$ref": "#/components/schemas/QueryConditionOp" + }, + "value": { + "oneOf": [ + { + "type": "null" + }, + { + "type": "boolean" + }, + { + "type": "number" + }, + { + "type": "string" + }, + { + "type": "array" + }, + { + "type": "object" + } + ] + } + }, + "additionalProperties": false, + "required": [ + "key", + "op", + "value" + ] + }, + "QueryConditionOp": { + "type": "string", + "enum": [ + "eq", + "ne", + "gt", + "lt" + ] + }, + "QuerySpansRequest": { + "type": "object", + "properties": { + "attribute_filters": { + "type": "array", + "items": { + "$ref": "#/components/schemas/QueryCondition" + } + }, + "attributes_to_return": { + "type": "array", + "items": { + "type": "string" + } + }, + "max_depth": { + "type": "integer" + } + }, + "additionalProperties": false, + "required": [ + "attribute_filters", + "attributes_to_return" + ] + }, + "Span": { + "type": "object", + "properties": { + "span_id": { + "type": "string" + }, + "trace_id": { + "type": "string" + }, + "parent_span_id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "start_time": { + "type": "string", + "format": "date-time" + }, + "end_time": { + "type": "string", + "format": "date-time" + }, + "attributes": { + "type": "object", + "additionalProperties": { + "oneOf": [ + { + "type": "null" + }, + { + "type": "boolean" + }, + { + "type": "number" + }, + { + "type": "string" + }, + { + "type": "array" + }, + { + "type": "object" + } + ] + } + } + }, + "additionalProperties": false, + "required": [ + "span_id", + "trace_id", + "name", + "start_time" + ] + }, + "QueryTracesRequest": { + "type": "object", + "properties": { + "attribute_filters": { + "type": "array", + "items": { + "$ref": "#/components/schemas/QueryCondition" + } + }, + "limit": { + "type": "integer" + }, + "offset": { + "type": "integer" + }, + "order_by": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "additionalProperties": false + }, + "Trace": { + "type": "object", + "properties": { + "trace_id": { + "type": "string" + }, + "root_span_id": { + "type": "string" + }, + "start_time": { + "type": "string", + "format": "date-time" + }, + "end_time": { + "type": "string", + "format": "date-time" + } + }, + "additionalProperties": false, + "required": [ + "trace_id", + "root_span_id", + "start_time" + ] + }, "RegisterDatasetRequest": { "type": "object", "properties": { @@ -7488,6 +7930,35 @@ }, "additionalProperties": false }, + "SaveSpansToDatasetRequest": { + "type": "object", + "properties": { + "attribute_filters": { + "type": "array", + "items": { + "$ref": "#/components/schemas/QueryCondition" + } + }, + "attributes_to_save": { + "type": "array", + "items": { + "type": "string" + } + }, + "dataset_id": { + "type": "string" + }, + "max_depth": { + "type": "integer" + } + }, + "additionalProperties": false, + "required": [ + "attribute_filters", + "attributes_to_save", + "dataset_id" + ] + }, "ScoreRequest": { "type": "object", "properties": { @@ -7927,6 +8398,18 @@ ], "title": "Response from the synthetic data generation. Batch of (prompt, response, score) tuples that pass the threshold." }, + "UnregisterDatasetRequest": { + "type": "object", + "properties": { + "dataset_id": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "dataset_id" + ] + }, "UnregisterMemoryBankRequest": { "type": "object", "properties": { @@ -7950,18 +8433,6 @@ "required": [ "model_id" ] - }, - "UnregisterDatasetRequest": { - "type": "object", - "properties": { - "dataset_id": { - "type": "string" - } - }, - "additionalProperties": false, - "required": [ - "dataset_id" - ] } }, "responses": {} @@ -8027,6 +8498,10 @@ "name": "AppEvalTaskConfig", "description": "" }, + { + "name": "AppendRowsRequest", + "description": "" + }, { "name": "Attachment", "description": "" @@ -8182,6 +8657,10 @@ "name": "GetAgentsSessionRequest", "description": "" }, + { + "name": "GetSpanTreeRequest", + "description": "" + }, { "name": "GraphMemoryBank", "description": "" @@ -8336,6 +8815,14 @@ "name": "QLoraFinetuningConfig", "description": "" }, + { + "name": "QueryCondition", + "description": "" + }, + { + "name": "QueryConditionOp", + "description": "" + }, { "name": "QueryDocumentsRequest", "description": "" @@ -8344,6 +8831,14 @@ "name": "QueryDocumentsResponse", "description": "" }, + { + "name": "QuerySpansRequest", + "description": "" + }, + { + "name": "QueryTracesRequest", + "description": "" + }, { "name": "RLHFAlgorithm", "description": "" @@ -8415,6 +8910,10 @@ "name": "SamplingStrategy", "description": "" }, + { + "name": "SaveSpansToDatasetRequest", + "description": "" + }, { "name": "ScoreBatchRequest", "description": "" @@ -8464,6 +8963,10 @@ { "name": "Shields" }, + { + "name": "Span", + "description": "" + }, { "name": "SpanEndPayload", "description": "" @@ -8476,6 +8979,10 @@ "name": "SpanStatus", "description": "" }, + { + "name": "SpanWithChildren", + "description": "" + }, { "name": "StopReason", "description": "" @@ -8566,6 +9073,10 @@ "name": "URL", "description": "" }, + { + "name": "UnregisterDatasetRequest", + "description": "" + }, { "name": "UnregisterMemoryBankRequest", "description": "" @@ -8574,10 +9085,6 @@ "name": "UnregisterModelRequest", "description": "" }, - { - "name": "UnregisterDatasetRequest", - "description": "" - }, { "name": "UnstructuredLogEvent", "description": "" @@ -8643,6 +9150,7 @@ "AgentTurnResponseTurnCompletePayload", "AgentTurnResponseTurnStartPayload", "AppEvalTaskConfig", + "AppendRowsRequest", "Attachment", "BatchChatCompletionRequest", "BatchChatCompletionResponse", @@ -8678,6 +9186,7 @@ "FinetuningAlgorithm", "FunctionCallToolDefinition", "GetAgentsSessionRequest", + "GetSpanTreeRequest", "GraphMemoryBank", "GraphMemoryBankParams", "HealthInfo", @@ -8712,8 +9221,12 @@ "PreferenceOptimizeRequest", "ProviderInfo", "QLoraFinetuningConfig", + "QueryCondition", + "QueryConditionOp", "QueryDocumentsRequest", "QueryDocumentsResponse", + "QuerySpansRequest", + "QueryTracesRequest", "RLHFAlgorithm", "RegexParserScoringFnParams", "RegisterDatasetRequest", @@ -8731,6 +9244,7 @@ "SafetyViolation", "SamplingParams", "SamplingStrategy", + "SaveSpansToDatasetRequest", "ScoreBatchRequest", "ScoreBatchResponse", "ScoreRequest", @@ -8741,9 +9255,11 @@ "Session", "Shield", "ShieldCallStep", + "Span", "SpanEndPayload", "SpanStartPayload", "SpanStatus", + "SpanWithChildren", "StopReason", "StructuredLogEvent", "SupervisedFineTuneRequest", @@ -8765,9 +9281,9 @@ "TrainingConfig", "Turn", "URL", + "UnregisterDatasetRequest", "UnregisterMemoryBankRequest", "UnregisterModelRequest", - "UnregisterDatasetRequest", "UnstructuredLogEvent", "UserMessage", "VectorMemoryBank", diff --git a/docs/resources/llama-stack-spec.yaml b/docs/resources/llama-stack-spec.yaml index 6564ddf3f..0b737a697 100644 --- a/docs/resources/llama-stack-spec.yaml +++ b/docs/resources/llama-stack-spec.yaml @@ -242,6 +242,27 @@ components: - eval_candidate - scoring_params type: object + AppendRowsRequest: + additionalProperties: false + properties: + dataset_id: + type: string + rows: + items: + additionalProperties: + oneOf: + - type: 'null' + - type: boolean + - type: number + - type: string + - type: array + - type: object + type: object + type: array + required: + - dataset_id + - rows + type: object Attachment: additionalProperties: false properties: @@ -1059,6 +1080,14 @@ components: type: string type: array type: object + GetSpanTreeRequest: + additionalProperties: false + properties: + attributes_to_return: + items: + type: string + type: array + type: object GraphMemoryBank: additionalProperties: false properties: @@ -1277,8 +1306,11 @@ components: - $ref: '#/components/schemas/UnstructuredLogEvent' - $ref: '#/components/schemas/MetricEvent' - $ref: '#/components/schemas/StructuredLogEvent' + ttl_seconds: + type: integer required: - event + - ttl_seconds type: object LogSeverity: enum: @@ -1825,6 +1857,33 @@ components: - rank - alpha type: object + QueryCondition: + additionalProperties: false + properties: + key: + type: string + op: + $ref: '#/components/schemas/QueryConditionOp' + value: + oneOf: + - type: 'null' + - type: boolean + - type: number + - type: string + - type: array + - type: object + required: + - key + - op + - value + type: object + QueryConditionOp: + enum: + - eq + - ne + - gt + - lt + type: string QueryDocumentsRequest: additionalProperties: false properties: @@ -1887,6 +1946,39 @@ components: - chunks - scores type: object + QuerySpansRequest: + additionalProperties: false + properties: + attribute_filters: + items: + $ref: '#/components/schemas/QueryCondition' + type: array + attributes_to_return: + items: + type: string + type: array + max_depth: + type: integer + required: + - attribute_filters + - attributes_to_return + type: object + QueryTracesRequest: + additionalProperties: false + properties: + attribute_filters: + items: + $ref: '#/components/schemas/QueryCondition' + type: array + limit: + type: integer + offset: + type: integer + order_by: + items: + type: string + type: array + type: object RLHFAlgorithm: enum: - dpo @@ -2392,6 +2484,26 @@ components: - top_p - top_k type: string + SaveSpansToDatasetRequest: + additionalProperties: false + properties: + attribute_filters: + items: + $ref: '#/components/schemas/QueryCondition' + type: array + attributes_to_save: + items: + type: string + type: array + dataset_id: + type: string + max_depth: + type: integer + required: + - attribute_filters + - attributes_to_save + - dataset_id + type: object ScoreBatchRequest: additionalProperties: false properties: @@ -2731,6 +2843,39 @@ components: - step_id - step_type type: object + Span: + additionalProperties: false + properties: + attributes: + additionalProperties: + oneOf: + - type: 'null' + - type: boolean + - type: number + - type: string + - type: array + - type: object + type: object + end_time: + format: date-time + type: string + name: + type: string + parent_span_id: + type: string + span_id: + type: string + start_time: + format: date-time + type: string + trace_id: + type: string + required: + - span_id + - trace_id + - name + - start_time + type: object SpanEndPayload: additionalProperties: false properties: @@ -2764,6 +2909,46 @@ components: - ok - error type: string + SpanWithChildren: + additionalProperties: false + properties: + attributes: + additionalProperties: + oneOf: + - type: 'null' + - type: boolean + - type: number + - type: string + - type: array + - type: object + type: object + children: + items: + $ref: '#/components/schemas/SpanWithChildren' + type: array + end_time: + format: date-time + type: string + name: + type: string + parent_span_id: + type: string + span_id: + type: string + start_time: + format: date-time + type: string + status: + $ref: '#/components/schemas/SpanStatus' + trace_id: + type: string + required: + - span_id + - trace_id + - name + - start_time + - children + type: object StopReason: enum: - end_of_turn @@ -3237,6 +3422,14 @@ components: format: uri pattern: ^(https?://|file://|data:) type: string + UnregisterDatasetRequest: + additionalProperties: false + properties: + dataset_id: + type: string + required: + - dataset_id + type: object UnregisterMemoryBankRequest: additionalProperties: false properties: @@ -3253,14 +3446,6 @@ components: required: - model_id type: object - UnregisterDatasetRequest: - additionalProperties: false - properties: - dataset_id: - type: string - required: - - dataset_id - type: object UnstructuredLogEvent: additionalProperties: false properties: @@ -3408,7 +3593,7 @@ components: info: description: "This is the specification of the Llama Stack that provides\n \ \ a set of endpoints and their corresponding interfaces that are tailored\ - \ to\n best leverage Llama Models. Generated at 2024-11-22 17:23:55.034164" + \ to\n best leverage Llama Models." title: Llama Stack Specification version: alpha jsonSchemaDialect: https://json-schema.org/draft/2020-12/schema @@ -3692,6 +3877,27 @@ paths: description: OK tags: - BatchInference (Coming Soon) + /alpha/datasetio/append-rows: + post: + parameters: + - description: JSON-encoded provider data which will be made available to the + adapter servicing the API + in: header + name: X-LlamaStack-ProviderData + required: false + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/AppendRowsRequest' + required: true + responses: + '200': + description: OK + tags: + - DatasetIO /alpha/datasetio/get-rows-paginated: get: parameters: @@ -4785,14 +4991,19 @@ paths: description: OK tags: - SyntheticDataGeneration (Coming Soon) - /alpha/telemetry/get-trace: - get: + /alpha/telemetry/get-span-tree: + post: parameters: - in: query - name: trace_id + name: span_id required: true schema: type: string + - in: query + name: max_depth + required: false + schema: + type: integer - description: JSON-encoded provider data which will be made available to the adapter servicing the API in: header @@ -4800,12 +5011,18 @@ paths: required: false schema: type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/GetSpanTreeRequest' + required: true responses: '200': content: application/json: schema: - $ref: '#/components/schemas/Trace' + $ref: '#/components/schemas/SpanWithChildren' description: OK tags: - Telemetry @@ -4830,6 +5047,77 @@ paths: description: OK tags: - Telemetry + /alpha/telemetry/query-spans: + post: + parameters: + - description: JSON-encoded provider data which will be made available to the + adapter servicing the API + in: header + name: X-LlamaStack-ProviderData + required: false + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/QuerySpansRequest' + required: true + responses: + '200': + content: + application/jsonl: + schema: + $ref: '#/components/schemas/Span' + description: OK + tags: + - Telemetry + /alpha/telemetry/query-traces: + post: + parameters: + - description: JSON-encoded provider data which will be made available to the + adapter servicing the API + in: header + name: X-LlamaStack-ProviderData + required: false + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/QueryTracesRequest' + required: true + responses: + '200': + content: + application/jsonl: + schema: + $ref: '#/components/schemas/Trace' + description: OK + tags: + - Telemetry + /alpha/telemetry/save-spans-to-dataset: + post: + parameters: + - description: JSON-encoded provider data which will be made available to the + adapter servicing the API + in: header + name: X-LlamaStack-ProviderData + required: false + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/SaveSpansToDatasetRequest' + required: true + responses: + '200': + description: OK + tags: + - Telemetry security: - Default: [] servers: @@ -4878,6 +5166,9 @@ tags: - description: name: AppEvalTaskConfig +- description: + name: AppendRowsRequest - description: name: Attachment - description: name: GetAgentsSessionRequest +- description: + name: GetSpanTreeRequest - description: name: GraphMemoryBank @@ -5105,12 +5399,23 @@ tags: - description: name: QLoraFinetuningConfig +- description: + name: QueryCondition +- description: + name: QueryConditionOp - description: name: QueryDocumentsRequest - description: name: QueryDocumentsResponse +- description: + name: QuerySpansRequest +- description: + name: QueryTracesRequest - description: name: RLHFAlgorithm - description: name: SamplingStrategy +- description: + name: SaveSpansToDatasetRequest - description: name: ScoreBatchRequest @@ -5190,6 +5498,8 @@ tags: - description: name: ShieldCallStep - name: Shields +- description: + name: Span - description: name: SpanEndPayload - description: name: SpanStatus +- description: + name: SpanWithChildren - description: name: StopReason - description: name: URL +- description: + name: UnregisterDatasetRequest - description: name: UnregisterMemoryBankRequest - description: name: UnregisterModelRequest -- description: - name: UnregisterDatasetRequest - description: name: UnstructuredLogEvent @@ -5326,6 +5639,7 @@ x-tagGroups: - AgentTurnResponseTurnCompletePayload - AgentTurnResponseTurnStartPayload - AppEvalTaskConfig + - AppendRowsRequest - Attachment - BatchChatCompletionRequest - BatchChatCompletionResponse @@ -5361,6 +5675,7 @@ x-tagGroups: - FinetuningAlgorithm - FunctionCallToolDefinition - GetAgentsSessionRequest + - GetSpanTreeRequest - GraphMemoryBank - GraphMemoryBankParams - HealthInfo @@ -5395,8 +5710,12 @@ x-tagGroups: - PreferenceOptimizeRequest - ProviderInfo - QLoraFinetuningConfig + - QueryCondition + - QueryConditionOp - QueryDocumentsRequest - QueryDocumentsResponse + - QuerySpansRequest + - QueryTracesRequest - RLHFAlgorithm - RegexParserScoringFnParams - RegisterDatasetRequest @@ -5414,6 +5733,7 @@ x-tagGroups: - SafetyViolation - SamplingParams - SamplingStrategy + - SaveSpansToDatasetRequest - ScoreBatchRequest - ScoreBatchResponse - ScoreRequest @@ -5424,9 +5744,11 @@ x-tagGroups: - Session - Shield - ShieldCallStep + - Span - SpanEndPayload - SpanStartPayload - SpanStatus + - SpanWithChildren - StopReason - StructuredLogEvent - SupervisedFineTuneRequest @@ -5448,9 +5770,9 @@ x-tagGroups: - TrainingConfig - Turn - URL + - UnregisterDatasetRequest - UnregisterMemoryBankRequest - UnregisterModelRequest - - UnregisterDatasetRequest - UnstructuredLogEvent - UserMessage - VectorMemoryBank diff --git a/llama_stack/apis/telemetry/telemetry.py b/llama_stack/apis/telemetry/telemetry.py index fd60d99a7..12ec5f1d9 100644 --- a/llama_stack/apis/telemetry/telemetry.py +++ b/llama_stack/apis/telemetry/telemetry.py @@ -155,16 +155,23 @@ class SpanWithChildren(Span): status: Optional[SpanStatus] = None +@json_schema_type +class QueryConditionOp(Enum): + EQ = "eq" + NE = "ne" + GT = "gt" + LT = "lt" + + @json_schema_type class QueryCondition(BaseModel): key: str - op: Literal["eq", "ne", "gt", "lt"] + op: QueryConditionOp value: Any @runtime_checkable class Telemetry(Protocol): - @webmethod(route="/telemetry/log-event") async def log_event( self, event: Event, ttl_seconds: int = DEFAULT_TTL_DAYS * 86400 diff --git a/llama_stack/providers/utils/telemetry/sqlite_trace_store.py b/llama_stack/providers/utils/telemetry/sqlite_trace_store.py index 031b6fc73..8d9035216 100644 --- a/llama_stack/providers/utils/telemetry/sqlite_trace_store.py +++ b/llama_stack/providers/utils/telemetry/sqlite_trace_store.py @@ -14,7 +14,6 @@ from llama_stack.apis.telemetry import QueryCondition, SpanWithChildren, Trace class TraceStore(Protocol): - async def query_traces( self, attribute_filters: Optional[List[QueryCondition]] = None, @@ -42,7 +41,6 @@ class SQLiteTraceStore(TraceStore): offset: Optional[int] = 0, order_by: Optional[List[str]] = None, ) -> List[Trace]: - def build_where_clause() -> tuple[str, list]: if not attribute_filters: return "", [] @@ -50,7 +48,7 @@ class SQLiteTraceStore(TraceStore): ops_map = {"eq": "=", "ne": "!=", "gt": ">", "lt": "<"} conditions = [ - f"json_extract(s.attributes, '$.{condition.key}') {ops_map[condition.op]} ?" + f"json_extract(s.attributes, '$.{condition.key}') {ops_map[condition.op.value]} ?" for condition in attribute_filters ] params = [condition.value for condition in attribute_filters]