OceanBase AI 动手实战营部署报错https://gitee.com/oceanbase-devhub/ai-workshop-2024

部署到: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 |
±---------------+

麻烦执行 poetry show | grep pyobvector 看一下版本号,另外,请问您使用的 python 版本具体是 python 3.9.x 的哪个版本呢?

[root@cjxdocker2 ai-workshop-2024]# poetry show |grep pyobvector
pyobvector 0.1.7 A python SDK for OceanBase Vector S…
[root@cjxdocker2 ai-workshop-2024]# python3 --version
Python 3.9.9

麻烦升级 pyobvector poetry add pyobvector@^0.1.14,升级完成后再执行嵌入脚本看看

可以了,非常感谢!!

解决了就好,我们也同步更新了代码仓库里 pyobvector 的版本,感谢您反馈这个问题!

我可以把自己的知识文档传上去吗,如果可以要求什么格式的?

可以的,目前文档需要是 markdown 格式。您需要准备一个目录,把文档放在该目录下,通过 embed_docs.py 脚本的 --doc_base 参数来指定这个目录进行处理。

好的,我自己尝试一下,阿里云百炼api-key是可以使用多久的?

您可以在阿里云百炼平台页面的模型广场里找到您使用的模型、查看免费额度以及免费额度的到期时间