From bfee50aa8380eb2fa31a1c6658542ff8a92467fb Mon Sep 17 00:00:00 2001 From: Ashwin Bharambe Date: Wed, 4 Sep 2024 10:29:20 -0700 Subject: [PATCH] A few more fixes to the OpenAPI generator --- .../llama-stack-spec.html | 229 ++++++++++++++---- .../llama-stack-spec.yaml | 152 ++++++++++-- rfcs/openapi_generator/pyopenapi/generator.py | 7 +- 3 files changed, 319 insertions(+), 69 deletions(-) diff --git a/rfcs/RFC-0001-llama-stack-assets/llama-stack-spec.html b/rfcs/RFC-0001-llama-stack-assets/llama-stack-spec.html index 722855f83..d417f02f3 100644 --- a/rfcs/RFC-0001-llama-stack-assets/llama-stack-spec.html +++ b/rfcs/RFC-0001-llama-stack-assets/llama-stack-spec.html @@ -21,7 +21,7 @@ "info": { "title": "[DRAFT] Llama Stack Specification", "version": "0.0.1", - "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. The specification is still in draft and subject to change.\n Generated at 2024-09-04 09:26:21.634687" + "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. The specification is still in draft and subject to change.\n Generated at 2024-09-04 10:28:38.779789" }, "servers": [ { @@ -104,7 +104,7 @@ "content": { "application/json": { "schema": { - "type": "string" + "$ref": "#/components/schemas/CancelEvaluationJobRequest" } } }, @@ -127,7 +127,7 @@ "content": { "application/json": { "schema": { - "type": "string" + "$ref": "#/components/schemas/CancelTrainingJobRequest" } } }, @@ -217,7 +217,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/AgentConfig" + "$ref": "#/components/schemas/CreateAgenticSystemRequest" } } }, @@ -413,7 +413,7 @@ "content": { "application/json": { "schema": { - "type": "string" + "$ref": "#/components/schemas/DeleteAgenticSystemRequest" } } }, @@ -459,7 +459,7 @@ "content": { "application/json": { "schema": { - "type": "string" + "$ref": "#/components/schemas/DeleteDatasetRequest" } } }, @@ -512,7 +512,7 @@ "content": { "application/json": { "schema": { - "type": "string" + "$ref": "#/components/schemas/DropMemoryBankRequest" } } }, @@ -679,17 +679,7 @@ "content": { "application/json": { "schema": { - "oneOf": [ - { - "type": "array", - "items": { - "type": "string" - } - }, - { - "type": "null" - } - ] + "$ref": "#/components/schemas/GetAgenticSystemSessionRequest" } } }, @@ -868,10 +858,7 @@ "content": { "application/json": { "schema": { - "type": "array", - "items": { - "type": "string" - } + "$ref": "#/components/schemas/GetDocumentsRequest" } } }, @@ -1262,7 +1249,7 @@ "content": { "application/json": { "schema": { - "type": "string" + "$ref": "#/components/schemas/ListArtifactsRequest" } } }, @@ -2104,6 +2091,30 @@ "completion_message_batch" ] }, + "CancelEvaluationJobRequest": { + "type": "object", + "properties": { + "job_uuid": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "job_uuid" + ] + }, + "CancelTrainingJobRequest": { + "type": "object", + "properties": { + "job_uuid": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "job_uuid" + ] + }, "ChatCompletionRequest": { "type": "object", "properties": { @@ -2772,6 +2783,18 @@ "type" ] }, + "CreateAgenticSystemRequest": { + "type": "object", + "properties": { + "agent_config": { + "$ref": "#/components/schemas/AgentConfig" + } + }, + "additionalProperties": false, + "required": [ + "agent_config" + ] + }, "AgenticSystemCreateResponse": { "type": "object", "properties": { @@ -3864,6 +3887,18 @@ "metadata" ] }, + "DeleteAgenticSystemRequest": { + "type": "object", + "properties": { + "agent_id": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "agent_id" + ] + }, "DeleteAgenticSystemSessionRequest": { "type": "object", "properties": { @@ -3880,6 +3915,18 @@ "session_id" ] }, + "DeleteDatasetRequest": { + "type": "object", + "properties": { + "dataset_uuid": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "dataset_uuid" + ] + }, "DeleteDocumentsRequest": { "type": "object", "properties": { @@ -3899,6 +3946,18 @@ "document_ids" ] }, + "DropMemoryBankRequest": { + "type": "object", + "properties": { + "bank_id": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "bank_id" + ] + }, "EmbeddingsRequest": { "type": "object", "properties": { @@ -4070,6 +4129,18 @@ ], "title": "Request to evaluate text generation." }, + "GetAgenticSystemSessionRequest": { + "type": "object", + "properties": { + "turn_ids": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "additionalProperties": false + }, "Session": { "type": "object", "properties": { @@ -4195,6 +4266,21 @@ "other" ] }, + "GetDocumentsRequest": { + "type": "object", + "properties": { + "document_ids": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "additionalProperties": false, + "required": [ + "document_ids" + ] + }, "MemoryBankDocument": { "type": "object", "properties": { @@ -4557,6 +4643,18 @@ "documents" ] }, + "ListArtifactsRequest": { + "type": "object", + "properties": { + "experiment_id": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "experiment_id" + ] + }, "LogMessagesRequest": { "type": "object", "properties": { @@ -5487,31 +5585,31 @@ "name": "Observability" }, { - "name": "Evaluations" - }, - { - "name": "Memory" - }, - { - "name": "BatchInference" - }, - { - "name": "RewardScoring" - }, - { - "name": "SyntheticDataGeneration" - }, - { - "name": "PostTraining" - }, - { - "name": "AgenticSystem" + "name": "Inference" }, { "name": "Datasets" }, { - "name": "Inference" + "name": "Memory" + }, + { + "name": "AgenticSystem" + }, + { + "name": "Evaluations" + }, + { + "name": "SyntheticDataGeneration" + }, + { + "name": "RewardScoring" + }, + { + "name": "PostTraining" + }, + { + "name": "BatchInference" }, { "name": "BatchChatCompletionRequest", @@ -5581,6 +5679,14 @@ "name": "BatchCompletionResponse", "description": "" }, + { + "name": "CancelEvaluationJobRequest", + "description": "" + }, + { + "name": "CancelTrainingJobRequest", + "description": "" + }, { "name": "ChatCompletionRequest", "description": "" @@ -5669,6 +5775,10 @@ "name": "WolframAlphaToolDefinition", "description": "" }, + { + "name": "CreateAgenticSystemRequest", + "description": "" + }, { "name": "AgenticSystemCreateResponse", "description": "" @@ -5785,14 +5895,26 @@ "name": "Run", "description": "" }, + { + "name": "DeleteAgenticSystemRequest", + "description": "" + }, { "name": "DeleteAgenticSystemSessionRequest", "description": "" }, + { + "name": "DeleteDatasetRequest", + "description": "" + }, { "name": "DeleteDocumentsRequest", "description": "" }, + { + "name": "DropMemoryBankRequest", + "description": "" + }, { "name": "EmbeddingsRequest", "description": "" @@ -5821,6 +5943,10 @@ "name": "EvaluateTextGenerationRequest", "description": "Request to evaluate text generation.\n\n" }, + { + "name": "GetAgenticSystemSessionRequest", + "description": "" + }, { "name": "Session", "description": "A single session of an interaction with an Agentic System.\n\n" @@ -5837,6 +5963,10 @@ "name": "ArtifactType", "description": "" }, + { + "name": "GetDocumentsRequest", + "description": "" + }, { "name": "MemoryBankDocument", "description": "" @@ -5889,6 +6019,10 @@ "name": "InsertDocumentsRequest", "description": "" }, + { + "name": "ListArtifactsRequest", + "description": "" + }, { "name": "LogMessagesRequest", "description": "" @@ -6031,6 +6165,8 @@ "BraveSearchToolDefinition", "BuiltinShield", "BuiltinTool", + "CancelEvaluationJobRequest", + "CancelTrainingJobRequest", "ChatCompletionRequest", "ChatCompletionResponseEvent", "ChatCompletionResponseEventType", @@ -6040,16 +6176,20 @@ "CompletionMessage", "CompletionRequest", "CompletionResponseStreamChunk", + "CreateAgenticSystemRequest", "CreateAgenticSystemSessionRequest", "CreateDatasetRequest", "CreateExperimentRequest", "CreateMemoryBankRequest", "CreateRunRequest", "DPOAlignmentConfig", + "DeleteAgenticSystemRequest", "DeleteAgenticSystemSessionRequest", + "DeleteDatasetRequest", "DeleteDocumentsRequest", "DialogGenerations", "DoraFinetuningConfig", + "DropMemoryBankRequest", "EmbeddingsRequest", "EmbeddingsResponse", "EvaluateQuestionAnsweringRequest", @@ -6063,8 +6203,11 @@ "ExperimentStatus", "FinetuningAlgorithm", "FunctionCallToolDefinition", + "GetAgenticSystemSessionRequest", + "GetDocumentsRequest", "InferenceStep", "InsertDocumentsRequest", + "ListArtifactsRequest", "Log", "LogMessagesRequest", "LogMetricsRequest", diff --git a/rfcs/RFC-0001-llama-stack-assets/llama-stack-spec.yaml b/rfcs/RFC-0001-llama-stack-assets/llama-stack-spec.yaml index 64c70ad2e..7560f3c88 100644 --- a/rfcs/RFC-0001-llama-stack-assets/llama-stack-spec.yaml +++ b/rfcs/RFC-0001-llama-stack-assets/llama-stack-spec.yaml @@ -413,6 +413,22 @@ components: - photogen - code_interpreter type: string + CancelEvaluationJobRequest: + additionalProperties: false + properties: + job_uuid: + type: string + required: + - job_uuid + type: object + CancelTrainingJobRequest: + additionalProperties: false + properties: + job_uuid: + type: string + required: + - job_uuid + type: object ChatCompletionRequest: additionalProperties: false properties: @@ -571,6 +587,14 @@ components: - delta title: streamed completion response. type: object + CreateAgenticSystemRequest: + additionalProperties: false + properties: + agent_config: + $ref: '#/components/schemas/AgentConfig' + required: + - agent_config + type: object CreateAgenticSystemSessionRequest: additionalProperties: false properties: @@ -700,6 +724,14 @@ components: - epsilon - gamma type: object + DeleteAgenticSystemRequest: + additionalProperties: false + properties: + agent_id: + type: string + required: + - agent_id + type: object DeleteAgenticSystemSessionRequest: additionalProperties: false properties: @@ -711,6 +743,14 @@ components: - agent_id - session_id type: object + DeleteDatasetRequest: + additionalProperties: false + properties: + dataset_uuid: + type: string + required: + - dataset_uuid + type: object DeleteDocumentsRequest: additionalProperties: false properties: @@ -769,6 +809,14 @@ components: - rank - alpha type: object + DropMemoryBankRequest: + additionalProperties: false + properties: + bank_id: + type: string + required: + - bank_id + type: object EmbeddingsRequest: additionalProperties: false properties: @@ -987,6 +1035,24 @@ components: - description - parameters type: object + GetAgenticSystemSessionRequest: + additionalProperties: false + properties: + turn_ids: + items: + type: string + type: array + type: object + GetDocumentsRequest: + additionalProperties: false + properties: + document_ids: + items: + type: string + type: array + required: + - document_ids + type: object InferenceStep: additionalProperties: false properties: @@ -1026,6 +1092,14 @@ components: - bank_id - documents type: object + ListArtifactsRequest: + additionalProperties: false + properties: + experiment_id: + type: string + required: + - experiment_id + type: object Log: additionalProperties: false properties: @@ -2385,7 +2459,7 @@ 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. The specification is still in\ - \ draft and subject to change.\n Generated at 2024-09-04 09:26:21.634687" + \ draft and subject to change.\n Generated at 2024-09-04 10:28:38.779789" title: '[DRAFT] Llama Stack Specification' version: 0.0.1 jsonSchemaDialect: https://json-schema.org/draft/2020-12/schema @@ -2398,7 +2472,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/AgentConfig' + $ref: '#/components/schemas/CreateAgenticSystemRequest' required: true responses: '200': @@ -2416,7 +2490,7 @@ paths: content: application/json: schema: - type: string + $ref: '#/components/schemas/DeleteAgenticSystemRequest' required: true responses: '200': @@ -2472,11 +2546,7 @@ paths: content: application/json: schema: - oneOf: - - items: - type: string - type: array - - type: 'null' + $ref: '#/components/schemas/GetAgenticSystemSessionRequest' required: true responses: '200': @@ -2628,7 +2698,7 @@ paths: content: application/json: schema: - type: string + $ref: '#/components/schemas/DeleteDatasetRequest' required: true responses: '200': @@ -2676,7 +2746,7 @@ paths: content: application/json: schema: - type: string + $ref: '#/components/schemas/CancelEvaluationJobRequest' required: true responses: '200': @@ -2790,7 +2860,7 @@ paths: content: application/json: schema: - type: string + $ref: '#/components/schemas/ListArtifactsRequest' required: true responses: '200': @@ -3014,9 +3084,7 @@ paths: content: application/json: schema: - items: - type: string - type: array + $ref: '#/components/schemas/GetDocumentsRequest' required: true responses: '200': @@ -3098,7 +3166,7 @@ paths: content: application/json: schema: - type: string + $ref: '#/components/schemas/DropMemoryBankRequest' required: true responses: '200': @@ -3164,7 +3232,7 @@ paths: content: application/json: schema: - type: string + $ref: '#/components/schemas/CancelTrainingJobRequest' required: true responses: '200': @@ -3344,15 +3412,15 @@ servers: - url: http://any-hosted-llama-stack.com tags: - name: Observability -- name: Evaluations -- name: Memory -- name: BatchInference -- name: RewardScoring -- name: SyntheticDataGeneration -- name: PostTraining -- name: AgenticSystem -- name: Datasets - name: Inference +- name: Datasets +- name: Memory +- name: AgenticSystem +- name: Evaluations +- name: SyntheticDataGeneration +- name: RewardScoring +- name: PostTraining +- name: BatchInference - description: name: BatchChatCompletionRequest @@ -3404,6 +3472,12 @@ tags: - description: name: BatchCompletionResponse +- description: + name: CancelEvaluationJobRequest +- description: + name: CancelTrainingJobRequest - description: name: ChatCompletionRequest @@ -3473,6 +3547,9 @@ tags: - description: name: WolframAlphaToolDefinition +- description: + name: CreateAgenticSystemRequest - description: name: AgenticSystemCreateResponse @@ -3561,12 +3638,21 @@ tags: name: CreateRunRequest - description: name: Run +- description: + name: DeleteAgenticSystemRequest - description: name: DeleteAgenticSystemSessionRequest +- description: + name: DeleteDatasetRequest - description: name: DeleteDocumentsRequest +- description: + name: DropMemoryBankRequest - description: name: EmbeddingsRequest @@ -3598,6 +3684,9 @@ tags: ' name: EvaluateTextGenerationRequest +- description: + name: GetAgenticSystemSessionRequest - description: 'A single session of an interaction with an Agentic System. @@ -3610,6 +3699,9 @@ tags: name: Artifact - description: name: ArtifactType +- description: + name: GetDocumentsRequest - description: name: MemoryBankDocument @@ -3658,6 +3750,9 @@ tags: - description: name: InsertDocumentsRequest +- description: + name: ListArtifactsRequest - description: name: LogMessagesRequest @@ -3785,6 +3880,8 @@ x-tagGroups: - BraveSearchToolDefinition - BuiltinShield - BuiltinTool + - CancelEvaluationJobRequest + - CancelTrainingJobRequest - ChatCompletionRequest - ChatCompletionResponseEvent - ChatCompletionResponseEventType @@ -3794,16 +3891,20 @@ x-tagGroups: - CompletionMessage - CompletionRequest - CompletionResponseStreamChunk + - CreateAgenticSystemRequest - CreateAgenticSystemSessionRequest - CreateDatasetRequest - CreateExperimentRequest - CreateMemoryBankRequest - CreateRunRequest - DPOAlignmentConfig + - DeleteAgenticSystemRequest - DeleteAgenticSystemSessionRequest + - DeleteDatasetRequest - DeleteDocumentsRequest - DialogGenerations - DoraFinetuningConfig + - DropMemoryBankRequest - EmbeddingsRequest - EmbeddingsResponse - EvaluateQuestionAnsweringRequest @@ -3817,8 +3918,11 @@ x-tagGroups: - ExperimentStatus - FinetuningAlgorithm - FunctionCallToolDefinition + - GetAgenticSystemSessionRequest + - GetDocumentsRequest - InferenceStep - InsertDocumentsRequest + - ListArtifactsRequest - Log - LogMessagesRequest - LogMetricsRequest diff --git a/rfcs/openapi_generator/pyopenapi/generator.py b/rfcs/openapi_generator/pyopenapi/generator.py index 576746e11..e1450074b 100644 --- a/rfcs/openapi_generator/pyopenapi/generator.py +++ b/rfcs/openapi_generator/pyopenapi/generator.py @@ -466,8 +466,11 @@ class Generator: # data passed in payload if op.request_params: builder = ContentBuilder(self.schema_builder) - if len(op.request_params) == 1: - request_name, request_type = op.request_params[0] + first = next(iter(op.request_params)) + request_name, request_type = first + if len(op.request_params) == 1 and "Request" in first[1].__name__: + # TODO(ashwin): Undo the "Request" hack and this entire block eventually + request_name, request_type = first else: from dataclasses import make_dataclass