Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 96 additions & 0 deletions backend/api/model/admin/config/config.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions backend/api/model/app/developer_api/developer_api.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions backend/bizpkg/config/modelmgr/builtin_conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ func getKnowledgeBuiltinModelClass() developer_api.ModelClass {
return developer_api.ModelClass_QWen
case "gemini":
return developer_api.ModelClass_Gemini
case "avian":
return developer_api.ModelClass_Avian
default:
return developer_api.ModelClass_SEED
}
Expand Down
12 changes: 12 additions & 0 deletions backend/bizpkg/config/modelmgr/mode_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,18 @@ func getModelProviderList() []*config.ModelProvider {
},
ModelClass: developer_api.ModelClass_QWen,
},
{
Name: &config.I18nText{
ZhCn: "Avian 模型",
EnUs: "Avian Model",
},
IconURI: "default_icon/avian.png",
Description: &config.I18nText{
ZhCn: "Avian 模型家族",
EnUs: "avian model family",
},
ModelClass: developer_api.ModelClass_Avian,
},
}
}

Expand Down
1 change: 1 addition & 0 deletions backend/bizpkg/config/modelmgr/model_save.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ func (c *ModelConfig) createModel(ctx context.Context, id *int64, modelClass dev
conn.Qwen = modelMeta.Connection.Qwen
conn.Ollama = modelMeta.Connection.Ollama
conn.Claude = modelMeta.Connection.Claude
conn.Avian = modelMeta.Connection.Avian
}

extraStr := "{}"
Expand Down
100 changes: 100 additions & 0 deletions backend/bizpkg/llm/modelbuilder/avian.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
/*
* 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 modelbuilder

import (
"context"

"github.com/cloudwego/eino-ext/components/model/openai"

"github.com/coze-dev/coze-studio/backend/api/model/admin/config"
"github.com/coze-dev/coze-studio/backend/api/model/app/bot_common"
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
)

const avianDefaultBaseURL = "https://api.avian.io/v1"

type avianModelBuilder struct {
cfg *config.Model
}

func newAvianModelBuilder(cfg *config.Model) Service {
return &avianModelBuilder{
cfg: cfg,
}
}

func (a *avianModelBuilder) getDefaultConfig() *openai.ChatModelConfig {
return &openai.ChatModelConfig{
BaseURL: avianDefaultBaseURL,
MaxCompletionTokens: ptr.Of(4096),
ResponseFormat: &openai.ChatCompletionResponseFormat{
Type: "text",
JSONSchema: nil,
},
}
}

func (a *avianModelBuilder) applyParamsToConfig(conf *openai.ChatModelConfig, params *LLMParams) {
if params == nil {
return
}

if params.Temperature != nil {
conf.Temperature = ptr.Of(*params.Temperature)
}

if params.MaxTokens != 0 {
conf.MaxCompletionTokens = ptr.Of(params.MaxTokens)
}

if params.FrequencyPenalty != 0 {
conf.FrequencyPenalty = ptr.Of(params.FrequencyPenalty)
}

if params.PresencePenalty != 0 {
conf.PresencePenalty = ptr.Of(params.PresencePenalty)
}

conf.TopP = params.TopP

if params.ResponseFormat == bot_common.ModelResponseFormat_JSON {
conf.ResponseFormat = &openai.ChatCompletionResponseFormat{
Type: openai.ChatCompletionResponseFormatTypeJSONObject,
}
} else {
conf.ResponseFormat = &openai.ChatCompletionResponseFormat{
Type: openai.ChatCompletionResponseFormatTypeText,
}
}
}

func (a *avianModelBuilder) Build(ctx context.Context, params *LLMParams) (ToolCallingChatModel, error) {
base := a.cfg.Connection.BaseConnInfo

conf := a.getDefaultConfig()
conf.APIKey = base.APIKey
conf.Model = base.Model

if base.BaseURL != "" {
conf.BaseURL = base.BaseURL
}

a.applyParamsToConfig(conf, params)

return openai.NewChatModel(ctx, conf)
}
1 change: 1 addition & 0 deletions backend/bizpkg/llm/modelbuilder/model_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ var modelClass2NewModelBuilder = map[developer_api.ModelClass]func(*config.Model
developer_api.ModelClass_Gemini: newGeminiModelBuilder,
developer_api.ModelClass_Llama: newOllamaModelBuilder,
developer_api.ModelClass_QWen: newQwenModelBuilder,
developer_api.ModelClass_Avian: newAvianModelBuilder,
}

func NewModelBuilder(modelClass developer_api.ModelClass, cfg *config.Model) (Service, error) {
Expand Down
Loading