Elffuss BraidHub

kikocis/llama-stack public

add safety to openapi spec (#62)

Changeset32ac8e99b31df7a5f477fa884ef0a333675798953f3e41f54ac4976345cb9d14
AuthorXi Yan <xiyan@meta.com> · 2024-09-10 17:47 -07:00
CommitterGitHub <noreply@github.com> · 2024-09-10 17:47 -07:00
Parents5ec25afa3bd5

Browse the files at this changeset

3 files changed

modified llama_toolchain/stack.py +2 −0
@@ -15,6 +15,7 @@
1515 from llama_toolchain.post_training.api import * # noqa: F403
1616 from llama_toolchain.reward_scoring.api import * # noqa: F403
1717 from llama_toolchain.synthetic_data_generation.api import * # noqa: F403
18+from llama_toolchain.safety.api import * # noqa: F403
1819
1920
2021 class LlamaStack(
@@ -22,6 +23,7 @@
2223 BatchInference,
2324 AgenticSystem,
2425 RewardScoring,
26+ Safety,
2527 SyntheticDataGeneration,
2628 Datasets,
2729 Telemetry,
modified rfcs/RFC-0001-llama-stack-assets/llama-stack-spec.html +0 −0

Not shown: the file is larger than the hub shows, or this page holds as much as it shows. View the file.

modified rfcs/RFC-0001-llama-stack-assets/llama-stack-spec.yaml +129 −36
@@ -25,7 +25,7 @@
2525 tools:
2626 items:
2727 oneOf:
28- - $ref: '#/components/schemas/BraveSearchToolDefinition'
28+ - $ref: '#/components/schemas/SearchToolDefinition'
2929 - $ref: '#/components/schemas/WolframAlphaToolDefinition'
3030 - $ref: '#/components/schemas/PhotogenToolDefinition'
3131 - $ref: '#/components/schemas/CodeInterpreterToolDefinition'
@@ -218,7 +218,7 @@
218218 tools:
219219 items:
220220 oneOf:
221- - $ref: '#/components/schemas/BraveSearchToolDefinition'
221+ - $ref: '#/components/schemas/SearchToolDefinition'
222222 - $ref: '#/components/schemas/WolframAlphaToolDefinition'
223223 - $ref: '#/components/schemas/PhotogenToolDefinition'
224224 - $ref: '#/components/schemas/CodeInterpreterToolDefinition'
@@ -635,25 +635,6 @@
635635 required:
636636 - completion_message_batch
637637 type: object
638- BraveSearchToolDefinition:
639- additionalProperties: false
640- properties:
641- input_shields:
642- items:
643- $ref: '#/components/schemas/ShieldDefinition'
644- type: array
645- output_shields:
646- items:
647- $ref: '#/components/schemas/ShieldDefinition'
648- type: array
649- remote_execution:
650- $ref: '#/components/schemas/RestAPIExecutionConfig'
651- type:
652- const: brave_search
653- type: string
654- required:
655- - type
656- type: object
657638 BuiltinShield:
658639 enum:
659640 - llama_guard
@@ -2011,17 +1992,35 @@
20111992 properties:
20121993 body:
20131994 additionalProperties:
2014- type: string
1995+ oneOf:
1996+ - type: 'null'
1997+ - type: boolean
1998+ - type: number
1999+ - type: string
2000+ - type: array
2001+ - type: object
20152002 type: object
20162003 headers:
20172004 additionalProperties:
2018- type: string
2005+ oneOf:
2006+ - type: 'null'
2007+ - type: boolean
2008+ - type: number
2009+ - type: string
2010+ - type: array
2011+ - type: object
20192012 type: object
20202013 method:
20212014 $ref: '#/components/schemas/RestAPIMethod'
20222015 params:
20232016 additionalProperties:
2024- type: string
2017+ oneOf:
2018+ - type: 'null'
2019+ - type: boolean
2020+ - type: number
2021+ - type: string
2022+ - type: array
2023+ - type: object
20252024 type: object
20262025 url:
20272026 $ref: '#/components/schemas/URL'
@@ -2103,6 +2102,43 @@
21032102 - started_at
21042103 - metadata
21052104 type: object
2105+ RunShieldRequest:
2106+ additionalProperties: false
2107+ properties:
2108+ messages:
2109+ items:
2110+ oneOf:
2111+ - $ref: '#/components/schemas/UserMessage'
2112+ - $ref: '#/components/schemas/SystemMessage'
2113+ - $ref: '#/components/schemas/ToolResponseMessage'
2114+ - $ref: '#/components/schemas/CompletionMessage'
2115+ type: array
2116+ shields:
2117+ items:
2118+ $ref: '#/components/schemas/ShieldDefinition'
2119+ type: array
2120+ required:
2121+ - messages
2122+ - shields
2123+ type: object
2124+ RunShieldRequestWrapper:
2125+ additionalProperties: false
2126+ properties:
2127+ request:
2128+ $ref: '#/components/schemas/RunShieldRequest'
2129+ required:
2130+ - request
2131+ type: object
2132+ RunShieldResponse:
2133+ additionalProperties: false
2134+ properties:
2135+ responses:
2136+ items:
2137+ $ref: '#/components/schemas/ShieldResponse'
2138+ type: array
2139+ required:
2140+ - responses
2141+ type: object
21062142 SamplingParams:
21072143 additionalProperties: false
21082144 properties:
@@ -2161,6 +2197,31 @@
21612197 - message
21622198 - score
21632199 type: object
2200+ SearchToolDefinition:
2201+ additionalProperties: false
2202+ properties:
2203+ engine:
2204+ enum:
2205+ - bing
2206+ - brave
2207+ type: string
2208+ input_shields:
2209+ items:
2210+ $ref: '#/components/schemas/ShieldDefinition'
2211+ type: array
2212+ output_shields:
2213+ items:
2214+ $ref: '#/components/schemas/ShieldDefinition'
2215+ type: array
2216+ remote_execution:
2217+ $ref: '#/components/schemas/RestAPIExecutionConfig'
2218+ type:
2219+ const: brave_search
2220+ type: string
2221+ required:
2222+ - type
2223+ - engine
2224+ type: object
21642225 Session:
21652226 additionalProperties: false
21662227 properties:
@@ -2777,7 +2838,7 @@
27772838 description: "This is the specification of the llama stack that provides\n \
27782839 \ a set of endpoints and their corresponding interfaces that are tailored\
27792840 \ to\n best leverage Llama Models. The specification is still in\
2780- \ draft and subject to change.\n Generated at 2024-09-10 01:13:08.531639"
2841+ \ draft and subject to change.\n Generated at 2024-09-10 16:42:15.870336"
27812842 title: '[DRAFT] Llama Stack Specification'
27822843 version: 0.0.1
27832844 jsonSchemaDialect: https://json-schema.org/draft/2020-12/schema
@@ -3706,6 +3767,24 @@
37063767 description: OK
37073768 tags:
37083769 - Telemetry
3770+ /safety/run_shields:
3771+ post:
3772+ parameters: []
3773+ requestBody:
3774+ content:
3775+ application/json:
3776+ schema:
3777+ $ref: '#/components/schemas/RunShieldRequestWrapper'
3778+ required: true
3779+ responses:
3780+ '200':
3781+ content:
3782+ application/json:
3783+ schema:
3784+ $ref: '#/components/schemas/RunShieldResponse'
3785+ description: OK
3786+ tags:
3787+ - Safety
37093788 /synthetic_data_generation/generate:
37103789 post:
37113790 parameters: []
@@ -3729,16 +3808,17 @@
37293808 servers:
37303809 - url: http://any-hosted-llama-stack.com
37313810 tags:
3732-- name: SyntheticDataGeneration
3733-- name: RewardScoring
3734-- name: Datasets
3735-- name: Memory
3736-- name: AgenticSystem
37373811 - name: BatchInference
3738-- name: PostTraining
3739-- name: Evaluations
3812+- name: Safety
37403813 - name: Telemetry
3814+- name: RewardScoring
3815+- name: Memory
3816+- name: SyntheticDataGeneration
37413817 - name: Inference
3818+- name: Evaluations
3819+- name: PostTraining
3820+- name: Datasets
3821+- name: AgenticSystem
37423822 - description: <SchemaDefinition schemaRef="#/components/schemas/BatchChatCompletionRequest"
37433823 />
37443824 name: BatchChatCompletionRequest
@@ -3844,9 +3924,6 @@
38443924 name: CompletionResponseStreamChunk
38453925 - description: <SchemaDefinition schemaRef="#/components/schemas/AgentConfig" />
38463926 name: AgentConfig
3847-- description: <SchemaDefinition schemaRef="#/components/schemas/BraveSearchToolDefinition"
3848- />
3849- name: BraveSearchToolDefinition
38503927 - description: <SchemaDefinition schemaRef="#/components/schemas/BuiltinShield" />
38513928 name: BuiltinShield
38523929 - description: <SchemaDefinition schemaRef="#/components/schemas/CodeInterpreterToolDefinition"
@@ -3866,6 +3943,9 @@
38663943 name: RestAPIExecutionConfig
38673944 - description: <SchemaDefinition schemaRef="#/components/schemas/RestAPIMethod" />
38683945 name: RestAPIMethod
3946+- description: <SchemaDefinition schemaRef="#/components/schemas/SearchToolDefinition"
3947+ />
3948+ name: SearchToolDefinition
38693949 - description: <SchemaDefinition schemaRef="#/components/schemas/ShieldDefinition"
38703950 />
38713951 name: ShieldDefinition
@@ -4163,6 +4243,15 @@
41634243 name: ScoredDialogGenerations
41644244 - description: <SchemaDefinition schemaRef="#/components/schemas/ScoredMessage" />
41654245 name: ScoredMessage
4246+- description: <SchemaDefinition schemaRef="#/components/schemas/RunShieldRequest"
4247+ />
4248+ name: RunShieldRequest
4249+- description: <SchemaDefinition schemaRef="#/components/schemas/RunShieldRequestWrapper"
4250+ />
4251+ name: RunShieldRequestWrapper
4252+- description: <SchemaDefinition schemaRef="#/components/schemas/RunShieldResponse"
4253+ />
4254+ name: RunShieldResponse
41664255 - description: <SchemaDefinition schemaRef="#/components/schemas/DoraFinetuningConfig"
41674256 />
41684257 name: DoraFinetuningConfig
@@ -4232,6 +4321,7 @@
42324321 - Memory
42334322 - PostTraining
42344323 - RewardScoring
4324+ - Safety
42354325 - SyntheticDataGeneration
42364326 - Telemetry
42374327 - name: Types
@@ -4258,7 +4348,6 @@
42584348 - BatchCompletionRequest
42594349 - BatchCompletionRequestWrapper
42604350 - BatchCompletionResponse
4261- - BraveSearchToolDefinition
42624351 - BuiltinShield
42634352 - BuiltinTool
42644353 - CancelEvaluationJobRequest
@@ -4346,10 +4435,14 @@
43464435 - RewardScoringRequestWrapper
43474436 - RewardScoringResponse
43484437 - Run
4438+ - RunShieldRequest
4439+ - RunShieldRequestWrapper
4440+ - RunShieldResponse
43494441 - SamplingParams
43504442 - SamplingStrategy
43514443 - ScoredDialogGenerations
43524444 - ScoredMessage
4445+ - SearchToolDefinition
43534446 - Session
43544447 - ShieldCallStep
43554448 - ShieldDefinition