Refactor model type to model class (#14426)

### What problem does this PR solve?

As title

### Type of change

- [x] Refactoring

Signed-off-by: Jin Hai <haijin.chn@gmail.com>
This commit is contained in:
Jin Hai
2026-04-28 16:05:15 +08:00
committed by GitHub
parent 7c25870923
commit f670913bb4
14 changed files with 18 additions and 20 deletions

View File

@@ -10,7 +10,6 @@
"embedding": "compatible-mode/v1/embeddings",
"models": "api/v1/deployments/models"
},
"series": "deepseek",
"models": [
{
"name": "qwen-flash",

View File

@@ -7,7 +7,7 @@
"chat": "chat/completions",
"models": "models"
},
"series": "deepseek",
"class": "deepseek",
"models": [
{
"name": "deepseek-v4-flash",

View File

@@ -6,7 +6,7 @@
"url_suffix": {
"models": "v1beta/models"
},
"series": "gemini",
"class": "gemini",
"models": [
{
"name": "gemini-2.5-flash",

View File

@@ -9,7 +9,7 @@
"tts": "v1/t2a_v2",
"files": "v1/files/list"
},
"series": "minimax",
"class": "minimax",
"models": [
{
"name": "minimax-m2.7",

View File

@@ -8,7 +8,7 @@
"models": "models",
"balance": "users/me/balance"
},
"series": "kimi",
"class": "kimi",
"models": [
{
"name": "kimi-k2.6",

View File

@@ -6,7 +6,7 @@
"url_suffix": {
"chat": "chat/completions"
},
"series": "gpt",
"class": "gpt",
"models": [
{
"name": "gpt-5.2-pro",

View File

@@ -7,7 +7,7 @@
"chat": "chat/completions",
"files": "files"
},
"series": "volcengine",
"class": "volcengine",
"models": [
{
"name": "doubao-seed-2-0-pro-260215",

View File

@@ -6,7 +6,7 @@
"url_suffix": {
"chat": "chat/completions"
},
"series": "grok",
"class": "grok",
"models": [
{
"name": "grok-4",

View File

@@ -11,7 +11,7 @@
"rerank": "rerank",
"files": "files"
},
"series": "glm",
"class": "glm",
"models": [
{
"name": "glm-5",

View File

@@ -159,7 +159,7 @@ type Model struct {
MaxTokens int `json:"max_tokens"`
ModelTypes []string `json:"model_types"`
Thinking *ModelThinking `json:"thinking"`
Type *string `json:"type"`
Class *string `json:"class"`
ModelTypeMap map[string]bool
}
@@ -170,7 +170,7 @@ type Provider struct {
URLSuffix models.URLSuffix `json:"url_suffix"`
Models []*Model `json:"models"`
Features Features `json:"features"`
Type string `json:"type"`
Class string `json:"class"`
ModelDriver models.ModelDriver
}
@@ -228,12 +228,12 @@ func NewProviderManager(dirPath string) (*ProviderManager, error) {
for _, model := range provider.Models {
// if the prefix of mode.Name is matched with keys of modelSupportThinking
if provider.Type == "" {
if provider.Class == "" {
pos := strings.Index(model.Name, "-")
modelType := model.Name[0:pos]
model.Type = &modelType
modelClass := model.Name[0:pos]
model.Class = &modelClass
} else {
model.Type = &provider.Name
model.Class = &provider.Name
}
model.ModelTypeMap = make(map[string]bool)

View File

@@ -172,7 +172,7 @@ func (z *GiteeModel) Chat(modelName, message *string, apiConfig *APIConfig, chat
return nil, fmt.Errorf("invalid content format")
}
thinking, answer := GetThinkingAndAnswer(chatModelConfig.ModelType, &content)
thinking, answer := GetThinkingAndAnswer(chatModelConfig.ModelClass, &content)
chatResponse := &ChatResponse{
Answer: answer,

View File

@@ -56,7 +56,6 @@ func (z *SiliconflowModel) Name() string {
return "siliconflow"
}
// SiliconflowRerankRequest represents SILICONFLOW rerank request
type SiliconflowRerankRequest struct {
Model string `json:"model"`
@@ -192,7 +191,7 @@ func (z *SiliconflowModel) Chat(modelName, message *string, apiConfig *APIConfig
return nil, fmt.Errorf("invalid content format")
}
thinking, answer := GetThinkingAndAnswer(chatModelConfig.ModelType, &content)
thinking, answer := GetThinkingAndAnswer(chatModelConfig.ModelClass, &content)
chatResponse := &ChatResponse{
Answer: answer,

View File

@@ -60,7 +60,7 @@ type ChatConfig struct {
TopP *float64
DoSample *bool
Stop *[]string
ModelType *string
ModelClass *string
Effort *string
Verbosity *string
}

View File

@@ -643,7 +643,7 @@ func (m *ModelProviderService) ChatToModel(providerName, instanceName, modelName
return nil, common.CodeNotFound, errors.New(fmt.Sprintf("provider %s model %s not found", providerName, modelName))
}
modelConfig.ModelType = model.Type
modelConfig.ModelClass = model.Class
var extra map[string]string
err = json.Unmarshal([]byte(instance.Extra), &extra)