Compare commits

...

9 Commits

25 changed files with 132 additions and 146 deletions

View File

@ -14,6 +14,7 @@ OCEANBASE_DEBUG_COMPOSE_FILE := docker/docker-compose-oceanbase_debug.yml
MYSQL_SCHEMA := ./docker/volumes/mysql/schema.sql
MYSQL_INIT_SQL := ./docker/volumes/mysql/sql_init.sql
ENV_FILE := ./docker/.env.debug
WEB_ENV_FILE := ./docker/.env
OCEANBASE_ENV_FILE := ./docker/.env.debug
STATIC_DIR := ./bin/resources/static
ES_INDEX_SCHEMA := ./docker/volumes/elasticsearch/es_index_schema
@ -65,13 +66,19 @@ build_docker:
@echo "Build docker image"
@docker compose -f $(COMPOSE_FILE) --profile build-server build
web:
web_env:
@if [ ! -f "$(WEB_ENV_FILE)" ]; then \
echo "Env file '$(WEB_ENV_FILE)' not found, using example env..."; \
cp ./docker/.env.example $(WEB_ENV_FILE); \
fi
web: web_env
@echo "Start web server in docker"
@docker compose -f docker/docker-compose.yml up -d
@docker compose -f docker/docker-compose.yml --env-file $(WEB_ENV_FILE) up -d
down_web:
@echo "Stop web server in docker"
@docker compose -f docker/docker-compose.yml down
@docker compose -f docker/docker-compose.yml --env-file $(WEB_ENV_FILE) down
down: env
@echo "Stop all docker containers"

View File

