mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-07-21 15:11:08 +08:00
Go: Admin list ingestion tasks (#14695)
### What problem does this PR solve? ``` RAGFlow(admin)> list tasks; +-------------+------------------+----------------------------------+-------------+-----------+----------------------------------+----------+----------------------+-------------+-----------+---------+ | chunk_count | digest | document_id | duration | from_page | id | priority | progress | retry_count | task_type | to_page | +-------------+------------------+----------------------------------+-------------+-----------+----------------------------------+----------+----------------------+-------------+-----------+---------+ | 16 | 8a0016a0dc3cbdbb | f6aa38bb4ad111f1ba6338a74640adcc | 1511.156966 | 0 | f91e4f104ad111f1aaaf38a74640adcc | 0 | 1 | 1 | | 12 | +-------------+------------------+----------------------------------+-------------+-----------+----------------------------------+----------+----------------------+-------------+-----------+---------+ ``` ### 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:
@@ -1118,3 +1118,30 @@ func (c *RAGFlowClient) DropAdminToken(cmd *Command) (ResponseIf, error) {
|
||||
result.Duration = resp.Duration
|
||||
return &result, nil
|
||||
}
|
||||
|
||||
func (c *RAGFlowClient) ListAdminTasks(cmd *Command) (ResponseIf, error) {
|
||||
if c.ServerType != "admin" {
|
||||
return nil, fmt.Errorf("this command is only allowed in ADMIN mode")
|
||||
}
|
||||
|
||||
resp, err := c.HTTPClient.Request("GET", "/admin/tasks", "admin", nil, nil)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to drop token: %w", err)
|
||||
}
|
||||
|
||||
if resp.StatusCode != 200 {
|
||||
return nil, fmt.Errorf("failed to drop token: HTTP %d, body: %s", resp.StatusCode, string(resp.Body))
|
||||
}
|
||||
|
||||
var result CommonResponse
|
||||
if err = json.Unmarshal(resp.Body, &result); err != nil {
|
||||
return nil, fmt.Errorf("drop token failed: invalid JSON (%w)", err)
|
||||
}
|
||||
|
||||
if result.Code != 0 {
|
||||
return nil, fmt.Errorf("%s", result.Message)
|
||||
}
|
||||
|
||||
result.Duration = resp.Duration
|
||||
return &result, nil
|
||||
}
|
||||
|
||||
@@ -190,6 +190,8 @@ func (p *Parser) parseAdminListCommand() (*Command, error) {
|
||||
return NewCommand("list_user_chats"), nil
|
||||
case TokenFiles:
|
||||
return p.parseAdminListFiles()
|
||||
case TokenTasks:
|
||||
return p.parseAdminListTasks()
|
||||
default:
|
||||
return nil, fmt.Errorf("unknown LIST target: %s", p.curToken.Value)
|
||||
}
|
||||
@@ -368,6 +370,12 @@ func (p *Parser) parseAdminListFiles() (*Command, error) {
|
||||
return cmd, nil
|
||||
}
|
||||
|
||||
func (p *Parser) parseAdminListTasks() (*Command, error) {
|
||||
p.nextToken() // consume TASKS
|
||||
cmd := NewCommand("list_admin_tasks")
|
||||
return cmd, nil
|
||||
}
|
||||
|
||||
func (p *Parser) parseAdminShowCommand() (*Command, error) {
|
||||
p.nextToken() // consume SHOW
|
||||
|
||||
|
||||
@@ -177,6 +177,8 @@ func (c *RAGFlowClient) ExecuteAdminCommand(cmd *Command) (ResponseIf, error) {
|
||||
return c.ListInstanceModels(cmd)
|
||||
case "show_model":
|
||||
return c.ShowModel(cmd)
|
||||
case "list_admin_tasks":
|
||||
return c.ListAdminTasks(cmd)
|
||||
// TODO: Implement other commands
|
||||
default:
|
||||
return nil, fmt.Errorf("command '%s' would be executed with API", cmd.Type)
|
||||
|
||||
@@ -427,6 +427,8 @@ func (l *Lexer) lookupIdent(ident string) Token {
|
||||
return Token{Type: TokenRegion, Value: ident}
|
||||
case "URL":
|
||||
return Token{Type: TokenURL, Value: ident}
|
||||
case "TASKS":
|
||||
return Token{Type: TokenTasks, Value: ident}
|
||||
case "LOG":
|
||||
return Token{Type: TokenLog, Value: ident}
|
||||
case "LEVEL":
|
||||
|
||||
@@ -143,6 +143,7 @@ const (
|
||||
TokenTag
|
||||
TokenRegion
|
||||
TokenURL
|
||||
TokenTasks
|
||||
TokenLog
|
||||
TokenLevel
|
||||
TokenDebug
|
||||
|
||||
Reference in New Issue
Block a user