mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-07-26 18:33:30 +08:00
Go: fix OCR command (#14891)
### What problem does this PR solve? RAGFlow(user)> ocr with 'hunyuanocr@test@gitee' file './picture.png' +----------------------------------------------------------+ | text | +----------------------------------------------------------+ | 生活不是等待风暴过去,而是学会在雨中翩翩起舞。 ——佚名 | +----------------------------------------------------------+ ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --------- Signed-off-by: Jin Hai <haijin.chn@gmail.com>
This commit is contained in:
@@ -2822,20 +2822,33 @@ func (p *Parser) parseOCRCommand() (*Command, error) {
|
||||
}
|
||||
p.nextToken()
|
||||
|
||||
if p.curToken.Type != TokenFile {
|
||||
return nil, fmt.Errorf("expected FILE to OCR")
|
||||
}
|
||||
p.nextToken() // consume FILE
|
||||
|
||||
file, err := p.parseQuotedString()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
p.nextToken()
|
||||
|
||||
cmd := NewCommand("ocr_user_command")
|
||||
|
||||
switch p.curToken.Type {
|
||||
case TokenFile:
|
||||
p.nextToken()
|
||||
var file string
|
||||
file, err = p.parseQuotedString()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
cmd.Params["file"] = file
|
||||
p.nextToken()
|
||||
case TokenURL:
|
||||
p.nextToken()
|
||||
var url string
|
||||
url, err = p.parseQuotedString()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
cmd.Params["url"] = url
|
||||
p.nextToken()
|
||||
default:
|
||||
return nil, fmt.Errorf("expected FILE or URL")
|
||||
}
|
||||
|
||||
cmd.Params["composite_model_name"] = compositeModelName
|
||||
cmd.Params["file"] = file
|
||||
|
||||
return cmd, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user