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

@@ -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)