From 29feff0df20da5f182ba381d27a81836ce94ed35 Mon Sep 17 00:00:00 2001 From: 0xff-dev Date: Thu, 25 Apr 2024 10:39:10 +0800 Subject: [PATCH] chore: swagger syntax error --- apiserver/docs/docs.go | 246 +++++++++++++++++++++++++++++------ apiserver/docs/swagger.json | 246 +++++++++++++++++++++++++++++------ apiserver/docs/swagger.yaml | 115 +++++++++++++++- apiserver/service/chat.go | 4 +- apiserver/service/forward.go | 27 ++++ 5 files changed, 556 insertions(+), 82 deletions(-) diff --git a/apiserver/docs/docs.go b/apiserver/docs/docs.go index 0fd80a4c1..d3630b539 100644 --- a/apiserver/docs/docs.go +++ b/apiserver/docs/docs.go @@ -986,11 +986,11 @@ const docTemplate = `{ } } }, - "/chat/conversations/:conversationID": { - "delete": { - "description": "delete one conversation", + "/chat/conversations/file": { + "post": { + "description": "receive conversational files for one conversation", "consumes": [ - "application/json" + "multipart/form-data" ], "produces": [ "application/json" @@ -998,13 +998,33 @@ const docTemplate = `{ "tags": [ "application" ], - "summary": "delete one conversation", + "summary": "receive conversational files for one conversation", "parameters": [ { "type": "string", - "description": "conversationID", - "name": "conversationID", - "in": "path", + "description": "namespace this request is in", + "name": "namespace", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "The app name for this conversation", + "name": "app_name", + "in": "formData", + "required": true + }, + { + "type": "string", + "description": "The conversation id for this file", + "name": "conversation_id", + "in": "formData" + }, + { + "type": "file", + "description": "This is the file for the conversation", + "name": "file", + "in": "formData", "required": true } ], @@ -1012,7 +1032,7 @@ const docTemplate = `{ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/chat.SimpleResp" + "$ref": "#/definitions/chat.ChatRespBody" } }, "400": { @@ -1030,11 +1050,11 @@ const docTemplate = `{ } } }, - "/chat/conversations/file": { - "post": { - "description": "receive conversational files for one conversation", + "/chat/conversations/{conversationID}": { + "delete": { + "description": "delete one conversation", "consumes": [ - "multipart/form-data" + "application/json" ], "produces": [ "application/json" @@ -1042,33 +1062,13 @@ const docTemplate = `{ "tags": [ "application" ], - "summary": "receive conversational files for one conversation", + "summary": "delete one conversation", "parameters": [ { "type": "string", - "description": "namespace this request is in", - "name": "namespace", - "in": "header", - "required": true - }, - { - "type": "string", - "description": "The app name for this conversation", - "name": "app_name", - "in": "formData", - "required": true - }, - { - "type": "string", - "description": "The conversation id for this file", - "name": "conversation_id", - "in": "formData" - }, - { - "type": "file", - "description": "This is the file for the conversation", - "name": "file", - "in": "formData", + "description": "conversationID", + "name": "conversationID", + "in": "path", "required": true } ], @@ -1076,7 +1076,7 @@ const docTemplate = `{ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/chat.ChatRespBody" + "$ref": "#/definitions/chat.SimpleResp" } }, "400": { @@ -1147,7 +1147,7 @@ const docTemplate = `{ } } }, - "/chat/messages/:messageID/references": { + "/chat/messages/{messageID}/references": { "post": { "description": "get one message's references", "consumes": [ @@ -1466,6 +1466,138 @@ const docTemplate = `{ } } } + }, + "/{repo}/revisions": { + "get": { + "description": "get the revisions of the model", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "forward" + ], + "summary": "get the revisions of the model", + "parameters": [ + { + "type": "string", + "description": "model ID", + "name": "modelid", + "in": "query", + "required": true + }, + { + "type": "string", + "description": "huggingface of modelscope", + "name": "repo", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "only for huggingface", + "name": "REPOTOKEN", + "in": "header" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/forwardrepo.Revision" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + } + } + }, + "/{repo}/summary": { + "get": { + "description": "get the summary of the model", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "forward" + ], + "summary": "get the summary of the model", + "parameters": [ + { + "type": "string", + "description": "model ID", + "name": "modelid", + "in": "query", + "required": true + }, + { + "type": "string", + "description": "branch or tag, default is main", + "name": "revision", + "in": "query" + }, + { + "type": "string", + "description": "huggingface of modelscope", + "name": "repo", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "only for huggingface", + "name": "REPOTOKEN", + "in": "header" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/service.SummaryResp" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + } + } } }, "definitions": { @@ -1736,6 +1868,34 @@ const docTemplate = `{ } } }, + "forwardrepo.BranchTag": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "targetCommit": { + "type": "string" + } + } + }, + "forwardrepo.Revision": { + "type": "object", + "properties": { + "branches": { + "type": "array", + "items": { + "$ref": "#/definitions/forwardrepo.BranchTag" + } + }, + "tags": { + "type": "array", + "items": { + "$ref": "#/definitions/forwardrepo.BranchTag" + } + } + } + }, "rag.RadarData": { "type": "object", "properties": { @@ -2020,6 +2180,14 @@ const docTemplate = `{ } } }, + "service.SummaryResp": { + "type": "object", + "properties": { + "summary": { + "type": "string" + } + } + }, "service.WebCrawlerFileBody": { "type": "object", "required": [ diff --git a/apiserver/docs/swagger.json b/apiserver/docs/swagger.json index 2240b313f..541037135 100644 --- a/apiserver/docs/swagger.json +++ b/apiserver/docs/swagger.json @@ -980,11 +980,11 @@ } } }, - "/chat/conversations/:conversationID": { - "delete": { - "description": "delete one conversation", + "/chat/conversations/file": { + "post": { + "description": "receive conversational files for one conversation", "consumes": [ - "application/json" + "multipart/form-data" ], "produces": [ "application/json" @@ -992,13 +992,33 @@ "tags": [ "application" ], - "summary": "delete one conversation", + "summary": "receive conversational files for one conversation", "parameters": [ { "type": "string", - "description": "conversationID", - "name": "conversationID", - "in": "path", + "description": "namespace this request is in", + "name": "namespace", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "The app name for this conversation", + "name": "app_name", + "in": "formData", + "required": true + }, + { + "type": "string", + "description": "The conversation id for this file", + "name": "conversation_id", + "in": "formData" + }, + { + "type": "file", + "description": "This is the file for the conversation", + "name": "file", + "in": "formData", "required": true } ], @@ -1006,7 +1026,7 @@ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/chat.SimpleResp" + "$ref": "#/definitions/chat.ChatRespBody" } }, "400": { @@ -1024,11 +1044,11 @@ } } }, - "/chat/conversations/file": { - "post": { - "description": "receive conversational files for one conversation", + "/chat/conversations/{conversationID}": { + "delete": { + "description": "delete one conversation", "consumes": [ - "multipart/form-data" + "application/json" ], "produces": [ "application/json" @@ -1036,33 +1056,13 @@ "tags": [ "application" ], - "summary": "receive conversational files for one conversation", + "summary": "delete one conversation", "parameters": [ { "type": "string", - "description": "namespace this request is in", - "name": "namespace", - "in": "header", - "required": true - }, - { - "type": "string", - "description": "The app name for this conversation", - "name": "app_name", - "in": "formData", - "required": true - }, - { - "type": "string", - "description": "The conversation id for this file", - "name": "conversation_id", - "in": "formData" - }, - { - "type": "file", - "description": "This is the file for the conversation", - "name": "file", - "in": "formData", + "description": "conversationID", + "name": "conversationID", + "in": "path", "required": true } ], @@ -1070,7 +1070,7 @@ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/chat.ChatRespBody" + "$ref": "#/definitions/chat.SimpleResp" } }, "400": { @@ -1141,7 +1141,7 @@ } } }, - "/chat/messages/:messageID/references": { + "/chat/messages/{messageID}/references": { "post": { "description": "get one message's references", "consumes": [ @@ -1460,6 +1460,138 @@ } } } + }, + "/{repo}/revisions": { + "get": { + "description": "get the revisions of the model", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "forward" + ], + "summary": "get the revisions of the model", + "parameters": [ + { + "type": "string", + "description": "model ID", + "name": "modelid", + "in": "query", + "required": true + }, + { + "type": "string", + "description": "huggingface of modelscope", + "name": "repo", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "only for huggingface", + "name": "REPOTOKEN", + "in": "header" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/forwardrepo.Revision" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + } + } + }, + "/{repo}/summary": { + "get": { + "description": "get the summary of the model", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "forward" + ], + "summary": "get the summary of the model", + "parameters": [ + { + "type": "string", + "description": "model ID", + "name": "modelid", + "in": "query", + "required": true + }, + { + "type": "string", + "description": "branch or tag, default is main", + "name": "revision", + "in": "query" + }, + { + "type": "string", + "description": "huggingface of modelscope", + "name": "repo", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "only for huggingface", + "name": "REPOTOKEN", + "in": "header" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/service.SummaryResp" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + } + } } }, "definitions": { @@ -1730,6 +1862,34 @@ } } }, + "forwardrepo.BranchTag": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "targetCommit": { + "type": "string" + } + } + }, + "forwardrepo.Revision": { + "type": "object", + "properties": { + "branches": { + "type": "array", + "items": { + "$ref": "#/definitions/forwardrepo.BranchTag" + } + }, + "tags": { + "type": "array", + "items": { + "$ref": "#/definitions/forwardrepo.BranchTag" + } + } + } + }, "rag.RadarData": { "type": "object", "properties": { @@ -2014,6 +2174,14 @@ } } }, + "service.SummaryResp": { + "type": "object", + "properties": { + "summary": { + "type": "string" + } + } + }, "service.WebCrawlerFileBody": { "type": "object", "required": [ diff --git a/apiserver/docs/swagger.yaml b/apiserver/docs/swagger.yaml index 5ff9919d0..b4eed4e8f 100644 --- a/apiserver/docs/swagger.yaml +++ b/apiserver/docs/swagger.yaml @@ -192,6 +192,24 @@ definitions: version: type: string type: object + forwardrepo.BranchTag: + properties: + name: + type: string + targetCommit: + type: string + type: object + forwardrepo.Revision: + properties: + branches: + items: + $ref: '#/definitions/forwardrepo.BranchTag' + type: array + tags: + items: + $ref: '#/definitions/forwardrepo.BranchTag' + type: array + type: object rag.RadarData: properties: color: @@ -386,6 +404,11 @@ definitions: uploadID: type: string type: object + service.SummaryResp: + properties: + summary: + type: string + type: object service.WebCrawlerFileBody: properties: datasource: @@ -515,6 +538,94 @@ info: title: ApiServer Swagger API version: "1.0" paths: + /{repo}/revisions: + get: + consumes: + - application/json + description: get the revisions of the model + parameters: + - description: model ID + in: query + name: modelid + required: true + type: string + - description: huggingface of modelscope + in: path + name: repo + required: true + type: string + - description: only for huggingface + in: header + name: REPOTOKEN + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/forwardrepo.Revision' + "400": + description: Bad Request + schema: + additionalProperties: + type: string + type: object + "500": + description: Internal Server Error + schema: + additionalProperties: + type: string + type: object + summary: get the revisions of the model + tags: + - forward + /{repo}/summary: + get: + consumes: + - application/json + description: get the summary of the model + parameters: + - description: model ID + in: query + name: modelid + required: true + type: string + - description: branch or tag, default is main + in: query + name: revision + type: string + - description: huggingface of modelscope + in: path + name: repo + required: true + type: string + - description: only for huggingface + in: header + name: REPOTOKEN + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/service.SummaryResp' + "400": + description: Bad Request + schema: + additionalProperties: + type: string + type: object + "500": + description: Internal Server Error + schema: + additionalProperties: + type: string + type: object + summary: get the summary of the model + tags: + - forward /bff/icon: get: consumes: @@ -1163,7 +1274,7 @@ paths: summary: list all conversations tags: - application - /chat/conversations/:conversationID: + /chat/conversations/{conversationID}: delete: consumes: - application/json @@ -1270,7 +1381,7 @@ paths: summary: get all messages history for one conversation tags: - application - /chat/messages/:messageID/references: + /chat/messages/{messageID}/references: post: consumes: - application/json diff --git a/apiserver/service/chat.go b/apiserver/service/chat.go index 5a12ec6cb..52aa46122 100644 --- a/apiserver/service/chat.go +++ b/apiserver/service/chat.go @@ -299,7 +299,7 @@ func (cs *ChatService) ListConversationHandler() gin.HandlerFunc { // @Success 200 {object} chat.SimpleResp // @Failure 400 {object} chat.ErrorResp // @Failure 500 {object} chat.ErrorResp -// @Router /chat/conversations/:conversationID [delete] +// @Router /chat/conversations/{conversationID} [delete] func (cs *ChatService) DeleteConversationHandler() gin.HandlerFunc { return func(c *gin.Context) { conversationID := c.Param("conversationID") @@ -364,7 +364,7 @@ func (cs *ChatService) HistoryHandler() gin.HandlerFunc { // @Success 200 {object} []retriever.Reference // @Failure 400 {object} chat.ErrorResp // @Failure 500 {object} chat.ErrorResp -// @Router /chat/messages/:messageID/references [post] +// @Router /chat/messages/{messageID}/references [post] func (cs *ChatService) ReferenceHandler() gin.HandlerFunc { return func(c *gin.Context) { messageID := c.Param("messageID") diff --git a/apiserver/service/forward.go b/apiserver/service/forward.go index 9bc0ca870..70bd1c7ad 100644 --- a/apiserver/service/forward.go +++ b/apiserver/service/forward.go @@ -52,6 +52,20 @@ type ( } ) +// @Summary get the summary of the model +// @Schemes +// @Description get the summary of the model +// @Tags forward +// @Accept json +// @Produce json +// @Param modelid query string true "model ID" +// @Param revision query string false "branch or tag, default is main" +// @Param repo path string true "huggingface of modelscope" +// @Param REPOTOKEN header string false "only for huggingface" +// @Success 200 {object} SummaryResp +// @Failure 400 {object} map[string]string +// @Failure 500 {object} map[string]string +// @Router /{repo}/summary [get] func (f *FrowarAPI) Summary(ctx *gin.Context) { modelID := ctx.Query(queryModelID) revision := ctx.DefaultQuery(queryParamRevision, "main") @@ -96,6 +110,19 @@ func (f *FrowarAPI) Summary(ctx *gin.Context) { }) } +// @Summary get the revisions of the model +// @Schemes +// @Description get the revisions of the model +// @Tags forward +// @Accept json +// @Produce json +// @Param modelid query string true "model ID" +// @Param repo path string true "huggingface of modelscope" +// @Param REPOTOKEN header string false "only for huggingface" +// @Success 200 {object} forwardrepo.Revision +// @Failure 400 {object} map[string]string +// @Failure 500 {object} map[string]string +// @Router /{repo}/revisions [get] func (f *FrowarAPI) Revisions(ctx *gin.Context) { modelID := ctx.Query(queryModelID) repo := ctx.Param(pathParamRepo)