Go: add new provider minimax (#14296)

### What problem does this PR solve?

1. Add new provider minimax
2. Add new command: CHECK INSTANCE 'instance_name' FROM 'provider_name';
```
RAGFlow(user)> check instance 'test' from 'minimax';
SUCCESS
```

### Type of change

- [x] New Feature (non-breaking change which adds functionality)

Signed-off-by: Jin Hai <haijin.chn@gmail.com>
This commit is contained in:
Jin Hai
2026-04-23 10:16:20 +08:00
committed by GitHub
parent 387e2903d3
commit 2b029882d7
22 changed files with 549 additions and 197 deletions

View File

@@ -250,6 +250,8 @@ func (c *RAGFlowClient) ExecuteUserCommand(cmd *Command) (ResponseIf, error) {
return c.ChatToModel(cmd)
case "think_chat_to_model":
return c.ChatToModel(cmd)
case "check_provider_connection":
return c.CheckProviderConnection(cmd)
case "use_model":
return c.UseModel(cmd)
case "show_current_model":

View File

@@ -385,6 +385,8 @@ func (l *Lexer) lookupIdent(ident string) Token {
return Token{Type: TokenFile, Value: ident}
case "USE":
return Token{Type: TokenUse, Value: ident}
case "CHECK":
return Token{Type: TokenCheck, Value: ident}
case "UPDATE":
return Token{Type: TokenUpdate, Value: ident}
case "REMOVE":

View File

@@ -196,6 +196,8 @@ func (p *Parser) parseUserCommand() (*Command, error) {
return p.parseChatCommand()
case TokenThink:
return p.parseThinkCommand()
case TokenCheck:
return p.parseCheckCommand()
case TokenLS:
return p.parseContextListCommand()
case TokenCat:

View File

@@ -115,6 +115,7 @@ const (
TokenDisable
TokenEnable
TokenUse
TokenCheck
TokenThink
TokenLS
TokenCat

View File

@@ -1579,6 +1579,46 @@ func (c *RAGFlowClient) ChatToModel(cmd *Command) (ResponseIf, error) {
return &result, nil
}
func (c *RAGFlowClient) CheckProviderConnection(cmd *Command) (ResponseIf, error) {
if c.HTTPClient.APIToken == "" && c.HTTPClient.LoginToken == "" {
return nil, fmt.Errorf("API token not set. Please login first")
}
if c.ServerType != "user" {
return nil, fmt.Errorf("this command is only allowed in USER mode")
}
instanceName, ok := cmd.Params["instance_name"].(string)
if !ok {
return nil, fmt.Errorf("instance name not provided")
}
providerName, ok := cmd.Params["provider_name"].(string)
if !ok {
return nil, fmt.Errorf("provider name not provided")
}
url := fmt.Sprintf("/providers/%s/instances/%s/connection", providerName, instanceName)
resp, err := c.HTTPClient.Request("GET", url, true, "web", nil, nil)
if err != nil {
return nil, fmt.Errorf("failed to check provider connection: %w", err)
}
if resp.StatusCode != 200 {
return nil, fmt.Errorf("failed to check provider connection: HTTP %d, body: %s", resp.StatusCode, string(resp.Body))
}
var result SimpleResponse
if err = json.Unmarshal(resp.Body, &result); err != nil {
return nil, fmt.Errorf("check provider connection failed: invalid JSON (%w)", err)
}
if result.Code != 0 {
return nil, fmt.Errorf("%s", result.Message)
}
result.Duration = resp.Duration
return &result, nil
}
// UseModel sets the current model for chat
func (c *RAGFlowClient) UseModel(cmd *Command) (ResponseIf, error) {
if c.HTTPClient.APIToken == "" && c.HTTPClient.LoginToken == "" {

View File

@@ -2325,6 +2325,42 @@ func (p *Parser) parseStreamCommand() (*Command, error) {
return command, nil
}
func (p *Parser) parseCheckCommand() (*Command, error) {
p.nextToken() // consume CHECK
if p.curToken.Type != TokenInstance {
return nil, fmt.Errorf("expected INSTANCE after CHECK")
}
p.nextToken()
if p.curToken.Type != TokenQuotedString {
return nil, fmt.Errorf("expected instance name after INSTANCE")
}
instanceName := p.curToken.Value
p.nextToken()
if p.curToken.Type != TokenFrom {
return nil, fmt.Errorf("expected FROM after instance name")
}
p.nextToken()
if p.curToken.Type != TokenQuotedString {
return nil, fmt.Errorf("expected provider name after FROM")
}
providerName := p.curToken.Value
p.nextToken()
// Semicolon is optional
if p.curToken.Type == TokenSemicolon {
p.nextToken()
}
cmd := NewCommand("check_provider_connection")
cmd.Params["provider_name"] = providerName
cmd.Params["instance_name"] = instanceName
return cmd, nil
}
func (p *Parser) parseUseCommand() (*Command, error) {
p.nextToken() // consume USE