mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-06-29 23:41:12 +08:00
fix: unable to chat after set model (#16195)
### What problem does this PR solve? ``` fixed: RAGFlow(api/default)> use model 'minimax-m2.5@test@minimax' SUCCESS RAGFlow(api/default)> chat message 'who r u' Answer: Hey! I'm MiniMax-M2.5, an AI assistant here to help you with questions, tasks, or whatever you need. What can I do for you? Time: 1.727263 ``` ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
@@ -2830,12 +2830,14 @@ optionsLoop:
|
||||
}
|
||||
cmd := NewCommand("chat_to_model")
|
||||
|
||||
if common.IsCompositeModelName(modelNameOrID) {
|
||||
cmd.Params["composite_model_name"] = modelNameOrID
|
||||
} else if common.IsUUID(modelNameOrID) {
|
||||
cmd.Params["model_id"] = modelNameOrID
|
||||
} else {
|
||||
return nil, fmt.Errorf("invalid format of model name or ID: %s", modelNameOrID)
|
||||
if modelNameOrID != "" {
|
||||
if common.IsCompositeModelName(modelNameOrID) {
|
||||
cmd.Params["composite_model_name"] = modelNameOrID
|
||||
} else if common.IsUUID(modelNameOrID) {
|
||||
cmd.Params["model_id"] = modelNameOrID
|
||||
} else {
|
||||
return nil, fmt.Errorf("invalid format of model name or ID: %s", modelNameOrID)
|
||||
}
|
||||
}
|
||||
cmd.Params["messages"] = messages
|
||||
cmd.Params["images"] = images
|
||||
|
||||
@@ -5,6 +5,32 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestParseChatMessageUsesCurrentModel(t *testing.T) {
|
||||
p := NewParser("chat message 'hi';")
|
||||
cmd, err := p.Parse(APIMode)
|
||||
if err != nil {
|
||||
t.Fatalf("Parse() error = %v", err)
|
||||
}
|
||||
|
||||
if cmd.Type != "chat_to_model" {
|
||||
t.Fatalf("Command Type = %v, expected chat_to_model", cmd.Type)
|
||||
}
|
||||
if _, ok := cmd.Params["composite_model_name"]; ok {
|
||||
t.Fatal("composite_model_name should not be set")
|
||||
}
|
||||
if _, ok := cmd.Params["model_id"]; ok {
|
||||
t.Fatal("model_id should not be set")
|
||||
}
|
||||
|
||||
gotMessages, ok := cmd.Params["messages"].([]string)
|
||||
if !ok {
|
||||
t.Fatalf("messages param has type %T, expected []string", cmd.Params["messages"])
|
||||
}
|
||||
if !reflect.DeepEqual(gotMessages, []string{"hi"}) {
|
||||
t.Fatalf("messages = %v, expected [hi]", gotMessages)
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseAddModelWithDimensions(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
|
||||
@@ -324,19 +324,19 @@ Time: 1.680416
|
||||
|
||||
### 6.19. Set, reset, and list default models
|
||||
```
|
||||
RAGFlow(api/default)> set default chat model 'zhipu-ai/test/glm-4.5-flash';
|
||||
RAGFlow(api/default)> set default chat model 'glm-4.5-flash@test@zhipu-ai';
|
||||
SUCCESS
|
||||
RAGFlow(api/default)> set default vision model 'zhipu-ai/test/glm-4.5v';
|
||||
RAGFlow(api/default)> set default vision model 'glm-4.5v@test@zhipu-ai';
|
||||
SUCCESS
|
||||
RAGFlow(api/default)> set default embedding model 'zhipu-ai/test/embedding-2';
|
||||
RAGFlow(api/default)> set default embedding model 'embedding-2@test@zhipu-ai';
|
||||
SUCCESS
|
||||
RAGFlow(api/default)> set default rerank model 'zhipu-ai/test/rerank';
|
||||
RAGFlow(api/default)> set default rerank model 'rerank@test@zhipu-ai';
|
||||
SUCCESS
|
||||
RAGFlow(api/default)> set default ocr model 'zhipu-ai/test/glm-ocr';
|
||||
RAGFlow(api/default)> set default ocr model 'glm-ocr@test@zhipu-ai';
|
||||
SUCCESS
|
||||
RAGFlow(api/default)> set default tts model 'zhipu-ai/test/glm-tts';
|
||||
RAGFlow(api/default)> set default tts model 'tts@test@zhipu-ai';
|
||||
SUCCESS
|
||||
RAGFlow(api/default)> set default asr model 'zhipu-ai/test/glm-asr-2512';
|
||||
RAGFlow(api/default)> set default asr model 'glm-asr-2512@test@zhipu-ai';
|
||||
SUCCESS
|
||||
RAGFlow(api/default)> list default models;
|
||||
+--------+----------------+---------------+----------------+------------+
|
||||
|
||||
Reference in New Issue
Block a user