diff --git a/internal/logic/admin/model.go b/internal/logic/admin/model.go index 46919fd..78c0438 100644 --- a/internal/logic/admin/model.go +++ b/internal/logic/admin/model.go @@ -90,7 +90,7 @@ func (s *sAdmin) ListModels(ctx context.Context, req *v1.ModelListReq) (*v1.Mode MaxOutputTokens int `json:"max_output_tokens"` Capabilities string `json:"capabilities"` Description string `json:"description"` - Tags string `json:"tags"` + Tags []string `json:"tags"` CreatedAt *gtime.Time `json:"created_at"` UpdatedAt *gtime.Time `json:"updated_at"` DeprecatedAt *gtime.Time `json:"deprecated_at"` @@ -145,7 +145,7 @@ func (s *sAdmin) ListModels(ctx context.Context, req *v1.ModelListReq) (*v1.Mode MaxOutput: m.MaxOutputTokens, Capabilities: parseCapabilities(m.Capabilities), Description: m.Description, - Tags: parseTagsArray(m.Tags), + Tags: m.Tags, CreatedAt: m.CreatedAt.String(), UpdatedAt: m.UpdatedAt.String(), } @@ -362,10 +362,6 @@ func (s *sAdmin) DeleteModel(ctx context.Context, req *v1.ModelDeleteReq) (*v1.M return nil, nil } -func parseTagsArray(tags string) []string { - return parsePgArray(tags) -} - func parseCapabilities(raw string) map[string]bool { if raw == "" || raw == "{}" { return nil diff --git a/internal/logic/admin/model_import_export.go b/internal/logic/admin/model_import_export.go index ad5dc90..452d74a 100644 --- a/internal/logic/admin/model_import_export.go +++ b/internal/logic/admin/model_import_export.go @@ -6,7 +6,6 @@ import ( "encoding/json" "io" "net/url" - "strings" "github.com/gogf/gf/v2/database/gdb" "github.com/gogf/gf/v2/errors/gcode" @@ -32,7 +31,7 @@ func (s *sAdmin) ExportModelsJson(ctx context.Context, req *v1.ModelExportJsonRe MaxContextTokens int `orm:"max_context_tokens" json:"max_context_tokens"` MaxOutputTokens int `orm:"max_output_tokens" json:"max_output_tokens"` Description string `orm:"description" json:"description"` - Tags string `orm:"tags" json:"tags"` + Tags []string `orm:"tags" json:"tags"` Capabilities string `orm:"capabilities" json:"capabilities"` SunsetDate *gtime.Time `orm:"sunset_date" json:"sunset_date"` ReplacementModel string `orm:"replacement_model" json:"replacement_model"` @@ -120,9 +119,7 @@ func (s *sAdmin) ExportModelsJson(ctx context.Context, req *v1.ModelExportJsonRe if m.SunsetDate != nil { em.SunsetDate = m.SunsetDate.Format("Y-m-d") } - if m.Tags != "" { - em.Tags = parsePgArray(m.Tags) - } + em.Tags = m.Tags result = append(result, em) } @@ -334,15 +331,3 @@ func (s *sAdmin) ImportModels(ctx context.Context, req *v1.ModelImportReq) (*v1. return res, err } - -// parsePgArray 解析 PostgreSQL 数组格式的字符串,如 {tag1,tag2} -func parsePgArray(raw string) []string { - if raw == "" || raw == "{}" || raw == "NULL" { - return nil - } - s := strings.Trim(raw, "{}") - if s == "" { - return nil - } - return strings.Split(s, ",") -} diff --git a/relay/channel/deepseek/adaptor.go b/relay/channel/deepseek/adaptor.go index cc45e31..c6a4cd8 100644 --- a/relay/channel/deepseek/adaptor.go +++ b/relay/channel/deepseek/adaptor.go @@ -108,9 +108,13 @@ func injectStreamOptions(rawMap map[string]json.RawMessage, info *common.RelayIn // injectThinkingParams 根据 RelayInfo 中的思考后缀注入 DeepSeek 思考模式参数。 // -// DeepSeek 思考模式参数说明: -// - thinking.type: "enabled"(默认) / "disabled" -// - reasoning_effort: "high"(默认) / "max",兼容映射:low/medium→high, xhigh→max +// DeepSeek 两类模型的参数差异: +// - V3 思考版(deepseek-chat):通过 thinking.type: "enabled"/"disabled" 控制;启用时需要 budget_tokens +// - R1 系列(deepseek-reasoner):不识别 thinking 参数,通过 reasoning_effort: "none"/"low"/"high"/"max" 控制 +// +// 关闭思考时同时注入两个参数,兼容两类模型: +// - thinking.type: "disabled"(V3 识别) +// - reasoning_effort: "none"(R1 识别) // // 注入优先级:客户端已显式设置 > 后缀路由注入 > 不干预(保留 DeepSeek 默认行为) func injectThinkingParams(rawMap map[string]json.RawMessage, info *common.RelayInfo) map[string]json.RawMessage { @@ -120,16 +124,18 @@ func injectThinkingParams(rawMap map[string]json.RawMessage, info *common.RelayI } // -nothinking 后缀:显式关闭思考 + // V3 模型:thinking.type: "disabled" 生效 + // R1 模型:thinking 参数被忽略,需 reasoning_effort: "none" 才能关闭思考 if info.ThinkingDisabled { rawMap["thinking"] = json.RawMessage(`{"type":"disabled"}`) - // 关闭思考时清理 reasoning_effort - delete(rawMap, "reasoning_effort") + rawMap["reasoning_effort"] = json.RawMessage(`"none"`) return rawMap } // -thinking 后缀:显式开启思考 + 可选 effort + // budget_tokens 为 V3 思考版必需字段,R1 模型忽略此参数 if info.ThinkingEnabled { - rawMap["thinking"] = json.RawMessage(`{"type":"enabled"}`) + rawMap["thinking"] = json.RawMessage(`{"type":"enabled","budget_tokens":16000}`) rawMap = injectReasoningEffort(rawMap, info) return rawMap }