mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-06-29 23:41:12 +08:00
Go: validate Baidu OCR inputs (#15168)
### What problem does this PR solve? Closes #15167. The Baidu Go provider advertises OCR support through `paddleocr-vl-0.9b`, but `BaiduModel.OCRFile` dereferenced required inputs before validating them. Calling OCR with a missing API config, API key, or model name could panic instead of returning a normal error. This PR adds explicit input validation for those required values. ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --------- Co-authored-by: Jin Hai <haijin.chn@gmail.com>
This commit is contained in:
@@ -638,6 +638,12 @@ func (b *BaiduModel) OCRFile(modelName *string, content []byte, fileURL *string,
|
||||
if (fileURL == nil || *fileURL == "") && (content == nil || len(content) == 0) {
|
||||
return nil, fmt.Errorf("image url or content is required")
|
||||
}
|
||||
if apiConfig == nil || apiConfig.ApiKey == nil || *apiConfig.ApiKey == "" {
|
||||
return nil, fmt.Errorf("api key is required")
|
||||
}
|
||||
if modelName == nil || *modelName == "" {
|
||||
return nil, fmt.Errorf("model name is required")
|
||||
}
|
||||
|
||||
region := "default"
|
||||
if apiConfig.Region != nil && *apiConfig.Region != "" {
|
||||
|
||||
Reference in New Issue
Block a user