diff --git a/module/zai/model.php b/module/zai/model.php index 27c6409604..4236b5c105 100644 --- a/module/zai/model.php +++ b/module/zai/model.php @@ -691,6 +691,27 @@ class zaiModel extends model return $filteredKnowledges; } + /** + * 提取文件内容。 + * Extract file content. + * + * @access public + * @param int $fileID + * @return array + */ + public function extractFileContent(int $fileID): array|null + { + $file = $this->loadModel('file')->getByID($fileID); + if(!is_object($file) || empty($file->realPath)) return null; + + $filePath = $file->realPath; + $cFile = new CURLFile($filePath, null, $file->title); + $result = $this->callAdminAPI('/v8/files/extract', 'POST', null, ['file' => $cFile]); + + if($result['result'] != 'success') return null; + return $result['data']; + } + /** * 用户对象可查看缓存配置。 * User object view cache configuration.