from langchain_community.output_parsers.rail_parser import GuardrailsOutputParser
warnings.warn(
Traceback (most recent call last):
File "C:\Users\liuzj.conda\envs\chatchat\lib\site-packages\sqlalchemy\engine\base.py", line 1964, in _exec_single_context
self.dialect.do_execute(
File "C:\Users\liuzj.conda\envs\chatchat\lib\site-packages\sqlalchemy\engine\default.py", line 942, in do_execute
cursor.execute(statement, parameters)
sqlite3.OperationalError: no such table: knowledge_base
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "", line 1, in
File "C:\Users\liuzj.conda\envs\chatchat\lib\multiprocessing\spawn.py", line 116, in spawn_main
exitcode = _main(fd, parent_sentinel)
File "C:\Users\liuzj.conda\envs\chatchat\lib\multiprocessing\spawn.py", line 125, in _main
prepare(preparation_data)
File "C:\Users\liuzj.conda\envs\chatchat\lib\multiprocessing\spawn.py", line 236, in prepare
_fixup_main_from_path(data['init_main_from_path'])
File "C:\Users\liuzj.conda\envs\chatchat\lib\multiprocessing\spawn.py", line 287, in _fixup_main_from_path
main_content = runpy.run_path(main_path,
File "C:\Users\liuzj.conda\envs\chatchat\lib\runpy.py", line 289, in run_path
return _run_module_code(code, init_globals, run_name,
File "C:\Users\liuzj.conda\envs\chatchat\lib\runpy.py", line 96, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "C:\Users\liuzj.conda\envs\chatchat\lib\runpy.py", line 86, in run_code
exec(code, run_globals)
File "C:\AI\code\chatchat\libs\chatchat-server\chatchat\cli.py", line 6, in
from chatchat.startup import main as startup_main
File "C:\AI\code\chatchat\libs\chatchat-server\chatchat\startup.py", line 18, in
from server.script.video import main1
File "C:\AI\code\chatchat\libs\chatchat-server\chatchat\server\script\video.py", line 17, in
from chatchat.server.api_new.api_other import create_openai_chat_input
File "C:\AI\code\chatchat\libs\chatchat-server\chatchat\server\api_new\api_other.py", line 14, in
from chatchat.server.api_server.kb_routes import kb_chat_endpoint
File "C:\AI\code\chatchat\libs\chatchat-server\chatchat\server\api_server\kb_routes.py", line 10, in
from chatchat.server.chat.kb_chat import kb_chat
File "C:\AI\code\chatchat\libs\chatchat-server\chatchat\server\chat\kb_chat.py", line 15, in
from chatchat.server.agent.tools_factory.search_internet import search_engine
File "C:\AI\code\chatchat\libs\chatchat-server\chatchat\server\agent\tools_factory_init.py", line 4, in
from .search_local_knowledgebase import search_local_knowledgebase
File "C:\AI\code\chatchat\libs\chatchat-server\chatchat\server\agent\tools_factory\search_local_knowledgebase.py", line 38, in
choices=[kb.kb_name for kb in list_kbs().data],
File "C:\AI\code\chatchat\libs\chatchat-server\chatchat\server\knowledge_base\kb_api.py", line 18, in list_kbs
return ListResponse(data=list_kbs_from_db())
File "C:\AI\code\chatchat\libs\chatchat-server\chatchat\server\db\session.py", line 28, in wrapper
result = f(session, *args, **kwargs)
File "C:\AI\code\chatchat\libs\chatchat-server\chatchat\server\db\repository\knowledge_base_repository.py", line 33, in list_kbs_from_db
.all()
File "C:\Users\liuzj.conda\envs\chatchat\lib\site-packages\sqlalchemy\orm\query.py", line 2699, in all
return self._iter().all() # type: ignore
File "C:\Users\liuzj.conda\envs\chatchat\lib\site-packages\sqlalchemy\orm\query.py", line 2853, in _iter
result: Union[ScalarResult[_T], Result[_T]] = self.session.execute(
File "C:\Users\liuzj.conda\envs\chatchat\lib\site-packages\sqlalchemy\orm\session.py", line 2365, in execute
return self._execute_internal(
File "C:\Users\liuzj.conda\envs\chatchat\lib\site-packages\sqlalchemy\orm\session.py", line 2251, in _execute_internal
result: Result[Any] = compile_state_cls.orm_execute_statement(
File "C:\Users\liuzj.conda\envs\chatchat\lib\site-packages\sqlalchemy\orm\context.py", line 305, in orm_execute_statement
result = conn.execute(
File "C:\Users\liuzj.conda\envs\chatchat\lib\site-packages\sqlalchemy\engine\base.py", line 1416, in execute
return meth(
File "C:\Users\liuzj.conda\envs\chatchat\lib\site-packages\sqlalchemy\sql\elements.py", line 515, in _execute_on_connection
return connection._execute_clauseelement(
File "C:\Users\liuzj.conda\envs\chatchat\lib\site-packages\sqlalchemy\engine\base.py", line 1638, in _execute_clauseelement
ret = self._execute_context(
File "C:\Users\liuzj.conda\envs\chatchat\lib\site-packages\sqlalchemy\engine\base.py", line 1843, in _execute_context
return self._exec_single_context(
File "C:\Users\liuzj.conda\envs\chatchat\lib\site-packages\sqlalchemy\engine\base.py", line 1983, in _exec_single_context
self._handle_dbapi_exception(
File "C:\Users\liuzj.conda\envs\chatchat\lib\site-packages\sqlalchemy\engine\base.py", line 2352, in _handle_dbapi_exception
raise sqlalchemy_exception.with_traceback(exc_info[2]) from e
File "C:\Users\liuzj.conda\envs\chatchat\lib\site-packages\sqlalchemy\engine\base.py", line 1964, in _exec_single_context
self.dialect.do_execute(
File "C:\Users\liuzj.conda\envs\chatchat\lib\site-packages\sqlalchemy\engine\default.py", line 942, in do_execute
cursor.execute(statement, parameters)
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such table: knowledge_base
[SQL: SELECT knowledge_base.id AS knowledge_base_id, knowledge_base.kb_name AS knowledge_base_kb_name, knowledge_base.kb_info AS knowledge_base_kb_info, knowledge_base.vs_type AS knowledge_base_vs_type, knowledge_base.embed_model AS knowledge_base_embed_model, knowledge_base.file_count AS knowledge_base_file_count, knowledge_base.create_time AS knowledge_base_create_time
FROM knowledge_base
WHERE knowledge_base.file_count > ?]
[parameters: (-1,)]
(Background on this error at: https://sqlalche.me/e/20/e3q8)
The error "no such table: knowledge_base" indicates that the database schema has not been initialized correctly, and the knowledge_base table is missing. To resolve this issue, you need to initialize the database schema for Langchain-Chatchat.
Here are the steps to initialize the database:
-
Initialize the Knowledge Base:
Run the following command to initialize the knowledge base, which will create the necessary tables:
cd libs/chatchat-server
python chatchat/cli.py kb --recreate-vs
-
Set Up Data Directory and Configuration:
Ensure that the root path for storing data is set using the CHATCHAT_ROOT environment variable, or it will default to the current directory:
export CHATCHAT_ROOT=/path/to/chatchat_data
-
Initialize Data and Configuration Templates:
Execute the following command to initialize data and YAML configuration templates:
chatchat init
These steps should create the knowledge_base table and resolve the error you're encountering [1][2].
To continue talking to Dosu, mention @dosu.
Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other