mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-08-10 20:19:22 +00:00
add metrics to all response types
This commit is contained in:
parent
afca9d92f9
commit
2214de9e54
3 changed files with 276 additions and 1 deletions
138
docs/_static/llama-stack-spec.html
vendored
138
docs/_static/llama-stack-spec.html
vendored
|
@ -3096,6 +3096,12 @@
|
||||||
"items": {
|
"items": {
|
||||||
"$ref": "#/components/schemas/ChatCompletionResponse"
|
"$ref": "#/components/schemas/ChatCompletionResponse"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"metrics": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/components/schemas/MetricEvent"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
|
@ -3116,6 +3122,12 @@
|
||||||
"$ref": "#/components/schemas/TokenLogProbs"
|
"$ref": "#/components/schemas/TokenLogProbs"
|
||||||
},
|
},
|
||||||
"description": "Optional log probabilities for generated tokens"
|
"description": "Optional log probabilities for generated tokens"
|
||||||
|
},
|
||||||
|
"metrics": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/components/schemas/MetricEvent"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
|
@ -3185,6 +3197,12 @@
|
||||||
"items": {
|
"items": {
|
||||||
"$ref": "#/components/schemas/CompletionResponse"
|
"$ref": "#/components/schemas/CompletionResponse"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"metrics": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/components/schemas/MetricEvent"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
|
@ -3214,6 +3232,12 @@
|
||||||
"$ref": "#/components/schemas/TokenLogProbs"
|
"$ref": "#/components/schemas/TokenLogProbs"
|
||||||
},
|
},
|
||||||
"description": "Optional log probabilities for generated tokens"
|
"description": "Optional log probabilities for generated tokens"
|
||||||
|
},
|
||||||
|
"metrics": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/components/schemas/MetricEvent"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
|
@ -3391,6 +3415,12 @@
|
||||||
"event": {
|
"event": {
|
||||||
"$ref": "#/components/schemas/ChatCompletionResponseEvent",
|
"$ref": "#/components/schemas/ChatCompletionResponseEvent",
|
||||||
"description": "The event containing the new content"
|
"description": "The event containing the new content"
|
||||||
|
},
|
||||||
|
"metrics": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/components/schemas/MetricEvent"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
|
@ -3556,6 +3586,12 @@
|
||||||
"$ref": "#/components/schemas/TokenLogProbs"
|
"$ref": "#/components/schemas/TokenLogProbs"
|
||||||
},
|
},
|
||||||
"description": "Optional log probabilities for generated tokens"
|
"description": "Optional log probabilities for generated tokens"
|
||||||
|
},
|
||||||
|
"metrics": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/components/schemas/MetricEvent"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
|
@ -3794,6 +3830,12 @@
|
||||||
"properties": {
|
"properties": {
|
||||||
"agent_id": {
|
"agent_id": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
},
|
||||||
|
"metrics": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/components/schemas/MetricEvent"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
|
@ -3818,6 +3860,12 @@
|
||||||
"properties": {
|
"properties": {
|
||||||
"session_id": {
|
"session_id": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
},
|
||||||
|
"metrics": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/components/schemas/MetricEvent"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
|
@ -4108,6 +4156,12 @@
|
||||||
},
|
},
|
||||||
"content": {
|
"content": {
|
||||||
"$ref": "#/components/schemas/InterleavedContent"
|
"$ref": "#/components/schemas/InterleavedContent"
|
||||||
|
},
|
||||||
|
"metrics": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/components/schemas/MetricEvent"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
|
@ -4418,6 +4472,12 @@
|
||||||
"properties": {
|
"properties": {
|
||||||
"event": {
|
"event": {
|
||||||
"$ref": "#/components/schemas/AgentTurnResponseEvent"
|
"$ref": "#/components/schemas/AgentTurnResponseEvent"
|
||||||
|
},
|
||||||
|
"metrics": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/components/schemas/MetricEvent"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
|
@ -4495,6 +4555,12 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"description": "List of embedding vectors, one per input content. Each embedding is a list of floats. The dimensionality of the embedding is model-specific; you can check model metadata using /models/{model_id}"
|
"description": "List of embedding vectors, one per input content. Each embedding is a list of floats. The dimensionality of the embedding is model-specific; you can check model metadata using /models/{model_id}"
|
||||||
|
},
|
||||||
|
"metrics": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/components/schemas/MetricEvent"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
|
@ -4822,6 +4888,12 @@
|
||||||
"additionalProperties": {
|
"additionalProperties": {
|
||||||
"$ref": "#/components/schemas/ScoringResult"
|
"$ref": "#/components/schemas/ScoringResult"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"metrics": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/components/schemas/MetricEvent"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
|
@ -4949,6 +5021,12 @@
|
||||||
"memory_retrieval": "#/components/schemas/MemoryRetrievalStep"
|
"memory_retrieval": "#/components/schemas/MemoryRetrievalStep"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"metrics": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/components/schemas/MetricEvent"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
|
@ -5625,6 +5703,12 @@
|
||||||
"additionalProperties": {
|
"additionalProperties": {
|
||||||
"$ref": "#/components/schemas/SpanWithStatus"
|
"$ref": "#/components/schemas/SpanWithStatus"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"metrics": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/components/schemas/MetricEvent"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
|
@ -5803,6 +5887,12 @@
|
||||||
"items": {
|
"items": {
|
||||||
"$ref": "#/components/schemas/Checkpoint"
|
"$ref": "#/components/schemas/Checkpoint"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"metrics": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/components/schemas/MetricEvent"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
|
@ -5872,6 +5962,12 @@
|
||||||
"items": {
|
"items": {
|
||||||
"$ref": "#/components/schemas/Checkpoint"
|
"$ref": "#/components/schemas/Checkpoint"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"metrics": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/components/schemas/MetricEvent"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
|
@ -7081,6 +7177,12 @@
|
||||||
"items": {
|
"items": {
|
||||||
"type": "number"
|
"type": "number"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"metrics": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/components/schemas/MetricEvent"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
|
@ -7145,6 +7247,12 @@
|
||||||
"items": {
|
"items": {
|
||||||
"$ref": "#/components/schemas/Span"
|
"$ref": "#/components/schemas/Span"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"metrics": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/components/schemas/MetricEvent"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
|
@ -7160,6 +7268,12 @@
|
||||||
"items": {
|
"items": {
|
||||||
"$ref": "#/components/schemas/Trace"
|
"$ref": "#/components/schemas/Trace"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"metrics": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/components/schemas/MetricEvent"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
|
@ -7536,6 +7650,12 @@
|
||||||
"properties": {
|
"properties": {
|
||||||
"violation": {
|
"violation": {
|
||||||
"$ref": "#/components/schemas/SafetyViolation"
|
"$ref": "#/components/schemas/SafetyViolation"
|
||||||
|
},
|
||||||
|
"metrics": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/components/schemas/MetricEvent"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": false
|
"additionalProperties": false
|
||||||
|
@ -7628,6 +7748,12 @@
|
||||||
"additionalProperties": {
|
"additionalProperties": {
|
||||||
"$ref": "#/components/schemas/ScoringResult"
|
"$ref": "#/components/schemas/ScoringResult"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"metrics": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/components/schemas/MetricEvent"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
|
@ -7676,6 +7802,12 @@
|
||||||
"additionalProperties": {
|
"additionalProperties": {
|
||||||
"$ref": "#/components/schemas/ScoringResult"
|
"$ref": "#/components/schemas/ScoringResult"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"metrics": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/components/schemas/MetricEvent"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
|
@ -7931,6 +8063,12 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"metrics": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/components/schemas/MetricEvent"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
|
|
92
docs/_static/llama-stack-spec.yaml
vendored
92
docs/_static/llama-stack-spec.yaml
vendored
|
@ -1919,6 +1919,10 @@ components:
|
||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
$ref: '#/components/schemas/ChatCompletionResponse'
|
$ref: '#/components/schemas/ChatCompletionResponse'
|
||||||
|
metrics:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/MetricEvent'
|
||||||
additionalProperties: false
|
additionalProperties: false
|
||||||
required:
|
required:
|
||||||
- batch
|
- batch
|
||||||
|
@ -1934,6 +1938,10 @@ components:
|
||||||
$ref: '#/components/schemas/TokenLogProbs'
|
$ref: '#/components/schemas/TokenLogProbs'
|
||||||
description: >-
|
description: >-
|
||||||
Optional log probabilities for generated tokens
|
Optional log probabilities for generated tokens
|
||||||
|
metrics:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/MetricEvent'
|
||||||
additionalProperties: false
|
additionalProperties: false
|
||||||
required:
|
required:
|
||||||
- completion_message
|
- completion_message
|
||||||
|
@ -1984,6 +1992,10 @@ components:
|
||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
$ref: '#/components/schemas/CompletionResponse'
|
$ref: '#/components/schemas/CompletionResponse'
|
||||||
|
metrics:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/MetricEvent'
|
||||||
additionalProperties: false
|
additionalProperties: false
|
||||||
required:
|
required:
|
||||||
- batch
|
- batch
|
||||||
|
@ -2006,6 +2018,10 @@ components:
|
||||||
$ref: '#/components/schemas/TokenLogProbs'
|
$ref: '#/components/schemas/TokenLogProbs'
|
||||||
description: >-
|
description: >-
|
||||||
Optional log probabilities for generated tokens
|
Optional log probabilities for generated tokens
|
||||||
|
metrics:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/MetricEvent'
|
||||||
additionalProperties: false
|
additionalProperties: false
|
||||||
required:
|
required:
|
||||||
- content
|
- content
|
||||||
|
@ -2176,6 +2192,10 @@ components:
|
||||||
event:
|
event:
|
||||||
$ref: '#/components/schemas/ChatCompletionResponseEvent'
|
$ref: '#/components/schemas/ChatCompletionResponseEvent'
|
||||||
description: The event containing the new content
|
description: The event containing the new content
|
||||||
|
metrics:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/MetricEvent'
|
||||||
additionalProperties: false
|
additionalProperties: false
|
||||||
required:
|
required:
|
||||||
- event
|
- event
|
||||||
|
@ -2303,6 +2323,10 @@ components:
|
||||||
$ref: '#/components/schemas/TokenLogProbs'
|
$ref: '#/components/schemas/TokenLogProbs'
|
||||||
description: >-
|
description: >-
|
||||||
Optional log probabilities for generated tokens
|
Optional log probabilities for generated tokens
|
||||||
|
metrics:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/MetricEvent'
|
||||||
additionalProperties: false
|
additionalProperties: false
|
||||||
required:
|
required:
|
||||||
- delta
|
- delta
|
||||||
|
@ -2449,6 +2473,10 @@ components:
|
||||||
properties:
|
properties:
|
||||||
agent_id:
|
agent_id:
|
||||||
type: string
|
type: string
|
||||||
|
metrics:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/MetricEvent'
|
||||||
additionalProperties: false
|
additionalProperties: false
|
||||||
required:
|
required:
|
||||||
- agent_id
|
- agent_id
|
||||||
|
@ -2465,6 +2493,10 @@ components:
|
||||||
properties:
|
properties:
|
||||||
session_id:
|
session_id:
|
||||||
type: string
|
type: string
|
||||||
|
metrics:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/MetricEvent'
|
||||||
additionalProperties: false
|
additionalProperties: false
|
||||||
required:
|
required:
|
||||||
- session_id
|
- session_id
|
||||||
|
@ -2653,6 +2685,10 @@ components:
|
||||||
- type: string
|
- type: string
|
||||||
content:
|
content:
|
||||||
$ref: '#/components/schemas/InterleavedContent'
|
$ref: '#/components/schemas/InterleavedContent'
|
||||||
|
metrics:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/MetricEvent'
|
||||||
additionalProperties: false
|
additionalProperties: false
|
||||||
required:
|
required:
|
||||||
- call_id
|
- call_id
|
||||||
|
@ -2847,6 +2883,10 @@ components:
|
||||||
properties:
|
properties:
|
||||||
event:
|
event:
|
||||||
$ref: '#/components/schemas/AgentTurnResponseEvent'
|
$ref: '#/components/schemas/AgentTurnResponseEvent'
|
||||||
|
metrics:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/MetricEvent'
|
||||||
additionalProperties: false
|
additionalProperties: false
|
||||||
required:
|
required:
|
||||||
- event
|
- event
|
||||||
|
@ -2910,6 +2950,10 @@ components:
|
||||||
List of embedding vectors, one per input content. Each embedding is a
|
List of embedding vectors, one per input content. Each embedding is a
|
||||||
list of floats. The dimensionality of the embedding is model-specific;
|
list of floats. The dimensionality of the embedding is model-specific;
|
||||||
you can check model metadata using /models/{model_id}
|
you can check model metadata using /models/{model_id}
|
||||||
|
metrics:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/MetricEvent'
|
||||||
additionalProperties: false
|
additionalProperties: false
|
||||||
required:
|
required:
|
||||||
- embeddings
|
- embeddings
|
||||||
|
@ -3117,6 +3161,10 @@ components:
|
||||||
type: object
|
type: object
|
||||||
additionalProperties:
|
additionalProperties:
|
||||||
$ref: '#/components/schemas/ScoringResult'
|
$ref: '#/components/schemas/ScoringResult'
|
||||||
|
metrics:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/MetricEvent'
|
||||||
additionalProperties: false
|
additionalProperties: false
|
||||||
required:
|
required:
|
||||||
- generations
|
- generations
|
||||||
|
@ -3188,6 +3236,10 @@ components:
|
||||||
tool_execution: '#/components/schemas/ToolExecutionStep'
|
tool_execution: '#/components/schemas/ToolExecutionStep'
|
||||||
shield_call: '#/components/schemas/ShieldCallStep'
|
shield_call: '#/components/schemas/ShieldCallStep'
|
||||||
memory_retrieval: '#/components/schemas/MemoryRetrievalStep'
|
memory_retrieval: '#/components/schemas/MemoryRetrievalStep'
|
||||||
|
metrics:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/MetricEvent'
|
||||||
additionalProperties: false
|
additionalProperties: false
|
||||||
required:
|
required:
|
||||||
- step
|
- step
|
||||||
|
@ -3602,6 +3654,10 @@ components:
|
||||||
type: object
|
type: object
|
||||||
additionalProperties:
|
additionalProperties:
|
||||||
$ref: '#/components/schemas/SpanWithStatus'
|
$ref: '#/components/schemas/SpanWithStatus'
|
||||||
|
metrics:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/MetricEvent'
|
||||||
additionalProperties: false
|
additionalProperties: false
|
||||||
required:
|
required:
|
||||||
- data
|
- data
|
||||||
|
@ -3714,6 +3770,10 @@ components:
|
||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
$ref: '#/components/schemas/Checkpoint'
|
$ref: '#/components/schemas/Checkpoint'
|
||||||
|
metrics:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/MetricEvent'
|
||||||
additionalProperties: false
|
additionalProperties: false
|
||||||
required:
|
required:
|
||||||
- job_uuid
|
- job_uuid
|
||||||
|
@ -3756,6 +3816,10 @@ components:
|
||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
$ref: '#/components/schemas/Checkpoint'
|
$ref: '#/components/schemas/Checkpoint'
|
||||||
|
metrics:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/MetricEvent'
|
||||||
additionalProperties: false
|
additionalProperties: false
|
||||||
required:
|
required:
|
||||||
- job_uuid
|
- job_uuid
|
||||||
|
@ -4514,6 +4578,10 @@ components:
|
||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
type: number
|
type: number
|
||||||
|
metrics:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/MetricEvent'
|
||||||
additionalProperties: false
|
additionalProperties: false
|
||||||
required:
|
required:
|
||||||
- chunks
|
- chunks
|
||||||
|
@ -4552,6 +4620,10 @@ components:
|
||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
$ref: '#/components/schemas/Span'
|
$ref: '#/components/schemas/Span'
|
||||||
|
metrics:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/MetricEvent'
|
||||||
additionalProperties: false
|
additionalProperties: false
|
||||||
required:
|
required:
|
||||||
- data
|
- data
|
||||||
|
@ -4562,6 +4634,10 @@ components:
|
||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
$ref: '#/components/schemas/Trace'
|
$ref: '#/components/schemas/Trace'
|
||||||
|
metrics:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/MetricEvent'
|
||||||
additionalProperties: false
|
additionalProperties: false
|
||||||
required:
|
required:
|
||||||
- data
|
- data
|
||||||
|
@ -4776,6 +4852,10 @@ components:
|
||||||
properties:
|
properties:
|
||||||
violation:
|
violation:
|
||||||
$ref: '#/components/schemas/SafetyViolation'
|
$ref: '#/components/schemas/SafetyViolation'
|
||||||
|
metrics:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/MetricEvent'
|
||||||
additionalProperties: false
|
additionalProperties: false
|
||||||
SaveSpansToDatasetRequest:
|
SaveSpansToDatasetRequest:
|
||||||
type: object
|
type: object
|
||||||
|
@ -4829,6 +4909,10 @@ components:
|
||||||
type: object
|
type: object
|
||||||
additionalProperties:
|
additionalProperties:
|
||||||
$ref: '#/components/schemas/ScoringResult'
|
$ref: '#/components/schemas/ScoringResult'
|
||||||
|
metrics:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/MetricEvent'
|
||||||
additionalProperties: false
|
additionalProperties: false
|
||||||
required:
|
required:
|
||||||
- results
|
- results
|
||||||
|
@ -4859,6 +4943,10 @@ components:
|
||||||
type: object
|
type: object
|
||||||
additionalProperties:
|
additionalProperties:
|
||||||
$ref: '#/components/schemas/ScoringResult'
|
$ref: '#/components/schemas/ScoringResult'
|
||||||
|
metrics:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/MetricEvent'
|
||||||
additionalProperties: false
|
additionalProperties: false
|
||||||
required:
|
required:
|
||||||
- results
|
- results
|
||||||
|
@ -5008,6 +5096,10 @@ components:
|
||||||
- type: string
|
- type: string
|
||||||
- type: array
|
- type: array
|
||||||
- type: object
|
- type: object
|
||||||
|
metrics:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/MetricEvent'
|
||||||
additionalProperties: false
|
additionalProperties: false
|
||||||
required:
|
required:
|
||||||
- synthetic_data
|
- synthetic_data
|
||||||
|
|
|
@ -55,6 +55,7 @@ from .specification import (
|
||||||
Tag,
|
Tag,
|
||||||
TagGroup,
|
TagGroup,
|
||||||
)
|
)
|
||||||
|
from llama_stack.apis.inference import ChatCompletionResponse
|
||||||
|
|
||||||
register_schema(
|
register_schema(
|
||||||
ipaddress.IPv4Address,
|
ipaddress.IPv4Address,
|
||||||
|
@ -106,6 +107,27 @@ class SchemaBuilder:
|
||||||
self.schema_generator = schema_generator
|
self.schema_generator = schema_generator
|
||||||
self.schemas = {}
|
self.schemas = {}
|
||||||
|
|
||||||
|
def _is_response_type(self, type_or_name: Union[str, type]) -> bool:
|
||||||
|
"""Helper method to check if a type or type name is a response type.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
type_or_name: Either a string type name or a type object
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
bool: True if the type represents a response, False otherwise
|
||||||
|
"""
|
||||||
|
name = type_or_name if isinstance(type_or_name, str) else type_or_name.__name__
|
||||||
|
return not name.startswith('List') and any(name.endswith(suffix) for suffix in ('Response', 'ResponseStreamChunk'))
|
||||||
|
|
||||||
|
def _add_metrics_to_schema(self, schema: Dict[str, Any]) -> None:
|
||||||
|
"""Helper method to add metrics field to a schema"""
|
||||||
|
if 'properties' not in schema:
|
||||||
|
schema['properties'] = {}
|
||||||
|
schema['properties']['metrics'] = {
|
||||||
|
'type': 'array',
|
||||||
|
'items': {'$ref': '#/components/schemas/MetricEvent'}
|
||||||
|
}
|
||||||
|
|
||||||
def classdef_to_schema(self, typ: type) -> Schema:
|
def classdef_to_schema(self, typ: type) -> Schema:
|
||||||
"""
|
"""
|
||||||
Converts a type to a JSON schema.
|
Converts a type to a JSON schema.
|
||||||
|
@ -114,7 +136,18 @@ class SchemaBuilder:
|
||||||
|
|
||||||
type_schema, type_definitions = self.schema_generator.classdef_to_schema(typ)
|
type_schema, type_definitions = self.schema_generator.classdef_to_schema(typ)
|
||||||
|
|
||||||
# append schema to list of known schemas, to be used in OpenAPI's Components Object section
|
# Add metrics field to all response schemas
|
||||||
|
if self._is_response_type(typ):
|
||||||
|
if isinstance(type_schema, dict) and '$ref' in type_schema:
|
||||||
|
# If it's a reference, modify the schema in type_definitions
|
||||||
|
ref_name = type_schema['$ref'].split('/')[-1]
|
||||||
|
if ref_name in type_definitions:
|
||||||
|
self._add_metrics_to_schema(type_definitions[ref_name])
|
||||||
|
else:
|
||||||
|
# Direct schema case
|
||||||
|
self._add_metrics_to_schema(type_schema)
|
||||||
|
|
||||||
|
# Register all schemas, including modified ones
|
||||||
for ref, schema in type_definitions.items():
|
for ref, schema in type_definitions.items():
|
||||||
self._add_ref(ref, schema)
|
self._add_ref(ref, schema)
|
||||||
|
|
||||||
|
@ -122,6 +155,14 @@ class SchemaBuilder:
|
||||||
|
|
||||||
def classdef_to_named_schema(self, name: str, typ: type) -> Schema:
|
def classdef_to_named_schema(self, name: str, typ: type) -> Schema:
|
||||||
schema = self.classdef_to_schema(typ)
|
schema = self.classdef_to_schema(typ)
|
||||||
|
# If this is a Response type, ensure the registered schema has metrics
|
||||||
|
if self._is_response_type(typ):
|
||||||
|
if isinstance(schema, dict) and '$ref' in schema:
|
||||||
|
ref_name = schema['$ref'].split('/')[-1]
|
||||||
|
if ref_name in self.schemas:
|
||||||
|
self._add_metrics_to_schema(self.schemas[ref_name])
|
||||||
|
else:
|
||||||
|
self._add_metrics_to_schema(schema)
|
||||||
self._add_ref(name, schema)
|
self._add_ref(name, schema)
|
||||||
return schema
|
return schema
|
||||||
|
|
||||||
|
@ -154,6 +195,10 @@ class SchemaBuilder:
|
||||||
|
|
||||||
def _add_ref(self, type_name: str, type_schema: Schema) -> None:
|
def _add_ref(self, type_name: str, type_schema: Schema) -> None:
|
||||||
if type_name not in self.schemas:
|
if type_name not in self.schemas:
|
||||||
|
# If adding a Response type, ensure it has metrics field
|
||||||
|
if self._is_response_type(type_name):
|
||||||
|
if isinstance(type_schema, dict):
|
||||||
|
self._add_metrics_to_schema(type_schema)
|
||||||
self.schemas[type_name] = type_schema
|
self.schemas[type_name] = type_schema
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue