部署到:5.3 将文档转换为向量并插入 OceanBase 数据库
poetry run python embed_docs.py --doc_base doc_repos/oceanbase-doc/zh-CN/640.ob-vector-search
提示错误
[root@cjxdocker2 ai-workshop-2024]# poetry run python embed_docs.py --doc_base doc_repos/oceanbase-doc/zh-CN/640.ob-vector-search
args Namespace(doc_base=‘doc_repos/oceanbase-doc/zh-CN/640.ob-vector-search’, table_name=‘corpus’, skip_patterns=[‘oracle’], batch_size=4, component=‘observer’, limit=300, echo=False)
Using RemoteOpenAI
0%| | 0/9 [00:29<?, ?it/s]
Traceback (most recent call last):
File “/root/ai-workshop-2024/embed_docs.py”, line 129, in
insert_batch(batch, comp=args.component)
File “/root/ai-workshop-2024/embed_docs.py”, line 113, in insert_batch
vs.add_documents(
File “/root/.cache/pypoetry/virtualenvs/ai-workshop-aLQYZfdO-py3.9/lib/python3.9/site-packages/langchain_core/vectorstores/base.py”, line 287, in add_documents
return self.add_texts(texts, metadatas, **kwargs)
File “/root/.cache/pypoetry/virtualenvs/ai-workshop-aLQYZfdO-py3.9/lib/python3.9/site-packages/langchain_community/vectorstores/oceanbase.py”, line 308, in add_texts
self._create_table_with_index(embeddings)
File “/root/.cache/pypoetry/virtualenvs/ai-workshop-aLQYZfdO-py3.9/lib/python3.9/site-packages/langchain_community/vectorstores/oceanbase.py”, line 239, in _create_table_with_index
self.obvector.create_table_with_index_params(
File “/root/.cache/pypoetry/virtualenvs/ai-workshop-aLQYZfdO-py3.9/lib/python3.9/site-packages/pyobvector/client/ob_vec_client.py”, line 192, in create_table_with_index_params
vidx.create(self.engine, checkfirst=True)
File “/root/.cache/pypoetry/virtualenvs/ai-workshop-aLQYZfdO-py3.9/lib/python3.9/site-packages/pyobvector/schema/vector_index.py”, line 52, in create
bind._run_ddl_visitor(ObSchemaGenerator, self, checkfirst=checkfirst)
File “/root/.cache/pypoetry/virtualenvs/ai-workshop-aLQYZfdO-py3.9/lib/python3.9/site-packages/sqlalchemy/engine/base.py”, line 3253, in _run_ddl_visitor
conn._run_ddl_visitor(visitorcallable, element, **kwargs)
File “/root/.cache/pypoetry/virtualenvs/ai-workshop-aLQYZfdO-py3.9/lib/python3.9/site-packages/sqlalchemy/engine/base.py”, line 2459, in _run_ddl_visitor
visitorcallable(self.dialect, self, **kwargs).traverse_single(element)
File “/root/.cache/pypoetry/virtualenvs/ai-workshop-aLQYZfdO-py3.9/lib/python3.9/site-packages/sqlalchemy/sql/visitors.py”, line 664, in traverse_single
return meth(obj, **kw)
File “/root/.cache/pypoetry/virtualenvs/ai-workshop-aLQYZfdO-py3.9/lib/python3.9/site-packages/pyobvector/schema/vector_index.py”, line 27, in visit_vector_index
if not create_ok and not self._can_create_index(index):
File “/root/.cache/pypoetry/virtualenvs/ai-workshop-aLQYZfdO-py3.9/lib/python3.9/site-packages/sqlalchemy/sql/ddl.py”, line 870, in _can_create_index
return not self.checkfirst or not self.dialect.has_index(
File “/root/.cache/pypoetry/virtualenvs/ai-workshop-aLQYZfdO-py3.9/lib/python3.9/site-packages/sqlalchemy/engine/default.py”, line 599, in has_index
for idx in self.get_indexes(
File “”, line 2, in get_indexes
File “/root/.cache/pypoetry/virtualenvs/ai-workshop-aLQYZfdO-py3.9/lib/python3.9/site-packages/sqlalchemy/engine/reflection.py”, line 89, in cache
return fn(self, con, *args, **kw)
File “/root/.cache/pypoetry/virtualenvs/ai-workshop-aLQYZfdO-py3.9/lib/python3.9/site-packages/sqlalchemy/dialects/mysql/base.py”, line 3136, in get_indexes
parsed_state = self._parsed_state_or_create(
File “/root/.cache/pypoetry/virtualenvs/ai-workshop-aLQYZfdO-py3.9/lib/python3.9/site-packages/sqlalchemy/dialects/mysql/base.py”, line 3226, in _parsed_state_or_create
return self._setup_parser(
File “”, line 2, in _setup_parser
File “/root/.cache/pypoetry/virtualenvs/ai-workshop-aLQYZfdO-py3.9/lib/python3.9/site-packages/sqlalchemy/engine/reflection.py”, line 89, in cache
return fn(self, con, *args, **kw)
File “/root/.cache/pypoetry/virtualenvs/ai-workshop-aLQYZfdO-py3.9/lib/python3.9/site-packages/sqlalchemy/dialects/mysql/base.py”, line 3247, in _setup_parser
parser = self._tabledef_parser
File “/root/.cache/pypoetry/virtualenvs/ai-workshop-aLQYZfdO-py3.9/lib/python3.9/site-packages/sqlalchemy/util/langhelpers.py”, line 1141, in get
obj.dict[self.name] = result = self.fget(obj)
File “/root/.cache/pypoetry/virtualenvs/ai-workshop-aLQYZfdO-py3.9/lib/python3.9/site-packages/pyobvector/schema/dialect.py”, line 26, in _tabledef_parser
return OceanBaseTableDefinitionParser(
File “/root/.cache/pypoetry/virtualenvs/ai-workshop-aLQYZfdO-py3.9/lib/python3.9/site-packages/pyobvector/schema/reflection.py”, line 9, in init
MySQLTableDefinitionParser.init(self, dialect, preparer)
File “/root/.cache/pypoetry/virtualenvs/ai-workshop-aLQYZfdO-py3.9/lib/python3.9/site-packages/sqlalchemy/dialects/mysql/reflection.py”, line 41, in init
self._prep_regexes()
File “/root/.cache/pypoetry/virtualenvs/ai-workshop-aLQYZfdO-py3.9/lib/python3.9/site-packages/pyobvector/schema/reflection.py”, line 18, in _prep_regexes
zip(
TypeError: zip() takes no keyword arguments
数据库是连接mysql -h obmt69nh5lg23fhc-mi.aliyun-cn-hangzhou-internet.oceanbase.cloud -P 3306 -u czx01 -D czx01 -p
bash utils/connect_db.sh
oceanbase数据库连接正常,建表成功但是没有插入向量数据
mysql> show tables;
±---------------+
| Tables_in_test |
±---------------+
| corpus |
±---------------+