From 0f607c7a280988ff77014a24c163a3dfb1a5eaac Mon Sep 17 00:00:00 2001 From: Andrew Maguire Date: Sat, 14 Jan 2023 22:40:33 +0000 Subject: [PATCH] export and auto-commit `docs/docs/api/openapi.json` as part of `test-api-contract` workflow (#719) - copies that openapi.json file to docs/docs/api/openapi.json as part of start-mock-server.sh. - adds a step to the end of the test-api-contract workflow that just auto-commits changes to the docs/docs/api/openapi.json file. - excludes docs/docs/api/openapi.json from pre-commit since its already been formatted by jq. --- .github/workflows/test-api-contract.yaml | 7 + .pre-commit-config.yaml | 2 +- backend/README.md | 3 + docs/docs/api/openapi.json | 1993 ++++++++++++++--- .../T5_closed_book_QA_generators.md | 12 +- .../T5_closed_book_QA_generators.py | 1 - .../backend-development/start-mock-server.sh | 3 + 7 files changed, 1712 insertions(+), 309 deletions(-) diff --git a/.github/workflows/test-api-contract.yaml b/.github/workflows/test-api-contract.yaml index dac53306..30ceb518 100644 --- a/.github/workflows/test-api-contract.yaml +++ b/.github/workflows/test-api-contract.yaml @@ -4,6 +4,7 @@ on: push: branches: - main + - add-api-docs-workflow paths: - "oasst-shared/**" - "backend/**" @@ -44,3 +45,9 @@ jobs: run: ./scripts/frontend-development/run-contract-test.sh - run: ./scripts/backend-development/stop-mock-server.sh + + - uses: stefanzweifel/git-auto-commit-action@v4 + with: + file_pattern: "docs/docs/api/openapi.json" + commit_message: + update docs/docs/api/openapi.json by run ${{ github.run_id }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0bb81e89..b31d1e8f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -26,7 +26,7 @@ # # /WARNING! -exclude: build|stubs|^bot/templates/$|openassistant/templates +exclude: build|stubs|^bot/templates/$|openassistant/templates|docs/docs/api/openapi.json repos: - repo: https://github.com/pre-commit/pre-commit-hooks diff --git a/backend/README.md b/backend/README.md index 056e0823..6fe10fe1 100644 --- a/backend/README.md +++ b/backend/README.md @@ -59,3 +59,6 @@ without having to actually set up and run a development backend. # save openapi.json to docs/docs/api wget localhost:8080/api/v1/openapi.json -O docs/docs/api/openapi.json ``` + +Note: The api docs should be automatically updated by the +`test-api-contract.yaml` workflow. diff --git a/docs/docs/api/openapi.json b/docs/docs/api/openapi.json index c6a985b3..540cceae 100644 --- a/docs/docs/api/openapi.json +++ b/docs/docs/api/openapi.json @@ -1,17 +1,24 @@ { "openapi": "3.0.2", - "info": { "title": "open-assistant backend", "version": "0.1.0" }, + "info": { + "title": "open-assistant backend", + "version": "0.1.0" + }, "paths": { "/api/v1/tasks/": { "post": { - "tags": ["tasks"], + "tags": [ + "tasks" + ], "summary": "Request Task", "description": "Create new task.", "operationId": "request_task_api_v1_tasks__post", "requestBody": { "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/TaskRequest" } + "schema": { + "$ref": "#/components/schemas/TaskRequest" + } } }, "required": true @@ -24,25 +31,51 @@ "schema": { "title": "Response Request Task Api V1 Tasks Post", "anyOf": [ - { "$ref": "#/components/schemas/TaskDone" }, - { "$ref": "#/components/schemas/SummarizeStoryTask" }, - { "$ref": "#/components/schemas/RateSummaryTask" }, - { "$ref": "#/components/schemas/InitialPromptTask" }, - { "$ref": "#/components/schemas/ReplyToConversationTask" }, - { "$ref": "#/components/schemas/PrompterReplyTask" }, - { "$ref": "#/components/schemas/AssistantReplyTask" }, - { "$ref": "#/components/schemas/RankInitialPromptsTask" }, + { + "$ref": "#/components/schemas/TaskDone" + }, + { + "$ref": "#/components/schemas/SummarizeStoryTask" + }, + { + "$ref": "#/components/schemas/RateSummaryTask" + }, + { + "$ref": "#/components/schemas/InitialPromptTask" + }, + { + "$ref": "#/components/schemas/ReplyToConversationTask" + }, + { + "$ref": "#/components/schemas/PrompterReplyTask" + }, + { + "$ref": "#/components/schemas/AssistantReplyTask" + }, + { + "$ref": "#/components/schemas/RankInitialPromptsTask" + }, { "$ref": "#/components/schemas/RankConversationRepliesTask" }, - { "$ref": "#/components/schemas/RankPrompterRepliesTask" }, - { "$ref": "#/components/schemas/RankAssistantRepliesTask" }, - { "$ref": "#/components/schemas/LabelInitialPromptTask" }, + { + "$ref": "#/components/schemas/RankPrompterRepliesTask" + }, + { + "$ref": "#/components/schemas/RankAssistantRepliesTask" + }, + { + "$ref": "#/components/schemas/LabelInitialPromptTask" + }, { "$ref": "#/components/schemas/LabelConversationReplyTask" }, - { "$ref": "#/components/schemas/LabelPrompterReplyTask" }, - { "$ref": "#/components/schemas/LabelAssistantReplyTask" } + { + "$ref": "#/components/schemas/LabelPrompterReplyTask" + }, + { + "$ref": "#/components/schemas/LabelAssistantReplyTask" + } ] } } @@ -52,17 +85,28 @@ "description": "Validation Error", "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } } } } }, - "security": [{ "APIKeyQuery": [] }, { "APIKeyHeader": [] }] + "security": [ + { + "APIKeyQuery": [] + }, + { + "APIKeyHeader": [] + } + ] } }, "/api/v1/tasks/{task_id}/ack": { "post": { - "tags": ["tasks"], + "tags": [ + "tasks" + ], "summary": "Tasks Acknowledge", "description": "The frontend acknowledges a task.", "operationId": "tasks_acknowledge_api_v1_tasks__task_id__ack_post", @@ -81,28 +125,43 @@ "requestBody": { "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/TaskAck" } + "schema": { + "$ref": "#/components/schemas/TaskAck" + } } }, "required": true }, "responses": { - "204": { "description": "Successful Response" }, + "204": { + "description": "Successful Response" + }, "422": { "description": "Validation Error", "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } } } } }, - "security": [{ "APIKeyQuery": [] }, { "APIKeyHeader": [] }] + "security": [ + { + "APIKeyQuery": [] + }, + { + "APIKeyHeader": [] + } + ] } }, "/api/v1/tasks/{task_id}/nack": { "post": { - "tags": ["tasks"], + "tags": [ + "tasks" + ], "summary": "Tasks Acknowledge Failure", "description": "The frontend reports failure to implement a task.", "operationId": "tasks_acknowledge_failure_api_v1_tasks__task_id__nack_post", @@ -121,28 +180,43 @@ "requestBody": { "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/TaskNAck" } + "schema": { + "$ref": "#/components/schemas/TaskNAck" + } } }, "required": true }, "responses": { - "204": { "description": "Successful Response" }, + "204": { + "description": "Successful Response" + }, "422": { "description": "Validation Error", "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } } } } }, - "security": [{ "APIKeyQuery": [] }, { "APIKeyHeader": [] }] + "security": [ + { + "APIKeyQuery": [] + }, + { + "APIKeyHeader": [] + } + ] } }, "/api/v1/tasks/interaction": { "post": { - "tags": ["tasks"], + "tags": [ + "tasks" + ], "summary": "Tasks Interaction", "description": "The frontend reports an interaction.", "operationId": "tasks_interaction_api_v1_tasks_interaction_post", @@ -152,10 +226,18 @@ "schema": { "title": "Interaction", "anyOf": [ - { "$ref": "#/components/schemas/TextReplyToMessage" }, - { "$ref": "#/components/schemas/MessageRating" }, - { "$ref": "#/components/schemas/MessageRanking" }, - { "$ref": "#/components/schemas/TextLabels" } + { + "$ref": "#/components/schemas/TextReplyToMessage" + }, + { + "$ref": "#/components/schemas/MessageRating" + }, + { + "$ref": "#/components/schemas/MessageRanking" + }, + { + "$ref": "#/components/schemas/TextLabels" + } ] } } @@ -167,7 +249,9 @@ "description": "Successful Response", "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/TaskDone" } + "schema": { + "$ref": "#/components/schemas/TaskDone" + } } } }, @@ -175,23 +259,36 @@ "description": "Validation Error", "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } } } } }, - "security": [{ "APIKeyQuery": [] }, { "APIKeyHeader": [] }] + "security": [ + { + "APIKeyQuery": [] + }, + { + "APIKeyHeader": [] + } + ] } }, "/api/v1/tasks/close": { "post": { - "tags": ["tasks"], + "tags": [ + "tasks" + ], "summary": "Close Collective Task", "operationId": "close_collective_task_api_v1_tasks_close_post", "requestBody": { "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/TaskClose" } + "schema": { + "$ref": "#/components/schemas/TaskClose" + } } }, "required": true @@ -201,7 +298,9 @@ "description": "Successful Response", "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/TaskDone" } + "schema": { + "$ref": "#/components/schemas/TaskDone" + } } } }, @@ -209,71 +308,109 @@ "description": "Validation Error", "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } } } } }, - "security": [{ "APIKeyQuery": [] }, { "APIKeyHeader": [] }] + "security": [ + { + "APIKeyQuery": [] + }, + { + "APIKeyHeader": [] + } + ] } }, "/api/v1/text_labels/": { "post": { - "tags": ["text_labels"], + "tags": [ + "text_labels" + ], "summary": "Label Text", "description": "Label a piece of text.", "operationId": "label_text_api_v1_text_labels__post", "requestBody": { "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/TextLabels" } + "schema": { + "$ref": "#/components/schemas/TextLabels" + } } }, "required": true }, "responses": { - "204": { "description": "Successful Response" }, + "204": { + "description": "Successful Response" + }, "422": { "description": "Validation Error", "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } } } } }, - "security": [{ "APIKeyQuery": [] }, { "APIKeyHeader": [] }] + "security": [ + { + "APIKeyQuery": [] + }, + { + "APIKeyHeader": [] + } + ] } }, "/api/v1/text_labels/valid_labels": { "get": { - "tags": ["text_labels"], + "tags": [ + "text_labels" + ], "summary": "Get Valid Lables", "operationId": "get_valid_lables_api_v1_text_labels_valid_labels_get", "responses": { "200": { "description": "Successful Response", - "content": { "application/json": { "schema": {} } } + "content": { + "application/json": { + "schema": {} + } + } } } } }, "/api/v1/messages/": { "get": { - "tags": ["messages"], + "tags": [ + "messages" + ], "summary": "Query Messages", "description": "Query messages.", "operationId": "query_messages_api_v1_messages__get", "parameters": [ { "required": false, - "schema": { "title": "Username", "type": "string" }, + "schema": { + "title": "Username", + "type": "string" + }, "name": "username", "in": "query" }, { "required": false, - "schema": { "title": "Api Client Id", "type": "string" }, + "schema": { + "title": "Api Client Id", + "type": "string" + }, "name": "api_client_id", "in": "query" }, @@ -281,8 +418,8 @@ "required": false, "schema": { "title": "Max Count", - "maximum": 1000.0, - "exclusiveMinimum": 0.0, + "maximum": 1000, + "exclusiveMinimum": 0, "type": "integer", "default": 10 }, @@ -321,7 +458,11 @@ }, { "required": false, - "schema": { "title": "Desc", "type": "boolean", "default": true }, + "schema": { + "title": "Desc", + "type": "boolean", + "default": true + }, "name": "desc", "in": "query" }, @@ -344,7 +485,9 @@ "schema": { "title": "Response Query Messages Api V1 Messages Get", "type": "array", - "items": { "$ref": "#/components/schemas/Message" } + "items": { + "$ref": "#/components/schemas/Message" + } } } } @@ -353,17 +496,28 @@ "description": "Validation Error", "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } } } } }, - "security": [{ "APIKeyQuery": [] }, { "APIKeyHeader": [] }] + "security": [ + { + "APIKeyQuery": [] + }, + { + "APIKeyHeader": [] + } + ] } }, "/api/v1/messages/{message_id}": { "get": { - "tags": ["messages"], + "tags": [ + "messages" + ], "summary": "Get Message", "description": "Get a message by its internal ID.", "operationId": "get_message_api_v1_messages__message_id__get", @@ -384,7 +538,9 @@ "description": "Successful Response", "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/Message" } + "schema": { + "$ref": "#/components/schemas/Message" + } } } }, @@ -392,15 +548,26 @@ "description": "Validation Error", "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } } } } }, - "security": [{ "APIKeyQuery": [] }, { "APIKeyHeader": [] }] + "security": [ + { + "APIKeyQuery": [] + }, + { + "APIKeyHeader": [] + } + ] }, "delete": { - "tags": ["messages"], + "tags": [ + "messages" + ], "summary": "Mark Message Deleted", "operationId": "mark_message_deleted_api_v1_messages__message_id__delete", "parameters": [ @@ -416,22 +583,35 @@ } ], "responses": { - "204": { "description": "Successful Response" }, + "204": { + "description": "Successful Response" + }, "422": { "description": "Validation Error", "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } } } } }, - "security": [{ "APIKeyQuery": [] }, { "APIKeyHeader": [] }] + "security": [ + { + "APIKeyQuery": [] + }, + { + "APIKeyHeader": [] + } + ] } }, "/api/v1/messages/{message_id}/conversation": { "get": { - "tags": ["messages"], + "tags": [ + "messages" + ], "summary": "Get Conv", "description": "Get a conversation from the tree root and up to the message with given internal ID.", "operationId": "get_conv_api_v1_messages__message_id__conversation_get", @@ -452,7 +632,9 @@ "description": "Successful Response", "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/Conversation" } + "schema": { + "$ref": "#/components/schemas/Conversation" + } } } }, @@ -460,17 +642,28 @@ "description": "Validation Error", "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } } } } }, - "security": [{ "APIKeyQuery": [] }, { "APIKeyHeader": [] }] + "security": [ + { + "APIKeyQuery": [] + }, + { + "APIKeyHeader": [] + } + ] } }, "/api/v1/messages/{message_id}/tree": { "get": { - "tags": ["messages"], + "tags": [ + "messages" + ], "summary": "Get Tree", "description": "Get all messages belonging to the same message tree.", "operationId": "get_tree_api_v1_messages__message_id__tree_get", @@ -491,7 +684,9 @@ "description": "Successful Response", "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/MessageTree" } + "schema": { + "$ref": "#/components/schemas/MessageTree" + } } } }, @@ -499,17 +694,28 @@ "description": "Validation Error", "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } } } } }, - "security": [{ "APIKeyQuery": [] }, { "APIKeyHeader": [] }] + "security": [ + { + "APIKeyQuery": [] + }, + { + "APIKeyHeader": [] + } + ] } }, "/api/v1/messages/{message_id}/children": { "get": { - "tags": ["messages"], + "tags": [ + "messages" + ], "summary": "Get Children", "description": "Get all messages belonging to the same message tree.", "operationId": "get_children_api_v1_messages__message_id__children_get", @@ -533,7 +739,9 @@ "schema": { "title": "Response Get Children Api V1 Messages Message Id Children Get", "type": "array", - "items": { "$ref": "#/components/schemas/Message" } + "items": { + "$ref": "#/components/schemas/Message" + } } } } @@ -542,17 +750,28 @@ "description": "Validation Error", "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } } } } }, - "security": [{ "APIKeyQuery": [] }, { "APIKeyHeader": [] }] + "security": [ + { + "APIKeyQuery": [] + }, + { + "APIKeyHeader": [] + } + ] } }, "/api/v1/messages/{message_id}/descendants": { "get": { - "tags": ["messages"], + "tags": [ + "messages" + ], "summary": "Get Descendants", "description": "Get a subtree which starts with this message.", "operationId": "get_descendants_api_v1_messages__message_id__descendants_get", @@ -573,7 +792,9 @@ "description": "Successful Response", "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/MessageTree" } + "schema": { + "$ref": "#/components/schemas/MessageTree" + } } } }, @@ -581,17 +802,28 @@ "description": "Validation Error", "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } } } } }, - "security": [{ "APIKeyQuery": [] }, { "APIKeyHeader": [] }] + "security": [ + { + "APIKeyQuery": [] + }, + { + "APIKeyHeader": [] + } + ] } }, "/api/v1/messages/{message_id}/longest_conversation_in_tree": { "get": { - "tags": ["messages"], + "tags": [ + "messages" + ], "summary": "Get Longest Conv", "description": "Get the longest conversation from the tree of the message.", "operationId": "get_longest_conv_api_v1_messages__message_id__longest_conversation_in_tree_get", @@ -612,7 +844,9 @@ "description": "Successful Response", "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/Conversation" } + "schema": { + "$ref": "#/components/schemas/Conversation" + } } } }, @@ -620,17 +854,28 @@ "description": "Validation Error", "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } } } } }, - "security": [{ "APIKeyQuery": [] }, { "APIKeyHeader": [] }] + "security": [ + { + "APIKeyQuery": [] + }, + { + "APIKeyHeader": [] + } + ] } }, "/api/v1/messages/{message_id}/max_children_in_tree": { "get": { - "tags": ["messages"], + "tags": [ + "messages" + ], "summary": "Get Max Children", "description": "Get message with the most children from the tree of the provided message.", "operationId": "get_max_children_api_v1_messages__message_id__max_children_in_tree_get", @@ -651,7 +896,9 @@ "description": "Successful Response", "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/MessageTree" } + "schema": { + "$ref": "#/components/schemas/MessageTree" + } } } }, @@ -659,24 +906,38 @@ "description": "Validation Error", "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } } } } }, - "security": [{ "APIKeyQuery": [] }, { "APIKeyHeader": [] }] + "security": [ + { + "APIKeyQuery": [] + }, + { + "APIKeyHeader": [] + } + ] } }, "/api/v1/frontend_messages/{message_id}": { "get": { - "tags": ["frontend_messages"], + "tags": [ + "frontend_messages" + ], "summary": "Get Message By Frontend Id", "description": "Get a message by its frontend ID.", "operationId": "get_message_by_frontend_id_api_v1_frontend_messages__message_id__get", "parameters": [ { "required": true, - "schema": { "title": "Message Id", "type": "string" }, + "schema": { + "title": "Message Id", + "type": "string" + }, "name": "message_id", "in": "path" } @@ -686,7 +947,9 @@ "description": "Successful Response", "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/Message" } + "schema": { + "$ref": "#/components/schemas/Message" + } } } }, @@ -694,24 +957,38 @@ "description": "Validation Error", "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } } } } }, - "security": [{ "APIKeyQuery": [] }, { "APIKeyHeader": [] }] + "security": [ + { + "APIKeyQuery": [] + }, + { + "APIKeyHeader": [] + } + ] } }, "/api/v1/frontend_messages/{message_id}/conversation": { "get": { - "tags": ["frontend_messages"], + "tags": [ + "frontend_messages" + ], "summary": "Get Conv By Frontend Id", "description": "Get a conversation from the tree root and up to the message with given frontend ID.", "operationId": "get_conv_by_frontend_id_api_v1_frontend_messages__message_id__conversation_get", "parameters": [ { "required": true, - "schema": { "title": "Message Id", "type": "string" }, + "schema": { + "title": "Message Id", + "type": "string" + }, "name": "message_id", "in": "path" } @@ -721,7 +998,9 @@ "description": "Successful Response", "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/Conversation" } + "schema": { + "$ref": "#/components/schemas/Conversation" + } } } }, @@ -729,24 +1008,38 @@ "description": "Validation Error", "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } } } } }, - "security": [{ "APIKeyQuery": [] }, { "APIKeyHeader": [] }] + "security": [ + { + "APIKeyQuery": [] + }, + { + "APIKeyHeader": [] + } + ] } }, "/api/v1/frontend_messages/{message_id}/tree": { "get": { - "tags": ["frontend_messages"], + "tags": [ + "frontend_messages" + ], "summary": "Get Tree By Frontend Id", "description": "Get all messages belonging to the same message tree.\nMessage is identified by its frontend ID.", "operationId": "get_tree_by_frontend_id_api_v1_frontend_messages__message_id__tree_get", "parameters": [ { "required": true, - "schema": { "title": "Message Id", "type": "string" }, + "schema": { + "title": "Message Id", + "type": "string" + }, "name": "message_id", "in": "path" } @@ -756,7 +1049,9 @@ "description": "Successful Response", "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/MessageTree" } + "schema": { + "$ref": "#/components/schemas/MessageTree" + } } } }, @@ -764,24 +1059,38 @@ "description": "Validation Error", "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } } } } }, - "security": [{ "APIKeyQuery": [] }, { "APIKeyHeader": [] }] + "security": [ + { + "APIKeyQuery": [] + }, + { + "APIKeyHeader": [] + } + ] } }, "/api/v1/frontend_messages/{message_id}/children": { "get": { - "tags": ["frontend_messages"], + "tags": [ + "frontend_messages" + ], "summary": "Get Children By Frontend Id", "description": "Get all messages belonging to the same message tree.", "operationId": "get_children_by_frontend_id_api_v1_frontend_messages__message_id__children_get", "parameters": [ { "required": true, - "schema": { "title": "Message Id", "type": "string" }, + "schema": { + "title": "Message Id", + "type": "string" + }, "name": "message_id", "in": "path" } @@ -794,7 +1103,9 @@ "schema": { "title": "Response Get Children By Frontend Id Api V1 Frontend Messages Message Id Children Get", "type": "array", - "items": { "$ref": "#/components/schemas/Message" } + "items": { + "$ref": "#/components/schemas/Message" + } } } } @@ -803,24 +1114,38 @@ "description": "Validation Error", "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } } } } }, - "security": [{ "APIKeyQuery": [] }, { "APIKeyHeader": [] }] + "security": [ + { + "APIKeyQuery": [] + }, + { + "APIKeyHeader": [] + } + ] } }, "/api/v1/frontend_messages/{message_id}/descendants": { "get": { - "tags": ["frontend_messages"], + "tags": [ + "frontend_messages" + ], "summary": "Get Descendants By Frontend Id", "description": "Get a subtree which starts with this message.\nThe message is identified by its frontend ID.", "operationId": "get_descendants_by_frontend_id_api_v1_frontend_messages__message_id__descendants_get", "parameters": [ { "required": true, - "schema": { "title": "Message Id", "type": "string" }, + "schema": { + "title": "Message Id", + "type": "string" + }, "name": "message_id", "in": "path" } @@ -830,7 +1155,9 @@ "description": "Successful Response", "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/MessageTree" } + "schema": { + "$ref": "#/components/schemas/MessageTree" + } } } }, @@ -838,24 +1165,38 @@ "description": "Validation Error", "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } } } } }, - "security": [{ "APIKeyQuery": [] }, { "APIKeyHeader": [] }] + "security": [ + { + "APIKeyQuery": [] + }, + { + "APIKeyHeader": [] + } + ] } }, "/api/v1/frontend_messages/{message_id}/longest_conversation_in_tree": { "get": { - "tags": ["frontend_messages"], + "tags": [ + "frontend_messages" + ], "summary": "Get Longest Conv By Frontend Id", "description": "Get the longest conversation from the tree of the message.\nThe message is identified by its frontend ID.", "operationId": "get_longest_conv_by_frontend_id_api_v1_frontend_messages__message_id__longest_conversation_in_tree_get", "parameters": [ { "required": true, - "schema": { "title": "Message Id", "type": "string" }, + "schema": { + "title": "Message Id", + "type": "string" + }, "name": "message_id", "in": "path" } @@ -865,7 +1206,9 @@ "description": "Successful Response", "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/Conversation" } + "schema": { + "$ref": "#/components/schemas/Conversation" + } } } }, @@ -873,24 +1216,38 @@ "description": "Validation Error", "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } } } } }, - "security": [{ "APIKeyQuery": [] }, { "APIKeyHeader": [] }] + "security": [ + { + "APIKeyQuery": [] + }, + { + "APIKeyHeader": [] + } + ] } }, "/api/v1/frontend_messages/{message_id}/max_children_in_tree": { "get": { - "tags": ["frontend_messages"], + "tags": [ + "frontend_messages" + ], "summary": "Get Max Children By Frontend Id", "description": "Get message with the most children from the tree of the provided message.\nThe message is identified by its frontend ID.", "operationId": "get_max_children_by_frontend_id_api_v1_frontend_messages__message_id__max_children_in_tree_get", "parameters": [ { "required": true, - "schema": { "title": "Message Id", "type": "string" }, + "schema": { + "title": "Message Id", + "type": "string" + }, "name": "message_id", "in": "path" } @@ -900,7 +1257,9 @@ "description": "Successful Response", "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/MessageTree" } + "schema": { + "$ref": "#/components/schemas/MessageTree" + } } } }, @@ -908,17 +1267,194 @@ "description": "Validation Error", "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } } } } }, - "security": [{ "APIKeyQuery": [] }, { "APIKeyHeader": [] }] + "security": [ + { + "APIKeyQuery": [] + }, + { + "APIKeyHeader": [] + } + ] + } + }, + "/api/v1/users/users/{user_id}": { + "get": { + "tags": [ + "users" + ], + "summary": "Get User", + "description": "Get a user by global user ID. Only trusted clients can resolve users they did not register.", + "operationId": "get_user_api_v1_users_users__user_id__get", + "parameters": [ + { + "required": true, + "schema": { + "title": "User Id", + "type": "string", + "format": "uuid" + }, + "name": "user_id", + "in": "path" + }, + { + "required": false, + "schema": { + "title": "Api Client Id", + "type": "string", + "format": "uuid" + }, + "name": "api_client_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/User" + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + }, + "security": [ + { + "APIKeyQuery": [] + }, + { + "APIKeyHeader": [] + } + ] + }, + "put": { + "tags": [ + "users" + ], + "summary": "Update User", + "description": "Update a user by global user ID. Only trusted clients can update users.", + "operationId": "update_user_api_v1_users_users__user_id__put", + "parameters": [ + { + "required": true, + "schema": { + "title": "User Id", + "type": "string", + "format": "uuid" + }, + "name": "user_id", + "in": "path" + }, + { + "required": false, + "schema": { + "title": "Enabled", + "type": "boolean" + }, + "name": "enabled", + "in": "query" + }, + { + "required": false, + "schema": { + "title": "Notes", + "type": "string" + }, + "name": "notes", + "in": "query" + } + ], + "responses": { + "204": { + "description": "Successful Response" + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + }, + "security": [ + { + "APIKeyQuery": [] + }, + { + "APIKeyHeader": [] + } + ] + }, + "delete": { + "tags": [ + "users" + ], + "summary": "Delete User", + "description": "Delete a user by global user ID. Only trusted clients can delete users.", + "operationId": "delete_user_api_v1_users_users__user_id__delete", + "parameters": [ + { + "required": true, + "schema": { + "title": "User Id", + "type": "string", + "format": "uuid" + }, + "name": "user_id", + "in": "path" + } + ], + "responses": { + "204": { + "description": "Successful Response" + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + }, + "security": [ + { + "APIKeyQuery": [] + }, + { + "APIKeyHeader": [] + } + ] } }, "/api/v1/users/{user_id}/messages": { "get": { - "tags": ["users"], + "tags": [ + "users" + ], "summary": "Query User Messages", "description": "Query user messages.", "operationId": "query_user_messages_api_v1_users__user_id__messages_get", @@ -947,8 +1483,8 @@ "required": false, "schema": { "title": "Max Count", - "maximum": 1000.0, - "exclusiveMinimum": 0.0, + "maximum": 1000, + "exclusiveMinimum": 0, "type": "integer", "default": 10 }, @@ -987,7 +1523,11 @@ }, { "required": false, - "schema": { "title": "Desc", "type": "boolean", "default": true }, + "schema": { + "title": "Desc", + "type": "boolean", + "default": true + }, "name": "desc", "in": "query" }, @@ -1010,7 +1550,9 @@ "schema": { "title": "Response Query User Messages Api V1 Users User Id Messages Get", "type": "array", - "items": { "$ref": "#/components/schemas/Message" } + "items": { + "$ref": "#/components/schemas/Message" + } } } } @@ -1019,15 +1561,26 @@ "description": "Validation Error", "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } } } } }, - "security": [{ "APIKeyQuery": [] }, { "APIKeyHeader": [] }] + "security": [ + { + "APIKeyQuery": [] + }, + { + "APIKeyHeader": [] + } + ] }, "delete": { - "tags": ["users"], + "tags": [ + "users" + ], "summary": "Mark User Messages Deleted", "operationId": "mark_user_messages_deleted_api_v1_users__user_id__messages_delete", "parameters": [ @@ -1043,35 +1596,237 @@ } ], "responses": { - "204": { "description": "Successful Response" }, + "204": { + "description": "Successful Response" + }, "422": { "description": "Validation Error", "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } } } } }, - "security": [{ "APIKeyQuery": [] }, { "APIKeyHeader": [] }] + "security": [ + { + "APIKeyQuery": [] + }, + { + "APIKeyHeader": [] + } + ] + } + }, + "/api/v1/frontend_users/": { + "get": { + "tags": [ + "frontend_users" + ], + "summary": "Get Users", + "operationId": "get_users_api_v1_frontend_users__get", + "parameters": [ + { + "required": false, + "schema": { + "title": "Api Client Id", + "type": "string", + "format": "uuid" + }, + "name": "api_client_id", + "in": "query" + }, + { + "required": false, + "schema": { + "title": "Max Count", + "maximum": 10000, + "exclusiveMinimum": 0, + "type": "integer", + "default": 100 + }, + "name": "max_count", + "in": "query" + }, + { + "required": false, + "schema": { + "title": "Gte", + "type": "string" + }, + "name": "gte", + "in": "query" + }, + { + "required": false, + "schema": { + "title": "Lt", + "type": "string" + }, + "name": "lt", + "in": "query" + }, + { + "required": false, + "schema": { + "title": "Auth Method", + "type": "string" + }, + "name": "auth_method", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "title": "Response Get Users Api V1 Frontend Users Get", + "type": "array", + "items": { + "$ref": "#/components/schemas/FrontEndUser" + } + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + }, + "security": [ + { + "APIKeyQuery": [] + }, + { + "APIKeyHeader": [] + } + ] + } + }, + "/api/v1/frontend_users/by_display_name": { + "get": { + "tags": [ + "frontend_users" + ], + "summary": "Query Frontend Users By Display Name", + "operationId": "query_frontend_users_by_display_name_api_v1_frontend_users_by_display_name_get", + "parameters": [ + { + "required": true, + "schema": { + "title": "Search Text", + "type": "string" + }, + "name": "search_text", + "in": "query" + }, + { + "required": false, + "schema": { + "title": "Exact", + "type": "boolean", + "default": false + }, + "name": "exact", + "in": "query" + }, + { + "required": false, + "schema": { + "title": "Api Client Id", + "type": "string", + "format": "uuid" + }, + "name": "api_client_id", + "in": "query" + }, + { + "required": false, + "schema": { + "title": "Max Count", + "maximum": 1000, + "exclusiveMinimum": 0, + "type": "integer", + "default": 20 + }, + "name": "max_count", + "in": "query" + }, + { + "required": false, + "schema": { + "title": "Auth Method", + "type": "string" + }, + "name": "auth_method", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": {} + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + }, + "security": [ + { + "APIKeyQuery": [] + }, + { + "APIKeyHeader": [] + } + ] } }, "/api/v1/frontend_users/{auth_method}/{username}": { "get": { - "tags": ["frontend_users"], + "tags": [ + "frontend_users" + ], "summary": "Query Frontend User", "description": "Query frontend user.", "operationId": "query_frontend_user_api_v1_frontend_users__auth_method___username__get", "parameters": [ { "required": true, - "schema": { "title": "Auth Method", "type": "string" }, + "schema": { + "title": "Auth Method", + "type": "string" + }, "name": "auth_method", "in": "path" }, { "required": true, - "schema": { "title": "Username", "type": "string" }, + "schema": { + "title": "Username", + "type": "string" + }, "name": "username", "in": "path" }, @@ -1091,7 +1846,9 @@ "description": "Successful Response", "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/User" } + "schema": { + "$ref": "#/components/schemas/FrontEndUser" + } } } }, @@ -1099,24 +1856,47 @@ "description": "Validation Error", "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } } } } }, - "security": [{ "APIKeyQuery": [] }, { "APIKeyHeader": [] }] + "security": [ + { + "APIKeyQuery": [] + }, + { + "APIKeyHeader": [] + } + ] } }, - "/api/v1/frontend_users/{username}/messages": { + "/api/v1/frontend_users/{auth_method}/{username}/messages": { "get": { - "tags": ["frontend_users"], + "tags": [ + "frontend_users" + ], "summary": "Query Frontend User Messages", "description": "Query frontend user messages.", - "operationId": "query_frontend_user_messages_api_v1_frontend_users__username__messages_get", + "operationId": "query_frontend_user_messages_api_v1_frontend_users__auth_method___username__messages_get", "parameters": [ { "required": true, - "schema": { "title": "Username", "type": "string" }, + "schema": { + "title": "Auth Method", + "type": "string" + }, + "name": "auth_method", + "in": "path" + }, + { + "required": true, + "schema": { + "title": "Username", + "type": "string" + }, "name": "username", "in": "path" }, @@ -1134,8 +1914,8 @@ "required": false, "schema": { "title": "Max Count", - "maximum": 1000.0, - "exclusiveMinimum": 0.0, + "maximum": 1000, + "exclusiveMinimum": 0, "type": "integer", "default": 10 }, @@ -1174,7 +1954,11 @@ }, { "required": false, - "schema": { "title": "Desc", "type": "boolean", "default": true }, + "schema": { + "title": "Desc", + "type": "boolean", + "default": true + }, "name": "desc", "in": "query" }, @@ -1195,9 +1979,11 @@ "content": { "application/json": { "schema": { - "title": "Response Query Frontend User Messages Api V1 Frontend Users Username Messages Get", + "title": "Response Query Frontend User Messages Api V1 Frontend Users Auth Method Username Messages Get", "type": "array", - "items": { "$ref": "#/components/schemas/Message" } + "items": { + "$ref": "#/components/schemas/Message" + } } } } @@ -1206,42 +1992,78 @@ "description": "Validation Error", "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } } } } }, - "security": [{ "APIKeyQuery": [] }, { "APIKeyHeader": [] }] + "security": [ + { + "APIKeyQuery": [] + }, + { + "APIKeyHeader": [] + } + ] }, "delete": { - "tags": ["frontend_users"], + "tags": [ + "frontend_users" + ], "summary": "Mark Frontend User Messages Deleted", - "operationId": "mark_frontend_user_messages_deleted_api_v1_frontend_users__username__messages_delete", + "operationId": "mark_frontend_user_messages_deleted_api_v1_frontend_users__auth_method___username__messages_delete", "parameters": [ { "required": true, - "schema": { "title": "Username", "type": "string" }, + "schema": { + "title": "Auth Method", + "type": "string" + }, + "name": "auth_method", + "in": "path" + }, + { + "required": true, + "schema": { + "title": "Username", + "type": "string" + }, "name": "username", "in": "path" } ], "responses": { - "204": { "description": "Successful Response" }, + "204": { + "description": "Successful Response" + }, "422": { "description": "Validation Error", "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } } } } }, - "security": [{ "APIKeyQuery": [] }, { "APIKeyHeader": [] }] + "security": [ + { + "APIKeyQuery": [] + }, + { + "APIKeyHeader": [] + } + ] } }, "/api/v1/stats/": { "get": { - "tags": ["stats"], + "tags": [ + "stats" + ], "summary": "Get Message Stats", "operationId": "get_message_stats_api_v1_stats__get", "responses": { @@ -1249,52 +2071,92 @@ "description": "Successful Response", "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/SystemStats" } + "schema": { + "$ref": "#/components/schemas/SystemStats" + } } } } }, - "security": [{ "APIKeyQuery": [] }, { "APIKeyHeader": [] }] + "security": [ + { + "APIKeyQuery": [] + }, + { + "APIKeyHeader": [] + } + ] } }, "/api/v1/experimental/leaderboards/create/assistant": { "get": { - "tags": ["leaderboards"], + "tags": [ + "leaderboards" + ], "summary": "Get Assistant Leaderboard", "operationId": "get_assistant_leaderboard_api_v1_experimental_leaderboards_create_assistant_get", "responses": { "200": { "description": "Successful Response", - "content": { "application/json": { "schema": {} } } + "content": { + "application/json": { + "schema": {} + } + } } }, - "security": [{ "APIKeyQuery": [] }, { "APIKeyHeader": [] }] + "security": [ + { + "APIKeyQuery": [] + }, + { + "APIKeyHeader": [] + } + ] } }, "/api/v1/experimental/leaderboards/create/prompter": { "get": { - "tags": ["leaderboards"], + "tags": [ + "leaderboards" + ], "summary": "Get Prompter Leaderboard", "operationId": "get_prompter_leaderboard_api_v1_experimental_leaderboards_create_prompter_get", "responses": { "200": { "description": "Successful Response", - "content": { "application/json": { "schema": {} } } + "content": { + "application/json": { + "schema": {} + } + } } }, - "security": [{ "APIKeyQuery": [] }, { "APIKeyHeader": [] }] + "security": [ + { + "APIKeyQuery": [] + }, + { + "APIKeyHeader": [] + } + ] } }, "/api/v1/hf/text_toxicity": { "get": { - "tags": ["hugging_face"], + "tags": [ + "hugging_face" + ], "summary": "Get Text Toxicity", "description": "Get the Message Toxicity from HuggingFace Roberta model.\n\nArgs:\n msg (str): the message that we want to analyze.\n api_client (ApiClient, optional): authentification of the user of the request.\n Defaults to Depends(deps.get_trusted_api_client).\n\nReturns:\n ToxicityClassification: the score of toxicity of the message.", "operationId": "get_text_toxicity_api_v1_hf_text_toxicity_get", "parameters": [ { "required": true, - "schema": { "title": "Msg", "type": "string" }, + "schema": { + "title": "Msg", + "type": "string" + }, "name": "msg", "in": "query" } @@ -1302,18 +2164,31 @@ "responses": { "200": { "description": "Successful Response", - "content": { "application/json": { "schema": {} } } + "content": { + "application/json": { + "schema": {} + } + } }, "422": { "description": "Validation Error", "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } } } } }, - "security": [{ "APIKeyQuery": [] }, { "APIKeyHeader": [] }] + "security": [ + { + "APIKeyQuery": [] + }, + { + "APIKeyHeader": [] + } + ] } } }, @@ -1321,17 +2196,27 @@ "schemas": { "AssistantReplyTask": { "title": "AssistantReplyTask", - "required": ["conversation"], + "required": [ + "conversation" + ], "type": "object", "properties": { - "id": { "title": "Id", "type": "string", "format": "uuid" }, + "id": { + "title": "Id", + "type": "string", + "format": "uuid" + }, "type": { "title": "Type", - "enum": ["assistant_reply"], + "enum": [ + "assistant_reply" + ], "type": "string", "default": "assistant_reply" }, - "conversation": { "$ref": "#/components/schemas/Conversation" } + "conversation": { + "$ref": "#/components/schemas/Conversation" + } }, "description": "A task to prompt the user to act as the assistant." }, @@ -1342,7 +2227,9 @@ "messages": { "title": "Messages", "type": "array", - "items": { "$ref": "#/components/schemas/ConversationMessage" }, + "items": { + "$ref": "#/components/schemas/ConversationMessage" + }, "default": [] } }, @@ -1350,23 +2237,85 @@ }, "ConversationMessage": { "title": "ConversationMessage", - "required": ["text", "is_assistant"], + "required": [ + "text", + "is_assistant" + ], "type": "object", "properties": { - "text": { "title": "Text", "type": "string" }, - "is_assistant": { "title": "Is Assistant", "type": "boolean" }, - "message_id": { - "title": "Message Id", + "id": { + "title": "Id", "type": "string", "format": "uuid" }, "frontend_message_id": { "title": "Frontend Message Id", "type": "string" + }, + "text": { + "title": "Text", + "type": "string" + }, + "is_assistant": { + "title": "Is Assistant", + "type": "boolean" } }, "description": "Represents a message in a conversation between the user and the assistant." }, + "FrontEndUser": { + "title": "FrontEndUser", + "required": [ + "id", + "display_name", + "auth_method", + "user_id", + "enabled", + "deleted", + "notes" + ], + "type": "object", + "properties": { + "id": { + "title": "Id", + "type": "string" + }, + "display_name": { + "title": "Display Name", + "type": "string" + }, + "auth_method": { + "title": "Auth Method", + "enum": [ + "discord", + "local" + ], + "type": "string" + }, + "user_id": { + "title": "User Id", + "type": "string", + "format": "uuid" + }, + "enabled": { + "title": "Enabled", + "type": "boolean" + }, + "deleted": { + "title": "Deleted", + "type": "boolean" + }, + "notes": { + "title": "Notes", + "type": "string" + }, + "created_date": { + "title": "Created Date", + "type": "string", + "format": "date-time" + } + } + }, "HTTPValidationError": { "title": "HTTPValidationError", "type": "object", @@ -1374,7 +2323,9 @@ "detail": { "title": "Detail", "type": "array", - "items": { "$ref": "#/components/schemas/ValidationError" } + "items": { + "$ref": "#/components/schemas/ValidationError" + } } } }, @@ -1382,11 +2333,20 @@ "title": "InitialPromptTask", "type": "object", "properties": { - "hint": { "title": "Hint", "type": "string" }, - "id": { "title": "Id", "type": "string", "format": "uuid" }, + "hint": { + "title": "Hint", + "type": "string" + }, + "id": { + "title": "Id", + "type": "string", + "format": "uuid" + }, "type": { "title": "Type", - "enum": ["initial_prompt"], + "enum": [ + "initial_prompt" + ], "type": "string", "default": "initial_prompt" } @@ -1395,67 +2355,133 @@ }, "LabelAssistantReplyTask": { "title": "LabelAssistantReplyTask", - "required": ["conversation", "message_id", "reply", "valid_labels"], + "required": [ + "conversation", + "message_id", + "reply", + "valid_labels" + ], "type": "object", "properties": { - "id": { "title": "Id", "type": "string", "format": "uuid" }, + "id": { + "title": "Id", + "type": "string", + "format": "uuid" + }, "type": { "title": "Type", - "enum": ["label_assistant_reply"], + "enum": [ + "label_assistant_reply" + ], "type": "string", "default": "label_assistant_reply" }, - "conversation": { "$ref": "#/components/schemas/Conversation" }, + "conversation": { + "$ref": "#/components/schemas/Conversation" + }, "message_id": { "title": "Message Id", "type": "string", "format": "uuid" }, - "reply": { "title": "Reply", "type": "string" }, + "reply": { + "title": "Reply", + "type": "string" + }, "valid_labels": { "title": "Valid Labels", "type": "array", - "items": { "type": "string" } + "items": { + "type": "string" + } + }, + "mandatory_labels": { + "title": "Mandatory Labels", + "type": "array", + "items": { + "type": "string" + } + }, + "mode": { + "$ref": "#/components/schemas/LabelTaskMode" } }, "description": "A task to label an assistant reply to a conversation." }, "LabelConversationReplyTask": { "title": "LabelConversationReplyTask", - "required": ["conversation", "message_id", "reply", "valid_labels"], + "required": [ + "conversation", + "message_id", + "reply", + "valid_labels" + ], "type": "object", "properties": { - "id": { "title": "Id", "type": "string", "format": "uuid" }, + "id": { + "title": "Id", + "type": "string", + "format": "uuid" + }, "type": { "title": "Type", - "enum": ["label_conversation_reply"], + "enum": [ + "label_conversation_reply" + ], "type": "string", "default": "label_conversation_reply" }, - "conversation": { "$ref": "#/components/schemas/Conversation" }, + "conversation": { + "$ref": "#/components/schemas/Conversation" + }, "message_id": { "title": "Message Id", "type": "string", "format": "uuid" }, - "reply": { "title": "Reply", "type": "string" }, + "reply": { + "title": "Reply", + "type": "string" + }, "valid_labels": { "title": "Valid Labels", "type": "array", - "items": { "type": "string" } + "items": { + "type": "string" + } + }, + "mandatory_labels": { + "title": "Mandatory Labels", + "type": "array", + "items": { + "type": "string" + } + }, + "mode": { + "$ref": "#/components/schemas/LabelTaskMode" } }, "description": "A task to label a reply to a conversation." }, "LabelInitialPromptTask": { "title": "LabelInitialPromptTask", - "required": ["message_id", "prompt", "valid_labels"], + "required": [ + "message_id", + "prompt", + "valid_labels" + ], "type": "object", "properties": { - "id": { "title": "Id", "type": "string", "format": "uuid" }, + "id": { + "title": "Id", + "type": "string", + "format": "uuid" + }, "type": { "title": "Type", - "enum": ["label_initial_prompt"], + "enum": [ + "label_initial_prompt" + ], "type": "string", "default": "label_initial_prompt" }, @@ -1464,51 +2490,104 @@ "type": "string", "format": "uuid" }, - "prompt": { "title": "Prompt", "type": "string" }, + "prompt": { + "title": "Prompt", + "type": "string" + }, "valid_labels": { "title": "Valid Labels", "type": "array", - "items": { "type": "string" } + "items": { + "type": "string" + } + }, + "mandatory_labels": { + "title": "Mandatory Labels", + "type": "array", + "items": { + "type": "string" + } + }, + "mode": { + "$ref": "#/components/schemas/LabelTaskMode" } }, "description": "A task to label an initial prompt." }, "LabelPrompterReplyTask": { "title": "LabelPrompterReplyTask", - "required": ["conversation", "message_id", "reply", "valid_labels"], + "required": [ + "conversation", + "message_id", + "reply", + "valid_labels" + ], "type": "object", "properties": { - "id": { "title": "Id", "type": "string", "format": "uuid" }, + "id": { + "title": "Id", + "type": "string", + "format": "uuid" + }, "type": { "title": "Type", - "enum": ["label_prompter_reply"], + "enum": [ + "label_prompter_reply" + ], "type": "string", "default": "label_prompter_reply" }, - "conversation": { "$ref": "#/components/schemas/Conversation" }, + "conversation": { + "$ref": "#/components/schemas/Conversation" + }, "message_id": { "title": "Message Id", "type": "string", "format": "uuid" }, - "reply": { "title": "Reply", "type": "string" }, + "reply": { + "title": "Reply", + "type": "string" + }, "valid_labels": { "title": "Valid Labels", "type": "array", - "items": { "type": "string" } + "items": { + "type": "string" + } + }, + "mandatory_labels": { + "title": "Mandatory Labels", + "type": "array", + "items": { + "type": "string" + } + }, + "mode": { + "$ref": "#/components/schemas/LabelTaskMode" } }, "description": "A task to label a prompter reply to a conversation." }, + "LabelTaskMode": { + "title": "LabelTaskMode", + "enum": [ + "simple", + "full" + ], + "type": "string", + "description": "Label task mode that allows frontends to select an appropriate UI." + }, "Message": { "title": "Message", - "required": ["text", "is_assistant", "id"], + "required": [ + "text", + "is_assistant" + ], "type": "object", "properties": { - "text": { "title": "Text", "type": "string" }, - "is_assistant": { "title": "Is Assistant", "type": "boolean" }, - "message_id": { - "title": "Message Id", + "id": { + "title": "Id", "type": "string", "format": "uuid" }, @@ -1516,7 +2595,14 @@ "title": "Frontend Message Id", "type": "string" }, - "id": { "title": "Id", "type": "string", "format": "uuid" }, + "text": { + "title": "Text", + "type": "string" + }, + "is_assistant": { + "title": "Is Assistant", + "type": "boolean" + }, "parent_id": { "title": "Parent Id", "type": "string", @@ -1532,42 +2618,66 @@ }, "MessageRanking": { "title": "MessageRanking", - "required": ["user", "message_id", "ranking"], + "required": [ + "user", + "message_id", + "ranking" + ], "type": "object", "properties": { "type": { "title": "Type", - "enum": ["message_ranking"], + "enum": [ + "message_ranking" + ], "type": "string", "default": "message_ranking" }, - "user": { "$ref": "#/components/schemas/User" }, - "message_id": { "title": "Message Id", "type": "string" }, + "user": { + "$ref": "#/components/schemas/User" + }, + "message_id": { + "title": "Message Id", + "type": "string" + }, "ranking": { "title": "Ranking", "minItems": 1, "type": "array", - "items": { "type": "integer" } + "items": { + "type": "integer" + } } }, "description": "A user has given a ranking for a message." }, "MessageRating": { "title": "MessageRating", - "required": ["user", "message_id", "rating"], + "required": [ + "user", + "message_id", + "rating" + ], "type": "object", "properties": { "type": { "title": "Type", - "enum": ["message_rating"], + "enum": [ + "message_rating" + ], "type": "string", "default": "message_rating" }, - "user": { "$ref": "#/components/schemas/User" }, - "message_id": { "title": "Message Id", "type": "string" }, + "user": { + "$ref": "#/components/schemas/User" + }, + "message_id": { + "title": "Message Id", + "type": "string" + }, "rating": { "title": "Rating", - "exclusiveMinimum": 0.0, + "exclusiveMinimum": 0, "type": "integer" } }, @@ -1575,14 +2685,22 @@ }, "MessageTree": { "title": "MessageTree", - "required": ["id"], + "required": [ + "id" + ], "type": "object", "properties": { - "id": { "title": "Id", "type": "string", "format": "uuid" }, + "id": { + "title": "Id", + "type": "string", + "format": "uuid" + }, "messages": { "title": "Messages", "type": "array", - "items": { "$ref": "#/components/schemas/Message" }, + "items": { + "$ref": "#/components/schemas/Message" + }, "default": [] } }, @@ -1590,164 +2708,310 @@ }, "PrompterReplyTask": { "title": "PrompterReplyTask", - "required": ["conversation"], + "required": [ + "conversation" + ], "type": "object", "properties": { - "hint": { "title": "Hint", "type": "string" }, - "id": { "title": "Id", "type": "string", "format": "uuid" }, + "hint": { + "title": "Hint", + "type": "string" + }, + "id": { + "title": "Id", + "type": "string", + "format": "uuid" + }, "type": { "title": "Type", - "enum": ["prompter_reply"], + "enum": [ + "prompter_reply" + ], "type": "string", "default": "prompter_reply" }, - "conversation": { "$ref": "#/components/schemas/Conversation" } + "conversation": { + "$ref": "#/components/schemas/Conversation" + } }, "description": "A task to prompt the user to submit a reply to the assistant." }, "RankAssistantRepliesTask": { "title": "RankAssistantRepliesTask", - "required": ["conversation", "replies"], + "required": [ + "conversation", + "replies", + "reply_messages" + ], "type": "object", "properties": { - "id": { "title": "Id", "type": "string", "format": "uuid" }, + "id": { + "title": "Id", + "type": "string", + "format": "uuid" + }, "type": { "title": "Type", - "enum": ["rank_assistant_replies"], + "enum": [ + "rank_assistant_replies" + ], "type": "string", "default": "rank_assistant_replies" }, - "conversation": { "$ref": "#/components/schemas/Conversation" }, + "conversation": { + "$ref": "#/components/schemas/Conversation" + }, "replies": { "title": "Replies", "type": "array", - "items": { "type": "string" } + "items": { + "type": "string" + } + }, + "reply_messages": { + "title": "Reply Messages", + "type": "array", + "items": { + "$ref": "#/components/schemas/ConversationMessage" + } } }, "description": "A task to rank a set of assistant replies to a conversation." }, "RankConversationRepliesTask": { "title": "RankConversationRepliesTask", - "required": ["conversation", "replies"], + "required": [ + "conversation", + "replies", + "reply_messages" + ], "type": "object", "properties": { - "id": { "title": "Id", "type": "string", "format": "uuid" }, + "id": { + "title": "Id", + "type": "string", + "format": "uuid" + }, "type": { "title": "Type", - "enum": ["rank_conversation_replies"], + "enum": [ + "rank_conversation_replies" + ], "type": "string", "default": "rank_conversation_replies" }, - "conversation": { "$ref": "#/components/schemas/Conversation" }, + "conversation": { + "$ref": "#/components/schemas/Conversation" + }, "replies": { "title": "Replies", "type": "array", - "items": { "type": "string" } + "items": { + "type": "string" + } + }, + "reply_messages": { + "title": "Reply Messages", + "type": "array", + "items": { + "$ref": "#/components/schemas/ConversationMessage" + } } }, "description": "A task to rank a set of replies to a conversation." }, "RankInitialPromptsTask": { "title": "RankInitialPromptsTask", - "required": ["prompts"], + "required": [ + "prompts", + "prompt_messages" + ], "type": "object", "properties": { - "id": { "title": "Id", "type": "string", "format": "uuid" }, + "id": { + "title": "Id", + "type": "string", + "format": "uuid" + }, "type": { "title": "Type", - "enum": ["rank_initial_prompts"], + "enum": [ + "rank_initial_prompts" + ], "type": "string", "default": "rank_initial_prompts" }, "prompts": { "title": "Prompts", "type": "array", - "items": { "type": "string" } + "items": { + "type": "string" + } + }, + "prompt_messages": { + "title": "Prompt Messages", + "type": "array", + "items": { + "$ref": "#/components/schemas/ConversationMessage" + } } }, "description": "A task to rank a set of initial prompts." }, "RankPrompterRepliesTask": { "title": "RankPrompterRepliesTask", - "required": ["conversation", "replies"], + "required": [ + "conversation", + "replies", + "reply_messages" + ], "type": "object", "properties": { - "id": { "title": "Id", "type": "string", "format": "uuid" }, + "id": { + "title": "Id", + "type": "string", + "format": "uuid" + }, "type": { "title": "Type", - "enum": ["rank_prompter_replies"], + "enum": [ + "rank_prompter_replies" + ], "type": "string", "default": "rank_prompter_replies" }, - "conversation": { "$ref": "#/components/schemas/Conversation" }, + "conversation": { + "$ref": "#/components/schemas/Conversation" + }, "replies": { "title": "Replies", "type": "array", - "items": { "type": "string" } + "items": { + "type": "string" + } + }, + "reply_messages": { + "title": "Reply Messages", + "type": "array", + "items": { + "$ref": "#/components/schemas/ConversationMessage" + } } }, "description": "A task to rank a set of prompter replies to a conversation." }, "RateSummaryTask": { "title": "RateSummaryTask", - "required": ["full_text", "summary"], + "required": [ + "full_text", + "summary" + ], "type": "object", "properties": { - "id": { "title": "Id", "type": "string", "format": "uuid" }, + "id": { + "title": "Id", + "type": "string", + "format": "uuid" + }, "type": { "title": "Type", - "enum": ["rate_summary"], + "enum": [ + "rate_summary" + ], "type": "string", "default": "rate_summary" }, "scale": { "title": "Scale", - "allOf": [{ "$ref": "#/components/schemas/RatingScale" }], - "default": { "min": 1, "max": 5 } + "allOf": [ + { + "$ref": "#/components/schemas/RatingScale" + } + ], + "default": { + "min": 1, + "max": 5 + } }, - "full_text": { "title": "Full Text", "type": "string" }, - "summary": { "title": "Summary", "type": "string" } + "full_text": { + "title": "Full Text", + "type": "string" + }, + "summary": { + "title": "Summary", + "type": "string" + } }, "description": "A task to rate a summary." }, "RatingScale": { "title": "RatingScale", - "required": ["min", "max"], + "required": [ + "min", + "max" + ], "type": "object", "properties": { - "min": { "title": "Min", "type": "integer" }, - "max": { "title": "Max", "type": "integer" } + "min": { + "title": "Min", + "type": "integer" + }, + "max": { + "title": "Max", + "type": "integer" + } } }, "ReplyToConversationTask": { "title": "ReplyToConversationTask", - "required": ["conversation"], + "required": [ + "conversation" + ], "type": "object", "properties": { - "id": { "title": "Id", "type": "string", "format": "uuid" }, + "id": { + "title": "Id", + "type": "string", + "format": "uuid" + }, "type": { "title": "Type", - "enum": ["reply_to_conversation"], + "enum": [ + "reply_to_conversation" + ], "type": "string", "default": "reply_to_conversation" }, - "conversation": { "$ref": "#/components/schemas/Conversation" } + "conversation": { + "$ref": "#/components/schemas/Conversation" + } }, "description": "A task to prompt the user to submit a reply to a conversation." }, "SummarizeStoryTask": { "title": "SummarizeStoryTask", - "required": ["story"], + "required": [ + "story" + ], "type": "object", "properties": { - "id": { "title": "Id", "type": "string", "format": "uuid" }, + "id": { + "title": "Id", + "type": "string", + "format": "uuid" + }, "type": { "title": "Type", - "enum": ["summarize_story"], + "enum": [ + "summarize_story" + ], "type": "string", "default": "summarize_story" }, - "story": { "title": "Story", "type": "string" } + "story": { + "title": "Story", + "type": "string" + } }, "description": "A task to summarize a story." }, @@ -1755,9 +3019,21 @@ "title": "SystemStats", "type": "object", "properties": { - "all": { "title": "All", "type": "integer", "default": 0 }, - "active": { "title": "Active", "type": "integer", "default": 0 }, - "deleted": { "title": "Deleted", "type": "integer", "default": 0 }, + "all": { + "title": "All", + "type": "integer", + "default": 0 + }, + "active": { + "title": "Active", + "type": "integer", + "default": 0 + }, + "deleted": { + "title": "Deleted", + "type": "integer", + "default": 0 + }, "message_trees": { "title": "Message Trees", "type": "integer", @@ -1767,19 +3043,29 @@ }, "TaskAck": { "title": "TaskAck", - "required": ["message_id"], + "required": [ + "message_id" + ], "type": "object", "properties": { - "message_id": { "title": "Message Id", "type": "string" } + "message_id": { + "title": "Message Id", + "type": "string" + } }, "description": "The frontend acknowledges that it has received a task and created a message." }, "TaskClose": { "title": "TaskClose", - "required": ["message_id"], + "required": [ + "message_id" + ], "type": "object", "properties": { - "message_id": { "title": "Message Id", "type": "string" } + "message_id": { + "title": "Message Id", + "type": "string" + } }, "description": "The frontend asks to mark task as done" }, @@ -1787,10 +3073,16 @@ "title": "TaskDone", "type": "object", "properties": { - "id": { "title": "Id", "type": "string", "format": "uuid" }, + "id": { + "title": "Id", + "type": "string", + "format": "uuid" + }, "type": { "title": "Type", - "enum": ["task_done"], + "enum": [ + "task_done" + ], "type": "string", "default": "task_done" } @@ -1799,9 +3091,16 @@ }, "TaskNAck": { "title": "TaskNAck", - "required": ["reason"], + "required": [ + "reason" + ], "type": "object", - "properties": { "reason": { "title": "Reason", "type": "string" } }, + "properties": { + "reason": { + "title": "Reason", + "type": "string" + } + }, "description": "The frontend acknowledges that it has received a task but cannot create a message." }, "TaskRequest": { @@ -1809,12 +3108,20 @@ "type": "object", "properties": { "type": { - "allOf": [{ "$ref": "#/components/schemas/TaskRequestType" }], + "allOf": [ + { + "$ref": "#/components/schemas/TaskRequestType" + } + ], "default": "random" }, "user": { "title": "User", - "allOf": [{ "$ref": "#/components/schemas/User" }], + "allOf": [ + { + "$ref": "#/components/schemas/User" + } + ], "nullable": true }, "collective": { @@ -1846,80 +3153,158 @@ }, "TextLabels": { "title": "TextLabels", - "required": ["user", "text", "labels", "message_id"], + "required": [ + "user", + "text", + "labels", + "message_id" + ], "type": "object", "properties": { "type": { "title": "Type", - "enum": ["text_labels"], + "enum": [ + "text_labels" + ], "type": "string", "default": "text_labels" }, - "user": { "$ref": "#/components/schemas/User" }, - "text": { "title": "Text", "type": "string" }, + "user": { + "$ref": "#/components/schemas/User" + }, + "text": { + "title": "Text", + "type": "string" + }, "labels": { "title": "Labels", "type": "object", - "additionalProperties": { "type": "number" } + "additionalProperties": { + "type": "number" + } }, "message_id": { "title": "Message Id", "type": "string", "format": "uuid" + }, + "task_id": { + "title": "Task Id", + "type": "string", + "format": "uuid" } }, "description": "A set of labels for a piece of text." }, "TextReplyToMessage": { "title": "TextReplyToMessage", - "required": ["user", "message_id", "user_message_id", "text"], + "required": [ + "user", + "message_id", + "user_message_id", + "text" + ], "type": "object", "properties": { "type": { "title": "Type", - "enum": ["text_reply_to_message"], + "enum": [ + "text_reply_to_message" + ], "type": "string", "default": "text_reply_to_message" }, - "user": { "$ref": "#/components/schemas/User" }, - "message_id": { "title": "Message Id", "type": "string" }, - "user_message_id": { "title": "User Message Id", "type": "string" }, - "text": { "title": "Text", "minLength": 1, "type": "string" } + "user": { + "$ref": "#/components/schemas/User" + }, + "message_id": { + "title": "Message Id", + "type": "string" + }, + "user_message_id": { + "title": "User Message Id", + "type": "string" + }, + "text": { + "title": "Text", + "minLength": 1, + "type": "string" + } }, "description": "A user has replied to a message with text." }, "User": { "title": "User", - "required": ["id", "display_name", "auth_method"], + "required": [ + "id", + "display_name", + "auth_method" + ], "type": "object", "properties": { - "id": { "title": "Id", "type": "string" }, - "display_name": { "title": "Display Name", "type": "string" }, + "id": { + "title": "Id", + "type": "string" + }, + "display_name": { + "title": "Display Name", + "type": "string" + }, "auth_method": { "title": "Auth Method", - "enum": ["discord", "local"], + "enum": [ + "discord", + "local" + ], "type": "string" } } }, "ValidationError": { "title": "ValidationError", - "required": ["loc", "msg", "type"], + "required": [ + "loc", + "msg", + "type" + ], "type": "object", "properties": { "loc": { "title": "Location", "type": "array", - "items": { "anyOf": [{ "type": "string" }, { "type": "integer" }] } + "items": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "integer" + } + ] + } }, - "msg": { "title": "Message", "type": "string" }, - "type": { "title": "Error Type", "type": "string" } + "msg": { + "title": "Message", + "type": "string" + }, + "type": { + "title": "Error Type", + "type": "string" + } } } }, "securitySchemes": { - "APIKeyQuery": { "type": "apiKey", "in": "query", "name": "api_key" }, - "APIKeyHeader": { "type": "apiKey", "in": "header", "name": "X-API-Key" } + "APIKeyQuery": { + "type": "apiKey", + "in": "query", + "name": "api_key" + }, + "APIKeyHeader": { + "type": "apiKey", + "in": "header", + "name": "X-API-Key" + } } } } diff --git a/notebooks/knowledge_extraction/T5_closed_book_QA_generators.md b/notebooks/knowledge_extraction/T5_closed_book_QA_generators.md index 686cf353..0dedd56f 100644 --- a/notebooks/knowledge_extraction/T5_closed_book_QA_generators.md +++ b/notebooks/knowledge_extraction/T5_closed_book_QA_generators.md @@ -1,6 +1,8 @@ # Generate Topics, Questions, and Answers from a paragraph of text -This python code can be used to generate topics, questions, and answers from a paragraph of text. This is a good way to generate ground truth knowledge about a topic from a trusted source. +This python code can be used to generate topics, questions, and answers from a +paragraph of text. This is a good way to generate ground truth knowledge about a +topic from a trusted source. The output of this is a dictionary with the following information: @@ -9,8 +11,12 @@ The output of this is a dictionary with the following information: 3. generated questions 4. generated topic prefixes that can be prepended to the questions 5. open book answer based only on the provided paragraph -6. closed book answers generated by FLAN-T5-11B (uses only question and optionally question prefix to generate the answer) +6. closed book answers generated by FLAN-T5-11B (uses only question and + optionally question prefix to generate the answer) ## Contributing -This code is verified to work on a 24GB vram graphics card (like an RTX3090). We are working on getting it to run on google colab TPUs and also it may be possible to use smaller T5 models like the 3 billion parameter model and still get acceptable results. +This code is verified to work on a 24GB vram graphics card (like an RTX3090). We +are working on getting it to run on google colab TPUs and also it may be +possible to use smaller T5 models like the 3 billion parameter model and still +get acceptable results. diff --git a/notebooks/knowledge_extraction/T5_closed_book_QA_generators.py b/notebooks/knowledge_extraction/T5_closed_book_QA_generators.py index 26ec2e5a..d6bcac19 100644 --- a/notebooks/knowledge_extraction/T5_closed_book_QA_generators.py +++ b/notebooks/knowledge_extraction/T5_closed_book_QA_generators.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # This notebook will run on a system with a single RTX3090 (24 GB vram) GPU. # You need to install accelerate, bitsandbytes, and transformers diff --git a/scripts/backend-development/start-mock-server.sh b/scripts/backend-development/start-mock-server.sh index 35a202a6..e985d1cc 100755 --- a/scripts/backend-development/start-mock-server.sh +++ b/scripts/backend-development/start-mock-server.sh @@ -11,6 +11,9 @@ echo "Generating OpenAPI schema..." python -m main --print-openapi-schema > $OPENAPI_JSON_FILE_NAME echo "Done!" +echo "Formatting & Copying OpenAPI schema to docs directory..." +jq . $OPENAPI_JSON_FILE_NAME > ../docs/docs/api/openapi.json + # If oasst-mock-backend docker container is already running, # just restart it if [ "$(docker ps -q -f name=oasst-mock-backend)" ]; then