mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-07-23 00:46:42 +08:00
Go: add office_oxide and parse docx file. (#15976)
### What problem does this PR solve? As title. ### 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:
@@ -29,6 +29,8 @@ import (
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"ragflow/internal/ingestion"
|
||||
"ragflow/internal/ingestion/parser"
|
||||
"ragflow/internal/utility"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
@@ -3249,6 +3251,22 @@ func (c *CLI) UserParseLocalFile(cmd *Command) (ResponseIf, error) {
|
||||
docParseModel = ""
|
||||
}
|
||||
|
||||
fileType := utility.GetFileType(filename)
|
||||
|
||||
fileParser, err := parser.GetParser(fileType)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
fileContent, err := os.ReadFile(filename)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to read dsl file: %w", err)
|
||||
}
|
||||
|
||||
if err = fileParser.Parse(filename, fileContent); err != nil {
|
||||
return nil, formatRequestError("parse local file", err)
|
||||
}
|
||||
|
||||
var result SimpleResponse
|
||||
result.Code = 0
|
||||
result.Message = fmt.Sprintf("Success to parse local file %q, vision: %v, chat: %v, asr: %v, ocr: %v, embedding: %v, doc_parse: %v", filename, visionModel, chatModel, asrModel, ocrModel, embeddingModel, docParseModel)
|
||||
|
||||
Reference in New Issue
Block a user