mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-06-29 23:41:12 +08:00
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:
@@ -10,7 +10,6 @@
|
||||
"embedding": "compatible-mode/v1/embeddings",
|
||||
"models": "api/v1/deployments/models"
|
||||
},
|
||||
"series": "deepseek",
|
||||
"models": [
|
||||
{
|
||||
"name": "qwen-flash",
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
"chat": "chat/completions",
|
||||
"models": "models"
|
||||
},
|
||||
"series": "deepseek",
|
||||
"class": "deepseek",
|
||||
"models": [
|
||||
{
|
||||
"name": "deepseek-v4-flash",
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
"url_suffix": {
|
||||
"models": "v1beta/models"
|
||||
},
|
||||
"series": "gemini",
|
||||
"class": "gemini",
|
||||
"models": [
|
||||
{
|
||||
"name": "gemini-2.5-flash",
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
"tts": "v1/t2a_v2",
|
||||
"files": "v1/files/list"
|
||||
},
|
||||
"series": "minimax",
|
||||
"class": "minimax",
|
||||
"models": [
|
||||
{
|
||||
"name": "minimax-m2.7",
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
"models": "models",
|
||||
"balance": "users/me/balance"
|
||||
},
|
||||
"series": "kimi",
|
||||
"class": "kimi",
|
||||
"models": [
|
||||
{
|
||||
"name": "kimi-k2.6",
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
"url_suffix": {
|
||||
"chat": "chat/completions"
|
||||
},
|
||||
"series": "gpt",
|
||||
"class": "gpt",
|
||||
"models": [
|
||||
{
|
||||
"name": "gpt-5.2-pro",
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
"chat": "chat/completions",
|
||||
"files": "files"
|
||||
},
|
||||
"series": "volcengine",
|
||||
"class": "volcengine",
|
||||
"models": [
|
||||
{
|
||||
"name": "doubao-seed-2-0-pro-260215",
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
"url_suffix": {
|
||||
"chat": "chat/completions"
|
||||
},
|
||||
"series": "grok",
|
||||
"class": "grok",
|
||||
"models": [
|
||||
{
|
||||
"name": "grok-4",
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
"rerank": "rerank",
|
||||
"files": "files"
|
||||
},
|
||||
"series": "glm",
|
||||
"class": "glm",
|
||||
"models": [
|
||||
{
|
||||
"name": "glm-5",
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -60,7 +60,7 @@ type ChatConfig struct {
|
||||
TopP *float64
|
||||
DoSample *bool
|
||||
Stop *[]string
|
||||
ModelType *string
|
||||
ModelClass *string
|
||||
Effort *string
|
||||
Verbosity *string
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user