@ -50,32 +50,22 @@ Deployment steps:
# Clone code
git clone https://github.com/coze-dev/coze-studio.git
```
2. Deploy and start the service. When deploying and starting Coze Studio for the first time, it may take a while to retrieve images and build local images. Please be patient. If you see the message "Container coze-server Started," it means the Coze Studio service has started successfully.
2. Configure the model.
1. Copy the template files of the doubao-seed-1.6 model from the template directory and paste them into the configuration file directory.
```Bash
cd coze-studio
# Copy model configuration template
cp backend/conf/model/template/model_template_ark_doubao-seed-1.6.yaml backend/conf/model/ark_doubao-seed-1.6.yaml
```
2. Modify the template file in the configuration file directory.
1. Enter the directory `backend/conf/model`. Open the file `ark_doubao-seed-1.6.yaml`.
2. Set the fields `id`, `meta.conn_config.api_key`, `meta.conn_config.model`, and save the file.
* **id**: The model ID in Coze Studio, defined by the developer, must be a non-zero integer and globally unique. Agents or workflows call models based on model IDs. For models that have already been launched, do not modify their IDs; otherwise, it may result in model call failures.
* **meta.conn_config.api_key**: The API Key for the model service. In this example, it is the API Key for Ark API Key. For more information, see [Get Volcengine Ark API Key](https://www.volcengine.com/docs/82379/1541594) or [Get BytePlus ModelArk API Key](https://docs.byteplus.com/en/docs/ModelArk/1361424?utm_source=github&utm_medium=readme&utm_campaign=coze_open_source).
* **meta.conn_config.model**: The Model name for the model service. In this example, it refers to the Model ID or Endpoint ID of Ark. For more information, see [Get Volcengine Ark Model ID](https://www.volcengine.com/docs/82379/1513689) / [Get Volcengine Ark Endpoint ID](https://www.volcengine.com/docs/82379/1099522) or [Get BytePlus ModelArk Model ID](https://docs.byteplus.com/en/docs/ModelArk/model_id?utm_source=github&utm_medium=readme&utm_campaign=coze_open_source) / [Get BytePlus ModelArk Endpoint ID](https://docs.byteplus.com/en/docs/ModelArk/1099522?utm_source=github&utm_medium=readme&utm_campaign=coze_open_source).
> For users in China, you may use Volcengine Ark; for users outside China, you may use BytePlus ModelArk instead.
3. Deploy and start the service.
When deploying and starting Coze Studio for the first time, it may take a while to retrieve images and build local images. Please be patient. During deployment, you will see the following log information. If you see the message "Container coze-server Started," it means the Coze Studio service has started successfully.
```Bash
# Start the service
cd docker
cd coze-studio
# start service
# for macOS or Linux
make web
# for windows
cp .env.example .env
docker compose up -d
docker compose -f ./docker/docker-compose.yml up
```
For common startup failure issues, **please refer to the [FAQ](https://github.com/coze-dev/coze-studio/wiki/9.-FAQ)**.
4. After starting the service, you can open Coze Studio by accessing `http://localhost:8888/` through your browser.
3. Register an account by visiting `http://localhost:8888/sign`, entering your username and password, and clicking the Register button.
4. Configure the model at `http://localhost:8888/admin/#model-management` by adding a new model. (The model management feature is currently in beta testing. To try it out, please change the images in `docker-compose.yml` to `cozedev/coze-studio-server:0.5.0.beta.3` and `cozedev/coze-studio-web:0.5.0.beta`.)
5. Visit Coze Studio at `http://localhost:8888/`.
> [!WARNING]
> If you want to deploy Coze Studio in a public network environment, it is recommended to assess security risks before you begin, and take corresponding protection measures. Possible security risks include account registration functions, Python execution environments in workflow code nodes, Coze Server listening address configurations, SSRF (Server - Side Request Forgery), and some horizontal privilege escalations in APIs. For more details, refer to [Quickstart](https://github.com/coze-dev/coze-studio/wiki/2.-Quickstart#security-risks-in-public-networks).

View File

@ -46,37 +46,29 @@ Coze Studio 的后端采用 Golang 开发,前端使用 React + TypeScript
部署步骤:
1. 获取源码。
```Bash
# 克隆代码
git clone https://github.com/coze-dev/coze-studio.git
```
2. 配置模型
1. 从模板目录复制 doubao-seed-1.6 模型的模版文件,并粘贴到配置文件目录。
```Bash
cd coze-studio
# 复制模型配置模版
cp backend/conf/model/template/model_template_ark_doubao-seed-1.6.yaml backend/conf/model/ark_doubao-seed-1.6.yaml
```
2. 在配置文件目录下,修改模版文件。
1. 进入目录 `backend/conf/model`。打开复制后的文件`ark_doubao-seed-1.6.yaml`。
2. 设置 `id`、`meta.conn_config.api_key`、`meta.conn_config.model` 字段,并保存文件。
* **id**Coze Studio 中的模型 ID由开发者自行定义必须是非 0 的整数,且全局唯一。智能体或工作流根据模型 ID 来调用模型。对于已上线的模型,请勿修改模型 ID否则可能导致模型调用失败。
* **meta.conn_config.api_key**:模型服务的 API Key在本示例中为火山方舟的 API Key获取方式可参考[获取火山方舟 API Key](https://www.volcengine.com/docs/82379/1541594) 或[获取 Byteplus ModelArk API Key](https://docs.byteplus.com/en/docs/ModelArk/1361424?utm_source=github&utm_medium=readme&utm_campaign=coze_open_source)。
* **meta.conn_config.model**:模型服务的 Model name在本示例中为火山方舟的 Model ID 或 Endpoint ID获取方式可参考 [获取火山方舟 Model ID](https://www.volcengine.com/docs/82379/1513689) / [获取火山方舟 Endpoint ID](https://www.volcengine.com/docs/82379/1099522),或者参考[获取 BytePlus ModelArk Model ID](https://docs.byteplus.com/en/docs/ModelArk/model_id?utm_source=github&utm_medium=readme&utm_campaign=coze_open_source) / [获取 BytePlus ModelArk Endpoint ID](https://docs.byteplus.com/en/docs/ModelArk/1099522?utm_source=github&utm_medium=readme&utm_campaign=coze_open_source)。
> 中国境内用户可选用火山方舟Volcengine Ark非中国境内的用户则可用 BytePlus ModelArk。
3. 部署并启动服务。
首次部署并启动 Coze Studio 需要拉取镜像、构建本地镜像,可能耗时较久,请耐心等待。部署过程中,你会看到以下日志信息。如果看到提示 "Container coze-server Started",表示 Coze Studio 服务已成功启动。
2. 部署并启动服务
首次部署并启动 Coze Studio 需要拉取镜像、构建本地镜像,可能耗时较久,请耐心等待。如果看到提示 "Container coze-server Started",表示 Coze Studio 服务已成功启动。
```Bash
# 启动服务
cd docker
cd coze-studio
# start service
# for macOS or Linux
make web
# for windows
cp .env.example .env
docker compose up -d
docker compose -f ./docker/docker-compose.yml up
```
**启动失败常见问题可参考[常见问题](https://github.com/coze-dev/coze-studio/wiki/9.-%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98)**。
4. 启动服务后,通过浏览器访问 `http://localhost:8888/` 即可打开 Coze Studio
3. 注册账号,访问 `http://localhost:8888/sign` 输入用户名、密码点击注册按钮。
4. 配置模型:访问 `http://localhost:8888/admin/#model-management` 新增模型。(模型管理功能还在 beta 测试中,请将 `docker-compose.yml` 文件中的 `coze-server` 和 `coze-web` 服务镜像分别修改为 `cozedev/coze-studio-server:0.5.0.beta.3` 和 `cozedev/coze-studio-web:0.5.0.beta`进行体验)
5. 访问 Coze Studio `http://localhost:8888/`。
> [!WARNING]
> 如果要将 Coze Studio 部署到公网环境,建议在部署前评估整体评估安全风险,例如账号注册功能、工作流代码节点 Python执行环境、Coze Server 监听地址配置、SSRF 和部分 API 水平越权的风险,并采取相应防护措施。详细信息可参考[快速开始](https://github.com/coze-dev/coze-studio/wiki/2.-%E5%BF%AB%E9%80%9F%E5%BC%80%E5%A7%8B#%E5%85%AC%E7%BD%91%E5%AE%89%E5%85%A8%E9%A3%8E%E9%99%A9)。

View File

@ -74,7 +74,6 @@ func (p *PluginApplicationService) GetBotDefaultParams(ctx context.Context, req
if err != nil {
return nil, errorx.Wrapf(err, "GetDraftAgentToolByName failed, agentID=%d, toolName=%s", req.BotID, req.APIName)
}
reqAPIParams, err := draftAgentTool.ToReqAPIParameter()
if err != nil {
return nil, err

View File

@ -282,6 +282,10 @@ func toNewModel(old *OldModel) (*Model, error) {
m.Connection.Claude = modelMeta.Connection.Claude
}
if old.Meta.ConnConfig.EnableBase64Url != nil {
m.EnableBase64URL = *old.Meta.ConnConfig.EnableBase64Url
}
logs.Debugf("to new model, old: %v \n new %v",
conv.DebugJsonToStr(old), conv.DebugJsonToStr(m))
@ -360,6 +364,7 @@ type OldConfig struct {
TopK *int `json:"top_k,omitempty" yaml:"top_k"`
Stop []string `json:"stop,omitempty" yaml:"stop"`
EnableThinking *bool `json:"enable_thinking,omitempty" yaml:"enable_thinking,omitempty"`
EnableBase64Url *bool `json:"enable_base64_url,omitempty" yaml:"enable_base64_url,omitempty"`
OpenAI *OpenAIConfig `json:"open_ai,omitempty" yaml:"openai"`
Claude *ClaudeConfig `json:"claude,omitempty" yaml:"claude"`

View File

@ -38,6 +38,7 @@ func newOllamaModelBuilder(cfg *config.Model) *ollamaModelBuilder {
func (o *ollamaModelBuilder) getDefaultOllamaConfig() *ollama.ChatModelConfig {
return &ollama.ChatModelConfig{
Options: &api.Options{},
BaseURL: "http://127.0.0.1:11434",
}
}

View File

@ -50,6 +50,8 @@ type ToolInfo struct {
Method *string
SubURL *string
Operation *Openapi3Operation
AgentID *int64
}
func (t ToolInfo) GetName() string {
@ -155,7 +157,7 @@ func (t ToolInfo) ToRespAPIParameter() ([]*common.APIParameter, error) {
location: string(consts.ParamInBody),
required: required[subParamName],
}
apiParam, err := toAPIParameter(paramMeta, prop.Value)
apiParam, err := t.toAPIParameter(paramMeta, prop.Value)
if err != nil {
return nil, err
}
@ -204,7 +206,7 @@ func (t ToolInfo) ToReqAPIParameter() ([]*common.APIParameter, error) {
location: paramVal.In,
required: paramVal.Required,
}
apiParam, err := toAPIParameter(paramMeta, schemaVal)
apiParam, err := t.toAPIParameter(paramMeta, schemaVal)
if err != nil {
return nil, err
}
@ -241,7 +243,7 @@ func (t ToolInfo) ToReqAPIParameter() ([]*common.APIParameter, error) {
location: string(consts.ParamInBody),
required: required[subParamName],
}
apiParam, err := toAPIParameter(paramMeta, prop.Value)
apiParam, err := t.toAPIParameter(paramMeta, prop.Value)
if err != nil {
return nil, err
}
@ -255,7 +257,7 @@ func (t ToolInfo) ToReqAPIParameter() ([]*common.APIParameter, error) {
return params, nil
}
func toAPIParameter(paramMeta paramMetaInfo, sc *openapi3.Schema) (*common.APIParameter, error) {
func (t ToolInfo) toAPIParameter(paramMeta paramMetaInfo, sc *openapi3.Schema) (*common.APIParameter, error) {
if sc == nil {
return nil, fmt.Errorf("schema is required")
}
@ -281,7 +283,9 @@ func toAPIParameter(paramMeta paramMetaInfo, sc *openapi3.Schema) (*common.APIPa
if sc.Default != nil {
apiParam.GlobalDefault = ptr.Of(fmt.Sprintf("%v", sc.Default))
apiParam.LocalDefault = ptr.Of(fmt.Sprintf("%v", sc.Default))
if t.AgentID != nil {
apiParam.LocalDefault = ptr.Of(fmt.Sprintf("%v", sc.Default))
}
}
if sc.Format != "" {
@ -333,7 +337,7 @@ func toAPIParameter(paramMeta paramMetaInfo, sc *openapi3.Schema) (*common.APIPa
required: required[subParamName],
location: paramMeta.location,
}
subParam, err := toAPIParameter(subMeta, prop.Value)
subParam, err := t.toAPIParameter(subMeta, prop.Value)
if err != nil {
return nil, err
}
@ -356,7 +360,7 @@ func toAPIParameter(paramMeta paramMetaInfo, sc *openapi3.Schema) (*common.APIPa
location: paramMeta.location,
required: paramMeta.required,
}
subParam, err := toAPIParameter(subMeta, item)
subParam, err := t.toAPIParameter(subMeta, item)
if err != nil {
return nil, err
}

View File

@ -18,12 +18,14 @@ package singleagent
import (
"context"
"errors"
"sort"
"time"
"github.com/coze-dev/coze-studio/backend/api/model/app/developer_api"
crossconnector "github.com/coze-dev/coze-studio/backend/crossdomain/contract/connector"
"github.com/coze-dev/coze-studio/backend/domain/agent/singleagent/entity"
"github.com/coze-dev/coze-studio/backend/pkg/kvstore"
"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"
@ -44,7 +46,7 @@ func (s *singleAgentImpl) SavePublishRecord(ctx context.Context, p *entity.Singl
}
func (s *singleAgentImpl) GetPublishedTime(ctx context.Context, agentID int64) (int64, error) {
pubInfo, err := s.PublishInfoRepo.Get(ctx, consts.PublishInfoKeyPrefix, conv.Int64ToStr(agentID))
pubInfo, err := s.GetPublishedInfo(ctx, agentID)
if err != nil {
return 0, err
}
@ -54,7 +56,7 @@ func (s *singleAgentImpl) GetPublishedTime(ctx context.Context, agentID int64) (
func (s *singleAgentImpl) UpdatePublishInfo(ctx context.Context, agentID int64, connectorIDs []int64) error {
now := time.Now().UnixMilli()
pubInfo, err := s.PublishInfoRepo.Get(ctx, consts.PublishInfoKeyPrefix, conv.Int64ToStr(agentID))
pubInfo, err := s.GetPublishedInfo(ctx, agentID)
if err != nil {
return err
}
@ -83,7 +85,15 @@ func (s *singleAgentImpl) UpdatePublishInfo(ctx context.Context, agentID int64,
}
func (s *singleAgentImpl) GetPublishedInfo(ctx context.Context, agentID int64) (*entity.PublishInfo, error) {
return s.PublishInfoRepo.Get(ctx, consts.PublishInfoKeyPrefix, conv.Int64ToStr(agentID))
pubInfo, err := s.PublishInfoRepo.Get(ctx, consts.PublishInfoKeyPrefix, conv.Int64ToStr(agentID))
if err != nil {
if errors.Is(err, kvstore.ErrKeyNotFound) {
return &entity.PublishInfo{}, nil
}
return nil, err
}
return pubInfo, nil
}
func (s *singleAgentImpl) GetPublishConnectorList(ctx context.Context, agentID int64) (*entity.PublishConnectorData, error) {

View File

@ -57,6 +57,7 @@ func (a agentToolDraftPO) ToDO() *entity.ToolInfo {
SubURL: &a.SubURL,
Operation: a.Operation,
Source: ptr.Of(bot_common.PluginFrom(a.Source)),
AgentID: ptr.Of(a.AgentID),
}
}

View File

@ -57,6 +57,7 @@ func (a agentToolVersionPO) ToDO() *entity.ToolInfo {
SubURL: &a.SubURL,
Operation: a.Operation,
Source: ptr.Of(bot_common.PluginFrom(a.Source)),
AgentID: ptr.Of(a.AgentID),
}
}

View File

@ -26,21 +26,19 @@ const TableNamePlugin = "plugin"
// Plugin Latest Plugin
type Plugin struct {
ID int64 `gorm:"column:id;primaryKey;comment:Plugin ID" json:"id"` // Plugin ID
SpaceID int64 `gorm:"column:space_id;not null;comment:Space ID" json:"space_id"` // Space ID
DeveloperID int64 `gorm:"column:developer_id;not null;comment:Developer ID" json:"developer_id"` // Developer ID
AppID int64 `gorm:"column:app_id;not null;comment:Application ID" json:"app_id"` // Application ID
IconURI string `gorm:"column:icon_uri;not null;comment:Icon URI" json:"icon_uri"` // Icon URI
ServerURL string `gorm:"column:server_url;not null;comment:Server URL" json:"server_url"` // Server URL
PluginType int32 `gorm:"column:plugin_type;not null;comment:Plugin Type, 1:http, 6:local" json:"plugin_type"` // Plugin Type, 1:http, 6:local
CreatedAt int64 `gorm:"column:created_at;not null;autoCreateTime:milli;comment:Create Time in Milliseconds" json:"created_at"` // Create Time in Milliseconds
UpdatedAt int64 `gorm:"column:updated_at;not null;autoUpdateTime:milli;comment:Update Time in Milliseconds" json:"updated_at"` // Update Time in Milliseconds
Version string `gorm:"column:version;not null;comment:Plugin Version, e.g. v1.0.0" json:"version"` // Plugin Version, e.g. v1.0.0
VersionDesc string `gorm:"column:version_desc;comment:Plugin Version Description" json:"version_desc"` // Plugin Version Description
Manifest *model.PluginManifest `gorm:"column:manifest;comment:Plugin Manifest;serializer:json" json:"manifest"` // Plugin Manifest
OpenapiDoc *model.Openapi3T `gorm:"column:openapi_doc;comment:OpenAPI Document, only stores the root;serializer:json" json:"openapi_doc"` // OpenAPI Document, only stores the root
Source int32 `gorm:"column:source;not null;comment:plugin source 1 from saas 0 default" json:"source"` // plugin source 1 from saas 0 default
Ext map[string]interface{} `gorm:"column:ext;comment:extra ;serializer:json" json:"ext"` // extra
ID int64 `gorm:"column:id;primaryKey;comment:Plugin ID" json:"id"` // Plugin ID
SpaceID int64 `gorm:"column:space_id;not null;comment:Space ID" json:"space_id"` // Space ID
DeveloperID int64 `gorm:"column:developer_id;not null;comment:Developer ID" json:"developer_id"` // Developer ID
AppID int64 `gorm:"column:app_id;not null;comment:Application ID" json:"app_id"` // Application ID
IconURI string `gorm:"column:icon_uri;not null;comment:Icon URI" json:"icon_uri"` // Icon URI
ServerURL string `gorm:"column:server_url;not null;comment:Server URL" json:"server_url"` // Server URL
PluginType int32 `gorm:"column:plugin_type;not null;comment:Plugin Type, 1:http, 6:local" json:"plugin_type"` // Plugin Type, 1:http, 6:local
CreatedAt int64 `gorm:"column:created_at;not null;autoCreateTime:milli;comment:Create Time in Milliseconds" json:"created_at"` // Create Time in Milliseconds
UpdatedAt int64 `gorm:"column:updated_at;not null;autoUpdateTime:milli;comment:Update Time in Milliseconds" json:"updated_at"` // Update Time in Milliseconds
Version string `gorm:"column:version;not null;comment:Plugin Version, e.g. v1.0.0" json:"version"` // Plugin Version, e.g. v1.0.0
VersionDesc string `gorm:"column:version_desc;comment:Plugin Version Description" json:"version_desc"` // Plugin Version Description
Manifest *model.PluginManifest `gorm:"column:manifest;comment:Plugin Manifest;serializer:json" json:"manifest"` // Plugin Manifest
OpenapiDoc *model.Openapi3T `gorm:"column:openapi_doc;comment:OpenAPI Document, only stores the root;serializer:json" json:"openapi_doc"` // OpenAPI Document, only stores the root
}
// TableName Plugin's table name

View File

@ -29,22 +29,20 @@ const TableNamePluginVersion = "plugin_version"
// PluginVersion Plugin Version
type PluginVersion struct {
ID int64 `gorm:"column:id;primaryKey;comment:Primary Key ID" json:"id"` // Primary Key ID
SpaceID int64 `gorm:"column:space_id;not null;comment:Space ID" json:"space_id"` // Space ID
DeveloperID int64 `gorm:"column:developer_id;not null;comment:Developer ID" json:"developer_id"` // Developer ID
PluginID int64 `gorm:"column:plugin_id;not null;comment:Plugin ID" json:"plugin_id"` // Plugin ID
AppID int64 `gorm:"column:app_id;not null;comment:Application ID" json:"app_id"` // Application ID
IconURI string `gorm:"column:icon_uri;not null;comment:Icon URI" json:"icon_uri"` // Icon URI
ServerURL string `gorm:"column:server_url;not null;comment:Server URL" json:"server_url"` // Server URL
PluginType int32 `gorm:"column:plugin_type;not null;comment:Plugin Type, 1:http, 6:local" json:"plugin_type"` // Plugin Type, 1:http, 6:local
Version string `gorm:"column:version;not null;comment:Plugin Version, e.g. v1.0.0" json:"version"` // Plugin Version, e.g. v1.0.0
VersionDesc string `gorm:"column:version_desc;comment:Plugin Version Description" json:"version_desc"` // Plugin Version Description
Manifest *model.PluginManifest `gorm:"column:manifest;comment:Plugin Manifest;serializer:json" json:"manifest"` // Plugin Manifest
OpenapiDoc *model.Openapi3T `gorm:"column:openapi_doc;comment:OpenAPI Document, only stores the root;serializer:json" json:"openapi_doc"` // OpenAPI Document, only stores the root
Source int32 `gorm:"column:source;not null;comment:plugin source 1 from saas 0 default" json:"source"` // plugin source 1 from saas 0 default
Ext map[string]interface{} `gorm:"column:ext;comment:extra ;serializer:json" json:"ext"` // extra
CreatedAt int64 `gorm:"column:created_at;not null;autoCreateTime:milli;comment:Create Time in Milliseconds" json:"created_at"` // Create Time in Milliseconds
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:Delete Time" json:"deleted_at"` // Delete Time
ID int64 `gorm:"column:id;primaryKey;comment:Primary Key ID" json:"id"` // Primary Key ID
SpaceID int64 `gorm:"column:space_id;not null;comment:Space ID" json:"space_id"` // Space ID
DeveloperID int64 `gorm:"column:developer_id;not null;comment:Developer ID" json:"developer_id"` // Developer ID
PluginID int64 `gorm:"column:plugin_id;not null;comment:Plugin ID" json:"plugin_id"` // Plugin ID
AppID int64 `gorm:"column:app_id;not null;comment:Application ID" json:"app_id"` // Application ID
IconURI string `gorm:"column:icon_uri;not null;comment:Icon URI" json:"icon_uri"` // Icon URI
ServerURL string `gorm:"column:server_url;not null;comment:Server URL" json:"server_url"` // Server URL
PluginType int32 `gorm:"column:plugin_type;not null;comment:Plugin Type, 1:http, 6:local" json:"plugin_type"` // Plugin Type, 1:http, 6:local
Version string `gorm:"column:version;not null;comment:Plugin Version, e.g. v1.0.0" json:"version"` // Plugin Version, e.g. v1.0.0
VersionDesc string `gorm:"column:version_desc;comment:Plugin Version Description" json:"version_desc"` // Plugin Version Description
Manifest *model.PluginManifest `gorm:"column:manifest;comment:Plugin Manifest;serializer:json" json:"manifest"` // Plugin Manifest
OpenapiDoc *model.Openapi3T `gorm:"column:openapi_doc;comment:OpenAPI Document, only stores the root;serializer:json" json:"openapi_doc"` // OpenAPI Document, only stores the root
CreatedAt int64 `gorm:"column:created_at;not null;autoCreateTime:milli;comment:Create Time in Milliseconds" json:"created_at"` // Create Time in Milliseconds
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:Delete Time" json:"deleted_at"` // Delete Time
}
// TableName PluginVersion's table name

View File

@ -35,8 +35,6 @@ type Tool struct {
Method string `gorm:"column:method;not null;comment:HTTP Request Method" json:"method"` // HTTP Request Method
Operation *model.Openapi3Operation `gorm:"column:operation;comment:Tool Openapi Operation Schema;serializer:json" json:"operation"` // Tool Openapi Operation Schema
ActivatedStatus int32 `gorm:"column:activated_status;not null;comment:0:activated; 1:deactivated" json:"activated_status"` // 0:activated; 1:deactivated
Source int32 `gorm:"column:source;not null;comment:tool source 1 coze saas 0 default" json:"source"` // tool source 1 coze saas 0 default
Ext map[string]interface{} `gorm:"column:ext;comment:extra;serializer:json" json:"ext"` // extra
}
// TableName Tool's table name

View File

@ -38,8 +38,6 @@ type ToolVersion struct {
Operation *model.Openapi3Operation `gorm:"column:operation;comment:Tool Openapi Operation Schema;serializer:json" json:"operation"` // Tool Openapi Operation Schema
CreatedAt int64 `gorm:"column:created_at;not null;autoCreateTime:milli;comment:Create Time in Milliseconds" json:"created_at"` // Create Time in Milliseconds
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:Delete Time" json:"deleted_at"` // Delete Time
Source int32 `gorm:"column:source;not null;comment:tool source 1 coze saas 0 default" json:"source"` // tool source 1 coze saas 0 default
Ext map[string]interface{} `gorm:"column:ext;comment:extra;serializer:json" json:"ext"` // extra
}
// TableName ToolVersion's table name

View File

@ -25,7 +25,6 @@ import (
"gorm.io/gen/field"
"gorm.io/gorm"
"github.com/coze-dev/coze-studio/backend/api/model/app/bot_common"
plugin_develop_common "github.com/coze-dev/coze-studio/backend/api/model/plugin_develop/common"
pluginModel "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/model"
"github.com/coze-dev/coze-studio/backend/domain/plugin/dto"
@ -64,8 +63,6 @@ func (p pluginPO) ToDO() *entity.PluginInfo {
VersionDesc: &p.VersionDesc,
Manifest: p.Manifest,
OpenapiDoc: p.OpenapiDoc,
Source: bot_common.PluginFromPtr(bot_common.PluginFrom(p.Source)),
Extra: p.Ext,
})
}

View File

@ -24,7 +24,6 @@ import (
"gorm.io/gen/field"
"gorm.io/gorm"
"github.com/coze-dev/coze-studio/backend/api/model/app/bot_common"
plugin_develop_common "github.com/coze-dev/coze-studio/backend/api/model/plugin_develop/common"
pluginModel "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/model"
"github.com/coze-dev/coze-studio/backend/domain/plugin/dto"
@ -63,8 +62,6 @@ func (p pluginVersionPO) ToDO() *entity.PluginInfo {
VersionDesc: &p.VersionDesc,
Manifest: p.Manifest,
OpenapiDoc: p.OpenapiDoc,
Source: bot_common.PluginFromPtr(bot_common.PluginFrom(p.Source)),
Extra: p.Ext,
})
}

View File

@ -56,8 +56,6 @@ func newPlugin(db *gorm.DB, opts ...gen.DOOption) plugin {
_plugin.VersionDesc = field.NewString(tableName, "version_desc")
_plugin.Manifest = field.NewField(tableName, "manifest")
_plugin.OpenapiDoc = field.NewField(tableName, "openapi_doc")
_plugin.Source = field.NewInt32(tableName, "source")
_plugin.Ext = field.NewField(tableName, "ext")
_plugin.fillFieldMap()
@ -82,8 +80,6 @@ type plugin struct {
VersionDesc field.String // Plugin Version Description
Manifest field.Field // Plugin Manifest
OpenapiDoc field.Field // OpenAPI Document, only stores the root
Source field.Int32 // plugin source 1 from saas 0 default
Ext field.Field // extra
fieldMap map[string]field.Expr
}
@ -113,8 +109,6 @@ func (p *plugin) updateTableName(table string) *plugin {
p.VersionDesc = field.NewString(table, "version_desc")
p.Manifest = field.NewField(table, "manifest")
p.OpenapiDoc = field.NewField(table, "openapi_doc")
p.Source = field.NewInt32(table, "source")
p.Ext = field.NewField(table, "ext")
p.fillFieldMap()
@ -131,7 +125,7 @@ func (p *plugin) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
}
func (p *plugin) fillFieldMap() {
p.fieldMap = make(map[string]field.Expr, 15)
p.fieldMap = make(map[string]field.Expr, 13)
p.fieldMap["id"] = p.ID
p.fieldMap["space_id"] = p.SpaceID
p.fieldMap["developer_id"] = p.DeveloperID
@ -145,8 +139,6 @@ func (p *plugin) fillFieldMap() {
p.fieldMap["version_desc"] = p.VersionDesc
p.fieldMap["manifest"] = p.Manifest
p.fieldMap["openapi_doc"] = p.OpenapiDoc
p.fieldMap["source"] = p.Source
p.fieldMap["ext"] = p.Ext
}
func (p plugin) clone(db *gorm.DB) plugin {

View File

@ -55,8 +55,6 @@ func newPluginVersion(db *gorm.DB, opts ...gen.DOOption) pluginVersion {
_pluginVersion.VersionDesc = field.NewString(tableName, "version_desc")
_pluginVersion.Manifest = field.NewField(tableName, "manifest")
_pluginVersion.OpenapiDoc = field.NewField(tableName, "openapi_doc")
_pluginVersion.Source = field.NewInt32(tableName, "source")
_pluginVersion.Ext = field.NewField(tableName, "ext")
_pluginVersion.CreatedAt = field.NewInt64(tableName, "created_at")
_pluginVersion.DeletedAt = field.NewField(tableName, "deleted_at")
@ -82,8 +80,6 @@ type pluginVersion struct {
VersionDesc field.String // Plugin Version Description
Manifest field.Field // Plugin Manifest
OpenapiDoc field.Field // OpenAPI Document, only stores the root
Source field.Int32 // plugin source 1 from saas 0 default
Ext field.Field // extra
CreatedAt field.Int64 // Create Time in Milliseconds
DeletedAt field.Field // Delete Time
@ -114,8 +110,6 @@ func (p *pluginVersion) updateTableName(table string) *pluginVersion {
p.VersionDesc = field.NewString(table, "version_desc")
p.Manifest = field.NewField(table, "manifest")
p.OpenapiDoc = field.NewField(table, "openapi_doc")
p.Source = field.NewInt32(table, "source")
p.Ext = field.NewField(table, "ext")
p.CreatedAt = field.NewInt64(table, "created_at")
p.DeletedAt = field.NewField(table, "deleted_at")
@ -134,7 +128,7 @@ func (p *pluginVersion) GetFieldByName(fieldName string) (field.OrderExpr, bool)
}
func (p *pluginVersion) fillFieldMap() {
p.fieldMap = make(map[string]field.Expr, 16)
p.fieldMap = make(map[string]field.Expr, 14)
p.fieldMap["id"] = p.ID
p.fieldMap["space_id"] = p.SpaceID
p.fieldMap["developer_id"] = p.DeveloperID
@ -147,8 +141,6 @@ func (p *pluginVersion) fillFieldMap() {
p.fieldMap["version_desc"] = p.VersionDesc
p.fieldMap["manifest"] = p.Manifest
p.fieldMap["openapi_doc"] = p.OpenapiDoc
p.fieldMap["source"] = p.Source
p.fieldMap["ext"] = p.Ext
p.fieldMap["created_at"] = p.CreatedAt
p.fieldMap["deleted_at"] = p.DeletedAt
}

View File

@ -52,8 +52,6 @@ func newTool(db *gorm.DB, opts ...gen.DOOption) tool {
_tool.Method = field.NewString(tableName, "method")
_tool.Operation = field.NewField(tableName, "operation")
_tool.ActivatedStatus = field.NewInt32(tableName, "activated_status")
_tool.Source = field.NewInt32(tableName, "source")
_tool.Ext = field.NewField(tableName, "ext")
_tool.fillFieldMap()
@ -74,8 +72,6 @@ type tool struct {
Method field.String // HTTP Request Method
Operation field.Field // Tool Openapi Operation Schema
ActivatedStatus field.Int32 // 0:activated; 1:deactivated
Source field.Int32 // tool source 1 coze saas 0 default
Ext field.Field // extra
fieldMap map[string]field.Expr
}
@ -101,8 +97,6 @@ func (t *tool) updateTableName(table string) *tool {
t.Method = field.NewString(table, "method")
t.Operation = field.NewField(table, "operation")
t.ActivatedStatus = field.NewInt32(table, "activated_status")
t.Source = field.NewInt32(table, "source")
t.Ext = field.NewField(table, "ext")
t.fillFieldMap()
@ -119,7 +113,7 @@ func (t *tool) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
}
func (t *tool) fillFieldMap() {
t.fieldMap = make(map[string]field.Expr, 11)
t.fieldMap = make(map[string]field.Expr, 9)
t.fieldMap["id"] = t.ID
t.fieldMap["plugin_id"] = t.PluginID
t.fieldMap["created_at"] = t.CreatedAt
@ -129,8 +123,6 @@ func (t *tool) fillFieldMap() {
t.fieldMap["method"] = t.Method
t.fieldMap["operation"] = t.Operation
t.fieldMap["activated_status"] = t.ActivatedStatus
t.fieldMap["source"] = t.Source
t.fieldMap["ext"] = t.Ext
}
func (t tool) clone(db *gorm.DB) tool {

View File

@ -52,8 +52,6 @@ func newToolVersion(db *gorm.DB, opts ...gen.DOOption) toolVersion {
_toolVersion.Operation = field.NewField(tableName, "operation")
_toolVersion.CreatedAt = field.NewInt64(tableName, "created_at")
_toolVersion.DeletedAt = field.NewField(tableName, "deleted_at")
_toolVersion.Source = field.NewInt32(tableName, "source")
_toolVersion.Ext = field.NewField(tableName, "ext")
_toolVersion.fillFieldMap()
@ -74,8 +72,6 @@ type toolVersion struct {
Operation field.Field // Tool Openapi Operation Schema
CreatedAt field.Int64 // Create Time in Milliseconds
DeletedAt field.Field // Delete Time
Source field.Int32 // tool source 1 coze saas 0 default
Ext field.Field // extra
fieldMap map[string]field.Expr
}
@ -101,8 +97,6 @@ func (t *toolVersion) updateTableName(table string) *toolVersion {
t.Operation = field.NewField(table, "operation")
t.CreatedAt = field.NewInt64(table, "created_at")
t.DeletedAt = field.NewField(table, "deleted_at")
t.Source = field.NewInt32(table, "source")
t.Ext = field.NewField(table, "ext")
t.fillFieldMap()
@ -119,7 +113,7 @@ func (t *toolVersion) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
}
func (t *toolVersion) fillFieldMap() {
t.fieldMap = make(map[string]field.Expr, 11)
t.fieldMap = make(map[string]field.Expr, 9)
t.fieldMap["id"] = t.ID
t.fieldMap["tool_id"] = t.ToolID
t.fieldMap["plugin_id"] = t.PluginID
@ -129,8 +123,6 @@ func (t *toolVersion) fillFieldMap() {
t.fieldMap["operation"] = t.Operation
t.fieldMap["created_at"] = t.CreatedAt
t.fieldMap["deleted_at"] = t.DeletedAt
t.fieldMap["source"] = t.Source
t.fieldMap["ext"] = t.Ext
}
func (t toolVersion) clone(db *gorm.DB) toolVersion {

View File

@ -24,7 +24,6 @@ import (
"gorm.io/gen/field"
"gorm.io/gorm"
"github.com/coze-dev/coze-studio/backend/api/model/app/bot_common"
"github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/consts"
"github.com/coze-dev/coze-studio/backend/domain/plugin/entity"
"github.com/coze-dev/coze-studio/backend/domain/plugin/internal/dal/model"
@ -59,9 +58,6 @@ func (t toolPO) ToDO() *entity.ToolInfo {
Method: ptr.Of(t.Method),
Operation: t.Operation,
ActivatedStatus: ptr.Of(consts.ActivatedStatus(t.ActivatedStatus)),
Source: bot_common.PluginFromPtr(bot_common.PluginFrom(t.Source)),
Extra: t.Ext,
}
}

View File

@ -22,7 +22,6 @@ import (
"gorm.io/gorm"
"github.com/coze-dev/coze-studio/backend/api/model/app/bot_common"
pluginModel "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/model"
"github.com/coze-dev/coze-studio/backend/domain/plugin/entity"
"github.com/coze-dev/coze-studio/backend/domain/plugin/internal/dal/model"
@ -55,9 +54,6 @@ func (t toolVersionPO) ToDO() *entity.ToolInfo {
SubURL: &t.SubURL,
Method: ptr.Of(t.Method),
Operation: t.Operation,
Source: bot_common.PluginFromPtr(bot_common.PluginFrom(t.Source)),
Extra: t.Ext,
}
}

View File

@ -51,6 +51,8 @@ func (s *saasCallImpl) Do(ctx context.Context, args *InvocationArgs) (request st
return "", "", err
}
s.injectUserAgentHeader(ctx, httpReq)
var reqBodyBytes []byte
if httpReq.GetBody != nil {
reqBody, err := httpReq.GetBody()
@ -118,6 +120,9 @@ func (s *saasCallImpl) injectAuthInfo(ctx context.Context, httpReq *http.Request
httpReq.Header.Set("Authorization", "Bearer "+saasapiClient.APIKey)
return nil
}
func (s *saasCallImpl) injectUserAgentHeader(ctx context.Context, httpReq *http.Request) {
httpReq.Header.Set("User-Agent", "open_coze/1.0.0")
}
func (s *saasCallImpl) buildHTTPRequest(ctx context.Context, args *InvocationArgs) (httpReq *http.Request, err error) {
tool := args.Tool

View File

@ -23,6 +23,7 @@ import (
"mime"
"net/http"
"path/filepath"
"strings"
)
type FileData struct {
@ -49,12 +50,36 @@ func URLToBase64(url string) (*FileData, error) {
var mimeType string
mimeType = resp.Header.Get("Content-Type")
contentType := resp.Header.Get("Content-Type")
if contentType != "" {
mediaType, _, err := mime.ParseMediaType(contentType)
if err == nil && mediaType != "" {
mimeType = mediaType
}
}
if mimeType == "" {
ext := filepath.Ext(url)
detectedType := http.DetectContentType(fileContent)
if detectedType != "application/octet-stream" {
mimeType = detectedType
}
}
if mimeType == "" || mimeType == "application/octet-stream" {
urlPath := url
if idx := strings.Index(urlPath, "?"); idx != -1 {
urlPath = urlPath[:idx]
}
if idx := strings.Index(urlPath, "#"); idx != -1 {
urlPath = urlPath[:idx]
}
ext := filepath.Ext(urlPath)
if ext != "" {
mimeType = mime.TypeByExtension(ext)
extMimeType := mime.TypeByExtension(ext)
if extMimeType != "" {
mimeType = extMimeType
}
}
}

View File

@ -18,7 +18,7 @@ server {
}
# API proxy
location ~ ^/(api|v[1-3]|admin)/ {
location ~ ^/(api|v[1-3]|admin)(/|$) {
proxy_pass http://coze-server:8888;
proxy_set_header Host $http_host;