xusenlinzy / api-for-open-llm

Openai style api for open large language models, using LLMs just as chatgpt! Support for LLaMA, LLaMA-2, BLOOM, Falcon, Baichuan, Qwen, Xverse, SqlCoder, CodeLLaMA, ChatGLM, ChatGLM2, ChatGLM3 etc. 开源大模型的统一后端接口
Apache License 2.0
2.35k stars 270 forks source link

doc chat 使用时报 FileNotFoundError: Table does not exist.Please first call db.create_table(, data) 错误 #299

Closed Weiqiang-Li closed 3 months ago

Weiqiang-Li commented 3 months ago

提交前必须检查以下项目 | The following items must be checked before submission

问题类型 | Type of problem

模型推理和部署 | Model inference and deployment

操作系统 | Operating system

Linux

详细描述问题 | Detailed description of the problem

streamlit run streamlit_app.py

启动 streamlit_app 后,正确完成了页面加载,并且上传了知识库文件

image

但是进行提问时,报了以下错误:

FileNotFoundError: Table does not exist.Please first call db.create_table(, data)

查找并修改了 /api-for-open-llm-master/streamlit-demo/streamlit_gallery/components/doc_chat/utils.py 中的代码 print了lancedb_path,检查该路径文件存在

但是并没有在 utils.py 中找到 建表语句。

所以请问这个报错如何解决,doc chat 在使用时,是如何进行表查询的?

Dependencies

# 请在此处粘贴依赖情况
# Please paste the dependencies here

运行日志或截图 | Runtime logs or screenshots

root@a83f86b258a1:~/models/api-for-open-llm-master/streamlit-demo# streamlit run streamlit_app.py

Collecting usage statistics. To deactivate, set browser.gatherUsageStats to false.

2024-07-26 06:56:00.268 Did not auto detect external IP.
Please go to https://docs.streamlit.io/ for debugging hints.

  You can now view your Streamlit app in your browser.

  Local URL: http://localhost:8501
  Network URL: http://172.17.0.2:8501

>>>>>>>>>>> lancedb_path:/root/models/api-for-open-llm-master/streamlit-demo/lancedb.db
2024-07-26 06:58:37.293 Uncaught app exception
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/streamlit/runtime/scriptrunner/script_runner.py", line 589, in _run_script
    exec(code, module.__dict__)
  File "/root/models/api-for-open-llm-master/streamlit-demo/streamlit_app.py", line 84, in <module>
    main()
  File "/root/models/api-for-open-llm-master/streamlit-demo/streamlit_app.py", line 79, in main
    page.show()
  File "/root/models/api-for-open-llm-master/streamlit-demo/streamlit_gallery/utils/page.py", line 49, in show
    self._selected()
  File "/root/models/api-for-open-llm-master/streamlit-demo/streamlit_gallery/components/doc_chat/streamlit_app.py", line 133, in main
    result = server.search(
  File "/root/models/api-for-open-llm-master/streamlit-demo/streamlit_gallery/components/doc_chat/utils.py", line 115, in search
    table = self.db.open_table(table_name)
  File "/usr/local/lib/python3.10/dist-packages/lancedb/db.py", line 445, in open_table
    return LanceTable.open(self, name, index_cache_size=index_cache_size)
  File "/usr/local/lib/python3.10/dist-packages/lancedb/table.py", line 936, in open
    raise FileNotFoundError(
FileNotFoundError: Table  does not exist.Please first call db.create_table(, data)

上方输出的 lancedb path 是我在 streamlit-demo/streamlit_gallery/components/doc_chat/utils.py 54 行插入了print 语句:

 42 class DocServer:
 43     def __init__(self, embeddings):
 44         self.embeddings = embeddings
 45         self.vector_store = None
 46         self.vs_path = None
 47         self.client = OpenAI(
 48             base_url=os.getenv("EMBEDDING_API_BASE"),
 49             api_key=os.getenv("API_KEY", ""),
 50         )
 51         self.db = lancedb.connect(
 52             os.path.join(Path(__file__).parents[3], "lancedb.db"),
 53         )
 54         print(">>>>>>>>>>> lancedb_path:"+os.path.join(Path(__file__).parents[3], "lancedb.db"))
 55
 56     def upload(
 57         self,
 58         filepath: Optional[str] = None,
 59         url: Optional[str] = None,
 60         chunk_size: int = 250,
 61         chunk_overlap: int = 50,
 62         table_name: str = None,
 63     ) -> str:
Weiqiang-Li commented 3 months ago

抱歉,我终于理解了 doc chat 页面的用法 需要在这里手动输入要使用的知识库文件,之前一直以为是默认的,尴尬 走查了一圈代码,终于找到了。。。

image