Skip to content

Commit 99141c2

Browse files
authored
feat: Add responses and safety impl extra_body (llamastack#3781)
# What does this PR do? Have closed the previous PR due to merge conflicts with multiple PRs Addressed all comments from llamastack#3768 (sorry for carrying over to this one) ## Test Plan Added UTs and integration tests
1 parent 8e7e0dd commit 99141c2

File tree

244 files changed

+36829
-235
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

244 files changed

+36829
-235
lines changed

docs/static/deprecated-llama-stack-spec.html

Lines changed: 46 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2135,7 +2135,7 @@
21352135
"deprecated": true,
21362136
"x-llama-stack-extra-body-params": [
21372137
{
2138-
"name": "shields",
2138+
"name": "guardrails",
21392139
"schema": {
21402140
"type": "array",
21412141
"items": {
@@ -2144,12 +2144,12 @@
21442144
"type": "string"
21452145
},
21462146
{
2147-
"$ref": "#/components/schemas/ResponseShieldSpec"
2147+
"$ref": "#/components/schemas/ResponseGuardrailSpec"
21482148
}
21492149
]
21502150
}
21512151
},
2152-
"description": "List of shields to apply during response generation. Shields provide safety and content moderation.",
2152+
"description": "List of guardrails to apply during response generation. Guardrails provide safety and content moderation.",
21532153
"required": false
21542154
}
21552155
]
@@ -8483,6 +8483,28 @@
84838483
}
84848484
}
84858485
},
8486+
"OpenAIResponseContentPartRefusal": {
8487+
"type": "object",
8488+
"properties": {
8489+
"type": {
8490+
"type": "string",
8491+
"const": "refusal",
8492+
"default": "refusal",
8493+
"description": "Content part type identifier, always \"refusal\""
8494+
},
8495+
"refusal": {
8496+
"type": "string",
8497+
"description": "Refusal text supplied by the model"
8498+
}
8499+
},
8500+
"additionalProperties": false,
8501+
"required": [
8502+
"type",
8503+
"refusal"
8504+
],
8505+
"title": "OpenAIResponseContentPartRefusal",
8506+
"description": "Refusal content within a streamed response part."
8507+
},
84868508
"OpenAIResponseError": {
84878509
"type": "object",
84888510
"properties": {
@@ -9063,6 +9085,23 @@
90639085
}
90649086
},
90659087
"OpenAIResponseOutputMessageContent": {
9088+
"oneOf": [
9089+
{
9090+
"$ref": "#/components/schemas/OpenAIResponseOutputMessageContentOutputText"
9091+
},
9092+
{
9093+
"$ref": "#/components/schemas/OpenAIResponseContentPartRefusal"
9094+
}
9095+
],
9096+
"discriminator": {
9097+
"propertyName": "type",
9098+
"mapping": {
9099+
"output_text": "#/components/schemas/OpenAIResponseOutputMessageContentOutputText",
9100+
"refusal": "#/components/schemas/OpenAIResponseContentPartRefusal"
9101+
}
9102+
}
9103+
},
9104+
"OpenAIResponseOutputMessageContentOutputText": {
90669105
"type": "object",
90679106
"properties": {
90689107
"text": {
@@ -9567,20 +9606,20 @@
95679606
"title": "OpenAIResponseUsage",
95689607
"description": "Usage information for OpenAI response."
95699608
},
9570-
"ResponseShieldSpec": {
9609+
"ResponseGuardrailSpec": {
95719610
"type": "object",
95729611
"properties": {
95739612
"type": {
95749613
"type": "string",
9575-
"description": "The type/identifier of the shield."
9614+
"description": "The type/identifier of the guardrail."
95769615
}
95779616
},
95789617
"additionalProperties": false,
95799618
"required": [
95809619
"type"
95819620
],
9582-
"title": "ResponseShieldSpec",
9583-
"description": "Specification for a shield to apply during response generation."
9621+
"title": "ResponseGuardrailSpec",
9622+
"description": "Specification for a guardrail to apply during response generation."
95849623
},
95859624
"OpenAIResponseInputTool": {
95869625
"oneOf": [
@@ -9981,28 +10020,6 @@
998110020
"title": "OpenAIResponseContentPartReasoningText",
998210021
"description": "Reasoning text emitted as part of a streamed response."
998310022
},
9984-
"OpenAIResponseContentPartRefusal": {
9985-
"type": "object",
9986-
"properties": {
9987-
"type": {
9988-
"type": "string",
9989-
"const": "refusal",
9990-
"default": "refusal",
9991-
"description": "Content part type identifier, always \"refusal\""
9992-
},
9993-
"refusal": {
9994-
"type": "string",
9995-
"description": "Refusal text supplied by the model"
9996-
}
9997-
},
9998-
"additionalProperties": false,
9999-
"required": [
10000-
"type",
10001-
"refusal"
10002-
],
10003-
"title": "OpenAIResponseContentPartRefusal",
10004-
"description": "Refusal content within a streamed response part."
10005-
},
1000610023
"OpenAIResponseObjectStream": {
1000710024
"oneOf": [
1000810025
{

docs/static/deprecated-llama-stack-spec.yaml

Lines changed: 36 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1569,16 +1569,16 @@ paths:
15691569
required: true
15701570
deprecated: true
15711571
x-llama-stack-extra-body-params:
1572-
- name: shields
1572+
- name: guardrails
15731573
schema:
15741574
type: array
15751575
items:
15761576
oneOf:
15771577
- type: string
1578-
- $ref: '#/components/schemas/ResponseShieldSpec'
1578+
- $ref: '#/components/schemas/ResponseGuardrailSpec'
15791579
description: >-
1580-
List of shields to apply during response generation. Shields provide safety
1581-
and content moderation.
1580+
List of guardrails to apply during response generation. Guardrails provide
1581+
safety and content moderation.
15821582
required: false
15831583
/v1/openai/v1/responses/{response_id}:
15841584
get:
@@ -6332,6 +6332,25 @@ components:
63326332
url_citation: '#/components/schemas/OpenAIResponseAnnotationCitation'
63336333
container_file_citation: '#/components/schemas/OpenAIResponseAnnotationContainerFileCitation'
63346334
file_path: '#/components/schemas/OpenAIResponseAnnotationFilePath'
6335+
OpenAIResponseContentPartRefusal:
6336+
type: object
6337+
properties:
6338+
type:
6339+
type: string
6340+
const: refusal
6341+
default: refusal
6342+
description: >-
6343+
Content part type identifier, always "refusal"
6344+
refusal:
6345+
type: string
6346+
description: Refusal text supplied by the model
6347+
additionalProperties: false
6348+
required:
6349+
- type
6350+
- refusal
6351+
title: OpenAIResponseContentPartRefusal
6352+
description: >-
6353+
Refusal content within a streamed response part.
63356354
OpenAIResponseError:
63366355
type: object
63376356
properties:
@@ -6755,6 +6774,15 @@ components:
67556774
mcp_list_tools: '#/components/schemas/OpenAIResponseOutputMessageMCPListTools'
67566775
mcp_approval_request: '#/components/schemas/OpenAIResponseMCPApprovalRequest'
67576776
OpenAIResponseOutputMessageContent:
6777+
oneOf:
6778+
- $ref: '#/components/schemas/OpenAIResponseOutputMessageContentOutputText'
6779+
- $ref: '#/components/schemas/OpenAIResponseContentPartRefusal'
6780+
discriminator:
6781+
propertyName: type
6782+
mapping:
6783+
output_text: '#/components/schemas/OpenAIResponseOutputMessageContentOutputText'
6784+
refusal: '#/components/schemas/OpenAIResponseContentPartRefusal'
6785+
"OpenAIResponseOutputMessageContentOutputText":
67586786
type: object
67596787
properties:
67606788
text:
@@ -7149,18 +7177,18 @@ components:
71497177
- total_tokens
71507178
title: OpenAIResponseUsage
71517179
description: Usage information for OpenAI response.
7152-
ResponseShieldSpec:
7180+
ResponseGuardrailSpec:
71537181
type: object
71547182
properties:
71557183
type:
71567184
type: string
7157-
description: The type/identifier of the shield.
7185+
description: The type/identifier of the guardrail.
71587186
additionalProperties: false
71597187
required:
71607188
- type
7161-
title: ResponseShieldSpec
7189+
title: ResponseGuardrailSpec
71627190
description: >-
7163-
Specification for a shield to apply during response generation.
7191+
Specification for a guardrail to apply during response generation.
71647192
OpenAIResponseInputTool:
71657193
oneOf:
71667194
- $ref: '#/components/schemas/OpenAIResponseInputToolWebSearch'
@@ -7466,25 +7494,6 @@ components:
74667494
title: OpenAIResponseContentPartReasoningText
74677495
description: >-
74687496
Reasoning text emitted as part of a streamed response.
7469-
OpenAIResponseContentPartRefusal:
7470-
type: object
7471-
properties:
7472-
type:
7473-
type: string
7474-
const: refusal
7475-
default: refusal
7476-
description: >-
7477-
Content part type identifier, always "refusal"
7478-
refusal:
7479-
type: string
7480-
description: Refusal text supplied by the model
7481-
additionalProperties: false
7482-
required:
7483-
- type
7484-
- refusal
7485-
title: OpenAIResponseContentPartRefusal
7486-
description: >-
7487-
Refusal content within a streamed response part.
74887497
OpenAIResponseObjectStream:
74897498
oneOf:
74907499
- $ref: '#/components/schemas/OpenAIResponseObjectStreamResponseCreated'

docs/static/llama-stack-spec.html

Lines changed: 46 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1833,7 +1833,7 @@
18331833
"deprecated": false,
18341834
"x-llama-stack-extra-body-params": [
18351835
{
1836-
"name": "shields",
1836+
"name": "guardrails",
18371837
"schema": {
18381838
"type": "array",
18391839
"items": {
@@ -1842,12 +1842,12 @@
18421842
"type": "string"
18431843
},
18441844
{
1845-
"$ref": "#/components/schemas/ResponseShieldSpec"
1845+
"$ref": "#/components/schemas/ResponseGuardrailSpec"
18461846
}
18471847
]
18481848
}
18491849
},
1850-
"description": "List of shields to apply during response generation. Shields provide safety and content moderation.",
1850+
"description": "List of guardrails to apply during response generation. Guardrails provide safety and content moderation.",
18511851
"required": false
18521852
}
18531853
]
@@ -5670,6 +5670,28 @@
56705670
}
56715671
}
56725672
},
5673+
"OpenAIResponseContentPartRefusal": {
5674+
"type": "object",
5675+
"properties": {
5676+
"type": {
5677+
"type": "string",
5678+
"const": "refusal",
5679+
"default": "refusal",
5680+
"description": "Content part type identifier, always \"refusal\""
5681+
},
5682+
"refusal": {
5683+
"type": "string",
5684+
"description": "Refusal text supplied by the model"
5685+
}
5686+
},
5687+
"additionalProperties": false,
5688+
"required": [
5689+
"type",
5690+
"refusal"
5691+
],
5692+
"title": "OpenAIResponseContentPartRefusal",
5693+
"description": "Refusal content within a streamed response part."
5694+
},
56735695
"OpenAIResponseInputFunctionToolCallOutput": {
56745696
"type": "object",
56755697
"properties": {
@@ -5905,6 +5927,23 @@
59055927
"description": "Corresponds to the various Message types in the Responses API. They are all under one type because the Responses API gives them all the same \"type\" value, and there is no way to tell them apart in certain scenarios."
59065928
},
59075929
"OpenAIResponseOutputMessageContent": {
5930+
"oneOf": [
5931+
{
5932+
"$ref": "#/components/schemas/OpenAIResponseOutputMessageContentOutputText"
5933+
},
5934+
{
5935+
"$ref": "#/components/schemas/OpenAIResponseContentPartRefusal"
5936+
}
5937+
],
5938+
"discriminator": {
5939+
"propertyName": "type",
5940+
"mapping": {
5941+
"output_text": "#/components/schemas/OpenAIResponseOutputMessageContentOutputText",
5942+
"refusal": "#/components/schemas/OpenAIResponseContentPartRefusal"
5943+
}
5944+
}
5945+
},
5946+
"OpenAIResponseOutputMessageContentOutputText": {
59085947
"type": "object",
59095948
"properties": {
59105949
"text": {
@@ -7814,20 +7853,20 @@
78147853
"title": "OpenAIResponseUsage",
78157854
"description": "Usage information for OpenAI response."
78167855
},
7817-
"ResponseShieldSpec": {
7856+
"ResponseGuardrailSpec": {
78187857
"type": "object",
78197858
"properties": {
78207859
"type": {
78217860
"type": "string",
7822-
"description": "The type/identifier of the shield."
7861+
"description": "The type/identifier of the guardrail."
78237862
}
78247863
},
78257864
"additionalProperties": false,
78267865
"required": [
78277866
"type"
78287867
],
7829-
"title": "ResponseShieldSpec",
7830-
"description": "Specification for a shield to apply during response generation."
7868+
"title": "ResponseGuardrailSpec",
7869+
"description": "Specification for a guardrail to apply during response generation."
78317870
},
78327871
"OpenAIResponseInputTool": {
78337872
"oneOf": [
@@ -8228,28 +8267,6 @@
82288267
"title": "OpenAIResponseContentPartReasoningText",
82298268
"description": "Reasoning text emitted as part of a streamed response."
82308269
},
8231-
"OpenAIResponseContentPartRefusal": {
8232-
"type": "object",
8233-
"properties": {
8234-
"type": {
8235-
"type": "string",
8236-
"const": "refusal",
8237-
"default": "refusal",
8238-
"description": "Content part type identifier, always \"refusal\""
8239-
},
8240-
"refusal": {
8241-
"type": "string",
8242-
"description": "Refusal text supplied by the model"
8243-
}
8244-
},
8245-
"additionalProperties": false,
8246-
"required": [
8247-
"type",
8248-
"refusal"
8249-
],
8250-
"title": "OpenAIResponseContentPartRefusal",
8251-
"description": "Refusal content within a streamed response part."
8252-
},
82538270
"OpenAIResponseObjectStream": {
82548271
"oneOf": [
82558272
{

0 commit comments

Comments
 (0)