mirror of
https://github.com/RYDE-WORK/Langchain-Chatchat.git
synced 2026-01-19 21:37:20 +08:00
- 重构 api.py:
- 按模块划分为不同的 router
- 添加 openai 兼容的转发接口,项目默认使用该接口以实现模型负载均衡
- 添加 /tools 接口,可以获取/调用编写的 agent tools
- 移除所有 EmbeddingFuncAdapter,统一改用 get_Embeddings
- 待办:
- /chat/chat 接口改为 openai 兼容
- 添加 /chat/kb_chat 接口,openai 兼容
- 改变 ntlk/knowledge_base/logs 等数据目录位置
26 lines
827 B
Python
26 lines
827 B
Python
from typing import List
|
|
from langchain_community.document_loaders.unstructured import UnstructuredFileLoader
|
|
from server.document_loaders.ocr import get_ocr
|
|
|
|
|
|
class RapidOCRLoader(UnstructuredFileLoader):
|
|
def _get_elements(self) -> List:
|
|
def img2text(filepath):
|
|
resp = ""
|
|
ocr = get_ocr()
|
|
result, _ = ocr(filepath)
|
|
if result:
|
|
ocr_result = [line[1] for line in result]
|
|
resp += "\n".join(ocr_result)
|
|
return resp
|
|
|
|
text = img2text(self.file_path)
|
|
from unstructured.partition.text import partition_text
|
|
return partition_text(text=text, **self.unstructured_kwargs)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
loader = RapidOCRLoader(file_path="../tests/samples/ocr_test.jpg")
|
|
docs = loader.load()
|
|
print(docs)
|