chore: import upstream snapshot with attribution
This commit is contained in:
@@ -0,0 +1,229 @@
|
||||
/*
|
||||
* Copyright 2025 coze-dev Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package coze
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"net/http"
|
||||
|
||||
"github.com/hertz-contrib/sse"
|
||||
|
||||
"github.com/cloudwego/hertz/pkg/app"
|
||||
"github.com/cloudwego/hertz/pkg/protocol/consts"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/conversation/run"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/application/conversation"
|
||||
sseImpl "github.com/coze-dev/coze-studio/backend/infra/sse/impl/sse"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/errorx"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
|
||||
"github.com/coze-dev/coze-studio/backend/types/errno"
|
||||
)
|
||||
|
||||
// AgentRun .
|
||||
// @router /api/conversation/chat [POST]
|
||||
func AgentRun(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req run.AgentRunRequest
|
||||
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if checkErr := checkParams(ctx, &req); checkErr != nil {
|
||||
invalidParamRequestResponse(c, checkErr.Error())
|
||||
return
|
||||
}
|
||||
|
||||
sseSender := sseImpl.NewSSESender(sse.NewStream(c))
|
||||
c.SetStatusCode(http.StatusOK)
|
||||
c.Response.Header.Set("X-Accel-Buffering", "no")
|
||||
|
||||
err = conversation.ConversationSVC.Run(ctx, sseSender, &req)
|
||||
if err != nil {
|
||||
errData := run.ErrorData{
|
||||
Code: errno.ErrConversationAgentRunError,
|
||||
Msg: err.Error(),
|
||||
}
|
||||
ed, _ := json.Marshal(errData)
|
||||
_ = sseSender.Send(ctx, &sse.Event{
|
||||
Event: run.RunEventError,
|
||||
Data: ed,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func checkParams(_ context.Context, ar *run.AgentRunRequest) error {
|
||||
if ar.BotID == 0 {
|
||||
return errorx.New(errno.ErrConversationInvalidParamCode, errorx.KV("msg", "bot id is required"))
|
||||
}
|
||||
|
||||
if ar.Scene == nil {
|
||||
return errorx.New(errno.ErrConversationInvalidParamCode, errorx.KV("msg", "scene is required"))
|
||||
}
|
||||
|
||||
if ar.ContentType == nil {
|
||||
ar.ContentType = ptr.Of(run.ContentTypeText)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// ChatV3 .
|
||||
// @router /v3/chat [POST]
|
||||
func ChatV3(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req run.ChatV3Request
|
||||
|
||||
// Pre-process parameters field: convert JSON object to string if needed
|
||||
if err = preprocessChatV3Parameters(c); err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
if checkErr := checkParamsV3(ctx, &req); checkErr != nil {
|
||||
invalidParamRequestResponse(c, checkErr.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if req.Stream != nil && !*req.Stream {
|
||||
|
||||
resp, err := conversation.ConversationOpenAPISVC.OpenapiAgentRunSync(ctx, &req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
return
|
||||
}
|
||||
|
||||
// Streaming mode (default)
|
||||
c.SetStatusCode(http.StatusOK)
|
||||
c.Response.Header.Set("X-Accel-Buffering", "no")
|
||||
sseSender := sseImpl.NewSSESender(sse.NewStream(c))
|
||||
err = conversation.ConversationOpenAPISVC.OpenapiAgentRun(ctx, sseSender, &req)
|
||||
if err != nil {
|
||||
errData := run.ErrorData{
|
||||
Code: errno.ErrConversationAgentRunError,
|
||||
Msg: err.Error(),
|
||||
}
|
||||
ed, _ := json.Marshal(errData)
|
||||
_ = sseSender.Send(ctx, &sse.Event{
|
||||
Event: run.RunEventError,
|
||||
Data: ed,
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func checkParamsV3(_ context.Context, ar *run.ChatV3Request) error {
|
||||
if ar.BotID == 0 {
|
||||
return errorx.New(errno.ErrConversationInvalidParamCode, errorx.KV("msg", "bot id is required"))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// CancelChatApi .
|
||||
// @router /v3/chat/cancel [POST]
|
||||
func CancelChatApi(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req run.CancelChatApiRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := conversation.ConversationOpenAPISVC.CancelRun(ctx, &req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// preprocessChatV3Parameters handles the conversion of parameters field from JSON object to string
|
||||
func preprocessChatV3Parameters(c *app.RequestContext) error {
|
||||
// Get the raw request body
|
||||
body := c.Request.Body()
|
||||
if len(body) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Parse the JSON body
|
||||
var requestData map[string]interface{}
|
||||
if err := json.Unmarshal(body, &requestData); err != nil {
|
||||
return nil // If it's not valid JSON, let BindAndValidate handle the error
|
||||
}
|
||||
|
||||
// Check if parameters field exists and is an object
|
||||
if parametersValue, exists := requestData["parameters"]; exists {
|
||||
// If parameters is already a string, no conversion needed
|
||||
if _, isString := parametersValue.(string); isString {
|
||||
return errors.New("parameters field should be an object, not a string")
|
||||
}
|
||||
|
||||
// If parameters is an object, convert it to JSON string
|
||||
if parametersObj, isObject := parametersValue.(map[string]interface{}); isObject {
|
||||
parametersJSON, err := json.Marshal(parametersObj)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
requestData["parameters"] = string(parametersJSON)
|
||||
|
||||
// Update the request body with the modified data
|
||||
modifiedBody, err := json.Marshal(requestData)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Replace the request body
|
||||
c.Request.SetBody(modifiedBody)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// RetrieveChatOpen .
|
||||
// @router /v3/chat/retrieve [GET]
|
||||
func RetrieveChatOpen(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req run.RetrieveChatOpenRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := conversation.ConversationOpenAPISVC.RetrieveRunRecord(ctx, &req)
|
||||
if err != nil {
|
||||
c.String(consts.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright 2025 coze-dev Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package coze
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/cloudwego/hertz/pkg/app"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/api/internal/httputil"
|
||||
)
|
||||
|
||||
func invalidParamRequestResponse(c *app.RequestContext, errMsg string) {
|
||||
httputil.BadRequest(c, errMsg)
|
||||
}
|
||||
|
||||
func internalServerErrorResponse(ctx context.Context, c *app.RequestContext, err error) {
|
||||
httputil.InternalError(ctx, c, err)
|
||||
}
|
||||
@@ -0,0 +1,153 @@
|
||||
/*
|
||||
* Copyright 2025 coze-dev Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by hertz generator.
|
||||
|
||||
package coze
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
openapiauthApp "github.com/coze-dev/coze-studio/backend/application/openauth"
|
||||
"github.com/coze-dev/coze-studio/backend/application/plugin"
|
||||
"github.com/coze-dev/coze-studio/backend/application/singleagent"
|
||||
"github.com/coze-dev/coze-studio/backend/application/upload"
|
||||
"github.com/coze-dev/coze-studio/backend/bizpkg/config"
|
||||
|
||||
"github.com/cloudwego/hertz/pkg/app"
|
||||
"github.com/cloudwego/hertz/pkg/protocol/consts"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/app/bot_open_api"
|
||||
)
|
||||
|
||||
// OauthAuthorizationCode .
|
||||
// @router /api/oauth/authorization_code [GET]
|
||||
func OauthAuthorizationCode(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req bot_open_api.OauthAuthorizationCodeReq
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if req.Code == "" {
|
||||
invalidParamRequestResponse(c, "authorization failed, code is required")
|
||||
return
|
||||
}
|
||||
if req.State == "" {
|
||||
invalidParamRequestResponse(c, "state is required")
|
||||
return
|
||||
}
|
||||
|
||||
_, err = plugin.PluginApplicationSVC.OauthAuthorizationCode(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
host, err := config.Base().GetServerHost(ctx)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
redirectURL := fmt.Sprintf("%s/information/auth/success", host)
|
||||
c.Redirect(consts.StatusFound, []byte(redirectURL))
|
||||
c.Abort()
|
||||
}
|
||||
|
||||
// UploadFileOpen .
|
||||
// @router /v1/files/upload [POST]
|
||||
func UploadFileOpen(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req bot_open_api.UploadFileOpenRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp := new(bot_open_api.UploadFileOpenResponse)
|
||||
resp, err = upload.SVC.UploadFileOpen(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// GetBotOnlineInfo .
|
||||
// @router /v1/bot/get_online_info [GET]
|
||||
func GetBotOnlineInfo(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req bot_open_api.GetBotOnlineInfoReq
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := singleagent.SingleAgentSVC.GetAgentOnlineInfo(ctx, &req)
|
||||
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// ImpersonateCozeUser .
|
||||
// @router /api/permission_api/coze_web_app/impersonate_coze_user [POST]
|
||||
func ImpersonateCozeUser(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req bot_open_api.ImpersonateCozeUserRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := openapiauthApp.OpenAuthApplication.ImpersonateCozeUserAccessToken(ctx, &req)
|
||||
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// OpenGetBotInfo .
|
||||
// @router /v1/bots/:bot_id [GET]
|
||||
func OpenGetBotInfo(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req bot_open_api.OpenGetBotInfoRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := singleagent.SingleAgentSVC.OpenGetBotInfo(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
@@ -0,0 +1,292 @@
|
||||
// Code generated by hertz generator.
|
||||
|
||||
package coze
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/cloudwego/eino/schema"
|
||||
"github.com/cloudwego/hertz/pkg/app"
|
||||
"github.com/cloudwego/hertz/pkg/protocol/consts"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/admin/config"
|
||||
bizConf "github.com/coze-dev/coze-studio/backend/bizpkg/config"
|
||||
"github.com/coze-dev/coze-studio/backend/bizpkg/config/modelmgr"
|
||||
"github.com/coze-dev/coze-studio/backend/bizpkg/llm/modelbuilder"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/embedding/impl"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/conv"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/logs"
|
||||
)
|
||||
|
||||
// GetBasicConfiguration .
|
||||
// @router /api/admin/config/basic/get [GET]
|
||||
func GetBasicConfiguration(ctx context.Context, c *app.RequestContext) {
|
||||
baseConfig, err := bizConf.Base().GetBaseConfig(ctx)
|
||||
if err != nil {
|
||||
c.String(consts.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp := new(config.GetBasicConfigurationResp)
|
||||
resp.Configuration = baseConfig
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// SaveBasicConfiguration .
|
||||
// @router /api/admin/config/basic/save [POST]
|
||||
func SaveBasicConfiguration(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req config.SaveBasicConfigurationReq
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
c.String(consts.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if req.Configuration == nil {
|
||||
invalidParamRequestResponse(c, "Configuration is nil")
|
||||
return
|
||||
}
|
||||
|
||||
// TODO: check coze api token
|
||||
|
||||
// Validate ServerHost: allow http/https URLs, or hostname:port
|
||||
if req.Configuration.ServerHost == "" {
|
||||
invalidParamRequestResponse(c, "ServerHost is empty")
|
||||
return
|
||||
}
|
||||
|
||||
host := req.Configuration.ServerHost
|
||||
if strings.Contains(host, "://") {
|
||||
u, parseErr := url.Parse(host)
|
||||
if parseErr != nil || u.Host == "" || (u.Scheme != "http" && u.Scheme != "https") {
|
||||
invalidParamRequestResponse(c, "ServerHost is invalid URL, require http/https")
|
||||
return
|
||||
}
|
||||
} else {
|
||||
// Expect hostname:port format
|
||||
h, p, splitErr := net.SplitHostPort(host)
|
||||
if splitErr != nil || h == "" {
|
||||
invalidParamRequestResponse(c, "ServerHost must be hostname:port or http(s) URL")
|
||||
return
|
||||
}
|
||||
port, portErr := strconv.Atoi(p)
|
||||
if portErr != nil || port <= 0 || port > 65535 {
|
||||
invalidParamRequestResponse(c, "ServerHost port is invalid")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
logs.Infof("server host is valid %s", req.Configuration.ServerHost)
|
||||
|
||||
if req.Configuration.CodeRunnerType.String() == "<UNSET>" {
|
||||
invalidParamRequestResponse(c, "CodeRunnerType is invalid")
|
||||
return
|
||||
}
|
||||
|
||||
err = bizConf.Base().SaveBaseConfig(ctx, req.Configuration)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, fmt.Errorf("save basic config failed: %w", err))
|
||||
return
|
||||
}
|
||||
|
||||
resp := new(config.SaveBasicConfigurationResp)
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// GetKnowledgeConfig .
|
||||
// @router /api/admin/config/knowledge/get [GET]
|
||||
func GetKnowledgeConfig(ctx context.Context, c *app.RequestContext) {
|
||||
knowledgeConfig, err := bizConf.Knowledge().GetKnowledgeConfig(ctx)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, fmt.Errorf("get knowledge config failed: %w", err))
|
||||
return
|
||||
}
|
||||
|
||||
resp := new(config.GetKnowledgeConfigResp)
|
||||
resp.KnowledgeConfig = knowledgeConfig
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// UpdateKnowledgeConfig .
|
||||
// @router /api/admin/config/knowledge/save [POST]
|
||||
func UpdateKnowledgeConfig(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req config.UpdateKnowledgeConfigReq
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
c.String(consts.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if req.KnowledgeConfig == nil {
|
||||
invalidParamRequestResponse(c, "KnowledgeConfig is nil")
|
||||
return
|
||||
}
|
||||
|
||||
if req.KnowledgeConfig.EmbeddingConfig == nil {
|
||||
invalidParamRequestResponse(c, "EmbeddingConfig is nil")
|
||||
return
|
||||
}
|
||||
|
||||
if req.KnowledgeConfig.EmbeddingConfig.Connection == nil {
|
||||
invalidParamRequestResponse(c, "Connection is nil")
|
||||
return
|
||||
}
|
||||
|
||||
if req.KnowledgeConfig.EmbeddingConfig.Connection.EmbeddingInfo == nil {
|
||||
invalidParamRequestResponse(c, "EmbeddingInfo is nil")
|
||||
return
|
||||
}
|
||||
|
||||
embedding, err := impl.GetEmbedding(ctx, req.KnowledgeConfig.EmbeddingConfig)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, fmt.Sprintf("get embedding failed: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
if req.KnowledgeConfig.EmbeddingConfig.Connection.EmbeddingInfo.Dims <= 0 {
|
||||
req.KnowledgeConfig.EmbeddingConfig.Connection.EmbeddingInfo.Dims = int32(embedding.Dimensions())
|
||||
|
||||
embedding, err = impl.GetEmbedding(ctx, req.KnowledgeConfig.EmbeddingConfig)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, fmt.Sprintf("get embedding failed: %v", err))
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
denseEmbeddings, err := embedding.EmbedStrings(ctx, []string{"test"})
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, fmt.Sprintf("embed test string failed: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
if len(denseEmbeddings) == 0 {
|
||||
invalidParamRequestResponse(c, fmt.Sprintf("embed test string failed: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
logs.CtxDebugf(ctx, "embed test string result: %d, expect %d",
|
||||
len(denseEmbeddings[0]), req.KnowledgeConfig.EmbeddingConfig.Connection.EmbeddingInfo.Dims)
|
||||
if len(denseEmbeddings[0]) != int(req.KnowledgeConfig.EmbeddingConfig.Connection.EmbeddingInfo.Dims) {
|
||||
invalidParamRequestResponse(c, fmt.Sprintf("embed test string failed: dims not match, expect %d, got %d",
|
||||
req.KnowledgeConfig.EmbeddingConfig.Connection.EmbeddingInfo.Dims, len(denseEmbeddings[0])))
|
||||
return
|
||||
}
|
||||
|
||||
err = bizConf.Knowledge().SaveKnowledgeConfig(ctx, req.KnowledgeConfig)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, fmt.Errorf("save knowledge config failed: %w", err))
|
||||
return
|
||||
}
|
||||
|
||||
resp := new(config.UpdateKnowledgeConfigResp)
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// GetModelList .
|
||||
// @router /api/admin/config/model/list [GET]
|
||||
func GetModelList(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req config.GetModelListReq
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
c.String(consts.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
modelList, err := bizConf.ModelConf().GetProviderModelList(ctx)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, fmt.Errorf("get model list failed: %w", err))
|
||||
return
|
||||
}
|
||||
|
||||
resp := new(config.GetModelListResp)
|
||||
resp.ProviderModelList = modelList
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// CreateModel .
|
||||
// @router /api/admin/config/model/create [POST]
|
||||
func CreateModel(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req config.CreateModelReq
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
c.String(consts.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
modelBuilder, err := modelbuilder.NewModelBuilder(req.ModelClass, &config.Model{
|
||||
EnableBase64URL: req.EnableBase64URL,
|
||||
Connection: req.Connection,
|
||||
})
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, fmt.Sprintf("create model builder failed: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
logs.CtxDebugf(ctx, "create model req: %s, conn: %s", conv.DebugJsonToStr(req), conv.DebugJsonToStr(req.Connection.BaseConnInfo))
|
||||
|
||||
chatModel, err := modelBuilder.Build(ctx, &modelbuilder.LLMParams{EnableThinking: ptr.Of(false)})
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, fmt.Sprintf("build model failed: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
respMsgs, err := chatModel.Generate(ctx, []*schema.Message{
|
||||
schema.SystemMessage("Just answer with a number, no explanation."),
|
||||
schema.UserMessage("1+1=?"),
|
||||
})
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, fmt.Sprintf("generate model failed: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
logs.CtxDebugf(ctx, "chatModel.Generate resp : %s", conv.DebugJsonToStr(respMsgs))
|
||||
|
||||
id, err := bizConf.ModelConf().CreateModel(ctx, req.ModelClass, req.ModelName, req.Connection, &modelmgr.ModelExtra{
|
||||
EnableBase64URL: req.EnableBase64URL,
|
||||
})
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, fmt.Sprintf("create model failed: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
resp := new(config.CreateModelResp)
|
||||
resp.ID = id
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// DeleteModel .
|
||||
// @router /api/admin/config/model/delete [POST]
|
||||
func DeleteModel(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req config.DeleteModelReq
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
c.String(consts.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
err = bizConf.ModelConf().DeleteModel(ctx, req.ID)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, fmt.Errorf("delete model failed: %w", err))
|
||||
return
|
||||
}
|
||||
|
||||
resp := new(config.DeleteModelResp)
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
@@ -0,0 +1,231 @@
|
||||
/*
|
||||
* Copyright 2025 coze-dev Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by hertz generator.
|
||||
|
||||
package coze
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/cloudwego/hertz/pkg/app"
|
||||
"github.com/cloudwego/hertz/pkg/protocol/consts"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/conversation/conversation"
|
||||
application "github.com/coze-dev/coze-studio/backend/application/conversation"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/errorx"
|
||||
"github.com/coze-dev/coze-studio/backend/types/errno"
|
||||
)
|
||||
|
||||
// ClearConversationHistory .
|
||||
// @router /api/conversation/clear_message [POST]
|
||||
func ClearConversationHistory(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req conversation.ClearConversationHistoryRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if checkErr := checkCCHParams(ctx, &req); checkErr != nil {
|
||||
invalidParamRequestResponse(c, checkErr.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := application.ConversationSVC.ClearHistory(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
func checkCCHParams(_ context.Context, req *conversation.ClearConversationHistoryRequest) error {
|
||||
if req.ConversationID <= 0 {
|
||||
return errorx.New(errno.ErrConversationInvalidParamCode, errorx.KV("msg", "invalid conversation id"))
|
||||
}
|
||||
|
||||
if req.Scene == nil {
|
||||
return errorx.New(errno.ErrConversationInvalidParamCode, errorx.KV("msg", "scene is required"))
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// ClearConversationCtx .
|
||||
// @router /api/conversation/create_section [POST]
|
||||
func ClearConversationCtx(ctx context.Context, c *app.RequestContext) {
|
||||
resp := new(conversation.ClearConversationCtxResponse)
|
||||
var err error
|
||||
var req conversation.ClearConversationCtxRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if checkErr := checkCCCParams(ctx, &req); checkErr != nil {
|
||||
invalidParamRequestResponse(c, checkErr.Error())
|
||||
return
|
||||
}
|
||||
|
||||
newSectionID, err := application.ConversationSVC.CreateSection(ctx, req.ConversationID)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
resp.NewSectionID = newSectionID
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
func checkCCCParams(ctx context.Context, req *conversation.ClearConversationCtxRequest) error {
|
||||
if req.ConversationID <= 0 {
|
||||
return errorx.New(errno.ErrConversationInvalidParamCode, errorx.KV("msg", "invalid conversation id"))
|
||||
}
|
||||
|
||||
if req.Scene == nil {
|
||||
return errorx.New(errno.ErrConversationInvalidParamCode, errorx.KV("msg", "scene is required"))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// CreateConversation .
|
||||
// @router /api/conversation/create [POST]
|
||||
func CreateConversation(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req conversation.CreateConversationRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := application.ConversationSVC.CreateConversation(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// ClearConversationApi .
|
||||
// @router /v1/conversations/:conversation_id/clear [POST]
|
||||
func ClearConversationApi(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req conversation.ClearConversationApiRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp := new(conversation.ClearConversationApiResponse)
|
||||
|
||||
sectionID, err := application.ConversationSVC.CreateSection(ctx, req.ConversationID)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
resp.Data = &conversation.Section{
|
||||
ID: sectionID,
|
||||
ConversationID: req.ConversationID,
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// ListConversationsApi .
|
||||
// @router /v1/conversations [GET]
|
||||
func ListConversationsApi(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req conversation.ListConversationsApiRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := application.ConversationSVC.ListConversation(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// UpdateConversationApi .
|
||||
// @router /v1/conversations/:conversation_id [PUT]
|
||||
func UpdateConversationApi(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req conversation.UpdateConversationApiRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := application.ConversationSVC.UpdateConversation(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// DeleteConversationApi .
|
||||
// @router /v1/conversations/:conversation_id [DELETE]
|
||||
func DeleteConversationApi(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req conversation.DeleteConversationApiRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
resp, err := application.ConversationSVC.DeleteConversation(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// RetrieveConversationApi .
|
||||
// @router /v1/conversation/retrieve [GET]
|
||||
func RetrieveConversationApi(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req conversation.RetrieveConversationApiRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := application.ConversationSVC.RetrieveConversation(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
@@ -0,0 +1,412 @@
|
||||
/*
|
||||
* Copyright 2025 coze-dev Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by hertz generator.
|
||||
|
||||
package coze
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/cloudwego/hertz/pkg/app"
|
||||
"github.com/cloudwego/hertz/pkg/protocol/consts"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/data/database/table"
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/data/knowledge"
|
||||
"github.com/coze-dev/coze-studio/backend/application/memory"
|
||||
"github.com/coze-dev/coze-studio/backend/application/singleagent"
|
||||
)
|
||||
|
||||
// ListDatabase .
|
||||
// @router /api/memory/database/list [POST]
|
||||
func ListDatabase(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req table.ListDatabaseRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := memory.DatabaseApplicationSVC.ListDatabase(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// GetDatabaseByID .
|
||||
// @router /api/memory/database/get_by_id [POST]
|
||||
func GetDatabaseByID(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req table.SingleDatabaseRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := memory.DatabaseApplicationSVC.GetDatabaseByID(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// AddDatabase .
|
||||
// @router /api/memory/database/add [POST]
|
||||
func AddDatabase(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req table.AddDatabaseRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := memory.DatabaseApplicationSVC.AddDatabase(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// UpdateDatabase .
|
||||
// @router /api/memory/database/update [POST]
|
||||
func UpdateDatabase(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req table.UpdateDatabaseRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := memory.DatabaseApplicationSVC.UpdateDatabase(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// DeleteDatabase .
|
||||
// @router /api/memory/database/delete [POST]
|
||||
func DeleteDatabase(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req table.DeleteDatabaseRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := memory.DatabaseApplicationSVC.DeleteDatabase(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// BindDatabase .
|
||||
// @router /api/memory/database/bind_to_bot [POST]
|
||||
func BindDatabase(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req table.BindDatabaseToBotRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := singleagent.SingleAgentSVC.BindDatabase(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// UnBindDatabase .
|
||||
// @router /api/memory/database/unbind_to_bot [POST]
|
||||
func UnBindDatabase(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req table.BindDatabaseToBotRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := singleagent.SingleAgentSVC.UnBindDatabase(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// ListDatabaseRecords .
|
||||
// @router /api/memory/database/list_records [POST]
|
||||
func ListDatabaseRecords(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req table.ListDatabaseRecordsRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := memory.DatabaseApplicationSVC.ListDatabaseRecords(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// UpdateDatabaseRecords .
|
||||
// @router /api/memory/database/update_records [POST]
|
||||
func UpdateDatabaseRecords(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req table.UpdateDatabaseRecordsRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := memory.DatabaseApplicationSVC.UpdateDatabaseRecords(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// GetOnlineDatabaseId .
|
||||
// @router /api/memory/database/get_online_database_id [POST]
|
||||
func GetOnlineDatabaseId(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req table.GetOnlineDatabaseIdRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := memory.DatabaseApplicationSVC.GetOnlineDatabaseId(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// ResetBotTable .
|
||||
// @router /api/memory/database/table/reset [POST]
|
||||
func ResetBotTable(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req table.ResetBotTableRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := memory.DatabaseApplicationSVC.ResetBotTable(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// GetDatabaseTemplate .
|
||||
// @router /api/memory/database/get_template [POST]
|
||||
func GetDatabaseTemplate(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req table.GetDatabaseTemplateRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := memory.DatabaseApplicationSVC.GetDatabaseTemplate(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// GetConnectorName .
|
||||
// @router /api/memory/database/get_connector_name [POST]
|
||||
func GetConnectorName(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req table.GetSpaceConnectorListRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := memory.DatabaseApplicationSVC.GetConnectorName(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// GetBotDatabase .
|
||||
// @router /api/memory/database/table/list_new [POST]
|
||||
func GetBotDatabase(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req table.GetBotTableRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := memory.DatabaseApplicationSVC.GetBotDatabase(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// UpdateDatabaseBotSwitch .
|
||||
// @router /api/memory/database/update_bot_switch [POST]
|
||||
func UpdateDatabaseBotSwitch(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req table.UpdateDatabaseBotSwitchRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := singleagent.SingleAgentSVC.UpdatePromptDisable(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// GetDatabaseTableSchema .
|
||||
// @router /api/memory/table_schema/get [POST]
|
||||
func GetDatabaseTableSchema(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req table.GetTableSchemaRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
var resp *knowledge.GetTableSchemaInfoResponse
|
||||
resp, err = memory.DatabaseApplicationSVC.GetDatabaseTableSchema(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// SubmitDatabaseInsertTask .
|
||||
// @router /api/memory/table_file/submit [POST]
|
||||
func SubmitDatabaseInsertTask(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req table.SubmitDatabaseInsertRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := memory.DatabaseApplicationSVC.SubmitDatabaseInsertTask(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// DatabaseFileProgressData .
|
||||
// @router /api/memory/table_file/get_progress [POST]
|
||||
func DatabaseFileProgressData(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req table.GetDatabaseFileProgressRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := memory.DatabaseApplicationSVC.DatabaseFileProgressData(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// ValidateDatabaseTableSchema .
|
||||
// @router /api/memory/table_schema/validate [POST]
|
||||
func ValidateDatabaseTableSchema(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req table.ValidateTableSchemaRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := memory.DatabaseApplicationSVC.ValidateDatabaseTableSchema(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
@@ -0,0 +1,494 @@
|
||||
/*
|
||||
* Copyright 2025 coze-dev Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by hertz generator.
|
||||
|
||||
package coze
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/sha256"
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"time"
|
||||
"unicode/utf8"
|
||||
|
||||
"github.com/cloudwego/hertz/pkg/app"
|
||||
"github.com/cloudwego/hertz/pkg/protocol/consts"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/app/developer_api"
|
||||
"github.com/coze-dev/coze-studio/backend/application/base/ctxutil"
|
||||
"github.com/coze-dev/coze-studio/backend/application/modelmgr"
|
||||
"github.com/coze-dev/coze-studio/backend/application/plugin"
|
||||
"github.com/coze-dev/coze-studio/backend/application/singleagent"
|
||||
application "github.com/coze-dev/coze-studio/backend/application/singleagent"
|
||||
"github.com/coze-dev/coze-studio/backend/application/upload"
|
||||
"github.com/coze-dev/coze-studio/backend/application/user"
|
||||
"github.com/coze-dev/coze-studio/backend/bizpkg/config"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/errorx"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
|
||||
"github.com/coze-dev/coze-studio/backend/types/errno"
|
||||
)
|
||||
|
||||
// DraftBotCreate .
|
||||
// @router /api/draftbot/create [POST]
|
||||
func DraftBotCreate(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req developer_api.DraftBotCreateRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if req.SpaceID <= 0 {
|
||||
invalidParamRequestResponse(c, "space id is not set")
|
||||
return
|
||||
}
|
||||
|
||||
if req.Name == "" {
|
||||
invalidParamRequestResponse(c, "name is nil")
|
||||
return
|
||||
}
|
||||
|
||||
if req.IconURI == "" {
|
||||
invalidParamRequestResponse(c, "icon uri is nil")
|
||||
return
|
||||
}
|
||||
|
||||
if utf8.RuneCountInString(req.Name) > 50 {
|
||||
invalidParamRequestResponse(c, "name is too long")
|
||||
return
|
||||
}
|
||||
|
||||
if utf8.RuneCountInString(req.Description) > 2000 {
|
||||
invalidParamRequestResponse(c, "description is too long")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := application.SingleAgentSVC.CreateSingleAgentDraft(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// DeleteDraftBot .
|
||||
// @router /api/draftbot/delete [POST]
|
||||
func DeleteDraftBot(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req developer_api.DeleteDraftBotRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := application.SingleAgentSVC.DeleteAgentDraft(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// UpdateDraftBotDisplayInfo .
|
||||
// @router /api/draftbot/update_display_info [POST]
|
||||
func UpdateDraftBotDisplayInfo(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req developer_api.UpdateDraftBotDisplayInfoRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
c.String(consts.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := application.SingleAgentSVC.UpdateAgentDraftDisplayInfo(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// DuplicateDraftBot .
|
||||
// @router /api/draftbot/duplicate [POST]
|
||||
func DuplicateDraftBot(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req developer_api.DuplicateDraftBotRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := application.SingleAgentSVC.DuplicateDraftBot(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// GetDraftBotDisplayInfo .
|
||||
// @router /api/draftbot/get_display_info [POST]
|
||||
func GetDraftBotDisplayInfo(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req developer_api.GetDraftBotDisplayInfoRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
c.String(consts.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := application.SingleAgentSVC.GetAgentDraftDisplayInfo(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// PublishDraftBot .
|
||||
// @router /api/draftbot/publish [POST]
|
||||
func PublishDraftBot(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req developer_api.PublishDraftBotRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
c.String(consts.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if len(req.Connectors) == 0 {
|
||||
invalidParamRequestResponse(c, "connectors is nil")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := application.SingleAgentSVC.PublishAgent(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// ListDraftBotHistory .
|
||||
// @router /api/draftbot/list_draft_history [POST]
|
||||
func ListDraftBotHistory(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req developer_api.ListDraftBotHistoryRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
c.String(consts.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if req.BotID == 0 {
|
||||
invalidParamRequestResponse(c, "bot id is not set")
|
||||
return
|
||||
}
|
||||
|
||||
if req.PageIndex <= 0 {
|
||||
req.PageIndex = 1
|
||||
}
|
||||
|
||||
if req.PageSize <= 0 {
|
||||
req.PageSize = 30
|
||||
}
|
||||
|
||||
resp, err := application.SingleAgentSVC.ListAgentPublishHistory(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// GetIcon .
|
||||
// @router /api/developer/get_icon [POST]
|
||||
func GetIcon(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req developer_api.GetIconRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := upload.SVC.GetIcon(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// GetUploadAuthToken .
|
||||
// @router /api/playground/upload/auth_token [POST]
|
||||
func GetUploadAuthToken(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req developer_api.GetUploadAuthTokenRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
c.String(consts.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := application.SingleAgentSVC.GetUploadAuthToken(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
func createSecret(uid int64, fileType string) string {
|
||||
num := 10
|
||||
input := fmt.Sprintf("upload_%d_Ma*9)fhi_%d_gou_%s_rand_%d", uid, time.Now().Unix(), fileType, rand.Intn(100000))
|
||||
// Do md5, take the first 20,//mapIntToBase62 map the number to Base62
|
||||
hash := sha256.Sum256([]byte(fmt.Sprintf("%s", input)))
|
||||
hashString := base64.StdEncoding.EncodeToString(hash[:])
|
||||
if len(hashString) > num {
|
||||
hashString = hashString[:num]
|
||||
}
|
||||
|
||||
result := ""
|
||||
for _, char := range hashString {
|
||||
index := int(char) % 62
|
||||
result += string(baseWord[index])
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
// UploadFile .
|
||||
// @router /api/bot/upload_file [POST]
|
||||
func UploadFile(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req developer_api.UploadFileRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
c.String(consts.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp := new(developer_api.UploadFileResponse)
|
||||
fileContent, err := base64.StdEncoding.DecodeString(req.Data)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
userID := ctxutil.GetUIDFromCtx(ctx)
|
||||
if userID == nil {
|
||||
internalServerErrorResponse(ctx, c, errorx.New(errno.ErrUploadPermissionCode, errorx.KV("msg", "session required")))
|
||||
return
|
||||
}
|
||||
secret := createSecret(ptr.From(userID), req.FileHead.FileType)
|
||||
fileName := fmt.Sprintf("%d_%d_%s.%s", ptr.From(userID), time.Now().UnixNano(), secret, req.FileHead.FileType)
|
||||
objectName := fmt.Sprintf("%s/%s", req.FileHead.BizType.String(), fileName)
|
||||
resp, err = upload.SVC.UploadFile(ctx, fileContent, objectName)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
const baseWord = "1Aa2Bb3Cc4Dd5Ee6Ff7Gg8Hh9Ii0JjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz"
|
||||
|
||||
// GetOnboarding .
|
||||
// @router /api/playground/get_onboarding [POST]
|
||||
func GetOnboarding(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req developer_api.GetOnboardingRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
c.String(consts.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp := new(developer_api.GetOnboardingResponse)
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// PublishConnectorList .
|
||||
// @router /api/draftbot/publish/connector/list [POST]
|
||||
func PublishConnectorList(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req developer_api.PublishConnectorListRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
c.String(consts.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if req.BotID == 0 {
|
||||
invalidParamRequestResponse(c, "bot id is not set")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := singleagent.SingleAgentSVC.GetPublishConnectorList(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// CheckDraftBotCommit .
|
||||
// @router /api/draftbot/commit_check [POST]
|
||||
func CheckDraftBotCommit(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req developer_api.CheckDraftBotCommitRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
c.String(consts.StatusBadRequest, err.Error())
|
||||
return
|
||||
|
||||
}
|
||||
resp := new(developer_api.CheckDraftBotCommitResponse)
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// UpdateUserProfileCheck .
|
||||
// @router /api/user/update_profile_check [POST]
|
||||
func UpdateUserProfileCheck(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req developer_api.UpdateUserProfileCheckRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
c.String(consts.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := user.UserApplicationSVC.UpdateUserProfileCheck(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// GetTypeList .
|
||||
// @router /api/bot/get_type_list [POST]
|
||||
func GetTypeList(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req developer_api.GetTypeListRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
c.String(consts.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := modelmgr.ModelmgrApplicationSVC.GetModelList(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// PluginOauthAuthorizationCode .
|
||||
// @router /api/plugin_oauth/:plugin_id/authorization_code [GET]
|
||||
func PluginOauthAuthorizationCode(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req developer_api.PluginOauthAuthorizationCodeReq
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if req.Code == "" {
|
||||
invalidParamRequestResponse(c, "authorization failed, code is required")
|
||||
return
|
||||
}
|
||||
if req.State == "" {
|
||||
invalidParamRequestResponse(c, "state is required")
|
||||
return
|
||||
}
|
||||
|
||||
confirmCode, err := plugin.PluginApplicationSVC.PluginOauthAuthorizationCode(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
host, err := config.Base().GetServerHost(ctx)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
redirectURL := fmt.Sprintf("%s/oauth/confirm?confirm_code=%s", host, confirmCode)
|
||||
c.Redirect(consts.StatusFound, []byte(redirectURL))
|
||||
c.Abort()
|
||||
}
|
||||
|
||||
// PluginOauthInfo .
|
||||
// @router /api/plugin/oauth/get_oauth_info [GET]
|
||||
func PluginOauthInfo(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req developer_api.PluginOauthInfoReq
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := plugin.PluginApplicationSVC.PluginOauthInfo(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// PluginOauthConfirm .
|
||||
// @router /api/plugin/oauth/confirm [POST]
|
||||
func PluginOauthConfirm(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req developer_api.PluginOauthConfirmReq
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := plugin.PluginApplicationSVC.PluginOauthConfirm(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
@@ -0,0 +1,426 @@
|
||||
/*
|
||||
* Copyright 2025 coze-dev Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by hertz generator.
|
||||
|
||||
package coze
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/cloudwego/hertz/pkg/app"
|
||||
"github.com/cloudwego/hertz/pkg/protocol/consts"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/app/intelligence"
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/app/intelligence/common"
|
||||
project "github.com/coze-dev/coze-studio/backend/api/model/app/intelligence/project"
|
||||
publish "github.com/coze-dev/coze-studio/backend/api/model/app/intelligence/publish"
|
||||
task "github.com/coze-dev/coze-studio/backend/api/model/app/intelligence/task"
|
||||
appApplication "github.com/coze-dev/coze-studio/backend/application/app"
|
||||
"github.com/coze-dev/coze-studio/backend/application/search"
|
||||
)
|
||||
|
||||
// GetDraftIntelligenceList .
|
||||
// @router /api/intelligence_api/search/get_draft_intelligence_list [POST]
|
||||
func GetDraftIntelligenceList(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req intelligence.GetDraftIntelligenceListRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := search.SearchSVC.GetDraftIntelligenceList(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// GetDraftIntelligenceInfo .
|
||||
// @router /api/intelligence_api/search/get_draft_intelligence_info [POST]
|
||||
func GetDraftIntelligenceInfo(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req intelligence.GetDraftIntelligenceInfoRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if req.IntelligenceID <= 0 {
|
||||
invalidParamRequestResponse(c, "invalid intelligence id")
|
||||
return
|
||||
}
|
||||
if req.IntelligenceType != common.IntelligenceType_Project {
|
||||
invalidParamRequestResponse(c, fmt.Sprintf("invalid intelligence type '%d'", req.IntelligenceType))
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := appApplication.APPApplicationSVC.GetDraftIntelligenceInfo(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// GetUserRecentlyEditIntelligence .
|
||||
// @router /api/intelligence_api/search/get_recently_edit_intelligence [POST]
|
||||
func GetUserRecentlyEditIntelligence(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req intelligence.GetUserRecentlyEditIntelligenceRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
c.String(consts.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp := new(intelligence.GetUserRecentlyEditIntelligenceResponse)
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// DraftProjectCreate .
|
||||
// @router /api/intelligence_api/draft_project/create [POST]
|
||||
func DraftProjectCreate(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req project.DraftProjectCreateRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if req.SpaceID <= 0 {
|
||||
invalidParamRequestResponse(c, "invalid space id")
|
||||
return
|
||||
}
|
||||
if req.Name == "" || len(req.Name) > 256 {
|
||||
invalidParamRequestResponse(c, "invalid name")
|
||||
return
|
||||
}
|
||||
if req.IconURI == "" || len(req.IconURI) > 512 {
|
||||
invalidParamRequestResponse(c, "invalid icon uri")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := appApplication.APPApplicationSVC.DraftProjectCreate(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// DraftProjectUpdate .
|
||||
// @router /api/intelligence_api/draft_project/update [POST]
|
||||
func DraftProjectUpdate(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req project.DraftProjectUpdateRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if req.ProjectID <= 0 {
|
||||
invalidParamRequestResponse(c, "invalid project id")
|
||||
return
|
||||
}
|
||||
if req.Name != nil && (len(*req.Name) == 0 || len(*req.Name) > 256) {
|
||||
invalidParamRequestResponse(c, "invalid name")
|
||||
return
|
||||
}
|
||||
if req.IconURI != nil && (len(*req.IconURI) == 0 || len(*req.IconURI) > 512) {
|
||||
invalidParamRequestResponse(c, "invalid icon uri")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := appApplication.APPApplicationSVC.DraftProjectUpdate(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// DraftProjectDelete .
|
||||
// @router /api/intelligence_api/draft_project/delete [POST]
|
||||
func DraftProjectDelete(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req project.DraftProjectDeleteRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if req.ProjectID <= 0 {
|
||||
invalidParamRequestResponse(c, "invalid project id")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := appApplication.APPApplicationSVC.DraftProjectDelete(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// GetProjectPublishedConnector .
|
||||
// @router /api/intelligence_api/publish/get_published_connector [POST]
|
||||
func GetProjectPublishedConnector(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req publish.GetProjectPublishedConnectorRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
c.String(consts.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp := new(publish.GetProjectPublishedConnectorResponse)
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// CheckProjectVersionNumber .
|
||||
// @router /api/intelligence_api/publish/check_version_number [POST]
|
||||
func CheckProjectVersionNumber(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req publish.CheckProjectVersionNumberRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if req.ProjectID <= 0 {
|
||||
invalidParamRequestResponse(c, "invalid project id")
|
||||
return
|
||||
}
|
||||
if req.VersionNumber == "" {
|
||||
invalidParamRequestResponse(c, "invalid version number")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := appApplication.APPApplicationSVC.CheckProjectVersionNumber(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// PublishProject .
|
||||
// @router /api/intelligence_api/publish/publish_project [POST]
|
||||
func PublishProject(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req publish.PublishProjectRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if req.ProjectID <= 0 {
|
||||
invalidParamRequestResponse(c, "invalid project id")
|
||||
return
|
||||
}
|
||||
if req.VersionNumber == "" {
|
||||
invalidParamRequestResponse(c, "invalid version number")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := appApplication.APPApplicationSVC.PublishAPP(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// GetPublishRecordList .
|
||||
// @router /api/intelligence_api/publish/publish_record_list [POST]
|
||||
func GetPublishRecordList(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req publish.GetPublishRecordListRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if req.ProjectID <= 0 {
|
||||
invalidParamRequestResponse(c, "invalid project id")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := appApplication.APPApplicationSVC.GetPublishRecordList(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// ProjectPublishConnectorList .
|
||||
// @router /api/intelligence_api/publish/connector_list [POST]
|
||||
func ProjectPublishConnectorList(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req publish.PublishConnectorListRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if req.ProjectID <= 0 {
|
||||
invalidParamRequestResponse(c, "invalid project id")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := appApplication.APPApplicationSVC.ProjectPublishConnectorList(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// GetPublishRecordDetail .
|
||||
// @router /api/intelligence_api/publish/publish_record_detail [POST]
|
||||
func GetPublishRecordDetail(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req publish.GetPublishRecordDetailRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if req.ProjectID <= 0 {
|
||||
invalidParamRequestResponse(c, "invalid project id")
|
||||
return
|
||||
}
|
||||
if req.PublishRecordID != nil && *req.PublishRecordID <= 0 {
|
||||
invalidParamRequestResponse(c, "invalid publish record id")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := appApplication.APPApplicationSVC.GetPublishRecordDetail(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// DraftProjectInnerTaskList .
|
||||
// @router /api/intelligence_api/draft_project/inner_task_list [POST]
|
||||
func DraftProjectInnerTaskList(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req task.DraftProjectInnerTaskListRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if req.ProjectID <= 0 {
|
||||
invalidParamRequestResponse(c, "invalid project id")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := appApplication.APPApplicationSVC.DraftProjectInnerTaskList(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// DraftProjectCopy .
|
||||
// @router /api/intelligence_api/draft_project/copy [POST]
|
||||
func DraftProjectCopy(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req project.DraftProjectCopyRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if req.ProjectID <= 0 {
|
||||
invalidParamRequestResponse(c, "invalid project id")
|
||||
return
|
||||
}
|
||||
if req.ToSpaceID <= 0 {
|
||||
invalidParamRequestResponse(c, "invalid to space id")
|
||||
return
|
||||
}
|
||||
if req.Name == "" || len(req.Name) > 256 {
|
||||
invalidParamRequestResponse(c, "invalid name")
|
||||
return
|
||||
}
|
||||
if req.IconURI == "" || len(req.IconURI) > 512 {
|
||||
invalidParamRequestResponse(c, "invalid icon uri")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := appApplication.APPApplicationSVC.DraftProjectCopy(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// GetOnlineAppData .
|
||||
// @router /v1/apps/:app_id [GET]
|
||||
func GetOnlineAppData(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req project.GetOnlineAppDataRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
c.String(consts.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := appApplication.APPApplicationSVC.GetOnlineAppData(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
@@ -0,0 +1,770 @@
|
||||
/*
|
||||
* Copyright 2025 coze-dev Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by hertz generator.
|
||||
|
||||
package coze
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/cloudwego/hertz/pkg/app"
|
||||
"github.com/cloudwego/hertz/pkg/protocol/consts"
|
||||
|
||||
dataset "github.com/coze-dev/coze-studio/backend/api/model/data/knowledge"
|
||||
"github.com/coze-dev/coze-studio/backend/application/knowledge"
|
||||
application "github.com/coze-dev/coze-studio/backend/application/knowledge"
|
||||
"github.com/coze-dev/coze-studio/backend/application/memory"
|
||||
"github.com/coze-dev/coze-studio/backend/application/upload"
|
||||
)
|
||||
|
||||
// CreateDataset .
|
||||
// @router /api/knowledge/create [POST]
|
||||
func CreateDataset(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req dataset.CreateDatasetRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
c.String(consts.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
resp := new(dataset.CreateDatasetResponse)
|
||||
resp, err = application.KnowledgeSVC.CreateKnowledge(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// DatasetDetail .
|
||||
// @router /api/knowledge/detail [POST]
|
||||
func DatasetDetail(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req dataset.DatasetDetailRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
c.String(consts.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
resp := new(dataset.DatasetDetailResponse)
|
||||
resp, err = application.KnowledgeSVC.DatasetDetail(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// ListDataset .
|
||||
// @router /api/knowledge/list [POST]
|
||||
func ListDataset(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req dataset.ListDatasetRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
c.String(consts.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp := new(dataset.ListDatasetResponse)
|
||||
resp, err = application.KnowledgeSVC.ListKnowledge(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// DeleteDataset .
|
||||
// @router /api/knowledge/delete [POST]
|
||||
func DeleteDataset(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req dataset.DeleteDatasetRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
c.String(consts.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp := new(dataset.DeleteDatasetResponse)
|
||||
resp, err = application.KnowledgeSVC.DeleteKnowledge(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// UpdateDataset .
|
||||
// @router /api/knowledge/update [POST]
|
||||
func UpdateDataset(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req dataset.UpdateDatasetRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
c.String(consts.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp := new(dataset.UpdateDatasetResponse)
|
||||
resp, err = application.KnowledgeSVC.UpdateKnowledge(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// CreateDocument .
|
||||
// @router /api/knowledge/document/create [POST]
|
||||
func CreateDocument(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req dataset.CreateDocumentRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
c.String(consts.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp := new(dataset.CreateDocumentResponse)
|
||||
resp, err = application.KnowledgeSVC.CreateDocument(ctx, &req, false)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// ListDocument .
|
||||
// @router /api/knowledge/document/list [POST]
|
||||
func ListDocument(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req dataset.ListDocumentRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
c.String(consts.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp := new(dataset.ListDocumentResponse)
|
||||
resp, err = application.KnowledgeSVC.ListDocument(ctx, &req, false)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// DeleteDocument .
|
||||
// @router /api/knowledge/document/delete [POST]
|
||||
func DeleteDocument(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req dataset.DeleteDocumentRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
c.String(consts.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp := new(dataset.DeleteDocumentResponse)
|
||||
resp, err = application.KnowledgeSVC.DeleteDocument(ctx, &req, false)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// UpdateDocument .
|
||||
// @router /api/knowledge/document/update [POST]
|
||||
func UpdateDocument(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req dataset.UpdateDocumentRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
c.String(consts.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp := new(dataset.UpdateDocumentResponse)
|
||||
resp, err = application.KnowledgeSVC.UpdateDocument(ctx, &req, false)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// GetDocumentProgress .
|
||||
// @router /api/knowledge/document/progress/get [POST]
|
||||
func GetDocumentProgress(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req dataset.GetDocumentProgressRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
c.String(consts.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp := new(dataset.GetDocumentProgressResponse)
|
||||
resp, err = application.KnowledgeSVC.GetDocumentProgress(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// Resegment .
|
||||
// @router /api/knowledge/document/resegment [POST]
|
||||
func Resegment(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req dataset.ResegmentRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
c.String(consts.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp := new(dataset.ResegmentResponse)
|
||||
resp, err = application.KnowledgeSVC.Resegment(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// UpdatePhotoCaption .
|
||||
// @router /api/knowledge/photo/caption [POST]
|
||||
func UpdatePhotoCaption(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req dataset.UpdatePhotoCaptionRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
c.String(consts.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp := new(dataset.UpdatePhotoCaptionResponse)
|
||||
resp, err = application.KnowledgeSVC.UpdatePhotoCaption(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// ListPhoto .
|
||||
// @router /api/knowledge/photo/list [POST]
|
||||
func ListPhoto(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req dataset.ListPhotoRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
c.String(consts.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp := new(dataset.ListPhotoResponse)
|
||||
resp, err = application.KnowledgeSVC.ListPhoto(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// PhotoDetail .
|
||||
// @router /api/knowledge/photo/detail [POST]
|
||||
func PhotoDetail(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req dataset.PhotoDetailRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
c.String(consts.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp := new(dataset.PhotoDetailResponse)
|
||||
resp, err = application.KnowledgeSVC.PhotoDetail(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// GetTableSchema .
|
||||
// @router /api/knowledge/table_schema/get [POST]
|
||||
func GetTableSchema(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req dataset.GetTableSchemaRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
c.String(consts.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp := new(dataset.GetTableSchemaResponse)
|
||||
resp, err = application.KnowledgeSVC.GetTableSchema(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// ValidateTableSchema .
|
||||
// @router /api/knowledge/table_schema/validate [POST]
|
||||
func ValidateTableSchema(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req dataset.ValidateTableSchemaRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
c.String(consts.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp := new(dataset.ValidateTableSchemaResponse)
|
||||
resp, err = application.KnowledgeSVC.ValidateTableSchema(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// DeleteSlice .
|
||||
// @router /api/knowledge/slice/delete [POST]
|
||||
func DeleteSlice(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req dataset.DeleteSliceRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
c.String(consts.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp := new(dataset.DeleteSliceResponse)
|
||||
resp, err = application.KnowledgeSVC.DeleteSlice(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// CreateSlice .
|
||||
// @router /api/knowledge/slice/create [POST]
|
||||
func CreateSlice(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req dataset.CreateSliceRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
c.String(consts.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp := new(dataset.CreateSliceResponse)
|
||||
resp, err = application.KnowledgeSVC.CreateSlice(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// UpdateSlice .
|
||||
// @router /api/knowledge/slice/update [POST]
|
||||
func UpdateSlice(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req dataset.UpdateSliceRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
c.String(consts.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp := new(dataset.UpdateSliceResponse)
|
||||
resp, err = application.KnowledgeSVC.UpdateSlice(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// ListSlice .
|
||||
// @router /api/knowledge/slice/list [POST]
|
||||
func ListSlice(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req dataset.ListSliceRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
c.String(consts.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp := new(dataset.ListSliceResponse)
|
||||
resp, err = application.KnowledgeSVC.ListSlice(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// CreateDocumentReview .
|
||||
// @router /api/knowledge/review/create [POST]
|
||||
func CreateDocumentReview(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req dataset.CreateDocumentReviewRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
c.String(consts.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp := new(dataset.CreateDocumentReviewResponse)
|
||||
resp, err = application.KnowledgeSVC.CreateDocumentReview(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// MGetDocumentReview .
|
||||
// @router /api/knowledge/review/mget [POST]
|
||||
func MGetDocumentReview(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req dataset.MGetDocumentReviewRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
c.String(consts.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp := new(dataset.MGetDocumentReviewResponse)
|
||||
resp, err = application.KnowledgeSVC.MGetDocumentReview(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// SaveDocumentReview .
|
||||
// @router /api/knowledge/review/save [POST]
|
||||
func SaveDocumentReview(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req dataset.SaveDocumentReviewRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
c.String(consts.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp := new(dataset.SaveDocumentReviewResponse)
|
||||
resp, err = application.KnowledgeSVC.SaveDocumentReview(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// GetIconForDataset .
|
||||
// @router /api/knowledge/icon/get [POST]
|
||||
func GetIconForDataset(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req dataset.GetIconRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
c.String(consts.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp := new(dataset.GetIconResponse)
|
||||
resp, err = upload.SVC.GetIconForDataset(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// ExtractPhotoCaption .
|
||||
// @router /api/knowledge/photo/extract_caption [POST]
|
||||
func ExtractPhotoCaption(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req dataset.ExtractPhotoCaptionRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
c.String(consts.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp := new(dataset.ExtractPhotoCaptionResponse)
|
||||
resp, err = application.KnowledgeSVC.ExtractPhotoCaption(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// GetDocumentTableInfo .
|
||||
// @router /api/memory/doc_table_info [GET]
|
||||
func GetDocumentTableInfo(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req dataset.GetDocumentTableInfoRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
c.String(consts.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp := new(dataset.GetDocumentTableInfoResponse)
|
||||
resp, err = knowledge.KnowledgeSVC.GetDocumentTableInfo(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// GetModeConfig .
|
||||
// @router /api/memory/table_mode_config [GET]
|
||||
func GetModeConfig(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req dataset.GetModeConfigRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
c.String(consts.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if req.BotID == 0 {
|
||||
invalidParamRequestResponse(c, "bot_id is zero")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := memory.DatabaseApplicationSVC.GetModeConfig(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// CreateDocumentOpenAPI .
|
||||
// @router /open_api/knowledge/document/create [POST]
|
||||
func CreateDocumentOpenAPI(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req dataset.CreateDocumentRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp := new(dataset.CreateDocumentResponse)
|
||||
resp, err = application.KnowledgeSVC.CreateDocument(ctx, &req, true)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// DeleteDocumentOpenAPI .
|
||||
// @router /open_api/knowledge/document/delete [POST]
|
||||
func DeleteDocumentOpenAPI(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req dataset.DeleteDocumentRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
c.String(consts.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp := new(dataset.DeleteDocumentResponse)
|
||||
resp, err = application.KnowledgeSVC.DeleteDocument(ctx, &req, true)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// UpdateDocumentOpenAPI .
|
||||
// @router /open_api/knowledge/document/update [POST]
|
||||
func UpdateDocumentOpenAPI(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req dataset.UpdateDocumentRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
c.String(consts.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp := new(dataset.UpdateDocumentResponse)
|
||||
resp, err = application.KnowledgeSVC.UpdateDocument(ctx, &req, true)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// ListDocumentOpenAPI .
|
||||
// @router /open_api/knowledge/document/list [POST]
|
||||
func ListDocumentOpenAPI(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req dataset.ListDocumentRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
c.String(consts.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp := new(dataset.ListDocumentResponse)
|
||||
resp, err = application.KnowledgeSVC.ListDocument(ctx, &req, true)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// CreateDatasetOpenAPI .
|
||||
// @router /v1/datasets [POST]
|
||||
func CreateDatasetOpenAPI(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req dataset.CreateDatasetOpenApiRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := application.KnowledgeSVC.CreateKnowledgeAPI(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// ListDatasetOpenAPI .
|
||||
// @router /v1/datasets [GET]
|
||||
func ListDatasetOpenAPI(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req dataset.ListDatasetOpenApiRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := application.KnowledgeSVC.ListKnowledgeAPI(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// UpdateDatasetOpenAPI .
|
||||
// @router /v1/datasets/:dataset_id [PUT]
|
||||
func UpdateDatasetOpenAPI(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req dataset.UpdateDatasetOpenApiRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := application.KnowledgeSVC.UpdateKnowledgeAPI(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// DeleteDatasetOpenAPI .
|
||||
// @router /v1/datasets/:dataset_id [DELETE]
|
||||
func DeleteDatasetOpenAPI(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req dataset.DeleteDatasetOpenApiRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := application.KnowledgeSVC.DeleteKnowledgeAPI(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// ListPhotoDocumentOpenAPI .
|
||||
// @router /v1/datasets/:dataset_id/images [GET]
|
||||
func ListPhotoDocumentOpenAPI(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req dataset.ListPhotoOpenApiRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := application.KnowledgeSVC.ListPhotoAPI(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// GetDocumentProgressOpenAPI .
|
||||
// @router /v1/datasets/:dataset_id/process [POST]
|
||||
func GetDocumentProgressOpenAPI(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req dataset.GetDocumentProgressOpenApiRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := application.KnowledgeSVC.GetDocumentProgressAPI(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
@@ -0,0 +1,229 @@
|
||||
/*
|
||||
* Copyright 2025 coze-dev Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by hertz generator.
|
||||
|
||||
package coze
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/cloudwego/hertz/pkg/app"
|
||||
"github.com/cloudwego/hertz/pkg/protocol/consts"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/data/variable/kvmemory"
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/data/variable/project_memory"
|
||||
appApplication "github.com/coze-dev/coze-studio/backend/application/app"
|
||||
"github.com/coze-dev/coze-studio/backend/application/memory"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/conv"
|
||||
)
|
||||
|
||||
// GetSysVariableConf .
|
||||
// @router /api/memory/sys_variable_conf [GET]
|
||||
func GetSysVariableConf(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req kvmemory.GetSysVariableConfRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
c.String(consts.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := memory.VariableApplicationSVC.GetSysVariableConf(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// GetProjectVariableList .
|
||||
// @router /api/memory/project/variable/meta_list [GET]
|
||||
func GetProjectVariableList(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req project_memory.GetProjectVariableListReq
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
c.String(consts.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if req.ProjectID == "" {
|
||||
invalidParamRequestResponse(c, "project_id is empty")
|
||||
return
|
||||
}
|
||||
|
||||
pID, err := conv.StrToInt64(req.ProjectID)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, "project_id is not int")
|
||||
return
|
||||
}
|
||||
|
||||
pInfo, err := appApplication.APPApplicationSVC.DomainSVC.GetDraftAPP(ctx, pID)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := memory.VariableApplicationSVC.GetProjectVariablesMeta(ctx, pInfo.OwnerID, &req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// UpdateProjectVariable .
|
||||
// @router /api/memory/project/variable/meta_update [POST]
|
||||
func UpdateProjectVariable(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req project_memory.UpdateProjectVariableReq
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
c.String(consts.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if req.ProjectID == "" {
|
||||
invalidParamRequestResponse(c, "project_id is empty")
|
||||
return
|
||||
}
|
||||
|
||||
key2Var := make(map[string]*project_memory.Variable)
|
||||
for _, v := range req.VariableList {
|
||||
if v.Keyword == "" {
|
||||
invalidParamRequestResponse(c, "variable name is empty")
|
||||
return
|
||||
}
|
||||
|
||||
if key2Var[v.Keyword] != nil {
|
||||
invalidParamRequestResponse(c, "variable keyword is duplicate")
|
||||
return
|
||||
}
|
||||
|
||||
key2Var[v.Keyword] = v
|
||||
}
|
||||
|
||||
resp, err := memory.VariableApplicationSVC.UpdateProjectVariable(ctx, req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// SetKvMemory .
|
||||
// @router /api/memory/variable/upsert [POST]
|
||||
func SetKvMemory(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req kvmemory.SetKvMemoryReq
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
c.String(consts.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if req.BotID == 0 && req.GetProjectID() == "" {
|
||||
invalidParamRequestResponse(c, "bot_id and project_id are both empty")
|
||||
return
|
||||
}
|
||||
|
||||
if len(req.Data) == 0 {
|
||||
invalidParamRequestResponse(c, "data is empty")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := memory.VariableApplicationSVC.SetVariableInstance(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// GetMemoryVariableMeta .
|
||||
// @router /api/memory/variable/get_meta [POST]
|
||||
func GetMemoryVariableMeta(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req project_memory.GetMemoryVariableMetaReq
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
c.String(consts.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := memory.VariableApplicationSVC.GetVariableMeta(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// DelProfileMemory .
|
||||
// @router /api/memory/variable/delete [POST]
|
||||
func DelProfileMemory(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req kvmemory.DelProfileMemoryRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
c.String(consts.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if req.BotID == 0 && req.GetProjectID() == "" {
|
||||
invalidParamRequestResponse(c, "bot_id and project_id are both empty")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := memory.VariableApplicationSVC.DeleteVariableInstance(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// GetPlayGroundMemory .
|
||||
// @router /api/memory/variable/get [POST]
|
||||
func GetPlayGroundMemory(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req kvmemory.GetProfileMemoryRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
c.String(consts.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if req.BotID == 0 && req.GetProjectID() == "" {
|
||||
invalidParamRequestResponse(c, "bot_id and project_id are both empty")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := memory.VariableApplicationSVC.GetPlayGroundMemory(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
@@ -0,0 +1,170 @@
|
||||
/*
|
||||
* Copyright 2025 coze-dev Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package coze
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"github.com/cloudwego/hertz/pkg/app"
|
||||
"github.com/cloudwego/hertz/pkg/protocol/consts"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/conversation/message"
|
||||
application "github.com/coze-dev/coze-studio/backend/application/conversation"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/errorx"
|
||||
"github.com/coze-dev/coze-studio/backend/types/errno"
|
||||
)
|
||||
|
||||
// GetMessageList .
|
||||
// @router /api/conversation/get_message_list [POST]
|
||||
func GetMessageList(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req message.GetMessageListRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if checkErr := checkMLParams(ctx, &req); checkErr != nil {
|
||||
invalidParamRequestResponse(c, checkErr.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := application.ConversationSVC.GetMessageList(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
func checkMLParams(ctx context.Context, req *message.GetMessageListRequest) error {
|
||||
if req.BotID == "" {
|
||||
return errorx.New(errno.ErrConversationInvalidParamCode, errorx.KV("msg", "agent id is required"))
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeleteMessage .
|
||||
// @router /api/conversation/delete_message [POST]
|
||||
func DeleteMessage(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req message.DeleteMessageRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
if checkErr := checkDMParams(ctx, &req); checkErr != nil {
|
||||
invalidParamRequestResponse(c, checkErr.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := application.ConversationSVC.DeleteMessage(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
func checkDMParams(_ context.Context, req *message.DeleteMessageRequest) error {
|
||||
if req.MessageID <= 0 {
|
||||
return errorx.New(errno.ErrConversationInvalidParamCode, errorx.KV("msg", "message id is invalid"))
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// BreakMessage .
|
||||
// @router /api/conversation/break_message [POST]
|
||||
func BreakMessage(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req message.BreakMessageRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if checkErr := checkBMParams(ctx, &req); checkErr != nil {
|
||||
invalidParamRequestResponse(c, checkErr.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := application.ConversationSVC.BreakMessage(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
func checkBMParams(_ context.Context, req *message.BreakMessageRequest) error {
|
||||
if req.AnswerMessageID == nil {
|
||||
return errors.New("answer message id is required")
|
||||
}
|
||||
if *req.AnswerMessageID <= 0 {
|
||||
return errorx.New(errno.ErrConversationInvalidParamCode, errorx.KV("msg", "answer message id is invalid"))
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetApiMessageList .
|
||||
// @router /v1/conversation/message/list [POST]
|
||||
func GetApiMessageList(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req message.ListMessageApiRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := application.OpenapiMessageSVC.GetApiMessageList(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// ListChatMessageApi .
|
||||
// @router /v3/chat/message/list [GET]
|
||||
func ListChatMessageApi(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req message.ListChatMessageApiRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := application.ConversationOpenAPISVC.ListChatMessageApi(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright 2025 coze-dev Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package coze
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
"github.com/bytedance/sonic"
|
||||
"github.com/cloudwego/hertz/pkg/app/server"
|
||||
"github.com/cloudwego/hertz/pkg/common/ut"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/conversation/common"
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/conversation/message"
|
||||
"github.com/coze-dev/coze-studio/backend/application"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
|
||||
)
|
||||
|
||||
func TestGetMessageList(t *testing.T) {
|
||||
h := server.Default()
|
||||
err := application.Init(context.Background())
|
||||
|
||||
t.Logf("application init err: %v", err)
|
||||
|
||||
h.POST("/api/conversation/get_message_list", GetMessageList)
|
||||
req := &message.GetMessageListRequest{
|
||||
BotID: "7366055842027922437",
|
||||
Scene: ptr.Of(common.Scene_Playground),
|
||||
ConversationID: "7496795464885338112",
|
||||
Count: 10,
|
||||
Cursor: "1746534530268",
|
||||
}
|
||||
m, err := sonic.Marshal(req)
|
||||
assert.Nil(t, err)
|
||||
w := ut.PerformRequest(h.Engine, "POST", "/api/conversation/get_message_list", &ut.Body{Body: bytes.NewBuffer(m), Len: len(m)}, ut.Header{Key: "Content-Type", Value: "application/json"})
|
||||
res := w.Result()
|
||||
t.Logf("get message list: %s", res.Body())
|
||||
|
||||
assert.Equal(t, http.StatusInternalServerError, w.Code)
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
/*
|
||||
* Copyright 2025 coze-dev Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by hertz generator.
|
||||
|
||||
package coze
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/cloudwego/hertz/pkg/app"
|
||||
"github.com/cloudwego/hertz/pkg/protocol/consts"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/permission/openapiauth"
|
||||
openapiauthApp "github.com/coze-dev/coze-studio/backend/application/openauth"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/errorx"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/logs"
|
||||
"github.com/coze-dev/coze-studio/backend/types/errno"
|
||||
)
|
||||
|
||||
// GetPersonalAccessTokenAndPermission .
|
||||
// @router /api/permission_api/pat/get_personal_access_token_and_permission [GET]
|
||||
func GetPersonalAccessTokenAndPermission(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req openapiauth.GetPersonalAccessTokenAndPermissionRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if req.ID == 0 {
|
||||
invalidParamRequestResponse(c, "id is required")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := openapiauthApp.OpenAuthApplication.GetPersonalAccessTokenAndPermission(ctx, &req)
|
||||
if err != nil {
|
||||
logs.CtxErrorf(ctx, "OpenAuthApplicationService.GetPersonalAccessTokenAndPermission failed, err=%v", err)
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// DeletePersonalAccessTokenAndPermission .
|
||||
// @router /api/permission_api/pat/delete_personal_access_token_and_permission [POST]
|
||||
func DeletePersonalAccessTokenAndPermission(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req openapiauth.DeletePersonalAccessTokenAndPermissionRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if req.ID <= 0 {
|
||||
invalidParamRequestResponse(c, "id is required")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := openapiauthApp.OpenAuthApplication.DeletePersonalAccessTokenAndPermission(ctx, &req)
|
||||
if err != nil {
|
||||
logs.CtxErrorf(ctx, "OpenAuthApplication.DeletePersonalAccessTokenAndPermission failed, err=%v", err)
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// ListPersonalAccessTokens .
|
||||
// @router /api/permission_api/pat/list_personal_access_tokens [GET]
|
||||
func ListPersonalAccessTokens(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req openapiauth.ListPersonalAccessTokensRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if req.Page == nil || *req.Page <= 0 {
|
||||
req.Page = ptr.Of(int64(1))
|
||||
}
|
||||
if req.Size == nil || *req.Size <= 0 {
|
||||
req.Size = ptr.Of(int64(10))
|
||||
}
|
||||
|
||||
resp, err := openapiauthApp.OpenAuthApplication.ListPersonalAccessTokens(ctx, &req)
|
||||
if err != nil {
|
||||
logs.CtxErrorf(ctx, "OpenAuthApplication.ListPersonalAccessTokens failed, err=%v", err)
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// CreatePersonalAccessTokenAndPermission .
|
||||
// @router /api/permission_api/pat/create_personal_access_token_and_permission [POST]
|
||||
func CreatePersonalAccessTokenAndPermission(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req openapiauth.CreatePersonalAccessTokenAndPermissionRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if err = checkCPATParams(ctx, &req); err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := openapiauthApp.OpenAuthApplication.CreatePersonalAccessToken(ctx, &req)
|
||||
if err != nil {
|
||||
logs.CtxErrorf(ctx, "OpenAuthApplicationService.CreatePersonalAccessToken failed, err=%v", err)
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// checkCPATParams Check parameters for creating personal access tokens
|
||||
func checkCPATParams(ctx context.Context, req *openapiauth.CreatePersonalAccessTokenAndPermissionRequest) error {
|
||||
|
||||
if req.Name == "" {
|
||||
return errorx.New(errno.ErrPermissionInvalidParamCode, errorx.KV("msg", "name is required"))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// UpdatePersonalAccessTokenAndPermission .
|
||||
// @router /api/permission_api/pat/update_personal_access_token_and_permission [POST]
|
||||
func UpdatePersonalAccessTokenAndPermission(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req openapiauth.UpdatePersonalAccessTokenAndPermissionRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := openapiauthApp.OpenAuthApplication.UpdatePersonalAccessTokenAndPermission(ctx, &req)
|
||||
if err != nil {
|
||||
logs.CtxErrorf(ctx, "OpenAuthApplication.UpdatePersonalAccessTokenAndPermission failed, err=%v", err)
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
@@ -0,0 +1,220 @@
|
||||
/*
|
||||
* Copyright 2025 coze-dev Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by hertz generator.
|
||||
|
||||
package coze
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/cloudwego/hertz/pkg/app"
|
||||
"github.com/cloudwego/hertz/pkg/protocol"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/passport"
|
||||
"github.com/coze-dev/coze-studio/backend/application/user"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/user/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/hertzutil/domain"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/i18n"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/logs"
|
||||
"github.com/coze-dev/coze-studio/backend/types/consts"
|
||||
)
|
||||
|
||||
// PassportWebEmailRegisterV2Post .
|
||||
// @router /passport/web/email/register/v2/ [POST]
|
||||
func PassportWebEmailRegisterV2Post(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req passport.PassportWebEmailRegisterV2PostRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
locale := string(i18n.GetLocale(ctx))
|
||||
|
||||
resp, sessionKey, err := user.UserApplicationSVC.PassportWebEmailRegisterV2(ctx, locale, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.SetCookie(entity.SessionKey,
|
||||
sessionKey,
|
||||
consts.SessionMaxAgeSecond,
|
||||
"/", domain.GetOriginHost(c),
|
||||
protocol.CookieSameSiteDefaultMode,
|
||||
false, true)
|
||||
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// PassportWebLogoutGet .
|
||||
// @router /passport/web/logout/ [GET]
|
||||
func PassportWebLogoutGet(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req passport.PassportWebLogoutGetRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
c.String(http.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := user.UserApplicationSVC.PassportWebLogoutGet(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// PassportWebEmailLoginPost .
|
||||
// @router /passport/web/email/login/ [POST]
|
||||
func PassportWebEmailLoginPost(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req passport.PassportWebEmailLoginPostRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
c.String(http.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, sessionKey, err := user.UserApplicationSVC.PassportWebEmailLoginPost(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
logs.Infof("[PassportWebEmailLoginPost] sessionKey: %s", sessionKey)
|
||||
|
||||
c.SetCookie(entity.SessionKey,
|
||||
sessionKey,
|
||||
consts.SessionMaxAgeSecond,
|
||||
"/", domain.GetOriginHost(c),
|
||||
protocol.CookieSameSiteDefaultMode,
|
||||
false, true)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// PassportWebEmailPasswordResetGet .
|
||||
// @router /passport/web/email/password/reset/ [GET]
|
||||
func PassportWebEmailPasswordResetGet(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req passport.PassportWebEmailPasswordResetGetRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
c.String(http.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := user.UserApplicationSVC.PassportWebEmailPasswordResetGet(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// PassportAccountInfoV2 .
|
||||
// @router /passport/account/info/v2/ [POST]
|
||||
func PassportAccountInfoV2(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req passport.PassportAccountInfoV2Request
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
c.String(http.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := user.UserApplicationSVC.PassportAccountInfoV2(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// UserUpdateAvatar .
|
||||
// @router web/user/update/upload_avatar/ [POST]
|
||||
func UserUpdateAvatar(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req passport.UserUpdateAvatarRequest
|
||||
|
||||
// Get the uploaded file
|
||||
file, err := c.FormFile("avatar")
|
||||
if err != nil {
|
||||
logs.CtxErrorf(ctx, "Get Avatar Fail failed, err=%v", err)
|
||||
invalidParamRequestResponse(c, "missing avatar file")
|
||||
return
|
||||
}
|
||||
|
||||
// Check file type
|
||||
if !strings.HasPrefix(file.Header.Get("Content-Type"), "image/") {
|
||||
invalidParamRequestResponse(c, "invalid file type, only image allowed")
|
||||
return
|
||||
}
|
||||
|
||||
// Read file content
|
||||
src, err := file.Open()
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
defer src.Close()
|
||||
|
||||
fileContent, err := io.ReadAll(src)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
req.Avatar = fileContent
|
||||
mimeType := file.Header.Get("Content-Type")
|
||||
|
||||
resp, err := user.UserApplicationSVC.UserUpdateAvatar(ctx, mimeType, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// UserUpdateProfile .
|
||||
// @router api/user/update_profile [POST]
|
||||
func UserUpdateProfile(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req passport.UserUpdateProfileRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
c.String(http.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := user.UserApplicationSVC.UserUpdateProfile(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
@@ -0,0 +1,373 @@
|
||||
/*
|
||||
* Copyright 2025 coze-dev Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by hertz generator.
|
||||
|
||||
package coze
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/cloudwego/hertz/pkg/app"
|
||||
"github.com/cloudwego/hertz/pkg/protocol/consts"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/playground"
|
||||
appApplication "github.com/coze-dev/coze-studio/backend/application/app"
|
||||
"github.com/coze-dev/coze-studio/backend/application/prompt"
|
||||
"github.com/coze-dev/coze-studio/backend/application/shortcutcmd"
|
||||
"github.com/coze-dev/coze-studio/backend/application/singleagent"
|
||||
"github.com/coze-dev/coze-studio/backend/application/upload"
|
||||
"github.com/coze-dev/coze-studio/backend/application/user"
|
||||
)
|
||||
|
||||
// UpdateDraftBotInfoAgw .
|
||||
// @router /api/playground_api/draftbot/update_draft_bot_info [POST]
|
||||
func UpdateDraftBotInfoAgw(ctx context.Context, c *app.RequestContext) {
|
||||
var req playground.UpdateDraftBotInfoAgwRequest
|
||||
err := c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if req.BotInfo == nil {
|
||||
invalidParamRequestResponse(c, "bot info is nil")
|
||||
return
|
||||
}
|
||||
|
||||
if req.BotInfo.BotId == nil {
|
||||
invalidParamRequestResponse(c, "bot id is nil")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := singleagent.SingleAgentSVC.UpdateSingleAgentDraft(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// GetDraftBotInfoAgw .
|
||||
// @router /api/playground_api/draftbot/get_draft_bot_info [POST]
|
||||
func GetDraftBotInfoAgw(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req playground.GetDraftBotInfoAgwRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if req.BotID == 0 {
|
||||
invalidParamRequestResponse(c, "bot id is nil")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := singleagent.SingleAgentSVC.GetAgentBotInfo(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// GetOfficialPromptResourceList .
|
||||
// @router /api/playground_api/get_official_prompt_list [POST]
|
||||
func GetOfficialPromptResourceList(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req playground.GetOfficialPromptResourceListRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := prompt.PromptSVC.GetOfficialPromptResourceList(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// GetPromptResourceInfo .
|
||||
// @router /api/playground_api/get_prompt_resource_info [GET]
|
||||
func GetPromptResourceInfo(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req playground.GetPromptResourceInfoRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := prompt.PromptSVC.GetPromptResourceInfo(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// UpsertPromptResource .
|
||||
// @router /api/playground_api/upsert_prompt_resource [POST]
|
||||
func UpsertPromptResource(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req playground.UpsertPromptResourceRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if req.Prompt == nil {
|
||||
invalidParamRequestResponse(c, "prompt is nil")
|
||||
return
|
||||
}
|
||||
|
||||
if req.Prompt.GetSpaceID() <= 0 {
|
||||
invalidParamRequestResponse(c, "space id is invalid")
|
||||
return
|
||||
}
|
||||
|
||||
if len(req.Prompt.GetName()) <= 0 {
|
||||
invalidParamRequestResponse(c, "name is empty")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := prompt.PromptSVC.UpsertPromptResource(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// DeletePromptResource .
|
||||
// @router /api/playground_api/delete_prompt_resource [POST]
|
||||
func DeletePromptResource(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req playground.DeletePromptResourceRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := prompt.PromptSVC.DeletePromptResource(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// GetSpaceListV2 .
|
||||
// @router /api/playground_api/space/list [POST]
|
||||
func GetSpaceListV2(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req playground.GetSpaceListV2Request
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := user.UserApplicationSVC.GetSpaceListV2(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// GetImagexShortUrl .
|
||||
// @router /api/playground_api/get_imagex_url [POST]
|
||||
func GetImagexShortUrl(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req playground.GetImagexShortUrlRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if len(req.Uris) == 0 {
|
||||
invalidParamRequestResponse(c, "uris is empty")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := singleagent.SingleAgentSVC.GetImagexShortUrl(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// MGetUserBasicInfo .
|
||||
// @router /api/playground_api/mget_user_info [POST]
|
||||
func MGetUserBasicInfo(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req playground.MGetUserBasicInfoRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := user.UserApplicationSVC.MGetUserBasicInfo(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// GetBotPopupInfo .
|
||||
// @router /api/playground_api/operate/get_bot_popup_info [POST]
|
||||
func GetBotPopupInfo(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req playground.GetBotPopupInfoRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if len(req.BotPopupTypes) == 0 {
|
||||
invalidParamRequestResponse(c, "bot popup types is empty")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := singleagent.SingleAgentSVC.GetAgentPopupInfo(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// UpdateBotPopupInfo .
|
||||
// @router /api/playground_api/operate/update_bot_popup_info [POST]
|
||||
func UpdateBotPopupInfo(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req playground.UpdateBotPopupInfoRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := singleagent.SingleAgentSVC.UpdateAgentPopupInfo(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// CreateUpdateShortcutCommand .
|
||||
// @router /api/playground_api/create_update_shortcut_command [POST]
|
||||
func CreateUpdateShortcutCommand(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req playground.CreateUpdateShortcutCommandRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
c.String(consts.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
shortCuts, err := shortcutcmd.ShortcutCmdSVC.Handler(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
resp := new(playground.CreateUpdateShortcutCommandResponse)
|
||||
resp.Shortcuts = shortCuts
|
||||
resp.Code = 0
|
||||
resp.Msg = ""
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// ReportUserBehavior .
|
||||
// @router /api/playground_api/report_user_behavior [POST]
|
||||
func ReportUserBehavior(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req playground.ReportUserBehaviorRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if req.ResourceID <= 0 {
|
||||
invalidParamRequestResponse(c, "resource id is invalid")
|
||||
return
|
||||
}
|
||||
|
||||
resp := new(playground.ReportUserBehaviorResponse)
|
||||
|
||||
if req.ResourceType == playground.SpaceResourceType_DraftBot {
|
||||
resp, err = singleagent.SingleAgentSVC.ReportUserBehavior(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
} else if req.ResourceType == playground.SpaceResourceType_Project {
|
||||
resp, err = appApplication.APPApplicationSVC.ReportUserBehavior(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// GetFileUrls .
|
||||
// @router /api/playground_api/get_file_list [POST]
|
||||
func GetFileUrls(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req playground.GetFileUrlsRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
c.String(consts.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
iconList, err := upload.SVC.GetShortcutIcons(ctx)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
resp := new(playground.GetFileUrlsResponse)
|
||||
resp.FileList = iconList
|
||||
resp.Code = 0
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
@@ -0,0 +1,915 @@
|
||||
/*
|
||||
* Copyright 2025 coze-dev Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by hertz generator.
|
||||
|
||||
package coze
|
||||
|
||||
import (
|
||||
"context"
|
||||
"regexp"
|
||||
|
||||
"github.com/cloudwego/hertz/pkg/app"
|
||||
"github.com/cloudwego/hertz/pkg/protocol/consts"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/plugin_develop"
|
||||
common "github.com/coze-dev/coze-studio/backend/api/model/plugin_develop/common"
|
||||
"github.com/coze-dev/coze-studio/backend/application/plugin"
|
||||
appworkflow "github.com/coze-dev/coze-studio/backend/application/workflow"
|
||||
)
|
||||
|
||||
// GetPlaygroundPluginList .
|
||||
// @router /api/plugin_api/get_playground_plugin_list [POST]
|
||||
func GetPlaygroundPluginList(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req plugin_develop.GetPlaygroundPluginListRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if req.GetSpaceID() <= 0 {
|
||||
invalidParamRequestResponse(c, "spaceID is invalid")
|
||||
return
|
||||
}
|
||||
if req.GetPage() <= 0 {
|
||||
invalidParamRequestResponse(c, "page is invalid")
|
||||
return
|
||||
}
|
||||
if req.GetSize() >= 30 {
|
||||
invalidParamRequestResponse(c, "size is invalid")
|
||||
return
|
||||
}
|
||||
|
||||
// when there is only one element in the types list, and the element type is workflow, use workflow service
|
||||
// TODO Figure out when there are multiple values for types
|
||||
if len(req.GetPluginTypes()) == 1 && req.GetPluginTypes()[0] == int32(common.PluginType_WORKFLOW) {
|
||||
resp, err := appworkflow.SVC.GetPlaygroundPluginList(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := plugin.PluginApplicationSVC.GetPlaygroundPluginList(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// RegisterPluginMeta .
|
||||
// @router /api/plugin_api/register_plugin_meta [POST]
|
||||
func RegisterPluginMeta(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req plugin_develop.RegisterPluginMetaRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if req.GetName() == "" {
|
||||
invalidParamRequestResponse(c, "plugin name is invalid")
|
||||
return
|
||||
}
|
||||
if req.GetDesc() == "" {
|
||||
invalidParamRequestResponse(c, "plugin desc is invalid")
|
||||
return
|
||||
}
|
||||
if req.URL != nil && (*req.URL == "" || len(*req.URL) > 512) {
|
||||
invalidParamRequestResponse(c, "plugin url is invalid")
|
||||
return
|
||||
}
|
||||
if req.Icon == nil || req.Icon.URI == "" || len(req.Icon.URI) > 512 {
|
||||
invalidParamRequestResponse(c, "plugin icon is invalid")
|
||||
return
|
||||
}
|
||||
if req.AuthType == nil {
|
||||
invalidParamRequestResponse(c, "plugin auth type is invalid")
|
||||
return
|
||||
}
|
||||
if req.SpaceID <= 0 {
|
||||
invalidParamRequestResponse(c, "spaceID is invalid")
|
||||
return
|
||||
}
|
||||
if req.ProjectID != nil {
|
||||
if *req.ProjectID <= 0 {
|
||||
invalidParamRequestResponse(c, "projectID is invalid")
|
||||
return
|
||||
}
|
||||
}
|
||||
if req.GetPluginType() != common.PluginType_PLUGIN {
|
||||
invalidParamRequestResponse(c, "plugin type is invalid")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := plugin.PluginApplicationSVC.RegisterPluginMeta(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// GetPluginAPIs .
|
||||
// @router /api/plugin_api/get_plugin_apis [POST]
|
||||
func GetPluginAPIs(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req plugin_develop.GetPluginAPIsRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if req.PluginID <= 0 {
|
||||
invalidParamRequestResponse(c, "pluginID is invalid")
|
||||
return
|
||||
}
|
||||
if len(req.APIIds) == 0 {
|
||||
if req.Page <= 0 {
|
||||
invalidParamRequestResponse(c, "page is invalid")
|
||||
return
|
||||
}
|
||||
if req.Size >= 30 {
|
||||
invalidParamRequestResponse(c, "size is invalid")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
resp, err := plugin.PluginApplicationSVC.GetPluginAPIs(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// GetPluginInfo .
|
||||
// @router /api/plugin_api/get_plugin_info [POST]
|
||||
func GetPluginInfo(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req plugin_develop.GetPluginInfoRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if req.PluginID <= 0 {
|
||||
invalidParamRequestResponse(c, "pluginID is invalid")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := plugin.PluginApplicationSVC.GetPluginInfo(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// GetUpdatedAPIs .
|
||||
// @router /api/plugin_api/get_updated_apis [POST]
|
||||
func GetUpdatedAPIs(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req plugin_develop.GetUpdatedAPIsRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if req.PluginID <= 0 {
|
||||
invalidParamRequestResponse(c, "pluginID is invalid")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := plugin.PluginApplicationSVC.GetUpdatedAPIs(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// GetOAuthStatus .
|
||||
// @router /api/plugin_api/get_oauth_status [POST]
|
||||
func GetOAuthStatus(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req plugin_develop.GetOAuthStatusRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if req.PluginID <= 0 {
|
||||
invalidParamRequestResponse(c, "pluginID is invalid")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := plugin.PluginApplicationSVC.GetOAuthStatus(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// CheckAndLockPluginEdit .
|
||||
// @router /api/plugin_api/check_and_lock_plugin_edit [POST]
|
||||
func CheckAndLockPluginEdit(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req plugin_develop.CheckAndLockPluginEditRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if req.PluginID <= 0 {
|
||||
invalidParamRequestResponse(c, "pluginID is invalid")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := plugin.PluginApplicationSVC.CheckAndLockPluginEdit(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// UpdatePlugin .
|
||||
// @router /api/plugin_api/update [POST]
|
||||
func UpdatePlugin(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req plugin_develop.UpdatePluginRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if req.PluginID <= 0 {
|
||||
invalidParamRequestResponse(c, "pluginID is invalid")
|
||||
return
|
||||
}
|
||||
if req.AiPlugin == "" {
|
||||
invalidParamRequestResponse(c, "plugin manifest is invalid")
|
||||
return
|
||||
}
|
||||
if req.Openapi == "" {
|
||||
invalidParamRequestResponse(c, "plugin openapi doc is invalid")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := plugin.PluginApplicationSVC.UpdatePlugin(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// DeleteAPI .
|
||||
// @router /api/plugin_api/delete_api [POST]
|
||||
func DeleteAPI(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req plugin_develop.DeleteAPIRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if req.PluginID <= 0 {
|
||||
invalidParamRequestResponse(c, "pluginID is invalid")
|
||||
return
|
||||
}
|
||||
if req.APIID <= 0 {
|
||||
invalidParamRequestResponse(c, "apiID is invalid")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := plugin.PluginApplicationSVC.DeleteAPI(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// DelPlugin .
|
||||
// @router /api/plugin_api/del_plugin [POST]
|
||||
func DelPlugin(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req plugin_develop.DelPluginRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if req.PluginID <= 0 {
|
||||
invalidParamRequestResponse(c, "pluginID is invalid")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := plugin.PluginApplicationSVC.DelPlugin(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// PublishPlugin .
|
||||
// @router /api/plugin_api/publish_plugin [POST]
|
||||
func PublishPlugin(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req plugin_develop.PublishPluginRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if req.PluginID <= 0 {
|
||||
invalidParamRequestResponse(c, "pluginID is invalid")
|
||||
return
|
||||
}
|
||||
if req.VersionName == "" || len(req.VersionName) > 255 {
|
||||
invalidParamRequestResponse(c, "version name is invalid")
|
||||
return
|
||||
}
|
||||
|
||||
match, _ := regexp.MatchString(`^v\d+\.\d+\.\d+$`, req.VersionName)
|
||||
if !match {
|
||||
invalidParamRequestResponse(c, "version name is invalid")
|
||||
return
|
||||
}
|
||||
|
||||
if req.VersionDesc == "" {
|
||||
invalidParamRequestResponse(c, "version desc is invalid")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := plugin.PluginApplicationSVC.PublishPlugin(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// UpdatePluginMeta .
|
||||
// @router /api/plugin_api/update_plugin_meta [POST]
|
||||
func UpdatePluginMeta(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req plugin_develop.UpdatePluginMetaRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if req.PluginID <= 0 {
|
||||
invalidParamRequestResponse(c, "pluginID is invalid")
|
||||
return
|
||||
}
|
||||
if req.Name != nil && *req.Name == "" {
|
||||
invalidParamRequestResponse(c, "plugin name is invalid")
|
||||
return
|
||||
}
|
||||
if req.Desc != nil && *req.Desc == "" {
|
||||
invalidParamRequestResponse(c, "plugin desc is invalid")
|
||||
return
|
||||
}
|
||||
if req.URL != nil && (*req.URL == "" || len(*req.URL) > 512) {
|
||||
invalidParamRequestResponse(c, "plugin server url is invalid")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := plugin.PluginApplicationSVC.UpdatePluginMeta(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// GetBotDefaultParams .
|
||||
// @router /api/plugin_api/get_bot_default_params [POST]
|
||||
func GetBotDefaultParams(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req plugin_develop.GetBotDefaultParamsRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if req.SpaceID <= 0 {
|
||||
invalidParamRequestResponse(c, "spaceID is invalid")
|
||||
return
|
||||
}
|
||||
if req.BotID <= 0 {
|
||||
invalidParamRequestResponse(c, "botID is invalid")
|
||||
return
|
||||
}
|
||||
if req.PluginID <= 0 {
|
||||
invalidParamRequestResponse(c, "pluginID is invalid")
|
||||
return
|
||||
}
|
||||
if req.APIName == "" {
|
||||
invalidParamRequestResponse(c, "apiName is invalid")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := plugin.PluginApplicationSVC.GetBotDefaultParams(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// UpdateBotDefaultParams .
|
||||
// @router /api/plugin_api/update_bot_default_params [POST]
|
||||
func UpdateBotDefaultParams(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req plugin_develop.UpdateBotDefaultParamsRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if req.SpaceID <= 0 {
|
||||
invalidParamRequestResponse(c, "spaceID is invalid")
|
||||
return
|
||||
}
|
||||
if req.BotID <= 0 {
|
||||
invalidParamRequestResponse(c, "botID is invalid")
|
||||
return
|
||||
}
|
||||
if req.PluginID <= 0 {
|
||||
invalidParamRequestResponse(c, "pluginID is invalid")
|
||||
return
|
||||
}
|
||||
if req.APIName == "" {
|
||||
invalidParamRequestResponse(c, "apiName is invalid")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := plugin.PluginApplicationSVC.UpdateBotDefaultParams(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// CreateAPI .
|
||||
// @router /api/plugin_api/create_api [POST]
|
||||
func CreateAPI(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req plugin_develop.CreateAPIRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if req.PluginID <= 0 {
|
||||
invalidParamRequestResponse(c, "pluginID is invalid")
|
||||
return
|
||||
}
|
||||
if req.Name == "" || len(req.Name) > 255 {
|
||||
invalidParamRequestResponse(c, "api name is invalid")
|
||||
return
|
||||
}
|
||||
if req.Desc == "" {
|
||||
invalidParamRequestResponse(c, "api desc is invalid")
|
||||
return
|
||||
}
|
||||
if req.Path != nil && (*req.Path == "" || len(*req.Path) > 512) {
|
||||
invalidParamRequestResponse(c, "api path is invalid")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := plugin.PluginApplicationSVC.CreateAPI(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// UpdateAPI .
|
||||
// @router /api/plugin_api/update_api [POST]
|
||||
func UpdateAPI(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req plugin_develop.UpdateAPIRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if req.PluginID <= 0 {
|
||||
invalidParamRequestResponse(c, "pluginID is invalid")
|
||||
return
|
||||
}
|
||||
if req.APIID <= 0 {
|
||||
invalidParamRequestResponse(c, "apiID is invalid")
|
||||
return
|
||||
}
|
||||
if req.Name != nil && (*req.Name == "" || len(*req.Name) > 255) {
|
||||
invalidParamRequestResponse(c, "api name is invalid")
|
||||
return
|
||||
}
|
||||
if req.Desc != nil && (*req.Desc == "" || len(*req.Desc) > 255) {
|
||||
invalidParamRequestResponse(c, "api desc is invalid")
|
||||
return
|
||||
}
|
||||
if req.Path != nil && (*req.Path == "" || len(*req.Path) > 512) {
|
||||
invalidParamRequestResponse(c, "api path is invalid")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := plugin.PluginApplicationSVC.UpdateAPI(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// GetUserAuthority .
|
||||
// @router /api/plugin_api/get_user_authority [POST]
|
||||
func GetUserAuthority(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req plugin_develop.GetUserAuthorityRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if req.PluginID <= 0 {
|
||||
invalidParamRequestResponse(c, "pluginID is invalid")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := plugin.PluginApplicationSVC.GetUserAuthority(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// DebugAPI .
|
||||
// @router /api/plugin_api/debug_api [POST]
|
||||
func DebugAPI(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req plugin_develop.DebugAPIRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if req.PluginID <= 0 {
|
||||
invalidParamRequestResponse(c, "pluginID is invalid")
|
||||
return
|
||||
}
|
||||
if req.APIID <= 0 {
|
||||
invalidParamRequestResponse(c, "apiID is invalid")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := plugin.PluginApplicationSVC.DebugAPI(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// UnlockPluginEdit .
|
||||
// @router /api/plugin_api/unlock_plugin_edit [POST]
|
||||
func UnlockPluginEdit(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req plugin_develop.UnlockPluginEditRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := plugin.PluginApplicationSVC.UnlockPluginEdit(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// GetPluginNextVersion .
|
||||
// @router /api/plugin_api/get_plugin_next_version [POST]
|
||||
func GetPluginNextVersion(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req plugin_develop.GetPluginNextVersionRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := plugin.PluginApplicationSVC.GetPluginNextVersion(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// RegisterPlugin .
|
||||
// @router /api/developer/register [POST]
|
||||
func RegisterPlugin(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req plugin_develop.RegisterPluginRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if req.GetSpaceID() <= 0 {
|
||||
invalidParamRequestResponse(c, "spaceID is invalid")
|
||||
return
|
||||
}
|
||||
if req.ProjectID != nil && *req.ProjectID <= 0 {
|
||||
invalidParamRequestResponse(c, "projectID is invalid")
|
||||
return
|
||||
}
|
||||
if req.AiPlugin == "" {
|
||||
invalidParamRequestResponse(c, "plugin manifest is invalid")
|
||||
return
|
||||
}
|
||||
if req.Openapi == "" {
|
||||
invalidParamRequestResponse(c, "plugin openapi doc is invalid")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := plugin.PluginApplicationSVC.RegisterPlugin(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// GetDevPluginList .
|
||||
// @router /api/plugin_api/get_dev_plugin_list [POST]
|
||||
func GetDevPluginList(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req plugin_develop.GetDevPluginListRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if req.SpaceID <= 0 {
|
||||
invalidParamRequestResponse(c, "spaceID is invalid")
|
||||
return
|
||||
}
|
||||
if req.ProjectID <= 0 {
|
||||
invalidParamRequestResponse(c, "projectID is invalid")
|
||||
return
|
||||
}
|
||||
if req.GetPage() <= 0 {
|
||||
invalidParamRequestResponse(c, "page is invalid")
|
||||
return
|
||||
}
|
||||
if req.GetSize() <= 0 {
|
||||
invalidParamRequestResponse(c, "size is invalid")
|
||||
return
|
||||
}
|
||||
if req.GetSize() > 50 {
|
||||
invalidParamRequestResponse(c, "size is too large")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := plugin.PluginApplicationSVC.GetDevPluginList(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// Convert2OpenAPI .
|
||||
// @router /api/plugin_api/convert_to_openapi [POST]
|
||||
func Convert2OpenAPI(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req plugin_develop.Convert2OpenAPIRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if req.SpaceID <= 0 {
|
||||
invalidParamRequestResponse(c, "spaceID is invalid")
|
||||
return
|
||||
}
|
||||
if req.Data == "" {
|
||||
invalidParamRequestResponse(c, "data is invalid")
|
||||
return
|
||||
}
|
||||
if req.PluginURL != nil && *req.PluginURL == "" {
|
||||
invalidParamRequestResponse(c, "pluginURL is invalid")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := plugin.PluginApplicationSVC.Convert2OpenAPI(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// GetOAuthSchemaAPI .
|
||||
// @router /api/plugin_api/get_oauth_schema [POST]
|
||||
func GetOAuthSchemaAPI(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req plugin_develop.GetOAuthSchemaRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := plugin.PluginApplicationSVC.GetOAuthSchema(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// GetOAuthSchema .
|
||||
// @router /api/plugin/get_oauth_schema [POST]
|
||||
func GetOAuthSchema(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req plugin_develop.GetOAuthSchemaRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := plugin.PluginApplicationSVC.GetOAuthSchema(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// BatchCreateAPI .
|
||||
// @router /api/plugin_api/batch_create_api [POST]
|
||||
func BatchCreateAPI(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req plugin_develop.BatchCreateAPIRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if req.SpaceID <= 0 {
|
||||
invalidParamRequestResponse(c, "spaceID is invalid")
|
||||
return
|
||||
}
|
||||
if req.PluginID <= 0 {
|
||||
invalidParamRequestResponse(c, "pluginID is invalid")
|
||||
return
|
||||
}
|
||||
if req.AiPlugin == "" {
|
||||
invalidParamRequestResponse(c, "plugin manifest is invalid")
|
||||
return
|
||||
}
|
||||
if req.Openapi == "" {
|
||||
invalidParamRequestResponse(c, "plugin openapi doc is invalid")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := plugin.PluginApplicationSVC.BatchCreateAPI(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// RevokeAuthToken .
|
||||
// @router /api/plugin_api/revoke_auth_token [POST]
|
||||
func RevokeAuthToken(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req plugin_develop.RevokeAuthTokenRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if req.PluginID <= 0 {
|
||||
invalidParamRequestResponse(c, "pluginID is invalid")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := plugin.PluginApplicationSVC.RevokeAuthToken(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// GetQueriedOAuthPluginList .
|
||||
// @router /api/plugin_api/get_queried_oauth_plugins [POST]
|
||||
func GetQueriedOAuthPluginList(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req plugin_develop.GetQueriedOAuthPluginListRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if req.BotID <= 0 {
|
||||
invalidParamRequestResponse(c, "entityID is required")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := plugin.PluginApplicationSVC.GetQueriedOAuthPluginList(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
@@ -0,0 +1,420 @@
|
||||
/*
|
||||
* Copyright 2025 coze-dev Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by hertz generator.
|
||||
|
||||
package coze
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
product_public_api "github.com/coze-dev/coze-studio/backend/api/model/marketplace/product_public_api"
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/workflow"
|
||||
appworkflow "github.com/coze-dev/coze-studio/backend/application/workflow"
|
||||
|
||||
"github.com/cloudwego/hertz/pkg/app"
|
||||
"github.com/cloudwego/hertz/pkg/protocol/consts"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/app/developer_api"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/app/bot_common"
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/marketplace/product_common"
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/playground"
|
||||
appApplication "github.com/coze-dev/coze-studio/backend/application/app"
|
||||
"github.com/coze-dev/coze-studio/backend/application/modelmgr"
|
||||
"github.com/coze-dev/coze-studio/backend/application/plugin"
|
||||
"github.com/coze-dev/coze-studio/backend/application/search"
|
||||
"github.com/coze-dev/coze-studio/backend/application/singleagent"
|
||||
"github.com/coze-dev/coze-studio/backend/application/template"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/logs"
|
||||
)
|
||||
|
||||
// PublicGetProductList .
|
||||
// @router /api/marketplace/product/list [GET]
|
||||
func PublicGetProductList(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req product_public_api.GetProductListRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
var resp *product_public_api.GetProductListResponse
|
||||
switch req.GetEntityType() {
|
||||
case product_common.ProductEntityType_Plugin:
|
||||
resp, err = plugin.PluginApplicationSVC.PublicGetProductList(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
case product_common.ProductEntityType_TemplateCommon:
|
||||
resp, err = template.ApplicationSVC.PublicGetProductList(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
case product_common.ProductEntityType_SaasPlugin:
|
||||
resp, err = plugin.PluginApplicationSVC.GetCozeSaasPluginList(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// PublicGetProductDetail .
|
||||
// @router /api/marketplace/product/detail [GET]
|
||||
func PublicGetProductDetail(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req product_public_api.GetProductDetailRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if req.GetProductID() <= 0 {
|
||||
invalidParamRequestResponse(c, "productID is invalid")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := plugin.PluginApplicationSVC.PublicGetProductDetail(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// PublicFavoriteProduct .
|
||||
// @router /api/marketplace/product/favorite [POST]
|
||||
func PublicFavoriteProduct(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req product_public_api.FavoriteProductRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if req.GetEntityID() <= 0 {
|
||||
invalidParamRequestResponse(c, "entityID is invalid")
|
||||
return
|
||||
}
|
||||
|
||||
// check entity id is valid
|
||||
if req.GetEntityType() == product_common.ProductEntityType_Bot {
|
||||
_, err = singleagent.SingleAgentSVC.ValidateAgentDraftAccess(ctx, req.GetEntityID())
|
||||
} else if req.GetEntityType() == product_common.ProductEntityType_Project {
|
||||
_, err = appApplication.APPApplicationSVC.ValidateDraftAPPAccess(ctx, req.GetEntityID())
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := search.SearchSVC.PublicFavoriteProduct(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// PublicGetUserFavoriteListV2 .
|
||||
// @router /api/marketplace/product/favorite/list.v2 [GET]
|
||||
func PublicGetUserFavoriteListV2(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req product_public_api.GetUserFavoriteListV2Request
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if req.GetPageSize() <= 0 {
|
||||
invalidParamRequestResponse(c, "pageSize is invalid")
|
||||
return
|
||||
}
|
||||
if req.GetEntityType() <= 0 {
|
||||
invalidParamRequestResponse(c, "entityType is invalid")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := search.SearchSVC.PublicGetUserFavoriteList(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// PublicDuplicateProduct .
|
||||
// @router /api/marketplace/product/duplicate [POST]
|
||||
func PublicDuplicateProduct(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req product_public_api.DuplicateProductRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp := new(product_public_api.DuplicateProductResponse)
|
||||
resp.Data = new(product_public_api.DuplicateProductData)
|
||||
|
||||
switch req.GetEntityType() {
|
||||
case product_common.ProductEntityType_BotTemplate:
|
||||
modelListResp, err := modelmgr.ModelmgrApplicationSVC.GetModelList(ctx, &developer_api.GetTypeListRequest{})
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
if modelListResp == nil || modelListResp.Data == nil || len(modelListResp.Data.ModelList) == 0 {
|
||||
invalidParamRequestResponse(c, "no model found")
|
||||
return
|
||||
}
|
||||
|
||||
bot, err := singleagent.SingleAgentSVC.DuplicateDraftBot(ctx, &developer_api.DuplicateDraftBotRequest{
|
||||
BotID: req.GetProductID(),
|
||||
SpaceID: req.GetSpaceID(),
|
||||
})
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
botInfo, err := singleagent.SingleAgentSVC.GetAgentBotInfo(ctx, &playground.GetDraftBotInfoAgwRequest{
|
||||
BotID: bot.Data.BotID,
|
||||
})
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
if botInfo.Data == nil || botInfo.Data.BotInfo == nil {
|
||||
invalidParamRequestResponse(c, "no bot info found")
|
||||
return
|
||||
}
|
||||
|
||||
modelInfo := botInfo.GetData().GetBotInfo().ModelInfo
|
||||
if modelInfo == nil {
|
||||
invalidParamRequestResponse(c, "no model info found in agent")
|
||||
return
|
||||
}
|
||||
modelInfo.ModelId = &modelListResp.Data.ModelList[0].ModelType
|
||||
|
||||
if req.Name != nil {
|
||||
_, err = singleagent.SingleAgentSVC.UpdateSingleAgentDraft(ctx, &playground.UpdateDraftBotInfoAgwRequest{
|
||||
BotInfo: &bot_common.BotInfoForUpdate{
|
||||
BotId: &bot.Data.BotID,
|
||||
Name: req.Name,
|
||||
ModelInfo: modelInfo,
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
resp.Data.NewEntityID = bot.Data.BotID
|
||||
|
||||
case product_common.ProductEntityType_WorkflowTemplateV2:
|
||||
workflowResp, err := appworkflow.SVC.CopyWorkflow(ctx, &workflow.CopyWorkflowRequest{
|
||||
WorkflowID: strconv.FormatInt(req.GetProductID(), 10),
|
||||
SpaceID: strconv.FormatInt(req.GetSpaceID(), 10),
|
||||
})
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
newWorkflowID, err := strconv.ParseInt(workflowResp.Data.WorkflowID, 10, 64)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
resp.Data.NewEntityID = newWorkflowID
|
||||
resp.Data.NewPluginID = &newWorkflowID
|
||||
|
||||
if req.Name != nil {
|
||||
_, err = appworkflow.SVC.UpdateWorkflowMeta(ctx, &workflow.UpdateWorkflowMetaRequest{
|
||||
WorkflowID: workflowResp.Data.WorkflowID,
|
||||
SpaceID: strconv.FormatInt(req.GetSpaceID(), 10),
|
||||
Name: req.Name,
|
||||
})
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// PublicSearchProduct .
|
||||
// @router /api/marketplace/product/search [GET]
|
||||
func PublicSearchProduct(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req product_public_api.SearchProductRequest
|
||||
|
||||
var categoryIDs []int64
|
||||
if categoryIDsStr := string(c.Query("category_ids")); categoryIDsStr != "" {
|
||||
categoryIDs, err = handlerCategoryIDs(c, &req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
c.Request.URI().QueryArgs().Del("category_ids")
|
||||
}
|
||||
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if len(categoryIDs) > 0 {
|
||||
req.CategoryIDs = categoryIDs
|
||||
}
|
||||
// Call plugin application service
|
||||
resp, err := plugin.PluginApplicationSVC.PublicSearchProduct(ctx, &req)
|
||||
if err != nil {
|
||||
logs.CtxErrorf(ctx, "PublicSearchProduct failed: %v", err)
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
func handlerCategoryIDs(c *app.RequestContext, req *product_public_api.SearchProductRequest) ([]int64, error) {
|
||||
var categoryIDs []int64
|
||||
if categoryIDsStr := string(c.Query("category_ids")); categoryIDsStr != "" {
|
||||
categoryIDStrs := strings.Split(categoryIDsStr, ",")
|
||||
categoryIDs = make([]int64, 0, len(categoryIDStrs))
|
||||
for _, idStr := range categoryIDStrs {
|
||||
idStr = strings.TrimSpace(idStr)
|
||||
if idStr != "" {
|
||||
// Validate that it's a valid integer
|
||||
if categoryID, parseErr := strconv.ParseInt(idStr, 10, 64); parseErr == nil {
|
||||
categoryIDs = append(categoryIDs, categoryID)
|
||||
} else {
|
||||
return nil, fmt.Errorf("invalid category_id: %s", idStr)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return categoryIDs, nil
|
||||
}
|
||||
|
||||
// PublicSearchSuggest .
|
||||
// @router /api/marketplace/product/search/suggest [GET]
|
||||
func PublicSearchSuggest(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req product_public_api.SearchSuggestRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
// Call plugin application service
|
||||
resp, err := plugin.PluginApplicationSVC.PublicSearchSuggest(ctx, &req)
|
||||
if err != nil {
|
||||
logs.CtxErrorf(ctx, "PublicSearchSuggest failed: %v", err)
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// PublicGetProductCategoryList .
|
||||
// @router /api/marketplace/product/category/list [GET]
|
||||
func PublicGetProductCategoryList(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req product_public_api.GetProductCategoryListRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
var resp *product_public_api.GetProductCategoryListResponse
|
||||
req.EntityType = product_common.ProductEntityType_SaasPlugin
|
||||
switch req.GetEntityType() {
|
||||
case product_common.ProductEntityType_SaasPlugin:
|
||||
resp, err = plugin.PluginApplicationSVC.GetSaasProductCategoryList(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
}
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// PublicGetProductCallInfo .
|
||||
// @router /api/marketplace/product/call_info [GET]
|
||||
func PublicGetProductCallInfo(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req product_public_api.GetProductCallInfoRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := plugin.PluginApplicationSVC.GetProductCallInfo(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// PublicGetMarketPluginConfig .
|
||||
// @router /api/marketplace/product/config [GET]
|
||||
func PublicGetMarketPluginConfig(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req product_public_api.GetMarketPluginConfigRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := plugin.PluginApplicationSVC.GetMarketPluginConfig(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
@@ -0,0 +1,179 @@
|
||||
/*
|
||||
* Copyright 2025 coze-dev Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by hertz generator.
|
||||
|
||||
package coze
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/cloudwego/hertz/pkg/app"
|
||||
"github.com/cloudwego/hertz/pkg/protocol/consts"
|
||||
|
||||
appApplication "github.com/coze-dev/coze-studio/backend/application/app"
|
||||
|
||||
resource "github.com/coze-dev/coze-studio/backend/api/model/resource"
|
||||
"github.com/coze-dev/coze-studio/backend/application/search"
|
||||
)
|
||||
|
||||
// LibraryResourceList .
|
||||
// @router /api/plugin_api/library_resource_list [POST]
|
||||
func LibraryResourceList(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req resource.LibraryResourceListRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if req.SpaceID <= 0 {
|
||||
invalidParamRequestResponse(c, "space_id is invalid")
|
||||
return
|
||||
}
|
||||
if req.GetSize() > 100 {
|
||||
invalidParamRequestResponse(c, "size is too large")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := search.SearchSVC.LibraryResourceList(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// ProjectResourceList .
|
||||
// @router /api/plugin_api/project_resource_list [POST]
|
||||
func ProjectResourceList(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req resource.ProjectResourceListRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if req.SpaceID <= 0 {
|
||||
invalidParamRequestResponse(c, "space_id is invalid")
|
||||
return
|
||||
}
|
||||
if req.ProjectID <= 0 {
|
||||
invalidParamRequestResponse(c, "project_id is invalid")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := search.SearchSVC.ProjectResourceList(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// ResourceCopyDispatch .
|
||||
// @router /api/plugin_api/resource_copy_dispatch [POST]
|
||||
func ResourceCopyDispatch(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req resource.ResourceCopyDispatchRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if req.ResID <= 0 {
|
||||
invalidParamRequestResponse(c, "res_id is invalid")
|
||||
return
|
||||
}
|
||||
if req.ResType <= 0 {
|
||||
invalidParamRequestResponse(c, "res_type is invalid")
|
||||
return
|
||||
}
|
||||
if req.GetProjectID() <= 0 {
|
||||
invalidParamRequestResponse(c, "project_id is invalid")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := appApplication.APPApplicationSVC.ResourceCopyDispatch(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// ResourceCopyDetail .
|
||||
// @router /api/plugin_api/resource_copy_detail [POST]
|
||||
func ResourceCopyDetail(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req resource.ResourceCopyDetailRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if req.TaskID == "" {
|
||||
invalidParamRequestResponse(c, "task_id is invalid")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := appApplication.APPApplicationSVC.ResourceCopyDetail(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// ResourceCopyRetry .
|
||||
// @router /api/plugin_api/resource_copy_retry [POST]
|
||||
func ResourceCopyRetry(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req resource.ResourceCopyRetryRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp := new(resource.ResourceCopyRetryResponse)
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// ResourceCopyCancel .
|
||||
// @router /api/plugin_api/resource_copy_cancel [POST]
|
||||
func ResourceCopyCancel(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req resource.ResourceCopyCancelRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
c.String(consts.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp := new(resource.ResourceCopyCancelResponse)
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright 2025 coze-dev Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by hertz generator.
|
||||
|
||||
package coze
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/cloudwego/hertz/pkg/app"
|
||||
"github.com/cloudwego/hertz/pkg/protocol/consts"
|
||||
|
||||
upload "github.com/coze-dev/coze-studio/backend/api/model/file/upload"
|
||||
uploadSVC "github.com/coze-dev/coze-studio/backend/application/upload"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
|
||||
)
|
||||
|
||||
// CommonUpload .
|
||||
// @router /api/common/upload/*tos_uri [POST]
|
||||
func CommonUpload(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req upload.CommonUploadRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
fullUrl := string(c.Request.URI().FullURI())
|
||||
|
||||
resp, err := uploadSVC.SVC.UploadFileCommon(ctx, &req, fullUrl)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// ApplyUploadAction .
|
||||
// @router /api/common/upload/apply_upload_action [GET]
|
||||
func ApplyUploadAction(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req upload.ApplyUploadActionRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
resp := new(upload.ApplyUploadActionResponse)
|
||||
host := c.Request.Host()
|
||||
if ptr.From(req.Action) == "ApplyImageUpload" {
|
||||
resp, err = uploadSVC.SVC.ApplyImageUpload(ctx, &req, string(host))
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
} else if ptr.From(req.Action) == "CommitImageUpload" {
|
||||
resp, err = uploadSVC.SVC.CommitImageUpload(ctx, &req, string(host))
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright 2025 coze-dev Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package httputil
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
|
||||
"github.com/cloudwego/hertz/pkg/app"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/errorx"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/logs"
|
||||
)
|
||||
|
||||
type data struct {
|
||||
Code int32 `json:"code"`
|
||||
Msg string `json:"msg"`
|
||||
}
|
||||
|
||||
func BadRequest(c *app.RequestContext, errMsg string) {
|
||||
c.AbortWithStatusJSON(http.StatusBadRequest, data{Code: http.StatusBadRequest, Msg: errMsg})
|
||||
}
|
||||
|
||||
func Unauthorized(c *app.RequestContext, errMsg string) {
|
||||
c.AbortWithStatusJSON(http.StatusUnauthorized, data{Code: http.StatusUnauthorized, Msg: errMsg})
|
||||
}
|
||||
|
||||
func InternalError(ctx context.Context, c *app.RequestContext, err error) {
|
||||
var customErr errorx.StatusError
|
||||
|
||||
if errors.As(err, &customErr) && customErr.Code() != 0 {
|
||||
logs.CtxWarnf(ctx, "[ErrorX] error: %v %v \n", customErr.Code(), err)
|
||||
c.AbortWithStatusJSON(http.StatusOK, data{Code: customErr.Code(), Msg: customErr.Msg()})
|
||||
return
|
||||
}
|
||||
|
||||
logs.CtxErrorf(ctx, "[InternalError] error: %v \n", err)
|
||||
c.AbortWithStatusJSON(http.StatusInternalServerError, data{Code: 500, Msg: "internal server error"})
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright 2025 coze-dev Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/ctxcache"
|
||||
|
||||
"github.com/cloudwego/hertz/pkg/app"
|
||||
)
|
||||
|
||||
func ContextCacheMW() app.HandlerFunc {
|
||||
return func(c context.Context, ctx *app.RequestContext) {
|
||||
c = ctxcache.Init(c)
|
||||
ctx.Next(c)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2025 coze-dev Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/cloudwego/hertz/pkg/app"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/ctxcache"
|
||||
"github.com/coze-dev/coze-studio/backend/types/consts"
|
||||
)
|
||||
|
||||
func SetHostMW() app.HandlerFunc {
|
||||
return func(c context.Context, ctx *app.RequestContext) {
|
||||
ctxcache.Store(c, consts.HostKeyInCtx, string(ctx.Host()))
|
||||
ctxcache.Store(c, consts.RequestSchemeKeyInCtx, string(ctx.GetRequest().Scheme()))
|
||||
ctx.Next(c)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright 2025 coze-dev Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
|
||||
"github.com/cloudwego/hertz/pkg/app"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/domain/user/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/ctxcache"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/i18n"
|
||||
"github.com/coze-dev/coze-studio/backend/types/consts"
|
||||
)
|
||||
|
||||
func I18nMW() app.HandlerFunc {
|
||||
return func(c context.Context, ctx *app.RequestContext) {
|
||||
session, ok := ctxcache.Get[*entity.Session](c, consts.SessionDataKeyInCtx)
|
||||
if ok {
|
||||
c = i18n.SetLocale(c, session.Locale)
|
||||
ctx.Next(c)
|
||||
return
|
||||
}
|
||||
|
||||
acceptLanguage := string(ctx.Request.Header.Get("Accept-Language"))
|
||||
locale := "en-US"
|
||||
if acceptLanguage != "" {
|
||||
languages := strings.Split(acceptLanguage, ",")
|
||||
if len(languages) > 0 {
|
||||
locale = languages[0]
|
||||
}
|
||||
}
|
||||
|
||||
c = i18n.SetLocale(c, locale)
|
||||
|
||||
ctx.Next(c)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright 2025 coze-dev Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
"unsafe"
|
||||
|
||||
"github.com/cloudwego/hertz/pkg/app"
|
||||
"github.com/google/uuid"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/i18n"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/logs"
|
||||
"github.com/coze-dev/coze-studio/backend/types/consts"
|
||||
)
|
||||
|
||||
func AccessLogMW() app.HandlerFunc {
|
||||
return func(c context.Context, ctx *app.RequestContext) {
|
||||
start := time.Now()
|
||||
ctx.Next(c)
|
||||
|
||||
status := ctx.Response.StatusCode()
|
||||
path := bytesToString(ctx.Request.URI().PathOriginal())
|
||||
latency := time.Since(start)
|
||||
method := bytesToString(ctx.Request.Header.Method())
|
||||
clientIP := ctx.ClientIP()
|
||||
|
||||
handlerPkgPath := strings.Split(ctx.HandlerName(), "/")
|
||||
handleName := ""
|
||||
if len(handlerPkgPath) > 0 {
|
||||
handleName = handlerPkgPath[len(handlerPkgPath)-1]
|
||||
}
|
||||
|
||||
requestType := ctx.GetInt32(RequestAuthTypeStr)
|
||||
baseLog := fmt.Sprintf("| %s | %s | %d | %v | %s | %s | %v | %s | %d | %s",
|
||||
string(ctx.GetRequest().Scheme()), ctx.Host(), status,
|
||||
latency, clientIP, method, path, handleName, requestType, i18n.GetLocale(c))
|
||||
|
||||
switch {
|
||||
case status >= http.StatusInternalServerError:
|
||||
logs.CtxErrorf(c, "%s", baseLog)
|
||||
case status >= http.StatusBadRequest:
|
||||
logs.CtxWarnf(c, "%s", baseLog)
|
||||
default:
|
||||
urlQuery := ctx.Request.URI().QueryString()
|
||||
reqBody := bytesToString(ctx.Request.Body())
|
||||
respBody := bytesToString(ctx.Response.Body())
|
||||
maxPrintLen := 3 * 1024
|
||||
if len(respBody) > maxPrintLen {
|
||||
respBody = respBody[:maxPrintLen]
|
||||
}
|
||||
if len(reqBody) > maxPrintLen {
|
||||
reqBody = reqBody[:maxPrintLen]
|
||||
}
|
||||
|
||||
requestAuthType := ctx.GetInt32(RequestAuthTypeStr)
|
||||
if requestAuthType != int32(RequestAuthTypeStaticFile) && filepath.Ext(path) == "" {
|
||||
logs.CtxInfof(c, "%s ", baseLog)
|
||||
logs.CtxDebugf(c, "query : %s \nreq : %s \nresp: %s",
|
||||
urlQuery, reqBody, respBody)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func SetLogIDMW() app.HandlerFunc {
|
||||
return func(ctx context.Context, c *app.RequestContext) {
|
||||
logID := uuid.New().String()
|
||||
ctx = context.WithValue(ctx, consts.CtxLogIDKey, logID)
|
||||
|
||||
c.Header("X-Log-ID", logID)
|
||||
c.Next(ctx)
|
||||
}
|
||||
}
|
||||
|
||||
func bytesToString(b []byte) string {
|
||||
return *(*string)(unsafe.Pointer(&b)) // nolint
|
||||
}
|
||||
@@ -0,0 +1,161 @@
|
||||
/*
|
||||
* Copyright 2025 coze-dev Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/md5"
|
||||
"encoding/hex"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/cloudwego/hertz/pkg/app"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/api/internal/httputil"
|
||||
"github.com/coze-dev/coze-studio/backend/application/openauth"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/ctxcache"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/errorx"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/conv"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/logs"
|
||||
"github.com/coze-dev/coze-studio/backend/types/consts"
|
||||
"github.com/coze-dev/coze-studio/backend/types/errno"
|
||||
)
|
||||
|
||||
const HeaderAuthorizationKey = "Authorization"
|
||||
|
||||
var needAuthPath = map[string]bool{
|
||||
"/v3/chat": true,
|
||||
"/v1/conversations": true,
|
||||
"/v1/conversation/create": true,
|
||||
"/v1/conversation/message/list": true,
|
||||
"/v1/files/upload": true,
|
||||
"/v1/workflow/run": true,
|
||||
"/v1/workflow/stream_run": true,
|
||||
"/v1/workflow/stream_resume": true,
|
||||
"/v1/workflow/get_run_history": true,
|
||||
"/v1/bot/get_online_info": true,
|
||||
"/v1/workflows/chat": true,
|
||||
"/v1/workflow/conversation/create": true,
|
||||
"/v3/chat/cancel": true,
|
||||
"/v1/conversation/retrieve": true,
|
||||
"/v3/chat/retrieve": true,
|
||||
"/v3/chat/message/list": true,
|
||||
"/open_api/knowledge/document/delete": true,
|
||||
"/open_api/knowledge/document/create": true,
|
||||
"/open_api/knowledge/document/update": true,
|
||||
"/open_api/knowledge/document/list": true,
|
||||
"/v1/datasets": true,
|
||||
}
|
||||
|
||||
var needAuthFunc = map[string]bool{
|
||||
"^/v1/conversations/[0-9]+/clear$": true, // v1/conversations/:conversation_id/clear
|
||||
"^/v1/bots/[0-9]+$": true,
|
||||
"^/v1/conversations/[0-9]+$": true,
|
||||
|
||||
"^/v1/workflows/[0-9]+$": true,
|
||||
"^/v1/apps/[0-9]+$": true,
|
||||
|
||||
"^/v1/datasets/[0-9]+$": true, // v1/datasets/:dataset_id
|
||||
"^/v1/datasets/[0-9]+/images$": true, // v1/datasets/:dataset_id/images
|
||||
"^/v1/datasets/[0-9]+/process$": true, // v1/datasets/:dataset_id/process
|
||||
}
|
||||
|
||||
func parseBearerAuthToken(authHeader string) string {
|
||||
if len(authHeader) == 0 {
|
||||
return ""
|
||||
}
|
||||
parts := strings.Split(authHeader, "Bearer")
|
||||
if len(parts) != 2 {
|
||||
return ""
|
||||
}
|
||||
|
||||
token := strings.TrimSpace(parts[1])
|
||||
if len(token) == 0 {
|
||||
return ""
|
||||
}
|
||||
|
||||
return token
|
||||
}
|
||||
|
||||
func isNeedOpenapiAuth(c *app.RequestContext) bool {
|
||||
isNeedAuth := false
|
||||
|
||||
uriPath := c.URI().Path()
|
||||
|
||||
for rule, res := range needAuthFunc {
|
||||
if regexp.MustCompile(rule).MatchString(string(uriPath)) {
|
||||
isNeedAuth = res
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if needAuthPath[string(c.GetRequest().URI().Path())] {
|
||||
isNeedAuth = true
|
||||
}
|
||||
|
||||
return isNeedAuth
|
||||
}
|
||||
|
||||
func OpenapiAuthMW() app.HandlerFunc {
|
||||
return func(ctx context.Context, c *app.RequestContext) {
|
||||
requestAuthType := c.GetInt32(RequestAuthTypeStr)
|
||||
if requestAuthType != int32(RequestAuthTypeOpenAPI) {
|
||||
c.Next(ctx)
|
||||
return
|
||||
}
|
||||
|
||||
// open api auth
|
||||
if len(c.Request.Header.Get(HeaderAuthorizationKey)) == 0 {
|
||||
httputil.InternalError(ctx, c,
|
||||
errorx.New(errno.ErrUserAuthenticationFailed, errorx.KV("reason", "missing authorization in header")))
|
||||
return
|
||||
}
|
||||
|
||||
apiKey := parseBearerAuthToken(c.Request.Header.Get(HeaderAuthorizationKey))
|
||||
if len(apiKey) == 0 {
|
||||
httputil.InternalError(ctx, c,
|
||||
errorx.New(errno.ErrUserAuthenticationFailed, errorx.KV("reason", "missing api_key in request")))
|
||||
return
|
||||
}
|
||||
|
||||
md5Hash := md5.Sum([]byte(apiKey))
|
||||
md5Key := hex.EncodeToString(md5Hash[:])
|
||||
apiKeyInfo, err := openauth.OpenAuthApplication.CheckPermission(ctx, md5Key)
|
||||
|
||||
if err != nil {
|
||||
logs.CtxErrorf(ctx, "OpenAuthApplication.CheckPermission failed, err=%v", err)
|
||||
httputil.InternalError(ctx, c,
|
||||
errorx.New(errno.ErrUserAuthenticationFailed, errorx.KV("reason", err.Error())))
|
||||
return
|
||||
}
|
||||
|
||||
if apiKeyInfo == nil {
|
||||
httputil.InternalError(ctx, c,
|
||||
errorx.New(errno.ErrUserAuthenticationFailed, errorx.KV("reason", "api key invalid")))
|
||||
return
|
||||
}
|
||||
|
||||
apiKeyInfo.ConnectorID = consts.APIConnectorID
|
||||
logs.CtxInfof(ctx, "OpenapiAuthMW: apiKeyInfo=%v", conv.DebugJsonToStr(apiKeyInfo))
|
||||
ctxcache.Store(ctx, consts.OpenapiAuthKeyInCtx, apiKeyInfo)
|
||||
err = openauth.OpenAuthApplication.UpdateLastUsedAt(ctx, apiKeyInfo.ID, apiKeyInfo.UserID)
|
||||
if err != nil {
|
||||
logs.CtxErrorf(ctx, "OpenAuthApplication.UpdateLastUsedAt failed, err=%v", err)
|
||||
}
|
||||
c.Next(ctx)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Copyright 2025 coze-dev Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
|
||||
"github.com/cloudwego/hertz/pkg/app"
|
||||
)
|
||||
|
||||
const RequestAuthTypeStr = "RequestAuthTypeStr"
|
||||
|
||||
type RequestAuthType = int32
|
||||
|
||||
const (
|
||||
RequestAuthTypeWebAPI RequestAuthType = 0
|
||||
RequestAuthTypeOpenAPI RequestAuthType = 1
|
||||
RequestAuthTypeStaticFile RequestAuthType = 2
|
||||
)
|
||||
|
||||
func RequestInspectorMW() app.HandlerFunc {
|
||||
return func(c context.Context, ctx *app.RequestContext) {
|
||||
authType := RequestAuthTypeWebAPI // default is web api, session auth
|
||||
|
||||
if isNeedOpenapiAuth(ctx) {
|
||||
authType = RequestAuthTypeOpenAPI
|
||||
} else if isStaticFile(ctx) {
|
||||
authType = RequestAuthTypeStaticFile
|
||||
}
|
||||
|
||||
ctx.Set(RequestAuthTypeStr, authType)
|
||||
ctx.Next(c)
|
||||
}
|
||||
}
|
||||
|
||||
var staticFilePath = map[string]bool{
|
||||
"/static": true,
|
||||
"/": true,
|
||||
"/sign": true,
|
||||
"/favicon.png": true,
|
||||
}
|
||||
|
||||
func isStaticFile(ctx *app.RequestContext) bool {
|
||||
path := string(ctx.GetRequest().URI().Path())
|
||||
if staticFilePath[path] {
|
||||
return true
|
||||
}
|
||||
|
||||
if strings.HasPrefix(path, "/static/") ||
|
||||
strings.HasPrefix(path, "/explore/") ||
|
||||
strings.HasPrefix(path, "/admin/") ||
|
||||
strings.HasPrefix(path, "/space/") {
|
||||
return true
|
||||
}
|
||||
|
||||
if path == "/information/auth/success" {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
* Copyright 2025 coze-dev Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/cloudwego/hertz/pkg/app"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/api/internal/httputil"
|
||||
"github.com/coze-dev/coze-studio/backend/application/user"
|
||||
"github.com/coze-dev/coze-studio/backend/bizpkg/config"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/user/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/ctxcache"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/errorx"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/logs"
|
||||
"github.com/coze-dev/coze-studio/backend/types/consts"
|
||||
"github.com/coze-dev/coze-studio/backend/types/errno"
|
||||
)
|
||||
|
||||
var noNeedSessionCheckPath = map[string]bool{
|
||||
"/api/passport/web/email/login/": true,
|
||||
"/api/passport/web/email/register/v2/": true,
|
||||
}
|
||||
|
||||
func SessionAuthMW() app.HandlerFunc {
|
||||
return func(c context.Context, ctx *app.RequestContext) {
|
||||
requestAuthType := ctx.GetInt32(RequestAuthTypeStr)
|
||||
if requestAuthType != int32(RequestAuthTypeWebAPI) {
|
||||
ctx.Next(c)
|
||||
return
|
||||
}
|
||||
|
||||
if noNeedSessionCheckPath[string(ctx.GetRequest().URI().Path())] {
|
||||
ctx.Next(c)
|
||||
return
|
||||
}
|
||||
|
||||
s := ctx.Cookie(entity.SessionKey)
|
||||
if len(s) == 0 {
|
||||
logs.Errorf("[SessionAuthMW] session id is nil")
|
||||
httputil.Unauthorized(ctx, "missing session_key in cookie")
|
||||
return
|
||||
}
|
||||
|
||||
// sessionID -> sessionData
|
||||
session, err := user.UserApplicationSVC.ValidateSession(c, string(s))
|
||||
if err != nil {
|
||||
logs.Errorf("[SessionAuthMW] validate session failed, err: %v", err)
|
||||
httputil.InternalError(c, ctx, err)
|
||||
return
|
||||
}
|
||||
|
||||
if session != nil {
|
||||
ctxcache.Store(c, consts.SessionDataKeyInCtx, session)
|
||||
}
|
||||
|
||||
ctx.Next(c)
|
||||
}
|
||||
}
|
||||
|
||||
func AdminAuthMW() app.HandlerFunc {
|
||||
return func(c context.Context, ctx *app.RequestContext) {
|
||||
session, ok := ctxcache.Get[*entity.Session](c, consts.SessionDataKeyInCtx)
|
||||
if !ok {
|
||||
logs.Errorf("[AdminAuthMW] session data is nil")
|
||||
httputil.InternalError(c, ctx,
|
||||
errorx.New(errno.ErrUserAuthenticationFailed, errorx.KV("reason", "session data is nil")))
|
||||
return
|
||||
}
|
||||
|
||||
baseConf, err := config.Base().GetBaseConfig(c)
|
||||
if err != nil {
|
||||
logs.Errorf("[AdminAuthMW] get base config failed, err: %v", err)
|
||||
httputil.InternalError(c, ctx, err)
|
||||
return
|
||||
}
|
||||
|
||||
if baseConf.AdminEmails == "" {
|
||||
baseConf.AdminEmails = os.Getenv(consts.AllowRegistrationEmail)
|
||||
}
|
||||
|
||||
if baseConf.AdminEmails == "" {
|
||||
logs.CtxWarnf(c, "[AdminAuthMW] admin emails is empty, you can set it by env %s", consts.AllowRegistrationEmail)
|
||||
}
|
||||
|
||||
adminEmails := strings.Split(baseConf.AdminEmails, ",")
|
||||
for _, adminEmail := range adminEmails {
|
||||
if strings.EqualFold(adminEmail, session.UserEmail) {
|
||||
ctx.Next(c)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
httputil.Unauthorized(ctx, "the account does not have permission to access")
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,818 @@
|
||||
// Code generated by thriftgo (0.4.2). DO NOT EDIT.
|
||||
|
||||
package common
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"database/sql/driver"
|
||||
"fmt"
|
||||
"github.com/apache/thrift/lib/go/thrift"
|
||||
)
|
||||
|
||||
type IntelligenceStatus int64
|
||||
|
||||
const (
|
||||
IntelligenceStatus_Using IntelligenceStatus = 1
|
||||
IntelligenceStatus_Deleted IntelligenceStatus = 2
|
||||
IntelligenceStatus_Banned IntelligenceStatus = 3
|
||||
// Migration failed
|
||||
IntelligenceStatus_MoveFailed IntelligenceStatus = 4
|
||||
// Copying
|
||||
IntelligenceStatus_Copying IntelligenceStatus = 5
|
||||
// Copy failed
|
||||
IntelligenceStatus_CopyFailed IntelligenceStatus = 6
|
||||
)
|
||||
|
||||
func (p IntelligenceStatus) String() string {
|
||||
switch p {
|
||||
case IntelligenceStatus_Using:
|
||||
return "Using"
|
||||
case IntelligenceStatus_Deleted:
|
||||
return "Deleted"
|
||||
case IntelligenceStatus_Banned:
|
||||
return "Banned"
|
||||
case IntelligenceStatus_MoveFailed:
|
||||
return "MoveFailed"
|
||||
case IntelligenceStatus_Copying:
|
||||
return "Copying"
|
||||
case IntelligenceStatus_CopyFailed:
|
||||
return "CopyFailed"
|
||||
}
|
||||
return "<UNSET>"
|
||||
}
|
||||
|
||||
func IntelligenceStatusFromString(s string) (IntelligenceStatus, error) {
|
||||
switch s {
|
||||
case "Using":
|
||||
return IntelligenceStatus_Using, nil
|
||||
case "Deleted":
|
||||
return IntelligenceStatus_Deleted, nil
|
||||
case "Banned":
|
||||
return IntelligenceStatus_Banned, nil
|
||||
case "MoveFailed":
|
||||
return IntelligenceStatus_MoveFailed, nil
|
||||
case "Copying":
|
||||
return IntelligenceStatus_Copying, nil
|
||||
case "CopyFailed":
|
||||
return IntelligenceStatus_CopyFailed, nil
|
||||
}
|
||||
return IntelligenceStatus(0), fmt.Errorf("not a valid IntelligenceStatus string")
|
||||
}
|
||||
|
||||
func IntelligenceStatusPtr(v IntelligenceStatus) *IntelligenceStatus { return &v }
|
||||
func (p *IntelligenceStatus) Scan(value interface{}) (err error) {
|
||||
var result sql.NullInt64
|
||||
err = result.Scan(value)
|
||||
*p = IntelligenceStatus(result.Int64)
|
||||
return
|
||||
}
|
||||
|
||||
func (p *IntelligenceStatus) Value() (driver.Value, error) {
|
||||
if p == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return int64(*p), nil
|
||||
}
|
||||
|
||||
type IntelligenceType int64
|
||||
|
||||
const (
|
||||
IntelligenceType_Bot IntelligenceType = 1
|
||||
IntelligenceType_Project IntelligenceType = 2
|
||||
)
|
||||
|
||||
func (p IntelligenceType) String() string {
|
||||
switch p {
|
||||
case IntelligenceType_Bot:
|
||||
return "Bot"
|
||||
case IntelligenceType_Project:
|
||||
return "Project"
|
||||
}
|
||||
return "<UNSET>"
|
||||
}
|
||||
|
||||
func IntelligenceTypeFromString(s string) (IntelligenceType, error) {
|
||||
switch s {
|
||||
case "Bot":
|
||||
return IntelligenceType_Bot, nil
|
||||
case "Project":
|
||||
return IntelligenceType_Project, nil
|
||||
}
|
||||
return IntelligenceType(0), fmt.Errorf("not a valid IntelligenceType string")
|
||||
}
|
||||
|
||||
func IntelligenceTypePtr(v IntelligenceType) *IntelligenceType { return &v }
|
||||
func (p *IntelligenceType) Scan(value interface{}) (err error) {
|
||||
var result sql.NullInt64
|
||||
err = result.Scan(value)
|
||||
*p = IntelligenceType(result.Int64)
|
||||
return
|
||||
}
|
||||
|
||||
func (p *IntelligenceType) Value() (driver.Value, error) {
|
||||
if p == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return int64(*p), nil
|
||||
}
|
||||
|
||||
type IntelligenceBasicInfo struct {
|
||||
ID int64 `thrift:"id,1" form:"id" json:"id,string" query:"id"`
|
||||
Name string `thrift:"name,2" form:"name" json:"name" query:"name"`
|
||||
Description string `thrift:"description,3" form:"description" json:"description" query:"description"`
|
||||
IconURI string `thrift:"icon_uri,4" form:"icon_uri" json:"icon_uri" query:"icon_uri"`
|
||||
IconURL string `thrift:"icon_url,5" form:"icon_url" json:"icon_url" query:"icon_url"`
|
||||
SpaceID int64 `thrift:"space_id,6" form:"space_id" json:"space_id,string" query:"space_id"`
|
||||
OwnerID int64 `thrift:"owner_id,7" form:"owner_id" json:"owner_id,string" query:"owner_id"`
|
||||
CreateTime int64 `thrift:"create_time,8" form:"create_time" json:"create_time,string" query:"create_time"`
|
||||
UpdateTime int64 `thrift:"update_time,9" form:"update_time" json:"update_time,string" query:"update_time"`
|
||||
Status IntelligenceStatus `thrift:"status,10" form:"status" json:"status" query:"status"`
|
||||
PublishTime int64 `thrift:"publish_time,11" form:"publish_time" json:"publish_time,string" query:"publish_time"`
|
||||
EnterpriseID *string `thrift:"enterprise_id,12,optional" form:"enterprise_id" json:"enterprise_id,omitempty" query:"enterprise_id"`
|
||||
OrganizationID *int64 `thrift:"organization_id,13,optional" form:"organization_id" json:"organization_id,omitempty" query:"organization_id"`
|
||||
}
|
||||
|
||||
func NewIntelligenceBasicInfo() *IntelligenceBasicInfo {
|
||||
return &IntelligenceBasicInfo{}
|
||||
}
|
||||
|
||||
func (p *IntelligenceBasicInfo) InitDefault() {
|
||||
}
|
||||
|
||||
func (p *IntelligenceBasicInfo) GetID() (v int64) {
|
||||
return p.ID
|
||||
}
|
||||
|
||||
func (p *IntelligenceBasicInfo) GetName() (v string) {
|
||||
return p.Name
|
||||
}
|
||||
|
||||
func (p *IntelligenceBasicInfo) GetDescription() (v string) {
|
||||
return p.Description
|
||||
}
|
||||
|
||||
func (p *IntelligenceBasicInfo) GetIconURI() (v string) {
|
||||
return p.IconURI
|
||||
}
|
||||
|
||||
func (p *IntelligenceBasicInfo) GetIconURL() (v string) {
|
||||
return p.IconURL
|
||||
}
|
||||
|
||||
func (p *IntelligenceBasicInfo) GetSpaceID() (v int64) {
|
||||
return p.SpaceID
|
||||
}
|
||||
|
||||
func (p *IntelligenceBasicInfo) GetOwnerID() (v int64) {
|
||||
return p.OwnerID
|
||||
}
|
||||
|
||||
func (p *IntelligenceBasicInfo) GetCreateTime() (v int64) {
|
||||
return p.CreateTime
|
||||
}
|
||||
|
||||
func (p *IntelligenceBasicInfo) GetUpdateTime() (v int64) {
|
||||
return p.UpdateTime
|
||||
}
|
||||
|
||||
func (p *IntelligenceBasicInfo) GetStatus() (v IntelligenceStatus) {
|
||||
return p.Status
|
||||
}
|
||||
|
||||
func (p *IntelligenceBasicInfo) GetPublishTime() (v int64) {
|
||||
return p.PublishTime
|
||||
}
|
||||
|
||||
var IntelligenceBasicInfo_EnterpriseID_DEFAULT string
|
||||
|
||||
func (p *IntelligenceBasicInfo) GetEnterpriseID() (v string) {
|
||||
if !p.IsSetEnterpriseID() {
|
||||
return IntelligenceBasicInfo_EnterpriseID_DEFAULT
|
||||
}
|
||||
return *p.EnterpriseID
|
||||
}
|
||||
|
||||
var IntelligenceBasicInfo_OrganizationID_DEFAULT int64
|
||||
|
||||
func (p *IntelligenceBasicInfo) GetOrganizationID() (v int64) {
|
||||
if !p.IsSetOrganizationID() {
|
||||
return IntelligenceBasicInfo_OrganizationID_DEFAULT
|
||||
}
|
||||
return *p.OrganizationID
|
||||
}
|
||||
|
||||
var fieldIDToName_IntelligenceBasicInfo = map[int16]string{
|
||||
1: "id",
|
||||
2: "name",
|
||||
3: "description",
|
||||
4: "icon_uri",
|
||||
5: "icon_url",
|
||||
6: "space_id",
|
||||
7: "owner_id",
|
||||
8: "create_time",
|
||||
9: "update_time",
|
||||
10: "status",
|
||||
11: "publish_time",
|
||||
12: "enterprise_id",
|
||||
13: "organization_id",
|
||||
}
|
||||
|
||||
func (p *IntelligenceBasicInfo) IsSetEnterpriseID() bool {
|
||||
return p.EnterpriseID != nil
|
||||
}
|
||||
|
||||
func (p *IntelligenceBasicInfo) IsSetOrganizationID() bool {
|
||||
return p.OrganizationID != nil
|
||||
}
|
||||
|
||||
func (p *IntelligenceBasicInfo) Read(iprot thrift.TProtocol) (err error) {
|
||||
var fieldTypeId thrift.TType
|
||||
var fieldId int16
|
||||
|
||||
if _, err = iprot.ReadStructBegin(); err != nil {
|
||||
goto ReadStructBeginError
|
||||
}
|
||||
|
||||
for {
|
||||
_, fieldTypeId, fieldId, err = iprot.ReadFieldBegin()
|
||||
if err != nil {
|
||||
goto ReadFieldBeginError
|
||||
}
|
||||
if fieldTypeId == thrift.STOP {
|
||||
break
|
||||
}
|
||||
|
||||
switch fieldId {
|
||||
case 1:
|
||||
if fieldTypeId == thrift.I64 {
|
||||
if err = p.ReadField1(iprot); err != nil {
|
||||
goto ReadFieldError
|
||||
}
|
||||
} else if err = iprot.Skip(fieldTypeId); err != nil {
|
||||
goto SkipFieldError
|
||||
}
|
||||
case 2:
|
||||
if fieldTypeId == thrift.STRING {
|
||||
if err = p.ReadField2(iprot); err != nil {
|
||||
goto ReadFieldError
|
||||
}
|
||||
} else if err = iprot.Skip(fieldTypeId); err != nil {
|
||||
goto SkipFieldError
|
||||
}
|
||||
case 3:
|
||||
if fieldTypeId == thrift.STRING {
|
||||
if err = p.ReadField3(iprot); err != nil {
|
||||
goto ReadFieldError
|
||||
}
|
||||
} else if err = iprot.Skip(fieldTypeId); err != nil {
|
||||
goto SkipFieldError
|
||||
}
|
||||
case 4:
|
||||
if fieldTypeId == thrift.STRING {
|
||||
if err = p.ReadField4(iprot); err != nil {
|
||||
goto ReadFieldError
|
||||
}
|
||||
} else if err = iprot.Skip(fieldTypeId); err != nil {
|
||||
goto SkipFieldError
|
||||
}
|
||||
case 5:
|
||||
if fieldTypeId == thrift.STRING {
|
||||
if err = p.ReadField5(iprot); err != nil {
|
||||
goto ReadFieldError
|
||||
}
|
||||
} else if err = iprot.Skip(fieldTypeId); err != nil {
|
||||
goto SkipFieldError
|
||||
}
|
||||
case 6:
|
||||
if fieldTypeId == thrift.I64 {
|
||||
if err = p.ReadField6(iprot); err != nil {
|
||||
goto ReadFieldError
|
||||
}
|
||||
} else if err = iprot.Skip(fieldTypeId); err != nil {
|
||||
goto SkipFieldError
|
||||
}
|
||||
case 7:
|
||||
if fieldTypeId == thrift.I64 {
|
||||
if err = p.ReadField7(iprot); err != nil {
|
||||
goto ReadFieldError
|
||||
}
|
||||
} else if err = iprot.Skip(fieldTypeId); err != nil {
|
||||
goto SkipFieldError
|
||||
}
|
||||
case 8:
|
||||
if fieldTypeId == thrift.I64 {
|
||||
if err = p.ReadField8(iprot); err != nil {
|
||||
goto ReadFieldError
|
||||
}
|
||||
} else if err = iprot.Skip(fieldTypeId); err != nil {
|
||||
goto SkipFieldError
|
||||
}
|
||||
case 9:
|
||||
if fieldTypeId == thrift.I64 {
|
||||
if err = p.ReadField9(iprot); err != nil {
|
||||
goto ReadFieldError
|
||||
}
|
||||
} else if err = iprot.Skip(fieldTypeId); err != nil {
|
||||
goto SkipFieldError
|
||||
}
|
||||
case 10:
|
||||
if fieldTypeId == thrift.I32 {
|
||||
if err = p.ReadField10(iprot); err != nil {
|
||||
goto ReadFieldError
|
||||
}
|
||||
} else if err = iprot.Skip(fieldTypeId); err != nil {
|
||||
goto SkipFieldError
|
||||
}
|
||||
case 11:
|
||||
if fieldTypeId == thrift.I64 {
|
||||
if err = p.ReadField11(iprot); err != nil {
|
||||
goto ReadFieldError
|
||||
}
|
||||
} else if err = iprot.Skip(fieldTypeId); err != nil {
|
||||
goto SkipFieldError
|
||||
}
|
||||
case 12:
|
||||
if fieldTypeId == thrift.STRING {
|
||||
if err = p.ReadField12(iprot); err != nil {
|
||||
goto ReadFieldError
|
||||
}
|
||||
} else if err = iprot.Skip(fieldTypeId); err != nil {
|
||||
goto SkipFieldError
|
||||
}
|
||||
case 13:
|
||||
if fieldTypeId == thrift.I64 {
|
||||
if err = p.ReadField13(iprot); err != nil {
|
||||
goto ReadFieldError
|
||||
}
|
||||
} else if err = iprot.Skip(fieldTypeId); err != nil {
|
||||
goto SkipFieldError
|
||||
}
|
||||
default:
|
||||
if err = iprot.Skip(fieldTypeId); err != nil {
|
||||
goto SkipFieldError
|
||||
}
|
||||
}
|
||||
if err = iprot.ReadFieldEnd(); err != nil {
|
||||
goto ReadFieldEndError
|
||||
}
|
||||
}
|
||||
if err = iprot.ReadStructEnd(); err != nil {
|
||||
goto ReadStructEndError
|
||||
}
|
||||
|
||||
return nil
|
||||
ReadStructBeginError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err)
|
||||
ReadFieldBeginError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err)
|
||||
ReadFieldError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_IntelligenceBasicInfo[fieldId]), err)
|
||||
SkipFieldError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err)
|
||||
|
||||
ReadFieldEndError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err)
|
||||
ReadStructEndError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
|
||||
}
|
||||
|
||||
func (p *IntelligenceBasicInfo) ReadField1(iprot thrift.TProtocol) error {
|
||||
|
||||
var _field int64
|
||||
if v, err := iprot.ReadI64(); err != nil {
|
||||
return err
|
||||
} else {
|
||||
_field = v
|
||||
}
|
||||
p.ID = _field
|
||||
return nil
|
||||
}
|
||||
func (p *IntelligenceBasicInfo) ReadField2(iprot thrift.TProtocol) error {
|
||||
|
||||
var _field string
|
||||
if v, err := iprot.ReadString(); err != nil {
|
||||
return err
|
||||
} else {
|
||||
_field = v
|
||||
}
|
||||
p.Name = _field
|
||||
return nil
|
||||
}
|
||||
func (p *IntelligenceBasicInfo) ReadField3(iprot thrift.TProtocol) error {
|
||||
|
||||
var _field string
|
||||
if v, err := iprot.ReadString(); err != nil {
|
||||
return err
|
||||
} else {
|
||||
_field = v
|
||||
}
|
||||
p.Description = _field
|
||||
return nil
|
||||
}
|
||||
func (p *IntelligenceBasicInfo) ReadField4(iprot thrift.TProtocol) error {
|
||||
|
||||
var _field string
|
||||
if v, err := iprot.ReadString(); err != nil {
|
||||
return err
|
||||
} else {
|
||||
_field = v
|
||||
}
|
||||
p.IconURI = _field
|
||||
return nil
|
||||
}
|
||||
func (p *IntelligenceBasicInfo) ReadField5(iprot thrift.TProtocol) error {
|
||||
|
||||
var _field string
|
||||
if v, err := iprot.ReadString(); err != nil {
|
||||
return err
|
||||
} else {
|
||||
_field = v
|
||||
}
|
||||
p.IconURL = _field
|
||||
return nil
|
||||
}
|
||||
func (p *IntelligenceBasicInfo) ReadField6(iprot thrift.TProtocol) error {
|
||||
|
||||
var _field int64
|
||||
if v, err := iprot.ReadI64(); err != nil {
|
||||
return err
|
||||
} else {
|
||||
_field = v
|
||||
}
|
||||
p.SpaceID = _field
|
||||
return nil
|
||||
}
|
||||
func (p *IntelligenceBasicInfo) ReadField7(iprot thrift.TProtocol) error {
|
||||
|
||||
var _field int64
|
||||
if v, err := iprot.ReadI64(); err != nil {
|
||||
return err
|
||||
} else {
|
||||
_field = v
|
||||
}
|
||||
p.OwnerID = _field
|
||||
return nil
|
||||
}
|
||||
func (p *IntelligenceBasicInfo) ReadField8(iprot thrift.TProtocol) error {
|
||||
|
||||
var _field int64
|
||||
if v, err := iprot.ReadI64(); err != nil {
|
||||
return err
|
||||
} else {
|
||||
_field = v
|
||||
}
|
||||
p.CreateTime = _field
|
||||
return nil
|
||||
}
|
||||
func (p *IntelligenceBasicInfo) ReadField9(iprot thrift.TProtocol) error {
|
||||
|
||||
var _field int64
|
||||
if v, err := iprot.ReadI64(); err != nil {
|
||||
return err
|
||||
} else {
|
||||
_field = v
|
||||
}
|
||||
p.UpdateTime = _field
|
||||
return nil
|
||||
}
|
||||
func (p *IntelligenceBasicInfo) ReadField10(iprot thrift.TProtocol) error {
|
||||
|
||||
var _field IntelligenceStatus
|
||||
if v, err := iprot.ReadI32(); err != nil {
|
||||
return err
|
||||
} else {
|
||||
_field = IntelligenceStatus(v)
|
||||
}
|
||||
p.Status = _field
|
||||
return nil
|
||||
}
|
||||
func (p *IntelligenceBasicInfo) ReadField11(iprot thrift.TProtocol) error {
|
||||
|
||||
var _field int64
|
||||
if v, err := iprot.ReadI64(); err != nil {
|
||||
return err
|
||||
} else {
|
||||
_field = v
|
||||
}
|
||||
p.PublishTime = _field
|
||||
return nil
|
||||
}
|
||||
func (p *IntelligenceBasicInfo) ReadField12(iprot thrift.TProtocol) error {
|
||||
|
||||
var _field *string
|
||||
if v, err := iprot.ReadString(); err != nil {
|
||||
return err
|
||||
} else {
|
||||
_field = &v
|
||||
}
|
||||
p.EnterpriseID = _field
|
||||
return nil
|
||||
}
|
||||
func (p *IntelligenceBasicInfo) ReadField13(iprot thrift.TProtocol) error {
|
||||
|
||||
var _field *int64
|
||||
if v, err := iprot.ReadI64(); err != nil {
|
||||
return err
|
||||
} else {
|
||||
_field = &v
|
||||
}
|
||||
p.OrganizationID = _field
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *IntelligenceBasicInfo) Write(oprot thrift.TProtocol) (err error) {
|
||||
var fieldId int16
|
||||
if err = oprot.WriteStructBegin("IntelligenceBasicInfo"); err != nil {
|
||||
goto WriteStructBeginError
|
||||
}
|
||||
if p != nil {
|
||||
if err = p.writeField1(oprot); err != nil {
|
||||
fieldId = 1
|
||||
goto WriteFieldError
|
||||
}
|
||||
if err = p.writeField2(oprot); err != nil {
|
||||
fieldId = 2
|
||||
goto WriteFieldError
|
||||
}
|
||||
if err = p.writeField3(oprot); err != nil {
|
||||
fieldId = 3
|
||||
goto WriteFieldError
|
||||
}
|
||||
if err = p.writeField4(oprot); err != nil {
|
||||
fieldId = 4
|
||||
goto WriteFieldError
|
||||
}
|
||||
if err = p.writeField5(oprot); err != nil {
|
||||
fieldId = 5
|
||||
goto WriteFieldError
|
||||
}
|
||||
if err = p.writeField6(oprot); err != nil {
|
||||
fieldId = 6
|
||||
goto WriteFieldError
|
||||
}
|
||||
if err = p.writeField7(oprot); err != nil {
|
||||
fieldId = 7
|
||||
goto WriteFieldError
|
||||
}
|
||||
if err = p.writeField8(oprot); err != nil {
|
||||
fieldId = 8
|
||||
goto WriteFieldError
|
||||
}
|
||||
if err = p.writeField9(oprot); err != nil {
|
||||
fieldId = 9
|
||||
goto WriteFieldError
|
||||
}
|
||||
if err = p.writeField10(oprot); err != nil {
|
||||
fieldId = 10
|
||||
goto WriteFieldError
|
||||
}
|
||||
if err = p.writeField11(oprot); err != nil {
|
||||
fieldId = 11
|
||||
goto WriteFieldError
|
||||
}
|
||||
if err = p.writeField12(oprot); err != nil {
|
||||
fieldId = 12
|
||||
goto WriteFieldError
|
||||
}
|
||||
if err = p.writeField13(oprot); err != nil {
|
||||
fieldId = 13
|
||||
goto WriteFieldError
|
||||
}
|
||||
}
|
||||
if err = oprot.WriteFieldStop(); err != nil {
|
||||
goto WriteFieldStopError
|
||||
}
|
||||
if err = oprot.WriteStructEnd(); err != nil {
|
||||
goto WriteStructEndError
|
||||
}
|
||||
return nil
|
||||
WriteStructBeginError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err)
|
||||
WriteFieldError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err)
|
||||
WriteFieldStopError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err)
|
||||
WriteStructEndError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err)
|
||||
}
|
||||
|
||||
func (p *IntelligenceBasicInfo) writeField1(oprot thrift.TProtocol) (err error) {
|
||||
if err = oprot.WriteFieldBegin("id", thrift.I64, 1); err != nil {
|
||||
goto WriteFieldBeginError
|
||||
}
|
||||
if err := oprot.WriteI64(p.ID); err != nil {
|
||||
return err
|
||||
}
|
||||
if err = oprot.WriteFieldEnd(); err != nil {
|
||||
goto WriteFieldEndError
|
||||
}
|
||||
return nil
|
||||
WriteFieldBeginError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err)
|
||||
WriteFieldEndError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err)
|
||||
}
|
||||
func (p *IntelligenceBasicInfo) writeField2(oprot thrift.TProtocol) (err error) {
|
||||
if err = oprot.WriteFieldBegin("name", thrift.STRING, 2); err != nil {
|
||||
goto WriteFieldBeginError
|
||||
}
|
||||
if err := oprot.WriteString(p.Name); err != nil {
|
||||
return err
|
||||
}
|
||||
if err = oprot.WriteFieldEnd(); err != nil {
|
||||
goto WriteFieldEndError
|
||||
}
|
||||
return nil
|
||||
WriteFieldBeginError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err)
|
||||
WriteFieldEndError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err)
|
||||
}
|
||||
func (p *IntelligenceBasicInfo) writeField3(oprot thrift.TProtocol) (err error) {
|
||||
if err = oprot.WriteFieldBegin("description", thrift.STRING, 3); err != nil {
|
||||
goto WriteFieldBeginError
|
||||
}
|
||||
if err := oprot.WriteString(p.Description); err != nil {
|
||||
return err
|
||||
}
|
||||
if err = oprot.WriteFieldEnd(); err != nil {
|
||||
goto WriteFieldEndError
|
||||
}
|
||||
return nil
|
||||
WriteFieldBeginError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field 3 begin error: ", p), err)
|
||||
WriteFieldEndError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err)
|
||||
}
|
||||
func (p *IntelligenceBasicInfo) writeField4(oprot thrift.TProtocol) (err error) {
|
||||
if err = oprot.WriteFieldBegin("icon_uri", thrift.STRING, 4); err != nil {
|
||||
goto WriteFieldBeginError
|
||||
}
|
||||
if err := oprot.WriteString(p.IconURI); err != nil {
|
||||
return err
|
||||
}
|
||||
if err = oprot.WriteFieldEnd(); err != nil {
|
||||
goto WriteFieldEndError
|
||||
}
|
||||
return nil
|
||||
WriteFieldBeginError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field 4 begin error: ", p), err)
|
||||
WriteFieldEndError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field 4 end error: ", p), err)
|
||||
}
|
||||
func (p *IntelligenceBasicInfo) writeField5(oprot thrift.TProtocol) (err error) {
|
||||
if err = oprot.WriteFieldBegin("icon_url", thrift.STRING, 5); err != nil {
|
||||
goto WriteFieldBeginError
|
||||
}
|
||||
if err := oprot.WriteString(p.IconURL); err != nil {
|
||||
return err
|
||||
}
|
||||
if err = oprot.WriteFieldEnd(); err != nil {
|
||||
goto WriteFieldEndError
|
||||
}
|
||||
return nil
|
||||
WriteFieldBeginError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field 5 begin error: ", p), err)
|
||||
WriteFieldEndError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field 5 end error: ", p), err)
|
||||
}
|
||||
func (p *IntelligenceBasicInfo) writeField6(oprot thrift.TProtocol) (err error) {
|
||||
if err = oprot.WriteFieldBegin("space_id", thrift.I64, 6); err != nil {
|
||||
goto WriteFieldBeginError
|
||||
}
|
||||
if err := oprot.WriteI64(p.SpaceID); err != nil {
|
||||
return err
|
||||
}
|
||||
if err = oprot.WriteFieldEnd(); err != nil {
|
||||
goto WriteFieldEndError
|
||||
}
|
||||
return nil
|
||||
WriteFieldBeginError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field 6 begin error: ", p), err)
|
||||
WriteFieldEndError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field 6 end error: ", p), err)
|
||||
}
|
||||
func (p *IntelligenceBasicInfo) writeField7(oprot thrift.TProtocol) (err error) {
|
||||
if err = oprot.WriteFieldBegin("owner_id", thrift.I64, 7); err != nil {
|
||||
goto WriteFieldBeginError
|
||||
}
|
||||
if err := oprot.WriteI64(p.OwnerID); err != nil {
|
||||
return err
|
||||
}
|
||||
if err = oprot.WriteFieldEnd(); err != nil {
|
||||
goto WriteFieldEndError
|
||||
}
|
||||
return nil
|
||||
WriteFieldBeginError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field 7 begin error: ", p), err)
|
||||
WriteFieldEndError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field 7 end error: ", p), err)
|
||||
}
|
||||
func (p *IntelligenceBasicInfo) writeField8(oprot thrift.TProtocol) (err error) {
|
||||
if err = oprot.WriteFieldBegin("create_time", thrift.I64, 8); err != nil {
|
||||
goto WriteFieldBeginError
|
||||
}
|
||||
if err := oprot.WriteI64(p.CreateTime); err != nil {
|
||||
return err
|
||||
}
|
||||
if err = oprot.WriteFieldEnd(); err != nil {
|
||||
goto WriteFieldEndError
|
||||
}
|
||||
return nil
|
||||
WriteFieldBeginError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field 8 begin error: ", p), err)
|
||||
WriteFieldEndError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field 8 end error: ", p), err)
|
||||
}
|
||||
func (p *IntelligenceBasicInfo) writeField9(oprot thrift.TProtocol) (err error) {
|
||||
if err = oprot.WriteFieldBegin("update_time", thrift.I64, 9); err != nil {
|
||||
goto WriteFieldBeginError
|
||||
}
|
||||
if err := oprot.WriteI64(p.UpdateTime); err != nil {
|
||||
return err
|
||||
}
|
||||
if err = oprot.WriteFieldEnd(); err != nil {
|
||||
goto WriteFieldEndError
|
||||
}
|
||||
return nil
|
||||
WriteFieldBeginError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field 9 begin error: ", p), err)
|
||||
WriteFieldEndError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field 9 end error: ", p), err)
|
||||
}
|
||||
func (p *IntelligenceBasicInfo) writeField10(oprot thrift.TProtocol) (err error) {
|
||||
if err = oprot.WriteFieldBegin("status", thrift.I32, 10); err != nil {
|
||||
goto WriteFieldBeginError
|
||||
}
|
||||
if err := oprot.WriteI32(int32(p.Status)); err != nil {
|
||||
return err
|
||||
}
|
||||
if err = oprot.WriteFieldEnd(); err != nil {
|
||||
goto WriteFieldEndError
|
||||
}
|
||||
return nil
|
||||
WriteFieldBeginError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field 10 begin error: ", p), err)
|
||||
WriteFieldEndError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field 10 end error: ", p), err)
|
||||
}
|
||||
func (p *IntelligenceBasicInfo) writeField11(oprot thrift.TProtocol) (err error) {
|
||||
if err = oprot.WriteFieldBegin("publish_time", thrift.I64, 11); err != nil {
|
||||
goto WriteFieldBeginError
|
||||
}
|
||||
if err := oprot.WriteI64(p.PublishTime); err != nil {
|
||||
return err
|
||||
}
|
||||
if err = oprot.WriteFieldEnd(); err != nil {
|
||||
goto WriteFieldEndError
|
||||
}
|
||||
return nil
|
||||
WriteFieldBeginError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field 11 begin error: ", p), err)
|
||||
WriteFieldEndError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field 11 end error: ", p), err)
|
||||
}
|
||||
func (p *IntelligenceBasicInfo) writeField12(oprot thrift.TProtocol) (err error) {
|
||||
if p.IsSetEnterpriseID() {
|
||||
if err = oprot.WriteFieldBegin("enterprise_id", thrift.STRING, 12); err != nil {
|
||||
goto WriteFieldBeginError
|
||||
}
|
||||
if err := oprot.WriteString(*p.EnterpriseID); err != nil {
|
||||
return err
|
||||
}
|
||||
if err = oprot.WriteFieldEnd(); err != nil {
|
||||
goto WriteFieldEndError
|
||||
}
|
||||
}
|
||||
return nil
|
||||
WriteFieldBeginError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field 12 begin error: ", p), err)
|
||||
WriteFieldEndError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field 12 end error: ", p), err)
|
||||
}
|
||||
func (p *IntelligenceBasicInfo) writeField13(oprot thrift.TProtocol) (err error) {
|
||||
if p.IsSetOrganizationID() {
|
||||
if err = oprot.WriteFieldBegin("organization_id", thrift.I64, 13); err != nil {
|
||||
goto WriteFieldBeginError
|
||||
}
|
||||
if err := oprot.WriteI64(*p.OrganizationID); err != nil {
|
||||
return err
|
||||
}
|
||||
if err = oprot.WriteFieldEnd(); err != nil {
|
||||
goto WriteFieldEndError
|
||||
}
|
||||
}
|
||||
return nil
|
||||
WriteFieldBeginError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field 13 begin error: ", p), err)
|
||||
WriteFieldEndError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field 13 end error: ", p), err)
|
||||
}
|
||||
|
||||
func (p *IntelligenceBasicInfo) String() string {
|
||||
if p == nil {
|
||||
return "<nil>"
|
||||
}
|
||||
return fmt.Sprintf("IntelligenceBasicInfo(%+v)", *p)
|
||||
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
// Code generated by thriftgo (0.4.2). DO NOT EDIT.
|
||||
|
||||
package common
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/apache/thrift/lib/go/thrift"
|
||||
)
|
||||
|
||||
type ProjectInnerTaskInfo struct {
|
||||
// Task ID
|
||||
TaskID int64 `thrift:"task_id,1" form:"task_id" json:"task_id,string" query:"task_id"`
|
||||
}
|
||||
|
||||
func NewProjectInnerTaskInfo() *ProjectInnerTaskInfo {
|
||||
return &ProjectInnerTaskInfo{}
|
||||
}
|
||||
|
||||
func (p *ProjectInnerTaskInfo) InitDefault() {
|
||||
}
|
||||
|
||||
func (p *ProjectInnerTaskInfo) GetTaskID() (v int64) {
|
||||
return p.TaskID
|
||||
}
|
||||
|
||||
var fieldIDToName_ProjectInnerTaskInfo = map[int16]string{
|
||||
1: "task_id",
|
||||
}
|
||||
|
||||
func (p *ProjectInnerTaskInfo) Read(iprot thrift.TProtocol) (err error) {
|
||||
var fieldTypeId thrift.TType
|
||||
var fieldId int16
|
||||
|
||||
if _, err = iprot.ReadStructBegin(); err != nil {
|
||||
goto ReadStructBeginError
|
||||
}
|
||||
|
||||
for {
|
||||
_, fieldTypeId, fieldId, err = iprot.ReadFieldBegin()
|
||||
if err != nil {
|
||||
goto ReadFieldBeginError
|
||||
}
|
||||
if fieldTypeId == thrift.STOP {
|
||||
break
|
||||
}
|
||||
|
||||
switch fieldId {
|
||||
case 1:
|
||||
if fieldTypeId == thrift.I64 {
|
||||
if err = p.ReadField1(iprot); err != nil {
|
||||
goto ReadFieldError
|
||||
}
|
||||
} else if err = iprot.Skip(fieldTypeId); err != nil {
|
||||
goto SkipFieldError
|
||||
}
|
||||
default:
|
||||
if err = iprot.Skip(fieldTypeId); err != nil {
|
||||
goto SkipFieldError
|
||||
}
|
||||
}
|
||||
if err = iprot.ReadFieldEnd(); err != nil {
|
||||
goto ReadFieldEndError
|
||||
}
|
||||
}
|
||||
if err = iprot.ReadStructEnd(); err != nil {
|
||||
goto ReadStructEndError
|
||||
}
|
||||
|
||||
return nil
|
||||
ReadStructBeginError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err)
|
||||
ReadFieldBeginError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err)
|
||||
ReadFieldError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ProjectInnerTaskInfo[fieldId]), err)
|
||||
SkipFieldError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err)
|
||||
|
||||
ReadFieldEndError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err)
|
||||
ReadStructEndError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
|
||||
}
|
||||
|
||||
func (p *ProjectInnerTaskInfo) ReadField1(iprot thrift.TProtocol) error {
|
||||
|
||||
var _field int64
|
||||
if v, err := iprot.ReadI64(); err != nil {
|
||||
return err
|
||||
} else {
|
||||
_field = v
|
||||
}
|
||||
p.TaskID = _field
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *ProjectInnerTaskInfo) Write(oprot thrift.TProtocol) (err error) {
|
||||
var fieldId int16
|
||||
if err = oprot.WriteStructBegin("ProjectInnerTaskInfo"); err != nil {
|
||||
goto WriteStructBeginError
|
||||
}
|
||||
if p != nil {
|
||||
if err = p.writeField1(oprot); err != nil {
|
||||
fieldId = 1
|
||||
goto WriteFieldError
|
||||
}
|
||||
}
|
||||
if err = oprot.WriteFieldStop(); err != nil {
|
||||
goto WriteFieldStopError
|
||||
}
|
||||
if err = oprot.WriteStructEnd(); err != nil {
|
||||
goto WriteStructEndError
|
||||
}
|
||||
return nil
|
||||
WriteStructBeginError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err)
|
||||
WriteFieldError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err)
|
||||
WriteFieldStopError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err)
|
||||
WriteStructEndError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err)
|
||||
}
|
||||
|
||||
func (p *ProjectInnerTaskInfo) writeField1(oprot thrift.TProtocol) (err error) {
|
||||
if err = oprot.WriteFieldBegin("task_id", thrift.I64, 1); err != nil {
|
||||
goto WriteFieldBeginError
|
||||
}
|
||||
if err := oprot.WriteI64(p.TaskID); err != nil {
|
||||
return err
|
||||
}
|
||||
if err = oprot.WriteFieldEnd(); err != nil {
|
||||
goto WriteFieldEndError
|
||||
}
|
||||
return nil
|
||||
WriteFieldBeginError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err)
|
||||
WriteFieldEndError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err)
|
||||
}
|
||||
|
||||
func (p *ProjectInnerTaskInfo) String() string {
|
||||
if p == nil {
|
||||
return "<nil>"
|
||||
}
|
||||
return fmt.Sprintf("ProjectInnerTaskInfo(%+v)", *p)
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,672 @@
|
||||
// Code generated by thriftgo (0.4.2). DO NOT EDIT.
|
||||
|
||||
package task
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/apache/thrift/lib/go/thrift"
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/app/intelligence/common"
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/base"
|
||||
)
|
||||
|
||||
type DraftProjectInnerTaskListRequest struct {
|
||||
ProjectID int64 `thrift:"project_id,1,required" form:"project_id,required" json:"project_id,string,required" query:"project_id,required"`
|
||||
Base *base.Base `thrift:"Base,255,optional" form:"-" json:"-" query:"-"`
|
||||
}
|
||||
|
||||
func NewDraftProjectInnerTaskListRequest() *DraftProjectInnerTaskListRequest {
|
||||
return &DraftProjectInnerTaskListRequest{}
|
||||
}
|
||||
|
||||
func (p *DraftProjectInnerTaskListRequest) InitDefault() {
|
||||
}
|
||||
|
||||
func (p *DraftProjectInnerTaskListRequest) GetProjectID() (v int64) {
|
||||
return p.ProjectID
|
||||
}
|
||||
|
||||
var DraftProjectInnerTaskListRequest_Base_DEFAULT *base.Base
|
||||
|
||||
func (p *DraftProjectInnerTaskListRequest) GetBase() (v *base.Base) {
|
||||
if !p.IsSetBase() {
|
||||
return DraftProjectInnerTaskListRequest_Base_DEFAULT
|
||||
}
|
||||
return p.Base
|
||||
}
|
||||
|
||||
var fieldIDToName_DraftProjectInnerTaskListRequest = map[int16]string{
|
||||
1: "project_id",
|
||||
255: "Base",
|
||||
}
|
||||
|
||||
func (p *DraftProjectInnerTaskListRequest) IsSetBase() bool {
|
||||
return p.Base != nil
|
||||
}
|
||||
|
||||
func (p *DraftProjectInnerTaskListRequest) Read(iprot thrift.TProtocol) (err error) {
|
||||
var fieldTypeId thrift.TType
|
||||
var fieldId int16
|
||||
var issetProjectID bool = false
|
||||
|
||||
if _, err = iprot.ReadStructBegin(); err != nil {
|
||||
goto ReadStructBeginError
|
||||
}
|
||||
|
||||
for {
|
||||
_, fieldTypeId, fieldId, err = iprot.ReadFieldBegin()
|
||||
if err != nil {
|
||||
goto ReadFieldBeginError
|
||||
}
|
||||
if fieldTypeId == thrift.STOP {
|
||||
break
|
||||
}
|
||||
|
||||
switch fieldId {
|
||||
case 1:
|
||||
if fieldTypeId == thrift.I64 {
|
||||
if err = p.ReadField1(iprot); err != nil {
|
||||
goto ReadFieldError
|
||||
}
|
||||
issetProjectID = true
|
||||
} else if err = iprot.Skip(fieldTypeId); err != nil {
|
||||
goto SkipFieldError
|
||||
}
|
||||
case 255:
|
||||
if fieldTypeId == thrift.STRUCT {
|
||||
if err = p.ReadField255(iprot); err != nil {
|
||||
goto ReadFieldError
|
||||
}
|
||||
} else if err = iprot.Skip(fieldTypeId); err != nil {
|
||||
goto SkipFieldError
|
||||
}
|
||||
default:
|
||||
if err = iprot.Skip(fieldTypeId); err != nil {
|
||||
goto SkipFieldError
|
||||
}
|
||||
}
|
||||
if err = iprot.ReadFieldEnd(); err != nil {
|
||||
goto ReadFieldEndError
|
||||
}
|
||||
}
|
||||
if err = iprot.ReadStructEnd(); err != nil {
|
||||
goto ReadStructEndError
|
||||
}
|
||||
|
||||
if !issetProjectID {
|
||||
fieldId = 1
|
||||
goto RequiredFieldNotSetError
|
||||
}
|
||||
return nil
|
||||
ReadStructBeginError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err)
|
||||
ReadFieldBeginError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err)
|
||||
ReadFieldError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_DraftProjectInnerTaskListRequest[fieldId]), err)
|
||||
SkipFieldError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err)
|
||||
|
||||
ReadFieldEndError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err)
|
||||
ReadStructEndError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
|
||||
RequiredFieldNotSetError:
|
||||
return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("required field %s is not set", fieldIDToName_DraftProjectInnerTaskListRequest[fieldId]))
|
||||
}
|
||||
|
||||
func (p *DraftProjectInnerTaskListRequest) ReadField1(iprot thrift.TProtocol) error {
|
||||
|
||||
var _field int64
|
||||
if v, err := iprot.ReadI64(); err != nil {
|
||||
return err
|
||||
} else {
|
||||
_field = v
|
||||
}
|
||||
p.ProjectID = _field
|
||||
return nil
|
||||
}
|
||||
func (p *DraftProjectInnerTaskListRequest) ReadField255(iprot thrift.TProtocol) error {
|
||||
_field := base.NewBase()
|
||||
if err := _field.Read(iprot); err != nil {
|
||||
return err
|
||||
}
|
||||
p.Base = _field
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *DraftProjectInnerTaskListRequest) Write(oprot thrift.TProtocol) (err error) {
|
||||
var fieldId int16
|
||||
if err = oprot.WriteStructBegin("DraftProjectInnerTaskListRequest"); err != nil {
|
||||
goto WriteStructBeginError
|
||||
}
|
||||
if p != nil {
|
||||
if err = p.writeField1(oprot); err != nil {
|
||||
fieldId = 1
|
||||
goto WriteFieldError
|
||||
}
|
||||
if err = p.writeField255(oprot); err != nil {
|
||||
fieldId = 255
|
||||
goto WriteFieldError
|
||||
}
|
||||
}
|
||||
if err = oprot.WriteFieldStop(); err != nil {
|
||||
goto WriteFieldStopError
|
||||
}
|
||||
if err = oprot.WriteStructEnd(); err != nil {
|
||||
goto WriteStructEndError
|
||||
}
|
||||
return nil
|
||||
WriteStructBeginError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err)
|
||||
WriteFieldError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err)
|
||||
WriteFieldStopError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err)
|
||||
WriteStructEndError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err)
|
||||
}
|
||||
|
||||
func (p *DraftProjectInnerTaskListRequest) writeField1(oprot thrift.TProtocol) (err error) {
|
||||
if err = oprot.WriteFieldBegin("project_id", thrift.I64, 1); err != nil {
|
||||
goto WriteFieldBeginError
|
||||
}
|
||||
if err := oprot.WriteI64(p.ProjectID); err != nil {
|
||||
return err
|
||||
}
|
||||
if err = oprot.WriteFieldEnd(); err != nil {
|
||||
goto WriteFieldEndError
|
||||
}
|
||||
return nil
|
||||
WriteFieldBeginError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err)
|
||||
WriteFieldEndError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err)
|
||||
}
|
||||
func (p *DraftProjectInnerTaskListRequest) writeField255(oprot thrift.TProtocol) (err error) {
|
||||
if p.IsSetBase() {
|
||||
if err = oprot.WriteFieldBegin("Base", thrift.STRUCT, 255); err != nil {
|
||||
goto WriteFieldBeginError
|
||||
}
|
||||
if err := p.Base.Write(oprot); err != nil {
|
||||
return err
|
||||
}
|
||||
if err = oprot.WriteFieldEnd(); err != nil {
|
||||
goto WriteFieldEndError
|
||||
}
|
||||
}
|
||||
return nil
|
||||
WriteFieldBeginError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field 255 begin error: ", p), err)
|
||||
WriteFieldEndError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field 255 end error: ", p), err)
|
||||
}
|
||||
|
||||
func (p *DraftProjectInnerTaskListRequest) String() string {
|
||||
if p == nil {
|
||||
return "<nil>"
|
||||
}
|
||||
return fmt.Sprintf("DraftProjectInnerTaskListRequest(%+v)", *p)
|
||||
|
||||
}
|
||||
|
||||
type DraftProjectInnerTaskListResponse struct {
|
||||
Data *DraftProjectInnerTaskListData `thrift:"data,1" form:"data" json:"data" query:"data"`
|
||||
Code int64 `thrift:"code,253,required" form:"code,required" json:"code,required" query:"code,required"`
|
||||
Msg string `thrift:"msg,254,required" form:"msg,required" json:"msg,required" query:"msg,required"`
|
||||
BaseResp *base.BaseResp `thrift:"BaseResp,255,optional" form:"-" json:"-" query:"-"`
|
||||
}
|
||||
|
||||
func NewDraftProjectInnerTaskListResponse() *DraftProjectInnerTaskListResponse {
|
||||
return &DraftProjectInnerTaskListResponse{}
|
||||
}
|
||||
|
||||
func (p *DraftProjectInnerTaskListResponse) InitDefault() {
|
||||
}
|
||||
|
||||
var DraftProjectInnerTaskListResponse_Data_DEFAULT *DraftProjectInnerTaskListData
|
||||
|
||||
func (p *DraftProjectInnerTaskListResponse) GetData() (v *DraftProjectInnerTaskListData) {
|
||||
if !p.IsSetData() {
|
||||
return DraftProjectInnerTaskListResponse_Data_DEFAULT
|
||||
}
|
||||
return p.Data
|
||||
}
|
||||
|
||||
func (p *DraftProjectInnerTaskListResponse) GetCode() (v int64) {
|
||||
return p.Code
|
||||
}
|
||||
|
||||
func (p *DraftProjectInnerTaskListResponse) GetMsg() (v string) {
|
||||
return p.Msg
|
||||
}
|
||||
|
||||
var DraftProjectInnerTaskListResponse_BaseResp_DEFAULT *base.BaseResp
|
||||
|
||||
func (p *DraftProjectInnerTaskListResponse) GetBaseResp() (v *base.BaseResp) {
|
||||
if !p.IsSetBaseResp() {
|
||||
return DraftProjectInnerTaskListResponse_BaseResp_DEFAULT
|
||||
}
|
||||
return p.BaseResp
|
||||
}
|
||||
|
||||
var fieldIDToName_DraftProjectInnerTaskListResponse = map[int16]string{
|
||||
1: "data",
|
||||
253: "code",
|
||||
254: "msg",
|
||||
255: "BaseResp",
|
||||
}
|
||||
|
||||
func (p *DraftProjectInnerTaskListResponse) IsSetData() bool {
|
||||
return p.Data != nil
|
||||
}
|
||||
|
||||
func (p *DraftProjectInnerTaskListResponse) IsSetBaseResp() bool {
|
||||
return p.BaseResp != nil
|
||||
}
|
||||
|
||||
func (p *DraftProjectInnerTaskListResponse) Read(iprot thrift.TProtocol) (err error) {
|
||||
var fieldTypeId thrift.TType
|
||||
var fieldId int16
|
||||
var issetCode bool = false
|
||||
var issetMsg bool = false
|
||||
|
||||
if _, err = iprot.ReadStructBegin(); err != nil {
|
||||
goto ReadStructBeginError
|
||||
}
|
||||
|
||||
for {
|
||||
_, fieldTypeId, fieldId, err = iprot.ReadFieldBegin()
|
||||
if err != nil {
|
||||
goto ReadFieldBeginError
|
||||
}
|
||||
if fieldTypeId == thrift.STOP {
|
||||
break
|
||||
}
|
||||
|
||||
switch fieldId {
|
||||
case 1:
|
||||
if fieldTypeId == thrift.STRUCT {
|
||||
if err = p.ReadField1(iprot); err != nil {
|
||||
goto ReadFieldError
|
||||
}
|
||||
} else if err = iprot.Skip(fieldTypeId); err != nil {
|
||||
goto SkipFieldError
|
||||
}
|
||||
case 253:
|
||||
if fieldTypeId == thrift.I64 {
|
||||
if err = p.ReadField253(iprot); err != nil {
|
||||
goto ReadFieldError
|
||||
}
|
||||
issetCode = true
|
||||
} else if err = iprot.Skip(fieldTypeId); err != nil {
|
||||
goto SkipFieldError
|
||||
}
|
||||
case 254:
|
||||
if fieldTypeId == thrift.STRING {
|
||||
if err = p.ReadField254(iprot); err != nil {
|
||||
goto ReadFieldError
|
||||
}
|
||||
issetMsg = true
|
||||
} else if err = iprot.Skip(fieldTypeId); err != nil {
|
||||
goto SkipFieldError
|
||||
}
|
||||
case 255:
|
||||
if fieldTypeId == thrift.STRUCT {
|
||||
if err = p.ReadField255(iprot); err != nil {
|
||||
goto ReadFieldError
|
||||
}
|
||||
} else if err = iprot.Skip(fieldTypeId); err != nil {
|
||||
goto SkipFieldError
|
||||
}
|
||||
default:
|
||||
if err = iprot.Skip(fieldTypeId); err != nil {
|
||||
goto SkipFieldError
|
||||
}
|
||||
}
|
||||
if err = iprot.ReadFieldEnd(); err != nil {
|
||||
goto ReadFieldEndError
|
||||
}
|
||||
}
|
||||
if err = iprot.ReadStructEnd(); err != nil {
|
||||
goto ReadStructEndError
|
||||
}
|
||||
|
||||
if !issetCode {
|
||||
fieldId = 253
|
||||
goto RequiredFieldNotSetError
|
||||
}
|
||||
|
||||
if !issetMsg {
|
||||
fieldId = 254
|
||||
goto RequiredFieldNotSetError
|
||||
}
|
||||
return nil
|
||||
ReadStructBeginError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err)
|
||||
ReadFieldBeginError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err)
|
||||
ReadFieldError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_DraftProjectInnerTaskListResponse[fieldId]), err)
|
||||
SkipFieldError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err)
|
||||
|
||||
ReadFieldEndError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err)
|
||||
ReadStructEndError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
|
||||
RequiredFieldNotSetError:
|
||||
return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("required field %s is not set", fieldIDToName_DraftProjectInnerTaskListResponse[fieldId]))
|
||||
}
|
||||
|
||||
func (p *DraftProjectInnerTaskListResponse) ReadField1(iprot thrift.TProtocol) error {
|
||||
_field := NewDraftProjectInnerTaskListData()
|
||||
if err := _field.Read(iprot); err != nil {
|
||||
return err
|
||||
}
|
||||
p.Data = _field
|
||||
return nil
|
||||
}
|
||||
func (p *DraftProjectInnerTaskListResponse) ReadField253(iprot thrift.TProtocol) error {
|
||||
|
||||
var _field int64
|
||||
if v, err := iprot.ReadI64(); err != nil {
|
||||
return err
|
||||
} else {
|
||||
_field = v
|
||||
}
|
||||
p.Code = _field
|
||||
return nil
|
||||
}
|
||||
func (p *DraftProjectInnerTaskListResponse) ReadField254(iprot thrift.TProtocol) error {
|
||||
|
||||
var _field string
|
||||
if v, err := iprot.ReadString(); err != nil {
|
||||
return err
|
||||
} else {
|
||||
_field = v
|
||||
}
|
||||
p.Msg = _field
|
||||
return nil
|
||||
}
|
||||
func (p *DraftProjectInnerTaskListResponse) ReadField255(iprot thrift.TProtocol) error {
|
||||
_field := base.NewBaseResp()
|
||||
if err := _field.Read(iprot); err != nil {
|
||||
return err
|
||||
}
|
||||
p.BaseResp = _field
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *DraftProjectInnerTaskListResponse) Write(oprot thrift.TProtocol) (err error) {
|
||||
var fieldId int16
|
||||
if err = oprot.WriteStructBegin("DraftProjectInnerTaskListResponse"); err != nil {
|
||||
goto WriteStructBeginError
|
||||
}
|
||||
if p != nil {
|
||||
if err = p.writeField1(oprot); err != nil {
|
||||
fieldId = 1
|
||||
goto WriteFieldError
|
||||
}
|
||||
if err = p.writeField253(oprot); err != nil {
|
||||
fieldId = 253
|
||||
goto WriteFieldError
|
||||
}
|
||||
if err = p.writeField254(oprot); err != nil {
|
||||
fieldId = 254
|
||||
goto WriteFieldError
|
||||
}
|
||||
if err = p.writeField255(oprot); err != nil {
|
||||
fieldId = 255
|
||||
goto WriteFieldError
|
||||
}
|
||||
}
|
||||
if err = oprot.WriteFieldStop(); err != nil {
|
||||
goto WriteFieldStopError
|
||||
}
|
||||
if err = oprot.WriteStructEnd(); err != nil {
|
||||
goto WriteStructEndError
|
||||
}
|
||||
return nil
|
||||
WriteStructBeginError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err)
|
||||
WriteFieldError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err)
|
||||
WriteFieldStopError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err)
|
||||
WriteStructEndError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err)
|
||||
}
|
||||
|
||||
func (p *DraftProjectInnerTaskListResponse) writeField1(oprot thrift.TProtocol) (err error) {
|
||||
if err = oprot.WriteFieldBegin("data", thrift.STRUCT, 1); err != nil {
|
||||
goto WriteFieldBeginError
|
||||
}
|
||||
if err := p.Data.Write(oprot); err != nil {
|
||||
return err
|
||||
}
|
||||
if err = oprot.WriteFieldEnd(); err != nil {
|
||||
goto WriteFieldEndError
|
||||
}
|
||||
return nil
|
||||
WriteFieldBeginError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err)
|
||||
WriteFieldEndError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err)
|
||||
}
|
||||
func (p *DraftProjectInnerTaskListResponse) writeField253(oprot thrift.TProtocol) (err error) {
|
||||
if err = oprot.WriteFieldBegin("code", thrift.I64, 253); err != nil {
|
||||
goto WriteFieldBeginError
|
||||
}
|
||||
if err := oprot.WriteI64(p.Code); err != nil {
|
||||
return err
|
||||
}
|
||||
if err = oprot.WriteFieldEnd(); err != nil {
|
||||
goto WriteFieldEndError
|
||||
}
|
||||
return nil
|
||||
WriteFieldBeginError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field 253 begin error: ", p), err)
|
||||
WriteFieldEndError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field 253 end error: ", p), err)
|
||||
}
|
||||
func (p *DraftProjectInnerTaskListResponse) writeField254(oprot thrift.TProtocol) (err error) {
|
||||
if err = oprot.WriteFieldBegin("msg", thrift.STRING, 254); err != nil {
|
||||
goto WriteFieldBeginError
|
||||
}
|
||||
if err := oprot.WriteString(p.Msg); err != nil {
|
||||
return err
|
||||
}
|
||||
if err = oprot.WriteFieldEnd(); err != nil {
|
||||
goto WriteFieldEndError
|
||||
}
|
||||
return nil
|
||||
WriteFieldBeginError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field 254 begin error: ", p), err)
|
||||
WriteFieldEndError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field 254 end error: ", p), err)
|
||||
}
|
||||
func (p *DraftProjectInnerTaskListResponse) writeField255(oprot thrift.TProtocol) (err error) {
|
||||
if p.IsSetBaseResp() {
|
||||
if err = oprot.WriteFieldBegin("BaseResp", thrift.STRUCT, 255); err != nil {
|
||||
goto WriteFieldBeginError
|
||||
}
|
||||
if err := p.BaseResp.Write(oprot); err != nil {
|
||||
return err
|
||||
}
|
||||
if err = oprot.WriteFieldEnd(); err != nil {
|
||||
goto WriteFieldEndError
|
||||
}
|
||||
}
|
||||
return nil
|
||||
WriteFieldBeginError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field 255 begin error: ", p), err)
|
||||
WriteFieldEndError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field 255 end error: ", p), err)
|
||||
}
|
||||
|
||||
func (p *DraftProjectInnerTaskListResponse) String() string {
|
||||
if p == nil {
|
||||
return "<nil>"
|
||||
}
|
||||
return fmt.Sprintf("DraftProjectInnerTaskListResponse(%+v)", *p)
|
||||
|
||||
}
|
||||
|
||||
type DraftProjectInnerTaskListData struct {
|
||||
TaskList []*common.ProjectInnerTaskInfo `thrift:"task_list,1" form:"task_list" json:"task_list" query:"task_list"`
|
||||
}
|
||||
|
||||
func NewDraftProjectInnerTaskListData() *DraftProjectInnerTaskListData {
|
||||
return &DraftProjectInnerTaskListData{}
|
||||
}
|
||||
|
||||
func (p *DraftProjectInnerTaskListData) InitDefault() {
|
||||
}
|
||||
|
||||
func (p *DraftProjectInnerTaskListData) GetTaskList() (v []*common.ProjectInnerTaskInfo) {
|
||||
return p.TaskList
|
||||
}
|
||||
|
||||
var fieldIDToName_DraftProjectInnerTaskListData = map[int16]string{
|
||||
1: "task_list",
|
||||
}
|
||||
|
||||
func (p *DraftProjectInnerTaskListData) Read(iprot thrift.TProtocol) (err error) {
|
||||
var fieldTypeId thrift.TType
|
||||
var fieldId int16
|
||||
|
||||
if _, err = iprot.ReadStructBegin(); err != nil {
|
||||
goto ReadStructBeginError
|
||||
}
|
||||
|
||||
for {
|
||||
_, fieldTypeId, fieldId, err = iprot.ReadFieldBegin()
|
||||
if err != nil {
|
||||
goto ReadFieldBeginError
|
||||
}
|
||||
if fieldTypeId == thrift.STOP {
|
||||
break
|
||||
}
|
||||
|
||||
switch fieldId {
|
||||
case 1:
|
||||
if fieldTypeId == thrift.LIST {
|
||||
if err = p.ReadField1(iprot); err != nil {
|
||||
goto ReadFieldError
|
||||
}
|
||||
} else if err = iprot.Skip(fieldTypeId); err != nil {
|
||||
goto SkipFieldError
|
||||
}
|
||||
default:
|
||||
if err = iprot.Skip(fieldTypeId); err != nil {
|
||||
goto SkipFieldError
|
||||
}
|
||||
}
|
||||
if err = iprot.ReadFieldEnd(); err != nil {
|
||||
goto ReadFieldEndError
|
||||
}
|
||||
}
|
||||
if err = iprot.ReadStructEnd(); err != nil {
|
||||
goto ReadStructEndError
|
||||
}
|
||||
|
||||
return nil
|
||||
ReadStructBeginError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err)
|
||||
ReadFieldBeginError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err)
|
||||
ReadFieldError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_DraftProjectInnerTaskListData[fieldId]), err)
|
||||
SkipFieldError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err)
|
||||
|
||||
ReadFieldEndError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err)
|
||||
ReadStructEndError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
|
||||
}
|
||||
|
||||
func (p *DraftProjectInnerTaskListData) ReadField1(iprot thrift.TProtocol) error {
|
||||
_, size, err := iprot.ReadListBegin()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_field := make([]*common.ProjectInnerTaskInfo, 0, size)
|
||||
values := make([]common.ProjectInnerTaskInfo, size)
|
||||
for i := 0; i < size; i++ {
|
||||
_elem := &values[i]
|
||||
_elem.InitDefault()
|
||||
|
||||
if err := _elem.Read(iprot); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_field = append(_field, _elem)
|
||||
}
|
||||
if err := iprot.ReadListEnd(); err != nil {
|
||||
return err
|
||||
}
|
||||
p.TaskList = _field
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *DraftProjectInnerTaskListData) Write(oprot thrift.TProtocol) (err error) {
|
||||
var fieldId int16
|
||||
if err = oprot.WriteStructBegin("DraftProjectInnerTaskListData"); err != nil {
|
||||
goto WriteStructBeginError
|
||||
}
|
||||
if p != nil {
|
||||
if err = p.writeField1(oprot); err != nil {
|
||||
fieldId = 1
|
||||
goto WriteFieldError
|
||||
}
|
||||
}
|
||||
if err = oprot.WriteFieldStop(); err != nil {
|
||||
goto WriteFieldStopError
|
||||
}
|
||||
if err = oprot.WriteStructEnd(); err != nil {
|
||||
goto WriteStructEndError
|
||||
}
|
||||
return nil
|
||||
WriteStructBeginError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err)
|
||||
WriteFieldError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err)
|
||||
WriteFieldStopError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err)
|
||||
WriteStructEndError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err)
|
||||
}
|
||||
|
||||
func (p *DraftProjectInnerTaskListData) writeField1(oprot thrift.TProtocol) (err error) {
|
||||
if err = oprot.WriteFieldBegin("task_list", thrift.LIST, 1); err != nil {
|
||||
goto WriteFieldBeginError
|
||||
}
|
||||
if err := oprot.WriteListBegin(thrift.STRUCT, len(p.TaskList)); err != nil {
|
||||
return err
|
||||
}
|
||||
for _, v := range p.TaskList {
|
||||
if err := v.Write(oprot); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if err := oprot.WriteListEnd(); err != nil {
|
||||
return err
|
||||
}
|
||||
if err = oprot.WriteFieldEnd(); err != nil {
|
||||
goto WriteFieldEndError
|
||||
}
|
||||
return nil
|
||||
WriteFieldBeginError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err)
|
||||
WriteFieldEndError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err)
|
||||
}
|
||||
|
||||
func (p *DraftProjectInnerTaskListData) String() string {
|
||||
if p == nil {
|
||||
return "<nil>"
|
||||
}
|
||||
return fmt.Sprintf("DraftProjectInnerTaskListData(%+v)", *p)
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,102 @@
|
||||
// Code generated by thriftgo (0.4.2). DO NOT EDIT.
|
||||
|
||||
package common
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"database/sql/driver"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type Scene int64
|
||||
|
||||
const (
|
||||
Scene_Default Scene = 0
|
||||
Scene_Explore Scene = 1
|
||||
Scene_BotStore Scene = 2
|
||||
Scene_CozeHome Scene = 3
|
||||
//debugging
|
||||
Scene_Playground Scene = 4
|
||||
// evaluation platform
|
||||
Scene_Evaluation Scene = 5
|
||||
Scene_AgentAPP Scene = 6
|
||||
//Prompt optimization
|
||||
Scene_PromptOptimize Scene = 7
|
||||
// Createbot's nl2bot features
|
||||
Scene_GenerateAgentInfo Scene = 8
|
||||
//openapi
|
||||
Scene_SceneOpenApi Scene = 9
|
||||
// workflow
|
||||
Scene_SceneWorkflow Scene = 50
|
||||
)
|
||||
|
||||
func (p Scene) String() string {
|
||||
switch p {
|
||||
case Scene_Default:
|
||||
return "Default"
|
||||
case Scene_Explore:
|
||||
return "Explore"
|
||||
case Scene_BotStore:
|
||||
return "BotStore"
|
||||
case Scene_CozeHome:
|
||||
return "CozeHome"
|
||||
case Scene_Playground:
|
||||
return "Playground"
|
||||
case Scene_Evaluation:
|
||||
return "Evaluation"
|
||||
case Scene_AgentAPP:
|
||||
return "AgentAPP"
|
||||
case Scene_PromptOptimize:
|
||||
return "PromptOptimize"
|
||||
case Scene_GenerateAgentInfo:
|
||||
return "GenerateAgentInfo"
|
||||
case Scene_SceneOpenApi:
|
||||
return "SceneOpenApi"
|
||||
case Scene_SceneWorkflow:
|
||||
return "SceneWorkflow"
|
||||
}
|
||||
return "<UNSET>"
|
||||
}
|
||||
|
||||
func SceneFromString(s string) (Scene, error) {
|
||||
switch s {
|
||||
case "Default":
|
||||
return Scene_Default, nil
|
||||
case "Explore":
|
||||
return Scene_Explore, nil
|
||||
case "BotStore":
|
||||
return Scene_BotStore, nil
|
||||
case "CozeHome":
|
||||
return Scene_CozeHome, nil
|
||||
case "Playground":
|
||||
return Scene_Playground, nil
|
||||
case "Evaluation":
|
||||
return Scene_Evaluation, nil
|
||||
case "AgentAPP":
|
||||
return Scene_AgentAPP, nil
|
||||
case "PromptOptimize":
|
||||
return Scene_PromptOptimize, nil
|
||||
case "GenerateAgentInfo":
|
||||
return Scene_GenerateAgentInfo, nil
|
||||
case "SceneOpenApi":
|
||||
return Scene_SceneOpenApi, nil
|
||||
case "SceneWorkflow":
|
||||
return Scene_SceneWorkflow, nil
|
||||
}
|
||||
return Scene(0), fmt.Errorf("not a valid Scene string")
|
||||
}
|
||||
|
||||
func ScenePtr(v Scene) *Scene { return &v }
|
||||
func (p *Scene) Scan(value interface{}) (err error) {
|
||||
var result sql.NullInt64
|
||||
err = result.Scan(value)
|
||||
*p = Scene(result.Int64)
|
||||
return
|
||||
}
|
||||
|
||||
func (p *Scene) Value() (driver.Value, error) {
|
||||
if p == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return int64(*p), nil
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,655 @@
|
||||
// Code generated by thriftgo (0.4.2). DO NOT EDIT.
|
||||
|
||||
package coze
|
||||
|
||||
import (
|
||||
"github.com/apache/thrift/lib/go/thrift"
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/admin/config"
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/app/bot_open_api"
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/app/developer_api"
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/app/intelligence"
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/conversation/agentrun"
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/conversation/conversation"
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/conversation/message"
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/data/database"
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/data/knowledge"
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/data/variable"
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/file/upload"
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/marketplace/product_public_api"
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/passport"
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/permission/openapiauth"
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/playground"
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/plugin_develop"
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/resource"
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/workflow"
|
||||
)
|
||||
|
||||
type IntelligenceService interface {
|
||||
intelligence.IntelligenceService
|
||||
}
|
||||
|
||||
type IntelligenceServiceClient struct {
|
||||
*intelligence.IntelligenceServiceClient
|
||||
}
|
||||
|
||||
func NewIntelligenceServiceClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *IntelligenceServiceClient {
|
||||
return &IntelligenceServiceClient{
|
||||
IntelligenceServiceClient: intelligence.NewIntelligenceServiceClientFactory(t, f),
|
||||
}
|
||||
}
|
||||
|
||||
func NewIntelligenceServiceClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *IntelligenceServiceClient {
|
||||
return &IntelligenceServiceClient{
|
||||
IntelligenceServiceClient: intelligence.NewIntelligenceServiceClientProtocol(t, iprot, oprot),
|
||||
}
|
||||
}
|
||||
|
||||
func NewIntelligenceServiceClient(c thrift.TClient) *IntelligenceServiceClient {
|
||||
return &IntelligenceServiceClient{
|
||||
IntelligenceServiceClient: intelligence.NewIntelligenceServiceClient(c),
|
||||
}
|
||||
}
|
||||
|
||||
type ConversationService interface {
|
||||
conversation.ConversationService
|
||||
}
|
||||
|
||||
type ConversationServiceClient struct {
|
||||
*conversation.ConversationServiceClient
|
||||
}
|
||||
|
||||
func NewConversationServiceClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *ConversationServiceClient {
|
||||
return &ConversationServiceClient{
|
||||
ConversationServiceClient: conversation.NewConversationServiceClientFactory(t, f),
|
||||
}
|
||||
}
|
||||
|
||||
func NewConversationServiceClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *ConversationServiceClient {
|
||||
return &ConversationServiceClient{
|
||||
ConversationServiceClient: conversation.NewConversationServiceClientProtocol(t, iprot, oprot),
|
||||
}
|
||||
}
|
||||
|
||||
func NewConversationServiceClient(c thrift.TClient) *ConversationServiceClient {
|
||||
return &ConversationServiceClient{
|
||||
ConversationServiceClient: conversation.NewConversationServiceClient(c),
|
||||
}
|
||||
}
|
||||
|
||||
type MessageService interface {
|
||||
message.MessageService
|
||||
}
|
||||
|
||||
type MessageServiceClient struct {
|
||||
*message.MessageServiceClient
|
||||
}
|
||||
|
||||
func NewMessageServiceClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *MessageServiceClient {
|
||||
return &MessageServiceClient{
|
||||
MessageServiceClient: message.NewMessageServiceClientFactory(t, f),
|
||||
}
|
||||
}
|
||||
|
||||
func NewMessageServiceClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *MessageServiceClient {
|
||||
return &MessageServiceClient{
|
||||
MessageServiceClient: message.NewMessageServiceClientProtocol(t, iprot, oprot),
|
||||
}
|
||||
}
|
||||
|
||||
func NewMessageServiceClient(c thrift.TClient) *MessageServiceClient {
|
||||
return &MessageServiceClient{
|
||||
MessageServiceClient: message.NewMessageServiceClient(c),
|
||||
}
|
||||
}
|
||||
|
||||
type AgentRunService interface {
|
||||
agentrun.AgentRunService
|
||||
}
|
||||
|
||||
type AgentRunServiceClient struct {
|
||||
*agentrun.AgentRunServiceClient
|
||||
}
|
||||
|
||||
func NewAgentRunServiceClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *AgentRunServiceClient {
|
||||
return &AgentRunServiceClient{
|
||||
AgentRunServiceClient: agentrun.NewAgentRunServiceClientFactory(t, f),
|
||||
}
|
||||
}
|
||||
|
||||
func NewAgentRunServiceClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *AgentRunServiceClient {
|
||||
return &AgentRunServiceClient{
|
||||
AgentRunServiceClient: agentrun.NewAgentRunServiceClientProtocol(t, iprot, oprot),
|
||||
}
|
||||
}
|
||||
|
||||
func NewAgentRunServiceClient(c thrift.TClient) *AgentRunServiceClient {
|
||||
return &AgentRunServiceClient{
|
||||
AgentRunServiceClient: agentrun.NewAgentRunServiceClient(c),
|
||||
}
|
||||
}
|
||||
|
||||
type OpenAPIAuthService interface {
|
||||
openapiauth.OpenAPIAuthService
|
||||
}
|
||||
|
||||
type OpenAPIAuthServiceClient struct {
|
||||
*openapiauth.OpenAPIAuthServiceClient
|
||||
}
|
||||
|
||||
func NewOpenAPIAuthServiceClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *OpenAPIAuthServiceClient {
|
||||
return &OpenAPIAuthServiceClient{
|
||||
OpenAPIAuthServiceClient: openapiauth.NewOpenAPIAuthServiceClientFactory(t, f),
|
||||
}
|
||||
}
|
||||
|
||||
func NewOpenAPIAuthServiceClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *OpenAPIAuthServiceClient {
|
||||
return &OpenAPIAuthServiceClient{
|
||||
OpenAPIAuthServiceClient: openapiauth.NewOpenAPIAuthServiceClientProtocol(t, iprot, oprot),
|
||||
}
|
||||
}
|
||||
|
||||
func NewOpenAPIAuthServiceClient(c thrift.TClient) *OpenAPIAuthServiceClient {
|
||||
return &OpenAPIAuthServiceClient{
|
||||
OpenAPIAuthServiceClient: openapiauth.NewOpenAPIAuthServiceClient(c),
|
||||
}
|
||||
}
|
||||
|
||||
type MemoryService interface {
|
||||
variable.MemoryService
|
||||
}
|
||||
|
||||
type MemoryServiceClient struct {
|
||||
*variable.MemoryServiceClient
|
||||
}
|
||||
|
||||
func NewMemoryServiceClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *MemoryServiceClient {
|
||||
return &MemoryServiceClient{
|
||||
MemoryServiceClient: variable.NewMemoryServiceClientFactory(t, f),
|
||||
}
|
||||
}
|
||||
|
||||
func NewMemoryServiceClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *MemoryServiceClient {
|
||||
return &MemoryServiceClient{
|
||||
MemoryServiceClient: variable.NewMemoryServiceClientProtocol(t, iprot, oprot),
|
||||
}
|
||||
}
|
||||
|
||||
func NewMemoryServiceClient(c thrift.TClient) *MemoryServiceClient {
|
||||
return &MemoryServiceClient{
|
||||
MemoryServiceClient: variable.NewMemoryServiceClient(c),
|
||||
}
|
||||
}
|
||||
|
||||
type PluginDevelopService interface {
|
||||
plugin_develop.PluginDevelopService
|
||||
}
|
||||
|
||||
type PluginDevelopServiceClient struct {
|
||||
*plugin_develop.PluginDevelopServiceClient
|
||||
}
|
||||
|
||||
func NewPluginDevelopServiceClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *PluginDevelopServiceClient {
|
||||
return &PluginDevelopServiceClient{
|
||||
PluginDevelopServiceClient: plugin_develop.NewPluginDevelopServiceClientFactory(t, f),
|
||||
}
|
||||
}
|
||||
|
||||
func NewPluginDevelopServiceClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *PluginDevelopServiceClient {
|
||||
return &PluginDevelopServiceClient{
|
||||
PluginDevelopServiceClient: plugin_develop.NewPluginDevelopServiceClientProtocol(t, iprot, oprot),
|
||||
}
|
||||
}
|
||||
|
||||
func NewPluginDevelopServiceClient(c thrift.TClient) *PluginDevelopServiceClient {
|
||||
return &PluginDevelopServiceClient{
|
||||
PluginDevelopServiceClient: plugin_develop.NewPluginDevelopServiceClient(c),
|
||||
}
|
||||
}
|
||||
|
||||
type PublicProductService interface {
|
||||
product_public_api.PublicProductService
|
||||
}
|
||||
|
||||
type PublicProductServiceClient struct {
|
||||
*product_public_api.PublicProductServiceClient
|
||||
}
|
||||
|
||||
func NewPublicProductServiceClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *PublicProductServiceClient {
|
||||
return &PublicProductServiceClient{
|
||||
PublicProductServiceClient: product_public_api.NewPublicProductServiceClientFactory(t, f),
|
||||
}
|
||||
}
|
||||
|
||||
func NewPublicProductServiceClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *PublicProductServiceClient {
|
||||
return &PublicProductServiceClient{
|
||||
PublicProductServiceClient: product_public_api.NewPublicProductServiceClientProtocol(t, iprot, oprot),
|
||||
}
|
||||
}
|
||||
|
||||
func NewPublicProductServiceClient(c thrift.TClient) *PublicProductServiceClient {
|
||||
return &PublicProductServiceClient{
|
||||
PublicProductServiceClient: product_public_api.NewPublicProductServiceClient(c),
|
||||
}
|
||||
}
|
||||
|
||||
type DeveloperApiService interface {
|
||||
developer_api.DeveloperApiService
|
||||
}
|
||||
|
||||
type DeveloperApiServiceClient struct {
|
||||
*developer_api.DeveloperApiServiceClient
|
||||
}
|
||||
|
||||
func NewDeveloperApiServiceClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *DeveloperApiServiceClient {
|
||||
return &DeveloperApiServiceClient{
|
||||
DeveloperApiServiceClient: developer_api.NewDeveloperApiServiceClientFactory(t, f),
|
||||
}
|
||||
}
|
||||
|
||||
func NewDeveloperApiServiceClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *DeveloperApiServiceClient {
|
||||
return &DeveloperApiServiceClient{
|
||||
DeveloperApiServiceClient: developer_api.NewDeveloperApiServiceClientProtocol(t, iprot, oprot),
|
||||
}
|
||||
}
|
||||
|
||||
func NewDeveloperApiServiceClient(c thrift.TClient) *DeveloperApiServiceClient {
|
||||
return &DeveloperApiServiceClient{
|
||||
DeveloperApiServiceClient: developer_api.NewDeveloperApiServiceClient(c),
|
||||
}
|
||||
}
|
||||
|
||||
type PlaygroundService interface {
|
||||
playground.PlaygroundService
|
||||
}
|
||||
|
||||
type PlaygroundServiceClient struct {
|
||||
*playground.PlaygroundServiceClient
|
||||
}
|
||||
|
||||
func NewPlaygroundServiceClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *PlaygroundServiceClient {
|
||||
return &PlaygroundServiceClient{
|
||||
PlaygroundServiceClient: playground.NewPlaygroundServiceClientFactory(t, f),
|
||||
}
|
||||
}
|
||||
|
||||
func NewPlaygroundServiceClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *PlaygroundServiceClient {
|
||||
return &PlaygroundServiceClient{
|
||||
PlaygroundServiceClient: playground.NewPlaygroundServiceClientProtocol(t, iprot, oprot),
|
||||
}
|
||||
}
|
||||
|
||||
func NewPlaygroundServiceClient(c thrift.TClient) *PlaygroundServiceClient {
|
||||
return &PlaygroundServiceClient{
|
||||
PlaygroundServiceClient: playground.NewPlaygroundServiceClient(c),
|
||||
}
|
||||
}
|
||||
|
||||
type DatabaseService interface {
|
||||
database.DatabaseService
|
||||
}
|
||||
|
||||
type DatabaseServiceClient struct {
|
||||
*database.DatabaseServiceClient
|
||||
}
|
||||
|
||||
func NewDatabaseServiceClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *DatabaseServiceClient {
|
||||
return &DatabaseServiceClient{
|
||||
DatabaseServiceClient: database.NewDatabaseServiceClientFactory(t, f),
|
||||
}
|
||||
}
|
||||
|
||||
func NewDatabaseServiceClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *DatabaseServiceClient {
|
||||
return &DatabaseServiceClient{
|
||||
DatabaseServiceClient: database.NewDatabaseServiceClientProtocol(t, iprot, oprot),
|
||||
}
|
||||
}
|
||||
|
||||
func NewDatabaseServiceClient(c thrift.TClient) *DatabaseServiceClient {
|
||||
return &DatabaseServiceClient{
|
||||
DatabaseServiceClient: database.NewDatabaseServiceClient(c),
|
||||
}
|
||||
}
|
||||
|
||||
type ResourceService interface {
|
||||
resource.ResourceService
|
||||
}
|
||||
|
||||
type ResourceServiceClient struct {
|
||||
*resource.ResourceServiceClient
|
||||
}
|
||||
|
||||
func NewResourceServiceClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *ResourceServiceClient {
|
||||
return &ResourceServiceClient{
|
||||
ResourceServiceClient: resource.NewResourceServiceClientFactory(t, f),
|
||||
}
|
||||
}
|
||||
|
||||
func NewResourceServiceClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *ResourceServiceClient {
|
||||
return &ResourceServiceClient{
|
||||
ResourceServiceClient: resource.NewResourceServiceClientProtocol(t, iprot, oprot),
|
||||
}
|
||||
}
|
||||
|
||||
func NewResourceServiceClient(c thrift.TClient) *ResourceServiceClient {
|
||||
return &ResourceServiceClient{
|
||||
ResourceServiceClient: resource.NewResourceServiceClient(c),
|
||||
}
|
||||
}
|
||||
|
||||
type PassportService interface {
|
||||
passport.PassportService
|
||||
}
|
||||
|
||||
type PassportServiceClient struct {
|
||||
*passport.PassportServiceClient
|
||||
}
|
||||
|
||||
func NewPassportServiceClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *PassportServiceClient {
|
||||
return &PassportServiceClient{
|
||||
PassportServiceClient: passport.NewPassportServiceClientFactory(t, f),
|
||||
}
|
||||
}
|
||||
|
||||
func NewPassportServiceClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *PassportServiceClient {
|
||||
return &PassportServiceClient{
|
||||
PassportServiceClient: passport.NewPassportServiceClientProtocol(t, iprot, oprot),
|
||||
}
|
||||
}
|
||||
|
||||
func NewPassportServiceClient(c thrift.TClient) *PassportServiceClient {
|
||||
return &PassportServiceClient{
|
||||
PassportServiceClient: passport.NewPassportServiceClient(c),
|
||||
}
|
||||
}
|
||||
|
||||
type WorkflowService interface {
|
||||
workflow.WorkflowService
|
||||
}
|
||||
|
||||
type WorkflowServiceClient struct {
|
||||
*workflow.WorkflowServiceClient
|
||||
}
|
||||
|
||||
func NewWorkflowServiceClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *WorkflowServiceClient {
|
||||
return &WorkflowServiceClient{
|
||||
WorkflowServiceClient: workflow.NewWorkflowServiceClientFactory(t, f),
|
||||
}
|
||||
}
|
||||
|
||||
func NewWorkflowServiceClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *WorkflowServiceClient {
|
||||
return &WorkflowServiceClient{
|
||||
WorkflowServiceClient: workflow.NewWorkflowServiceClientProtocol(t, iprot, oprot),
|
||||
}
|
||||
}
|
||||
|
||||
func NewWorkflowServiceClient(c thrift.TClient) *WorkflowServiceClient {
|
||||
return &WorkflowServiceClient{
|
||||
WorkflowServiceClient: workflow.NewWorkflowServiceClient(c),
|
||||
}
|
||||
}
|
||||
|
||||
type KnowledgeService interface {
|
||||
knowledge.DatasetService
|
||||
}
|
||||
|
||||
type KnowledgeServiceClient struct {
|
||||
*knowledge.DatasetServiceClient
|
||||
}
|
||||
|
||||
func NewKnowledgeServiceClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *KnowledgeServiceClient {
|
||||
return &KnowledgeServiceClient{
|
||||
DatasetServiceClient: knowledge.NewDatasetServiceClientFactory(t, f),
|
||||
}
|
||||
}
|
||||
|
||||
func NewKnowledgeServiceClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *KnowledgeServiceClient {
|
||||
return &KnowledgeServiceClient{
|
||||
DatasetServiceClient: knowledge.NewDatasetServiceClientProtocol(t, iprot, oprot),
|
||||
}
|
||||
}
|
||||
|
||||
func NewKnowledgeServiceClient(c thrift.TClient) *KnowledgeServiceClient {
|
||||
return &KnowledgeServiceClient{
|
||||
DatasetServiceClient: knowledge.NewDatasetServiceClient(c),
|
||||
}
|
||||
}
|
||||
|
||||
type BotOpenApiService interface {
|
||||
bot_open_api.BotOpenApiService
|
||||
}
|
||||
|
||||
type BotOpenApiServiceClient struct {
|
||||
*bot_open_api.BotOpenApiServiceClient
|
||||
}
|
||||
|
||||
func NewBotOpenApiServiceClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *BotOpenApiServiceClient {
|
||||
return &BotOpenApiServiceClient{
|
||||
BotOpenApiServiceClient: bot_open_api.NewBotOpenApiServiceClientFactory(t, f),
|
||||
}
|
||||
}
|
||||
|
||||
func NewBotOpenApiServiceClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *BotOpenApiServiceClient {
|
||||
return &BotOpenApiServiceClient{
|
||||
BotOpenApiServiceClient: bot_open_api.NewBotOpenApiServiceClientProtocol(t, iprot, oprot),
|
||||
}
|
||||
}
|
||||
|
||||
func NewBotOpenApiServiceClient(c thrift.TClient) *BotOpenApiServiceClient {
|
||||
return &BotOpenApiServiceClient{
|
||||
BotOpenApiServiceClient: bot_open_api.NewBotOpenApiServiceClient(c),
|
||||
}
|
||||
}
|
||||
|
||||
type UploadService interface {
|
||||
upload.UploadService
|
||||
}
|
||||
|
||||
type UploadServiceClient struct {
|
||||
*upload.UploadServiceClient
|
||||
}
|
||||
|
||||
func NewUploadServiceClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *UploadServiceClient {
|
||||
return &UploadServiceClient{
|
||||
UploadServiceClient: upload.NewUploadServiceClientFactory(t, f),
|
||||
}
|
||||
}
|
||||
|
||||
func NewUploadServiceClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *UploadServiceClient {
|
||||
return &UploadServiceClient{
|
||||
UploadServiceClient: upload.NewUploadServiceClientProtocol(t, iprot, oprot),
|
||||
}
|
||||
}
|
||||
|
||||
func NewUploadServiceClient(c thrift.TClient) *UploadServiceClient {
|
||||
return &UploadServiceClient{
|
||||
UploadServiceClient: upload.NewUploadServiceClient(c),
|
||||
}
|
||||
}
|
||||
|
||||
type ConfigService interface {
|
||||
config.ConfigService
|
||||
}
|
||||
|
||||
type ConfigServiceClient struct {
|
||||
*config.ConfigServiceClient
|
||||
}
|
||||
|
||||
func NewConfigServiceClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *ConfigServiceClient {
|
||||
return &ConfigServiceClient{
|
||||
ConfigServiceClient: config.NewConfigServiceClientFactory(t, f),
|
||||
}
|
||||
}
|
||||
|
||||
func NewConfigServiceClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *ConfigServiceClient {
|
||||
return &ConfigServiceClient{
|
||||
ConfigServiceClient: config.NewConfigServiceClientProtocol(t, iprot, oprot),
|
||||
}
|
||||
}
|
||||
|
||||
func NewConfigServiceClient(c thrift.TClient) *ConfigServiceClient {
|
||||
return &ConfigServiceClient{
|
||||
ConfigServiceClient: config.NewConfigServiceClient(c),
|
||||
}
|
||||
}
|
||||
|
||||
type IntelligenceServiceProcessor struct {
|
||||
*intelligence.IntelligenceServiceProcessor
|
||||
}
|
||||
|
||||
func NewIntelligenceServiceProcessor(handler IntelligenceService) *IntelligenceServiceProcessor {
|
||||
self := &IntelligenceServiceProcessor{intelligence.NewIntelligenceServiceProcessor(handler)}
|
||||
return self
|
||||
}
|
||||
|
||||
type ConversationServiceProcessor struct {
|
||||
*conversation.ConversationServiceProcessor
|
||||
}
|
||||
|
||||
func NewConversationServiceProcessor(handler ConversationService) *ConversationServiceProcessor {
|
||||
self := &ConversationServiceProcessor{conversation.NewConversationServiceProcessor(handler)}
|
||||
return self
|
||||
}
|
||||
|
||||
type MessageServiceProcessor struct {
|
||||
*message.MessageServiceProcessor
|
||||
}
|
||||
|
||||
func NewMessageServiceProcessor(handler MessageService) *MessageServiceProcessor {
|
||||
self := &MessageServiceProcessor{message.NewMessageServiceProcessor(handler)}
|
||||
return self
|
||||
}
|
||||
|
||||
type AgentRunServiceProcessor struct {
|
||||
*agentrun.AgentRunServiceProcessor
|
||||
}
|
||||
|
||||
func NewAgentRunServiceProcessor(handler AgentRunService) *AgentRunServiceProcessor {
|
||||
self := &AgentRunServiceProcessor{agentrun.NewAgentRunServiceProcessor(handler)}
|
||||
return self
|
||||
}
|
||||
|
||||
type OpenAPIAuthServiceProcessor struct {
|
||||
*openapiauth.OpenAPIAuthServiceProcessor
|
||||
}
|
||||
|
||||
func NewOpenAPIAuthServiceProcessor(handler OpenAPIAuthService) *OpenAPIAuthServiceProcessor {
|
||||
self := &OpenAPIAuthServiceProcessor{openapiauth.NewOpenAPIAuthServiceProcessor(handler)}
|
||||
return self
|
||||
}
|
||||
|
||||
type MemoryServiceProcessor struct {
|
||||
*variable.MemoryServiceProcessor
|
||||
}
|
||||
|
||||
func NewMemoryServiceProcessor(handler MemoryService) *MemoryServiceProcessor {
|
||||
self := &MemoryServiceProcessor{variable.NewMemoryServiceProcessor(handler)}
|
||||
return self
|
||||
}
|
||||
|
||||
type PluginDevelopServiceProcessor struct {
|
||||
*plugin_develop.PluginDevelopServiceProcessor
|
||||
}
|
||||
|
||||
func NewPluginDevelopServiceProcessor(handler PluginDevelopService) *PluginDevelopServiceProcessor {
|
||||
self := &PluginDevelopServiceProcessor{plugin_develop.NewPluginDevelopServiceProcessor(handler)}
|
||||
return self
|
||||
}
|
||||
|
||||
type PublicProductServiceProcessor struct {
|
||||
*product_public_api.PublicProductServiceProcessor
|
||||
}
|
||||
|
||||
func NewPublicProductServiceProcessor(handler PublicProductService) *PublicProductServiceProcessor {
|
||||
self := &PublicProductServiceProcessor{product_public_api.NewPublicProductServiceProcessor(handler)}
|
||||
return self
|
||||
}
|
||||
|
||||
type DeveloperApiServiceProcessor struct {
|
||||
*developer_api.DeveloperApiServiceProcessor
|
||||
}
|
||||
|
||||
func NewDeveloperApiServiceProcessor(handler DeveloperApiService) *DeveloperApiServiceProcessor {
|
||||
self := &DeveloperApiServiceProcessor{developer_api.NewDeveloperApiServiceProcessor(handler)}
|
||||
return self
|
||||
}
|
||||
|
||||
type PlaygroundServiceProcessor struct {
|
||||
*playground.PlaygroundServiceProcessor
|
||||
}
|
||||
|
||||
func NewPlaygroundServiceProcessor(handler PlaygroundService) *PlaygroundServiceProcessor {
|
||||
self := &PlaygroundServiceProcessor{playground.NewPlaygroundServiceProcessor(handler)}
|
||||
return self
|
||||
}
|
||||
|
||||
type DatabaseServiceProcessor struct {
|
||||
*database.DatabaseServiceProcessor
|
||||
}
|
||||
|
||||
func NewDatabaseServiceProcessor(handler DatabaseService) *DatabaseServiceProcessor {
|
||||
self := &DatabaseServiceProcessor{database.NewDatabaseServiceProcessor(handler)}
|
||||
return self
|
||||
}
|
||||
|
||||
type ResourceServiceProcessor struct {
|
||||
*resource.ResourceServiceProcessor
|
||||
}
|
||||
|
||||
func NewResourceServiceProcessor(handler ResourceService) *ResourceServiceProcessor {
|
||||
self := &ResourceServiceProcessor{resource.NewResourceServiceProcessor(handler)}
|
||||
return self
|
||||
}
|
||||
|
||||
type PassportServiceProcessor struct {
|
||||
*passport.PassportServiceProcessor
|
||||
}
|
||||
|
||||
func NewPassportServiceProcessor(handler PassportService) *PassportServiceProcessor {
|
||||
self := &PassportServiceProcessor{passport.NewPassportServiceProcessor(handler)}
|
||||
return self
|
||||
}
|
||||
|
||||
type WorkflowServiceProcessor struct {
|
||||
*workflow.WorkflowServiceProcessor
|
||||
}
|
||||
|
||||
func NewWorkflowServiceProcessor(handler WorkflowService) *WorkflowServiceProcessor {
|
||||
self := &WorkflowServiceProcessor{workflow.NewWorkflowServiceProcessor(handler)}
|
||||
return self
|
||||
}
|
||||
|
||||
type KnowledgeServiceProcessor struct {
|
||||
*knowledge.DatasetServiceProcessor
|
||||
}
|
||||
|
||||
func NewKnowledgeServiceProcessor(handler KnowledgeService) *KnowledgeServiceProcessor {
|
||||
self := &KnowledgeServiceProcessor{knowledge.NewDatasetServiceProcessor(handler)}
|
||||
return self
|
||||
}
|
||||
|
||||
type BotOpenApiServiceProcessor struct {
|
||||
*bot_open_api.BotOpenApiServiceProcessor
|
||||
}
|
||||
|
||||
func NewBotOpenApiServiceProcessor(handler BotOpenApiService) *BotOpenApiServiceProcessor {
|
||||
self := &BotOpenApiServiceProcessor{bot_open_api.NewBotOpenApiServiceProcessor(handler)}
|
||||
return self
|
||||
}
|
||||
|
||||
type UploadServiceProcessor struct {
|
||||
*upload.UploadServiceProcessor
|
||||
}
|
||||
|
||||
func NewUploadServiceProcessor(handler UploadService) *UploadServiceProcessor {
|
||||
self := &UploadServiceProcessor{upload.NewUploadServiceProcessor(handler)}
|
||||
return self
|
||||
}
|
||||
|
||||
type ConfigServiceProcessor struct {
|
||||
*config.ConfigServiceProcessor
|
||||
}
|
||||
|
||||
func NewConfigServiceProcessor(handler ConfigService) *ConfigServiceProcessor {
|
||||
self := &ConfigServiceProcessor{config.NewConfigServiceProcessor(handler)}
|
||||
return self
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,298 @@
|
||||
// Code generated by thriftgo (0.4.2). DO NOT EDIT.
|
||||
|
||||
package marketplace_common
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"database/sql/driver"
|
||||
"fmt"
|
||||
"github.com/apache/thrift/lib/go/thrift"
|
||||
)
|
||||
|
||||
type FollowType int64
|
||||
|
||||
const (
|
||||
// Unknown
|
||||
FollowType_Unknown FollowType = 0
|
||||
// followee
|
||||
FollowType_Followee FollowType = 1
|
||||
// follower
|
||||
FollowType_Follower FollowType = 2
|
||||
// MutualFollow
|
||||
FollowType_MutualFollow FollowType = 3
|
||||
)
|
||||
|
||||
func (p FollowType) String() string {
|
||||
switch p {
|
||||
case FollowType_Unknown:
|
||||
return "Unknown"
|
||||
case FollowType_Followee:
|
||||
return "Followee"
|
||||
case FollowType_Follower:
|
||||
return "Follower"
|
||||
case FollowType_MutualFollow:
|
||||
return "MutualFollow"
|
||||
}
|
||||
return "<UNSET>"
|
||||
}
|
||||
|
||||
func FollowTypeFromString(s string) (FollowType, error) {
|
||||
switch s {
|
||||
case "Unknown":
|
||||
return FollowType_Unknown, nil
|
||||
case "Followee":
|
||||
return FollowType_Followee, nil
|
||||
case "Follower":
|
||||
return FollowType_Follower, nil
|
||||
case "MutualFollow":
|
||||
return FollowType_MutualFollow, nil
|
||||
}
|
||||
return FollowType(0), fmt.Errorf("not a valid FollowType string")
|
||||
}
|
||||
|
||||
func FollowTypePtr(v FollowType) *FollowType { return &v }
|
||||
func (p *FollowType) Scan(value interface{}) (err error) {
|
||||
var result sql.NullInt64
|
||||
err = result.Scan(value)
|
||||
*p = FollowType(result.Int64)
|
||||
return
|
||||
}
|
||||
|
||||
func (p *FollowType) Value() (driver.Value, error) {
|
||||
if p == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return int64(*p), nil
|
||||
}
|
||||
|
||||
type Price struct {
|
||||
// amount
|
||||
Amount int64 `thrift:"Amount,1" form:"amount" json:"amount,string"`
|
||||
// Currencies such as USD and CNY
|
||||
Currency string `thrift:"Currency,2" form:"currency" json:"currency"`
|
||||
// decimal places
|
||||
DecimalNum int8 `thrift:"DecimalNum,3" form:"decimal_num" json:"decimal_num"`
|
||||
}
|
||||
|
||||
func NewPrice() *Price {
|
||||
return &Price{}
|
||||
}
|
||||
|
||||
func (p *Price) InitDefault() {
|
||||
}
|
||||
|
||||
func (p *Price) GetAmount() (v int64) {
|
||||
return p.Amount
|
||||
}
|
||||
|
||||
func (p *Price) GetCurrency() (v string) {
|
||||
return p.Currency
|
||||
}
|
||||
|
||||
func (p *Price) GetDecimalNum() (v int8) {
|
||||
return p.DecimalNum
|
||||
}
|
||||
|
||||
var fieldIDToName_Price = map[int16]string{
|
||||
1: "Amount",
|
||||
2: "Currency",
|
||||
3: "DecimalNum",
|
||||
}
|
||||
|
||||
func (p *Price) Read(iprot thrift.TProtocol) (err error) {
|
||||
var fieldTypeId thrift.TType
|
||||
var fieldId int16
|
||||
|
||||
if _, err = iprot.ReadStructBegin(); err != nil {
|
||||
goto ReadStructBeginError
|
||||
}
|
||||
|
||||
for {
|
||||
_, fieldTypeId, fieldId, err = iprot.ReadFieldBegin()
|
||||
if err != nil {
|
||||
goto ReadFieldBeginError
|
||||
}
|
||||
if fieldTypeId == thrift.STOP {
|
||||
break
|
||||
}
|
||||
|
||||
switch fieldId {
|
||||
case 1:
|
||||
if fieldTypeId == thrift.I64 {
|
||||
if err = p.ReadField1(iprot); err != nil {
|
||||
goto ReadFieldError
|
||||
}
|
||||
} else if err = iprot.Skip(fieldTypeId); err != nil {
|
||||
goto SkipFieldError
|
||||
}
|
||||
case 2:
|
||||
if fieldTypeId == thrift.STRING {
|
||||
if err = p.ReadField2(iprot); err != nil {
|
||||
goto ReadFieldError
|
||||
}
|
||||
} else if err = iprot.Skip(fieldTypeId); err != nil {
|
||||
goto SkipFieldError
|
||||
}
|
||||
case 3:
|
||||
if fieldTypeId == thrift.BYTE {
|
||||
if err = p.ReadField3(iprot); err != nil {
|
||||
goto ReadFieldError
|
||||
}
|
||||
} else if err = iprot.Skip(fieldTypeId); err != nil {
|
||||
goto SkipFieldError
|
||||
}
|
||||
default:
|
||||
if err = iprot.Skip(fieldTypeId); err != nil {
|
||||
goto SkipFieldError
|
||||
}
|
||||
}
|
||||
if err = iprot.ReadFieldEnd(); err != nil {
|
||||
goto ReadFieldEndError
|
||||
}
|
||||
}
|
||||
if err = iprot.ReadStructEnd(); err != nil {
|
||||
goto ReadStructEndError
|
||||
}
|
||||
|
||||
return nil
|
||||
ReadStructBeginError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err)
|
||||
ReadFieldBeginError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err)
|
||||
ReadFieldError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_Price[fieldId]), err)
|
||||
SkipFieldError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err)
|
||||
|
||||
ReadFieldEndError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err)
|
||||
ReadStructEndError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
|
||||
}
|
||||
|
||||
func (p *Price) ReadField1(iprot thrift.TProtocol) error {
|
||||
|
||||
var _field int64
|
||||
if v, err := iprot.ReadI64(); err != nil {
|
||||
return err
|
||||
} else {
|
||||
_field = v
|
||||
}
|
||||
p.Amount = _field
|
||||
return nil
|
||||
}
|
||||
func (p *Price) ReadField2(iprot thrift.TProtocol) error {
|
||||
|
||||
var _field string
|
||||
if v, err := iprot.ReadString(); err != nil {
|
||||
return err
|
||||
} else {
|
||||
_field = v
|
||||
}
|
||||
p.Currency = _field
|
||||
return nil
|
||||
}
|
||||
func (p *Price) ReadField3(iprot thrift.TProtocol) error {
|
||||
|
||||
var _field int8
|
||||
if v, err := iprot.ReadByte(); err != nil {
|
||||
return err
|
||||
} else {
|
||||
_field = v
|
||||
}
|
||||
p.DecimalNum = _field
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *Price) Write(oprot thrift.TProtocol) (err error) {
|
||||
var fieldId int16
|
||||
if err = oprot.WriteStructBegin("Price"); err != nil {
|
||||
goto WriteStructBeginError
|
||||
}
|
||||
if p != nil {
|
||||
if err = p.writeField1(oprot); err != nil {
|
||||
fieldId = 1
|
||||
goto WriteFieldError
|
||||
}
|
||||
if err = p.writeField2(oprot); err != nil {
|
||||
fieldId = 2
|
||||
goto WriteFieldError
|
||||
}
|
||||
if err = p.writeField3(oprot); err != nil {
|
||||
fieldId = 3
|
||||
goto WriteFieldError
|
||||
}
|
||||
}
|
||||
if err = oprot.WriteFieldStop(); err != nil {
|
||||
goto WriteFieldStopError
|
||||
}
|
||||
if err = oprot.WriteStructEnd(); err != nil {
|
||||
goto WriteStructEndError
|
||||
}
|
||||
return nil
|
||||
WriteStructBeginError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err)
|
||||
WriteFieldError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err)
|
||||
WriteFieldStopError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err)
|
||||
WriteStructEndError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err)
|
||||
}
|
||||
|
||||
func (p *Price) writeField1(oprot thrift.TProtocol) (err error) {
|
||||
if err = oprot.WriteFieldBegin("Amount", thrift.I64, 1); err != nil {
|
||||
goto WriteFieldBeginError
|
||||
}
|
||||
if err := oprot.WriteI64(p.Amount); err != nil {
|
||||
return err
|
||||
}
|
||||
if err = oprot.WriteFieldEnd(); err != nil {
|
||||
goto WriteFieldEndError
|
||||
}
|
||||
return nil
|
||||
WriteFieldBeginError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err)
|
||||
WriteFieldEndError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err)
|
||||
}
|
||||
func (p *Price) writeField2(oprot thrift.TProtocol) (err error) {
|
||||
if err = oprot.WriteFieldBegin("Currency", thrift.STRING, 2); err != nil {
|
||||
goto WriteFieldBeginError
|
||||
}
|
||||
if err := oprot.WriteString(p.Currency); err != nil {
|
||||
return err
|
||||
}
|
||||
if err = oprot.WriteFieldEnd(); err != nil {
|
||||
goto WriteFieldEndError
|
||||
}
|
||||
return nil
|
||||
WriteFieldBeginError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err)
|
||||
WriteFieldEndError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err)
|
||||
}
|
||||
func (p *Price) writeField3(oprot thrift.TProtocol) (err error) {
|
||||
if err = oprot.WriteFieldBegin("DecimalNum", thrift.BYTE, 3); err != nil {
|
||||
goto WriteFieldBeginError
|
||||
}
|
||||
if err := oprot.WriteByte(p.DecimalNum); err != nil {
|
||||
return err
|
||||
}
|
||||
if err = oprot.WriteFieldEnd(); err != nil {
|
||||
goto WriteFieldEndError
|
||||
}
|
||||
return nil
|
||||
WriteFieldBeginError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field 3 begin error: ", p), err)
|
||||
WriteFieldEndError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err)
|
||||
}
|
||||
|
||||
func (p *Price) String() string {
|
||||
if p == nil {
|
||||
return "<nil>"
|
||||
}
|
||||
return fmt.Sprintf("Price(%+v)", *p)
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,561 @@
|
||||
/*
|
||||
* Copyright 2025 coze-dev Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by hertz generator. DO NOT EDIT.
|
||||
|
||||
package coze
|
||||
|
||||
import (
|
||||
"github.com/cloudwego/hertz/pkg/app/server"
|
||||
coze "github.com/coze-dev/coze-studio/backend/api/handler/coze"
|
||||
)
|
||||
|
||||
/*
|
||||
This file will register all the routes of the services in the master idl.
|
||||
And it will update automatically when you use the "update" command for the idl.
|
||||
So don't modify the contents of the file, or your code will be deleted when it is updated.
|
||||
*/
|
||||
|
||||
// Register register routes based on the IDL 'api.${HTTP Method}' annotation.
|
||||
func Register(r *server.Hertz) {
|
||||
|
||||
root := r.Group("/", rootMw()...)
|
||||
{
|
||||
_api := root.Group("/api", _apiMw()...)
|
||||
{
|
||||
_admin := _api.Group("/admin", _adminMw()...)
|
||||
{
|
||||
_config := _admin.Group("/config", _configMw()...)
|
||||
{
|
||||
_basic := _config.Group("/basic", _basicMw()...)
|
||||
_basic.GET("/get", append(_getbasicconfigurationMw(), coze.GetBasicConfiguration)...)
|
||||
_basic.POST("/save", append(_savebasicconfigurationMw(), coze.SaveBasicConfiguration)...)
|
||||
}
|
||||
{
|
||||
_knowledge := _config.Group("/knowledge", _knowledgeMw()...)
|
||||
_knowledge.GET("/get", append(_getknowledgeconfigMw(), coze.GetKnowledgeConfig)...)
|
||||
_knowledge.POST("/save", append(_updateknowledgeconfigMw(), coze.UpdateKnowledgeConfig)...)
|
||||
}
|
||||
{
|
||||
_model := _config.Group("/model", _modelMw()...)
|
||||
_model.POST("/create", append(_createmodelMw(), coze.CreateModel)...)
|
||||
_model.POST("/delete", append(_deletemodelMw(), coze.DeleteModel)...)
|
||||
_model.GET("/list", append(_getmodellistMw(), coze.GetModelList)...)
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
_bot := _api.Group("/bot", _botMw()...)
|
||||
_bot.POST("/get_type_list", append(_gettypelistMw(), coze.GetTypeList)...)
|
||||
_bot.POST("/upload_file", append(_uploadfileMw(), coze.UploadFile)...)
|
||||
}
|
||||
{
|
||||
_common := _api.Group("/common", _commonMw()...)
|
||||
{
|
||||
_upload := _common.Group("/upload", _uploadMw()...)
|
||||
_upload.GET("/apply_upload_action", append(_applyuploadactionMw(), coze.ApplyUploadAction)...)
|
||||
_upload.POST("/apply_upload_action", append(_applyuploadaction0Mw(), coze.ApplyUploadAction)...)
|
||||
_upload.POST("/*tos_uri", append(_commonuploadMw(), coze.CommonUpload)...)
|
||||
}
|
||||
}
|
||||
{
|
||||
_conversation := _api.Group("/conversation", _conversationMw()...)
|
||||
_conversation.POST("/break_message", append(_breakmessageMw(), coze.BreakMessage)...)
|
||||
_conversation.POST("/chat", append(_agentrunMw(), coze.AgentRun)...)
|
||||
_conversation.POST("/clear_message", append(_clearconversationhistoryMw(), coze.ClearConversationHistory)...)
|
||||
_conversation.POST("/create_section", append(_clearconversationctxMw(), coze.ClearConversationCtx)...)
|
||||
_conversation.POST("/delete_message", append(_deletemessageMw(), coze.DeleteMessage)...)
|
||||
_conversation.POST("/get_message_list", append(_getmessagelistMw(), coze.GetMessageList)...)
|
||||
}
|
||||
{
|
||||
_developer := _api.Group("/developer", _developerMw()...)
|
||||
_developer.POST("/get_icon", append(_geticonMw(), coze.GetIcon)...)
|
||||
}
|
||||
{
|
||||
_draftbot := _api.Group("/draftbot", _draftbotMw()...)
|
||||
_draftbot.POST("/commit_check", append(_checkdraftbotcommitMw(), coze.CheckDraftBotCommit)...)
|
||||
_draftbot.POST("/create", append(_draftbotcreateMw(), coze.DraftBotCreate)...)
|
||||
_draftbot.POST("/delete", append(_deletedraftbotMw(), coze.DeleteDraftBot)...)
|
||||
_draftbot.POST("/duplicate", append(_duplicatedraftbotMw(), coze.DuplicateDraftBot)...)
|
||||
_draftbot.POST("/get_display_info", append(_getdraftbotdisplayinfoMw(), coze.GetDraftBotDisplayInfo)...)
|
||||
_draftbot.POST("/list_draft_history", append(_listdraftbothistoryMw(), coze.ListDraftBotHistory)...)
|
||||
_draftbot.POST("/publish", append(_publishdraftbotMw(), coze.PublishDraftBot)...)
|
||||
_draftbot.POST("/update_display_info", append(_updatedraftbotdisplayinfoMw(), coze.UpdateDraftBotDisplayInfo)...)
|
||||
{
|
||||
_publish := _draftbot.Group("/publish", _publishMw()...)
|
||||
{
|
||||
_connector := _publish.Group("/connector", _connectorMw()...)
|
||||
_connector.POST("/list", append(_publishconnectorlistMw(), coze.PublishConnectorList)...)
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
_intelligence_api := _api.Group("/intelligence_api", _intelligence_apiMw()...)
|
||||
{
|
||||
_draft_project := _intelligence_api.Group("/draft_project", _draft_projectMw()...)
|
||||
_draft_project.POST("/copy", append(_draftprojectcopyMw(), coze.DraftProjectCopy)...)
|
||||
_draft_project.POST("/create", append(_draftprojectcreateMw(), coze.DraftProjectCreate)...)
|
||||
_draft_project.POST("/delete", append(_draftprojectdeleteMw(), coze.DraftProjectDelete)...)
|
||||
_draft_project.POST("/inner_task_list", append(_draftprojectinnertasklistMw(), coze.DraftProjectInnerTaskList)...)
|
||||
_draft_project.POST("/update", append(_draftprojectupdateMw(), coze.DraftProjectUpdate)...)
|
||||
}
|
||||
{
|
||||
_publish0 := _intelligence_api.Group("/publish", _publish0Mw()...)
|
||||
_publish0.POST("/check_version_number", append(_checkprojectversionnumberMw(), coze.CheckProjectVersionNumber)...)
|
||||
_publish0.POST("/connector_list", append(_projectpublishconnectorlistMw(), coze.ProjectPublishConnectorList)...)
|
||||
_publish0.POST("/get_published_connector", append(_getprojectpublishedconnectorMw(), coze.GetProjectPublishedConnector)...)
|
||||
_publish0.POST("/publish_project", append(_publishprojectMw(), coze.PublishProject)...)
|
||||
_publish0.POST("/publish_record_detail", append(_getpublishrecorddetailMw(), coze.GetPublishRecordDetail)...)
|
||||
_publish0.POST("/publish_record_list", append(_getpublishrecordlistMw(), coze.GetPublishRecordList)...)
|
||||
}
|
||||
{
|
||||
_search := _intelligence_api.Group("/search", _searchMw()...)
|
||||
_search.POST("/get_draft_intelligence_info", append(_getdraftintelligenceinfoMw(), coze.GetDraftIntelligenceInfo)...)
|
||||
_search.POST("/get_draft_intelligence_list", append(_getdraftintelligencelistMw(), coze.GetDraftIntelligenceList)...)
|
||||
_search.POST("/get_recently_edit_intelligence", append(_getuserrecentlyeditintelligenceMw(), coze.GetUserRecentlyEditIntelligence)...)
|
||||
}
|
||||
}
|
||||
{
|
||||
_knowledge0 := _api.Group("/knowledge", _knowledge0Mw()...)
|
||||
_knowledge0.POST("/create", append(_createdatasetMw(), coze.CreateDataset)...)
|
||||
_knowledge0.POST("/delete", append(_deletedatasetMw(), coze.DeleteDataset)...)
|
||||
_knowledge0.POST("/detail", append(_datasetdetailMw(), coze.DatasetDetail)...)
|
||||
_knowledge0.POST("/list", append(_listdatasetMw(), coze.ListDataset)...)
|
||||
_knowledge0.POST("/update", append(_updatedatasetMw(), coze.UpdateDataset)...)
|
||||
{
|
||||
_document := _knowledge0.Group("/document", _documentMw()...)
|
||||
_document.POST("/create", append(_createdocumentMw(), coze.CreateDocument)...)
|
||||
_document.POST("/delete", append(_deletedocumentMw(), coze.DeleteDocument)...)
|
||||
_document.POST("/list", append(_listdocumentMw(), coze.ListDocument)...)
|
||||
_document.POST("/resegment", append(_resegmentMw(), coze.Resegment)...)
|
||||
_document.POST("/update", append(_updatedocumentMw(), coze.UpdateDocument)...)
|
||||
{
|
||||
_progress := _document.Group("/progress", _progressMw()...)
|
||||
_progress.POST("/get", append(_getdocumentprogressMw(), coze.GetDocumentProgress)...)
|
||||
}
|
||||
}
|
||||
{
|
||||
_icon := _knowledge0.Group("/icon", _iconMw()...)
|
||||
_icon.POST("/get", append(_geticonfordatasetMw(), coze.GetIconForDataset)...)
|
||||
}
|
||||
{
|
||||
_photo := _knowledge0.Group("/photo", _photoMw()...)
|
||||
_photo.POST("/caption", append(_updatephotocaptionMw(), coze.UpdatePhotoCaption)...)
|
||||
_photo.POST("/detail", append(_photodetailMw(), coze.PhotoDetail)...)
|
||||
_photo.POST("/extract_caption", append(_extractphotocaptionMw(), coze.ExtractPhotoCaption)...)
|
||||
_photo.POST("/list", append(_listphotoMw(), coze.ListPhoto)...)
|
||||
}
|
||||
{
|
||||
_review := _knowledge0.Group("/review", _reviewMw()...)
|
||||
_review.POST("/create", append(_createdocumentreviewMw(), coze.CreateDocumentReview)...)
|
||||
_review.POST("/mget", append(_mgetdocumentreviewMw(), coze.MGetDocumentReview)...)
|
||||
_review.POST("/save", append(_savedocumentreviewMw(), coze.SaveDocumentReview)...)
|
||||
}
|
||||
{
|
||||
_slice := _knowledge0.Group("/slice", _sliceMw()...)
|
||||
_slice.POST("/create", append(_createsliceMw(), coze.CreateSlice)...)
|
||||
_slice.POST("/delete", append(_deletesliceMw(), coze.DeleteSlice)...)
|
||||
_slice.POST("/list", append(_listsliceMw(), coze.ListSlice)...)
|
||||
_slice.POST("/update", append(_updatesliceMw(), coze.UpdateSlice)...)
|
||||
}
|
||||
{
|
||||
_table_schema := _knowledge0.Group("/table_schema", _table_schemaMw()...)
|
||||
_table_schema.POST("/get", append(_gettableschemaMw(), coze.GetTableSchema)...)
|
||||
_table_schema.POST("/validate", append(_validatetableschemaMw(), coze.ValidateTableSchema)...)
|
||||
}
|
||||
}
|
||||
{
|
||||
_marketplace := _api.Group("/marketplace", _marketplaceMw()...)
|
||||
{
|
||||
_product := _marketplace.Group("/product", _productMw()...)
|
||||
_product.GET("/call_info", append(_publicgetproductcallinfoMw(), coze.PublicGetProductCallInfo)...)
|
||||
_product.GET("/config", append(_publicgetmarketpluginconfigMw(), coze.PublicGetMarketPluginConfig)...)
|
||||
_product.GET("/detail", append(_publicgetproductdetailMw(), coze.PublicGetProductDetail)...)
|
||||
_product.POST("/duplicate", append(_publicduplicateproductMw(), coze.PublicDuplicateProduct)...)
|
||||
_product.POST("/favorite", append(_publicfavoriteproductMw(), coze.PublicFavoriteProduct)...)
|
||||
_favorite := _product.Group("/favorite", _favoriteMw()...)
|
||||
_favorite.GET("/list.v2", append(_publicgetuserfavoritelistv2Mw(), coze.PublicGetUserFavoriteListV2)...)
|
||||
_product.GET("/list", append(_publicgetproductlistMw(), coze.PublicGetProductList)...)
|
||||
_product.GET("/search", append(_publicsearchproductMw(), coze.PublicSearchProduct)...)
|
||||
_search0 := _product.Group("/search", _search0Mw()...)
|
||||
_search0.GET("/suggest", append(_publicsearchsuggestMw(), coze.PublicSearchSuggest)...)
|
||||
{
|
||||
_category := _product.Group("/category", _categoryMw()...)
|
||||
_category.GET("/list", append(_publicgetproductcategorylistMw(), coze.PublicGetProductCategoryList)...)
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
_memory := _api.Group("/memory", _memoryMw()...)
|
||||
_memory.GET("/doc_table_info", append(_getdocumenttableinfoMw(), coze.GetDocumentTableInfo)...)
|
||||
_memory.GET("/sys_variable_conf", append(_getsysvariableconfMw(), coze.GetSysVariableConf)...)
|
||||
_memory.GET("/table_mode_config", append(_getmodeconfigMw(), coze.GetModeConfig)...)
|
||||
{
|
||||
_database := _memory.Group("/database", _databaseMw()...)
|
||||
_database.POST("/add", append(_adddatabaseMw(), coze.AddDatabase)...)
|
||||
_database.POST("/bind_to_bot", append(_binddatabaseMw(), coze.BindDatabase)...)
|
||||
_database.POST("/delete", append(_deletedatabaseMw(), coze.DeleteDatabase)...)
|
||||
_database.POST("/get_by_id", append(_getdatabasebyidMw(), coze.GetDatabaseByID)...)
|
||||
_database.POST("/get_connector_name", append(_getconnectornameMw(), coze.GetConnectorName)...)
|
||||
_database.POST("/get_online_database_id", append(_getonlinedatabaseidMw(), coze.GetOnlineDatabaseId)...)
|
||||
_database.POST("/get_template", append(_getdatabasetemplateMw(), coze.GetDatabaseTemplate)...)
|
||||
_database.POST("/list", append(_listdatabaseMw(), coze.ListDatabase)...)
|
||||
_database.POST("/list_records", append(_listdatabaserecordsMw(), coze.ListDatabaseRecords)...)
|
||||
_database.POST("/unbind_to_bot", append(_unbinddatabaseMw(), coze.UnBindDatabase)...)
|
||||
_database.POST("/update", append(_updatedatabaseMw(), coze.UpdateDatabase)...)
|
||||
_database.POST("/update_bot_switch", append(_updatedatabasebotswitchMw(), coze.UpdateDatabaseBotSwitch)...)
|
||||
_database.POST("/update_records", append(_updatedatabaserecordsMw(), coze.UpdateDatabaseRecords)...)
|
||||
{
|
||||
_table := _database.Group("/table", _tableMw()...)
|
||||
_table.POST("/list_new", append(_getbotdatabaseMw(), coze.GetBotDatabase)...)
|
||||
_table.POST("/reset", append(_resetbottableMw(), coze.ResetBotTable)...)
|
||||
}
|
||||
}
|
||||
{
|
||||
_project := _memory.Group("/project", _projectMw()...)
|
||||
{
|
||||
_variable := _project.Group("/variable", _variableMw()...)
|
||||
_variable.GET("/meta_list", append(_getprojectvariablelistMw(), coze.GetProjectVariableList)...)
|
||||
_variable.POST("/meta_update", append(_updateprojectvariableMw(), coze.UpdateProjectVariable)...)
|
||||
}
|
||||
}
|
||||
{
|
||||
_table_file := _memory.Group("/table_file", _table_fileMw()...)
|
||||
_table_file.POST("/get_progress", append(_databasefileprogressdataMw(), coze.DatabaseFileProgressData)...)
|
||||
_table_file.POST("/submit", append(_submitdatabaseinserttaskMw(), coze.SubmitDatabaseInsertTask)...)
|
||||
}
|
||||
{
|
||||
_table_schema0 := _memory.Group("/table_schema", _table_schema0Mw()...)
|
||||
_table_schema0.POST("/get", append(_getdatabasetableschemaMw(), coze.GetDatabaseTableSchema)...)
|
||||
_table_schema0.POST("/validate", append(_validatedatabasetableschemaMw(), coze.ValidateDatabaseTableSchema)...)
|
||||
}
|
||||
{
|
||||
_variable0 := _memory.Group("/variable", _variable0Mw()...)
|
||||
_variable0.POST("/delete", append(_delprofilememoryMw(), coze.DelProfileMemory)...)
|
||||
_variable0.POST("/get", append(_getplaygroundmemoryMw(), coze.GetPlayGroundMemory)...)
|
||||
_variable0.POST("/get_meta", append(_getmemoryvariablemetaMw(), coze.GetMemoryVariableMeta)...)
|
||||
_variable0.POST("/upsert", append(_setkvmemoryMw(), coze.SetKvMemory)...)
|
||||
}
|
||||
}
|
||||
{
|
||||
_oauth := _api.Group("/oauth", _oauthMw()...)
|
||||
_oauth.GET("/authorization_code", append(_oauthauthorizationcodeMw(), coze.OauthAuthorizationCode)...)
|
||||
}
|
||||
{
|
||||
_passport := _api.Group("/passport", _passportMw()...)
|
||||
{
|
||||
_account := _passport.Group("/account", _accountMw()...)
|
||||
{
|
||||
_info := _account.Group("/info", _infoMw()...)
|
||||
{
|
||||
_v2 := _info.Group("/v2", _v2Mw()...)
|
||||
_v2.POST("/", append(_passportaccountinfov2Mw(), coze.PassportAccountInfoV2)...)
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
_web := _passport.Group("/web", _webMw()...)
|
||||
{
|
||||
_email := _web.Group("/email", _emailMw()...)
|
||||
{
|
||||
_login := _email.Group("/login", _loginMw()...)
|
||||
_login.POST("/", append(_passportwebemailloginpostMw(), coze.PassportWebEmailLoginPost)...)
|
||||
}
|
||||
{
|
||||
_password := _email.Group("/password", _passwordMw()...)
|
||||
{
|
||||
_reset := _password.Group("/reset", _resetMw()...)
|
||||
_reset.GET("/", append(_passportwebemailpasswordresetgetMw(), coze.PassportWebEmailPasswordResetGet)...)
|
||||
}
|
||||
}
|
||||
{
|
||||
_register := _email.Group("/register", _registerMw()...)
|
||||
{
|
||||
_v20 := _register.Group("/v2", _v20Mw()...)
|
||||
_v20.POST("/", append(_passportwebemailregisterv2postMw(), coze.PassportWebEmailRegisterV2Post)...)
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
_logout := _web.Group("/logout", _logoutMw()...)
|
||||
_logout.GET("/", append(_passportweblogoutgetMw(), coze.PassportWebLogoutGet)...)
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
_permission_api := _api.Group("/permission_api", _permission_apiMw()...)
|
||||
{
|
||||
_coze_web_app := _permission_api.Group("/coze_web_app", _coze_web_appMw()...)
|
||||
_coze_web_app.POST("/impersonate_coze_user", append(_impersonatecozeuserMw(), coze.ImpersonateCozeUser)...)
|
||||
}
|
||||
{
|
||||
_pat := _permission_api.Group("/pat", _patMw()...)
|
||||
_pat.POST("/create_personal_access_token_and_permission", append(_createpersonalaccesstokenandpermissionMw(), coze.CreatePersonalAccessTokenAndPermission)...)
|
||||
_pat.POST("/delete_personal_access_token_and_permission", append(_deletepersonalaccesstokenandpermissionMw(), coze.DeletePersonalAccessTokenAndPermission)...)
|
||||
_pat.GET("/get_personal_access_token_and_permission", append(_getpersonalaccesstokenandpermissionMw(), coze.GetPersonalAccessTokenAndPermission)...)
|
||||
_pat.GET("/list_personal_access_tokens", append(_listpersonalaccesstokensMw(), coze.ListPersonalAccessTokens)...)
|
||||
_pat.POST("/update_personal_access_token_and_permission", append(_updatepersonalaccesstokenandpermissionMw(), coze.UpdatePersonalAccessTokenAndPermission)...)
|
||||
}
|
||||
}
|
||||
{
|
||||
_playground := _api.Group("/playground", _playgroundMw()...)
|
||||
_playground.POST("/get_onboarding", append(_getonboardingMw(), coze.GetOnboarding)...)
|
||||
{
|
||||
_upload0 := _playground.Group("/upload", _upload0Mw()...)
|
||||
_upload0.POST("/auth_token", append(_getuploadauthtokenMw(), coze.GetUploadAuthToken)...)
|
||||
}
|
||||
}
|
||||
{
|
||||
_playground_api := _api.Group("/playground_api", _playground_apiMw()...)
|
||||
_playground_api.POST("/create_update_shortcut_command", append(_createupdateshortcutcommandMw(), coze.CreateUpdateShortcutCommand)...)
|
||||
_playground_api.POST("/delete_prompt_resource", append(_deletepromptresourceMw(), coze.DeletePromptResource)...)
|
||||
_playground_api.POST("/get_file_list", append(_getfileurlsMw(), coze.GetFileUrls)...)
|
||||
_playground_api.POST("/get_imagex_url", append(_getimagexshorturlMw(), coze.GetImagexShortUrl)...)
|
||||
_playground_api.POST("/get_official_prompt_list", append(_getofficialpromptresourcelistMw(), coze.GetOfficialPromptResourceList)...)
|
||||
_playground_api.GET("/get_prompt_resource_info", append(_getpromptresourceinfoMw(), coze.GetPromptResourceInfo)...)
|
||||
_playground_api.POST("/mget_user_info", append(_mgetuserbasicinfoMw(), coze.MGetUserBasicInfo)...)
|
||||
_playground_api.POST("/report_user_behavior", append(_reportuserbehaviorMw(), coze.ReportUserBehavior)...)
|
||||
_playground_api.POST("/upsert_prompt_resource", append(_upsertpromptresourceMw(), coze.UpsertPromptResource)...)
|
||||
{
|
||||
_draftbot0 := _playground_api.Group("/draftbot", _draftbot0Mw()...)
|
||||
_draftbot0.POST("/get_draft_bot_info", append(_getdraftbotinfoagwMw(), coze.GetDraftBotInfoAgw)...)
|
||||
_draftbot0.POST("/update_draft_bot_info", append(_updatedraftbotinfoagwMw(), coze.UpdateDraftBotInfoAgw)...)
|
||||
}
|
||||
{
|
||||
_operate := _playground_api.Group("/operate", _operateMw()...)
|
||||
_operate.POST("/get_bot_popup_info", append(_getbotpopupinfoMw(), coze.GetBotPopupInfo)...)
|
||||
_operate.POST("/update_bot_popup_info", append(_updatebotpopupinfoMw(), coze.UpdateBotPopupInfo)...)
|
||||
}
|
||||
{
|
||||
_space := _playground_api.Group("/space", _spaceMw()...)
|
||||
_space.POST("/list", append(_getspacelistv2Mw(), coze.GetSpaceListV2)...)
|
||||
}
|
||||
}
|
||||
{
|
||||
_plugin := _api.Group("/plugin", _pluginMw()...)
|
||||
_plugin.POST("/get_oauth_schema", append(_getoauthschemaMw(), coze.GetOAuthSchema)...)
|
||||
{
|
||||
_oauth0 := _plugin.Group("/oauth", _oauth0Mw()...)
|
||||
_oauth0.POST("/confirm", append(_pluginoauthconfirmMw(), coze.PluginOauthConfirm)...)
|
||||
_oauth0.GET("/get_oauth_info", append(_pluginoauthinfoMw(), coze.PluginOauthInfo)...)
|
||||
}
|
||||
}
|
||||
{
|
||||
_plugin_api := _api.Group("/plugin_api", _plugin_apiMw()...)
|
||||
_plugin_api.POST("/batch_create_api", append(_batchcreateapiMw(), coze.BatchCreateAPI)...)
|
||||
_plugin_api.POST("/check_and_lock_plugin_edit", append(_checkandlockplugineditMw(), coze.CheckAndLockPluginEdit)...)
|
||||
_plugin_api.POST("/convert_to_openapi", append(_convert2openapiMw(), coze.Convert2OpenAPI)...)
|
||||
_plugin_api.POST("/create_api", append(_createapiMw(), coze.CreateAPI)...)
|
||||
_plugin_api.POST("/debug_api", append(_debugapiMw(), coze.DebugAPI)...)
|
||||
_plugin_api.POST("/del_plugin", append(_delpluginMw(), coze.DelPlugin)...)
|
||||
_plugin_api.POST("/delete_api", append(_deleteapiMw(), coze.DeleteAPI)...)
|
||||
_plugin_api.POST("/get_bot_default_params", append(_getbotdefaultparamsMw(), coze.GetBotDefaultParams)...)
|
||||
_plugin_api.POST("/get_dev_plugin_list", append(_getdevpluginlistMw(), coze.GetDevPluginList)...)
|
||||
_plugin_api.POST("/get_oauth_schema", append(_getoauthschemaapiMw(), coze.GetOAuthSchemaAPI)...)
|
||||
_plugin_api.POST("/get_oauth_status", append(_getoauthstatusMw(), coze.GetOAuthStatus)...)
|
||||
_plugin_api.POST("/get_playground_plugin_list", append(_getplaygroundpluginlistMw(), coze.GetPlaygroundPluginList)...)
|
||||
_plugin_api.POST("/get_plugin_apis", append(_getpluginapisMw(), coze.GetPluginAPIs)...)
|
||||
_plugin_api.POST("/get_plugin_info", append(_getplugininfoMw(), coze.GetPluginInfo)...)
|
||||
_plugin_api.POST("/get_plugin_next_version", append(_getpluginnextversionMw(), coze.GetPluginNextVersion)...)
|
||||
_plugin_api.POST("/get_queried_oauth_plugins", append(_getqueriedoauthpluginlistMw(), coze.GetQueriedOAuthPluginList)...)
|
||||
_plugin_api.POST("/get_updated_apis", append(_getupdatedapisMw(), coze.GetUpdatedAPIs)...)
|
||||
_plugin_api.POST("/get_user_authority", append(_getuserauthorityMw(), coze.GetUserAuthority)...)
|
||||
_plugin_api.POST("/library_resource_list", append(_libraryresourcelistMw(), coze.LibraryResourceList)...)
|
||||
_plugin_api.POST("/project_resource_list", append(_projectresourcelistMw(), coze.ProjectResourceList)...)
|
||||
_plugin_api.POST("/publish_plugin", append(_publishpluginMw(), coze.PublishPlugin)...)
|
||||
_plugin_api.POST("/register", append(_registerpluginMw(), coze.RegisterPlugin)...)
|
||||
_plugin_api.POST("/register_plugin_meta", append(_registerpluginmetaMw(), coze.RegisterPluginMeta)...)
|
||||
_plugin_api.POST("/resource_copy_cancel", append(_resourcecopycancelMw(), coze.ResourceCopyCancel)...)
|
||||
_plugin_api.POST("/resource_copy_detail", append(_resourcecopydetailMw(), coze.ResourceCopyDetail)...)
|
||||
_plugin_api.POST("/resource_copy_dispatch", append(_resourcecopydispatchMw(), coze.ResourceCopyDispatch)...)
|
||||
_plugin_api.POST("/resource_copy_retry", append(_resourcecopyretryMw(), coze.ResourceCopyRetry)...)
|
||||
_plugin_api.POST("/revoke_auth_token", append(_revokeauthtokenMw(), coze.RevokeAuthToken)...)
|
||||
_plugin_api.POST("/unlock_plugin_edit", append(_unlockplugineditMw(), coze.UnlockPluginEdit)...)
|
||||
_plugin_api.POST("/update", append(_updatepluginMw(), coze.UpdatePlugin)...)
|
||||
_plugin_api.POST("/update_api", append(_updateapiMw(), coze.UpdateAPI)...)
|
||||
_plugin_api.POST("/update_bot_default_params", append(_updatebotdefaultparamsMw(), coze.UpdateBotDefaultParams)...)
|
||||
_plugin_api.POST("/update_plugin_meta", append(_updatepluginmetaMw(), coze.UpdatePluginMeta)...)
|
||||
}
|
||||
{
|
||||
_plugin_oauth := _api.Group("/plugin_oauth", _plugin_oauthMw()...)
|
||||
{
|
||||
_plugin_id := _plugin_oauth.Group("/:plugin_id", _plugin_idMw()...)
|
||||
_plugin_id.GET("/authorization_code", append(_pluginoauthauthorizationcodeMw(), coze.PluginOauthAuthorizationCode)...)
|
||||
}
|
||||
}
|
||||
{
|
||||
_user := _api.Group("/user", _userMw()...)
|
||||
_user.POST("/update_profile", append(_userupdateprofileMw(), coze.UserUpdateProfile)...)
|
||||
_user.POST("/update_profile_check", append(_updateuserprofilecheckMw(), coze.UpdateUserProfileCheck)...)
|
||||
}
|
||||
{
|
||||
_web0 := _api.Group("/web", _web0Mw()...)
|
||||
{
|
||||
_user0 := _web0.Group("/user", _user0Mw()...)
|
||||
{
|
||||
_update := _user0.Group("/update", _updateMw()...)
|
||||
{
|
||||
_upload_avatar := _update.Group("/upload_avatar", _upload_avatarMw()...)
|
||||
_upload_avatar.POST("/", append(_userupdateavatarMw(), coze.UserUpdateAvatar)...)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
_workflow_api := _api.Group("/workflow_api", _workflow_apiMw()...)
|
||||
_workflow_api.GET("/apiDetail", append(_getapidetailMw(), coze.GetApiDetail)...)
|
||||
_workflow_api.POST("/batch_delete", append(_batchdeleteworkflowMw(), coze.BatchDeleteWorkflow)...)
|
||||
_workflow_api.POST("/cancel", append(_cancelworkflowMw(), coze.CancelWorkFlow)...)
|
||||
_workflow_api.POST("/canvas", append(_getcanvasinfoMw(), coze.GetCanvasInfo)...)
|
||||
_workflow_api.POST("/copy", append(_copyworkflowMw(), coze.CopyWorkflow)...)
|
||||
_workflow_api.POST("/copy_wk_template", append(_copywktemplateapiMw(), coze.CopyWkTemplateApi)...)
|
||||
_workflow_api.POST("/create", append(_createworkflowMw(), coze.CreateWorkflow)...)
|
||||
_workflow_api.POST("/delete", append(_deleteworkflowMw(), coze.DeleteWorkflow)...)
|
||||
_workflow_api.POST("/delete_strategy", append(_getdeletestrategyMw(), coze.GetDeleteStrategy)...)
|
||||
_workflow_api.POST("/example_workflow_list", append(_getexampleworkflowlistMw(), coze.GetExampleWorkFlowList)...)
|
||||
_workflow_api.GET("/get_node_execute_history", append(_getnodeexecutehistoryMw(), coze.GetNodeExecuteHistory)...)
|
||||
_workflow_api.GET("/get_process", append(_getworkflowprocessMw(), coze.GetWorkFlowProcess)...)
|
||||
_workflow_api.POST("/get_trace", append(_gettracesdkMw(), coze.GetTraceSDK)...)
|
||||
_workflow_api.POST("/history_schema", append(_gethistoryschemaMw(), coze.GetHistorySchema)...)
|
||||
_workflow_api.POST("/list_publish_workflow", append(_listpublishworkflowMw(), coze.ListPublishWorkflow)...)
|
||||
_workflow_api.POST("/list_spans", append(_listrootspansMw(), coze.ListRootSpans)...)
|
||||
_workflow_api.POST("/llm_fc_setting_detail", append(_getllmnodefcsettingdetailMw(), coze.GetLLMNodeFCSettingDetail)...)
|
||||
_workflow_api.POST("/llm_fc_setting_merged", append(_getllmnodefcsettingsmergedMw(), coze.GetLLMNodeFCSettingsMerged)...)
|
||||
_workflow_api.POST("/nodeDebug", append(_workflownodedebugv2Mw(), coze.WorkflowNodeDebugV2)...)
|
||||
_workflow_api.POST("/node_panel_search", append(_nodepanelsearchMw(), coze.NodePanelSearch)...)
|
||||
_workflow_api.POST("/node_template_list", append(_nodetemplatelistMw(), coze.NodeTemplateList)...)
|
||||
_workflow_api.POST("/node_type", append(_queryworkflownodetypesMw(), coze.QueryWorkflowNodeTypes)...)
|
||||
_workflow_api.POST("/publish", append(_publishworkflowMw(), coze.PublishWorkflow)...)
|
||||
_workflow_api.POST("/released_workflows", append(_getreleasedworkflowsMw(), coze.GetReleasedWorkflows)...)
|
||||
_workflow_api.POST("/save", append(_saveworkflowMw(), coze.SaveWorkflow)...)
|
||||
_workflow_api.POST("/sign_image_url", append(_signimageurlMw(), coze.SignImageURL)...)
|
||||
_workflow_api.POST("/test_resume", append(_workflowtestresumeMw(), coze.WorkFlowTestResume)...)
|
||||
_workflow_api.POST("/test_run", append(_workflowtestrunMw(), coze.WorkFlowTestRun)...)
|
||||
_workflow_api.POST("/update_meta", append(_updateworkflowmetaMw(), coze.UpdateWorkflowMeta)...)
|
||||
_workflow_api.POST("/validate_tree", append(_validatetreeMw(), coze.ValidateTree)...)
|
||||
_workflow_api.POST("/workflow_detail", append(_getworkflowdetailMw(), coze.GetWorkflowDetail)...)
|
||||
_workflow_api.POST("/workflow_detail_info", append(_getworkflowdetailinfoMw(), coze.GetWorkflowDetailInfo)...)
|
||||
_workflow_api.POST("/workflow_list", append(_getworkflowlistMw(), coze.GetWorkFlowList)...)
|
||||
_workflow_api.POST("/workflow_references", append(_getworkflowreferencesMw(), coze.GetWorkflowReferences)...)
|
||||
{
|
||||
_chat_flow_role := _workflow_api.Group("/chat_flow_role", _chat_flow_roleMw()...)
|
||||
_chat_flow_role.POST("/create", append(_createchatflowroleMw(), coze.CreateChatFlowRole)...)
|
||||
_chat_flow_role.POST("/delete", append(_deletechatflowroleMw(), coze.DeleteChatFlowRole)...)
|
||||
_chat_flow_role.GET("/get", append(_getchatflowroleMw(), coze.GetChatFlowRole)...)
|
||||
}
|
||||
{
|
||||
_project_conversation := _workflow_api.Group("/project_conversation", _project_conversationMw()...)
|
||||
_project_conversation.POST("/create", append(_createprojectconversationdefMw(), coze.CreateProjectConversationDef)...)
|
||||
_project_conversation.POST("/delete", append(_deleteprojectconversationdefMw(), coze.DeleteProjectConversationDef)...)
|
||||
_project_conversation.GET("/list", append(_listprojectconversationdefMw(), coze.ListProjectConversationDef)...)
|
||||
_project_conversation.POST("/update", append(_updateprojectconversationdefMw(), coze.UpdateProjectConversationDef)...)
|
||||
}
|
||||
{
|
||||
_upload1 := _workflow_api.Group("/upload", _upload1Mw()...)
|
||||
_upload1.POST("/auth_token", append(_getworkflowuploadauthtokenMw(), coze.GetWorkflowUploadAuthToken)...)
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
_open_api := root.Group("/open_api", _open_apiMw()...)
|
||||
{
|
||||
_knowledge1 := _open_api.Group("/knowledge", _knowledge1Mw()...)
|
||||
{
|
||||
_document0 := _knowledge1.Group("/document", _document0Mw()...)
|
||||
_document0.POST("/create", append(_createdocumentopenapiMw(), coze.CreateDocumentOpenAPI)...)
|
||||
_document0.POST("/list", append(_listdocumentopenapiMw(), coze.ListDocumentOpenAPI)...)
|
||||
_document0.POST("/update", append(_updatedocumentopenapiMw(), coze.UpdateDocumentOpenAPI)...)
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
_v1 := root.Group("/v1", _v1Mw()...)
|
||||
_v1.GET("/conversations", append(_listconversationsapiMw(), coze.ListConversationsApi)...)
|
||||
_conversations := _v1.Group("/conversations", _conversationsMw()...)
|
||||
_conversations.DELETE("/:conversation_id", append(_deleteconversationapiMw(), coze.DeleteConversationApi)...)
|
||||
_conversations.PUT("/:conversation_id", append(_updateconversationapiMw(), coze.UpdateConversationApi)...)
|
||||
_v1.GET("/datasets", append(_listdatasetopenapiMw(), coze.ListDatasetOpenAPI)...)
|
||||
_datasets := _v1.Group("/datasets", _datasetsMw()...)
|
||||
_datasets.DELETE("/:dataset_id", append(_deletedatasetopenapiMw(), coze.DeleteDatasetOpenAPI)...)
|
||||
_dataset_id := _datasets.Group("/:dataset_id", _dataset_idMw()...)
|
||||
_dataset_id.GET("/images", append(_listphotodocumentopenapiMw(), coze.ListPhotoDocumentOpenAPI)...)
|
||||
_dataset_id.POST("/process", append(_getdocumentprogressopenapiMw(), coze.GetDocumentProgressOpenAPI)...)
|
||||
_datasets.PUT("/:dataset_id", append(_updatedatasetopenapiMw(), coze.UpdateDatasetOpenAPI)...)
|
||||
_v1.POST("/datasets", append(_createdatasetopenapiMw(), coze.CreateDatasetOpenAPI)...)
|
||||
{
|
||||
_apps := _v1.Group("/apps", _appsMw()...)
|
||||
_apps.GET("/:app_id", append(_getonlineappdataMw(), coze.GetOnlineAppData)...)
|
||||
}
|
||||
{
|
||||
_bot0 := _v1.Group("/bot", _bot0Mw()...)
|
||||
_bot0.GET("/get_online_info", append(_getbotonlineinfoMw(), coze.GetBotOnlineInfo)...)
|
||||
}
|
||||
{
|
||||
_bots := _v1.Group("/bots", _botsMw()...)
|
||||
_bots.GET("/:bot_id", append(_opengetbotinfoMw(), coze.OpenGetBotInfo)...)
|
||||
}
|
||||
{
|
||||
_conversation0 := _v1.Group("/conversation", _conversation0Mw()...)
|
||||
_conversation0.POST("/create", append(_createconversationMw(), coze.CreateConversation)...)
|
||||
_conversation0.GET("/retrieve", append(_retrieveconversationapiMw(), coze.RetrieveConversationApi)...)
|
||||
{
|
||||
_message := _conversation0.Group("/message", _messageMw()...)
|
||||
_message.POST("/list", append(_getapimessagelistMw(), coze.GetApiMessageList)...)
|
||||
}
|
||||
}
|
||||
{
|
||||
_conversations0 := _v1.Group("/conversations", _conversations0Mw()...)
|
||||
{
|
||||
_conversation_id := _conversations0.Group("/:conversation_id", _conversation_idMw()...)
|
||||
_conversation_id.POST("/clear", append(_clearconversationapiMw(), coze.ClearConversationApi)...)
|
||||
}
|
||||
}
|
||||
{
|
||||
_files := _v1.Group("/files", _filesMw()...)
|
||||
_files.POST("/upload", append(_uploadfileopenMw(), coze.UploadFileOpen)...)
|
||||
}
|
||||
{
|
||||
_workflow := _v1.Group("/workflow", _workflowMw()...)
|
||||
_workflow.GET("/get_run_history", append(_openapigetworkflowrunhistoryMw(), coze.OpenAPIGetWorkflowRunHistory)...)
|
||||
_workflow.POST("/run", append(_openapirunflowMw(), coze.OpenAPIRunFlow)...)
|
||||
_workflow.POST("/stream_resume", append(_openapistreamresumeflowMw(), coze.OpenAPIStreamResumeFlow)...)
|
||||
_workflow.POST("/stream_run", append(_openapistreamrunflowMw(), coze.OpenAPIStreamRunFlow)...)
|
||||
{
|
||||
_conversation1 := _workflow.Group("/conversation", _conversation1Mw()...)
|
||||
_conversation1.POST("/create", append(_openapicreateconversationMw(), coze.OpenAPICreateConversation)...)
|
||||
}
|
||||
}
|
||||
{
|
||||
_workflows := _v1.Group("/workflows", _workflowsMw()...)
|
||||
_workflows.POST("/chat", append(_openapichatflowrunMw(), coze.OpenAPIChatFlowRun)...)
|
||||
_workflows.GET("/:workflow_id", append(_openapigetworkflowinfoMw(), coze.OpenAPIGetWorkflowInfo)...)
|
||||
}
|
||||
}
|
||||
{
|
||||
_v3 := root.Group("/v3", _v3Mw()...)
|
||||
_v3.POST("/chat", append(_chatv3Mw(), coze.ChatV3)...)
|
||||
_chat := _v3.Group("/chat", _chatMw()...)
|
||||
_chat.POST("/cancel", append(_cancelchatapiMw(), coze.CancelChatApi)...)
|
||||
_chat.GET("/retrieve", append(_retrievechatopenMw(), coze.RetrieveChatOpen)...)
|
||||
{
|
||||
_chat0 := _v3.Group("/chat", _chat0Mw()...)
|
||||
{
|
||||
_message0 := _chat0.Group("/message", _message0Mw()...)
|
||||
_message0.GET("/list", append(_listchatmessageapiMw(), coze.ListChatMessageApi)...)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Copyright 2025 coze-dev Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by hertz generator. DO NOT EDIT.
|
||||
|
||||
package router
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
"github.com/cloudwego/hertz/pkg/app"
|
||||
"github.com/cloudwego/hertz/pkg/app/server"
|
||||
|
||||
coze "github.com/coze-dev/coze-studio/backend/api/router/coze"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/logs"
|
||||
)
|
||||
|
||||
// GeneratedRegister registers routers generated by IDL.
|
||||
func GeneratedRegister(r *server.Hertz) {
|
||||
//INSERT_POINT: DO NOT DELETE THIS LINE!
|
||||
coze.Register(r)
|
||||
staticFileRegister(r)
|
||||
}
|
||||
|
||||
// staticFileRegister registers web page router.
|
||||
func staticFileRegister(r *server.Hertz) {
|
||||
cwd, err := os.Getwd()
|
||||
if err != nil {
|
||||
logs.Warnf("[staticFileRegister] Failed to get current working directory: %v", err)
|
||||
cwd = os.Getenv("PWD")
|
||||
}
|
||||
|
||||
staticFile := path.Join(cwd, "resources/static/index.html")
|
||||
|
||||
r.Static("/static", path.Join(cwd, "/resources/static"))
|
||||
r.StaticFile("/favicon.png", "./resources/static/favicon.png")
|
||||
r.StaticFile("/", staticFile)
|
||||
r.StaticFile("/sign", staticFile)
|
||||
|
||||
r.StaticFS("/admin", &app.FS{
|
||||
Root: path.Join(cwd, "/resources/conf"),
|
||||
GenerateIndexPages: true,
|
||||
IndexNames: []string{"index.html"},
|
||||
})
|
||||
|
||||
// r.StaticFS("/admin", &app.FS{
|
||||
// Root: path.Join(cwd, "/../backend/conf"),
|
||||
// GenerateIndexPages: true,
|
||||
// IndexNames: []string{"index.html"},
|
||||
// })
|
||||
|
||||
type data struct {
|
||||
Code int32 `json:"code"`
|
||||
Msg string `json:"msg"`
|
||||
}
|
||||
|
||||
r.NoRoute(func(c context.Context, ctx *app.RequestContext) {
|
||||
path := string(ctx.GetRequest().URI().Path())
|
||||
if strings.HasPrefix(path, "/api/") ||
|
||||
strings.HasPrefix(path, "/v1/") ||
|
||||
strings.HasPrefix(path, "/v3/") {
|
||||
ctx.JSON(404, data{
|
||||
Code: 404,
|
||||
Msg: "not found",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// index page will show 404 error
|
||||
ctx.File(staticFile)
|
||||
})
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user