Coder Social home page Coder Social logo

history_rag's Introduction

史料RAG

本项目展示如何使用向量数据库基于RAG(检索增强生成)方式搭建一个**历史问答应用。这个应用接受用户的询问,从历史语料库中检索相关的历史资料片段,利用大语言模型给出较为可靠的回答。相比于直接询问大模型,这种方式具有回答准确率高,不容易产生大模型的“幻觉”问题等优点。关于history_rag的详细解读可以看这篇知乎文章

史料RAG演示

本项目实现了两种使用方式,“Milvus方案“在本地启动一个Milvus向量数据库的Docker服务,使用LlamaIndex框架和本地BAAI/bge-base-zh-v1.5Embedding模型实现RAG的业务逻辑。“Zilliz Cloud Pipelines方案”使用云上的知识库检索服务Zilliz Cloud Pipelines,该服务包括了RAG流程的文档切片、向量化、向量检索等功能。两种方案均使用OpenAI的GPT4作为大语言模型。

运行本项目将会需要:

获取OpenAI API Key 
安装Milvus 2.3.3版本 或者 获取Zilliz Cloud账号
安装LlamaIndex
安装Docker
安装python3

更新

  • 6/11/2024: 升级到了LlamaIndex 0.10.x版本,并更新了pipeline,目前pipeline也加入了reranker功能。
  • 3/1/2024: darius-gs添加了对于使用本地LLM服务的支持(例如fastchat),使用请参考文档
  • 2/5/2024: BetterAndBetterII添加了对于使用中转站的Gemini模型的支持,使用请参考文档
  • 1/30/2024: taihaozesong添加了基于gradio的web ui界面。使用请参考文档
  • 1/29/2024: 针对windows环境,添加了一些说明
  • 1/27/2024: leyiang添加了使用通义千问作为LLM的方式,详情请参考文档

Milvus方案

步骤1: 配置OpenAI API key

项目中使用OpenAI的GPT4作为大语言模型,在开始之前,配置环境变量存放 OpenAI API Key (格式类似于sk-xxxxxxxx)。如果没有,请参考OpenAI官方文档获取。在terminal中输入以下命令添加环境变量:

export OPENAI_API_KEY='your-api-key-here'

步骤2: 安装Milvus

使用Docker启动向量数据库Milvus服务,使用的默认端口为19530。如果你使用Mac系统,执行以下命令前请确保Docker Desktop已经安装并运行(如何安装参考这里):

cd db
sudo docker compose up -d
cd ..

步骤3: 安装Python依赖项

如果你的环境中没有Python3,可以参考这里安装。

(可选)本项目中使用的python依赖可能会和你的现有环境产生冲突,如果你担心这一点,可以使用virtualenv工具建立一个新的依赖环境,退出该环境时使用deactivate。请注意使用这种方式会重新下载pytorch等依赖项(即便本机已经安装了它们),可能耗时较长。

pip install virtualenv
virtualenv rag
source rag/bin/activate

现在安装所需依赖(以下命令无论是否在virtualenv中都是一样的):

pip install -r requirements.txt

步骤4: 构建史料知识库

导入文本史料构建知识库,该过程中会将文本切片并生成向量,构建向量索引。

执行交互程序cli.py,选择milvus模式,然后输入要构建的语料,例如build ./data/history_24/baihuasanguozhi.txt会将白话版《三国志》导入。

python cli.py
(rag) milvus
(rag) build ./data/history_24/baihuasanguozhi.txt

注意,二十四史语料库较大。如果输入build ./data/history_24/会将该目录下所有文件进行索引构建,耗费时间较长,针对大规模语料库建议使用下面的“Zilliz Cloud Pipelines方案”。

步骤5: 进行问题查询

输入ask进入提问模式。输入我们感兴趣的问题。

(rag) ask
(rag) 问题:关公刮骨疗毒是真的吗

Zilliz Cloud Pipelines方案

📒 Zilliz Cloud Pipelines的实现与上文中Milvus方案存在差异,可能会产生不同的回答。这是由于使用的文档切片方式、embedding模型等不同导致的。Zilliz Cloud Pipelines服务提供了更好的伸缩弹性,免去了维护生产环境中复杂组件的麻烦,其召回质量会随着云上功能的迭代持续更新优化,并且支持召回方案的个性化配置。

步骤1: 配置OpenAI API key

项目中使用OpenAI的GPT4作为大语言模型,在开始之前,配置环境变量存放 OpenAI API Key (格式类似于sk-xxxxxxxx)。如果没有,请参考OpenAI官方文档获取。在terminal中输入以下命令添加环境变量:

export OPENAI_API_KEY='your-api-key-here'

步骤2: 获取Zilliz Cloud的配置信息

注册Zilliz Cloud账号,获取相应的配置,这个方案可以利用云端的算力进行大量文档的处理。你可以参考这里了解更加详细的使用教程。 Pipeline所需要的projectId Pipeline中所需要的两个配置信息 同样在环境变量中添加

export ZILLIZ_PROJECT_ID=<一图中的信息> 
export ZILLIZ_TOKEN=<二图左边红框的信息> 
export ZILLIZ_CLUSTER_ID=<二图右边红框的信息>

步骤3: 安装Python依赖项

如果你的环境中没有Python3,可以参考这里安装。

(可选)本项目中使用的python依赖可能会和你的现有环境产生冲突,如果你担心这一点,可以使用virtualenv工具建立一个新的依赖环境,退出该环境时使用deactivate。请注意使用这种方式会重新下载pytorch等依赖项(即便本机已经安装了它们),可能耗时较长。

pip install virtualenv
virtualenv rag
source rag/bin/activate

现在安装所需依赖

pip install -r requirements.txt

步骤4: 构建史料知识库

执行交互程序cli.py,选择milvus模式,然后输入要构建的语料,例如build ./data/history_24/baihuasanguozhi.txt会将白话版《三国志》导入。

python cli.py
(rag) milvus
(rag) build ./data/history_24/baihuasanguozhi.txt

注意,二十四史语料库较大。如果输入build ./data/history_24/会将该目录下所有文件进行索引构建,耗费时间较长,针对大规模语料库建议使用下面的“Zilliz Cloud Pipelines方案”。

导入文本史料构建知识库,该过程中会将文本切片并生成向量,构建向量索引。

执行交互程序cli.py,选择pipeline模式,然后输入要构建的史料,,

python cli.py
(rag) pipeline
(rag) build https://raw.githubusercontent.com/wxywb/history_rag/master/data/history_24/baihuasanguozhi.txt 

如果想一次性导入所有二十四史文件,可以运行build https://raw.githubusercontent.com/wxywb/history_rag/master/data/history_24/将该目录下所有文件上传进行索引构建。 注意,Zilliz Cloud Pipelines方案目前仅支持文件以URL的形式导入,后续会支持本地文件和文件夹导入。

步骤5: 进行问题查询

输入ask进入提问模式。输入我们感兴趣的问题。

ask
问题:关公刮骨疗毒是真的吗

FAQ

问题:huggingface无法连接上,无法下载模型怎么办?

回答:运行下面的命令,添加环境变量使用镜像站https://hf-mirror.com下载。

export HF_ENDPOINT=https://hf-mirror.com

问题:模型太大,网络连接不稳定,容易失败怎么办?

回答:运行下面命令,将模型下载到本地,然后就可以进行使用。

huggingface-cli download --resume-download BAAI/bge-reranker-large

如果你的环境中没有huggingface-cli,可以运行下面的pip install工具安装。

pip install -U "huggingface_hub[cli]"

问题:为什么我的问答每次效果都不一样?

回答:RAG中的Retrieval(召回)过程都是确定性的,但是大语言模型的内容生成存在一定随机性。存在一些方法让其进一步稳定,例如调整executor.py中的PROMPT,使用COT等Prompt Engineering方案,或者调整GPT-4 中的seed和temperature参数(但这可能会影响大模型的泛化能力)。

问题:可以添加别的史料吗?

回答:可以,但是由于会根据纪传体格式来判断引用时候的章节名,所以最好是每一个章节以"某某传"开头(无缩进),然后使用缩进来表示正文。

问题:如何使用别的embedding模型以及reranker模型?

回答:embedding模型以及reranker模型是在cfgs/config.yaml文件中配置的,可以修改该文件配置你想使用的模型,注意不同的embedding模型模型向量维度可能不同,在配置文件中要对应修改向量维度参数。

问题:可以使用其他LLM吗?

回答:可以,Llama Index所支持的LLM都可以很轻松的使用。项目默认使用的是OpenAI的GPT4模型。如果使用其他模型,需要在cfgs/config.yaml配置文件中修改llm配置项,并且修改executor.py中的逻辑,初始化其他LLM来进行集成。

指令附录

Command Flag(s) Description
build 目录或者文件进行索引构建,Milvus模式下为本地文件,Pipeline下为Url
build -overwrite 同上,但是进行覆盖构建,已有索引将被清空
ask 进入问答模式,输入quit退出该模式
ask -d 同上,但是开启Debug模式,将返回出来搜索出来的语料信息
remove 删除「文件名」中倒入的索引
quit 退出当前状态

history_rag's People

Contributors

betterandbetterii avatar chi-cat avatar codingjaguar avatar darius-gs avatar grantduan avatar iamaaronyu avatar iouakira avatar leyiang avatar shiyu22 avatar taihaozesong avatar wxywb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

history_rag's Issues

RuntimeError: {'code': 90019, 'message': 'Pipeline server error: call server failed, msg=internal error'}

➜ history_rag git:(master) ✗ python3 cli.py
___ ___ _____ _ _ _ _____ _____ _____ _____ __ __
/ |/ | | _ \ | | | | | | / / | | / _ \ | _ \ \ \ / /
/ /| /| | | |
| | | |
| | | | | |
__ | | | | | | | || | \ / /
/ / |/ | | | _ / | _ | | | _ \ | | | | | | | _ / \ /
/ / | | | | \ \ | | | | | | | | | | | || | | | \ \ / /
/
/ |
| |
| _\ || || || /_____/ || ___/ || _\ //


  • Version:2.0 *

  • Author:Bruce Young *

(rag) 选择[milvus|pipeline]方案
(rag) pipeline
Embeddings have been explicitly disabled. Using MockEmbedding.
(rag) pipeline模式已选择, 使用build https://raw.githubusercontent.com/wxywb/history_rag/master/data/history_24/baihuasanguozhi.txt来进行知识库构建。
1.使用build https://raw.githubusercontent.com/wxywb/history_rag/master/data/history_24/baihuasanguozhi.txt来进行知 识库构建。
2.已有索引可以使用ask进行提问, -d参数以debug模式进入。
3.删除已有索引可以使用remove baihuasanguozhi.txt
(rag) build https://raw.githubusercontent.com/Yi-Lyu/MyVimConfig/master/20240228.txt
Traceback (most recent call last):
File "/root/code/history_rag/cli.py", line 120, in
cli.run()
File "/root/code/history_rag/cli.py", line 53, in run
self.parse_input(command_text)
File "/root/code/history_rag/cli.py", line 65, in parse_input
self.build_index(path=commands[1], overwrite=False)
File "/root/code/history_rag/cli.py", line 92, in build_index
self._executor.build_index(path, overwrite)
File "/root/code/history_rag/executor.py", line 328, in build_index
self.index.insert_doc_url(
File "/root/code/history_rag/custom/zilliz/base.py", line 135, in insert_doc_url
raise RuntimeError(response_dict)
RuntimeError: {'code': 90019, 'message': 'Pipeline server error: call server failed, msg=internal error'}

把模型换成gpt-3.5-turbo了,但是回答准确率比较低。

(rag) 问题: 张飞的妻子是谁?
张飞的妻子是后主敬哀皇后的长女。
+---------------------------------------------------------------------------------------------------------------------+

(rag) 问题: 后主敬哀皇后是谁?
后主敬哀皇后是车骑将军张飞的长女。
+---------------------------------------------------------------------------------------------------------------------+

在 HF 部署一个 demo?

您好,这个项目太棒了,是否考虑来 HF 弄一个 demo 吗?这样很多没有技术背景的同学也都可以直接用起来啦~

可以用类似 https://huggingface.co/spaces/fastx/Gpt-4-chatbot 这里的方式让大家输入自己的 API key 我们应该也可以提供一些国内模型的 api token

我的微信: zhou_a_zhou

祝好~
铁震

ImportError: cannot import name 'ServiceContext' from 'llama_index' (unknown location)

按照步骤安装完成,运行时报错:
(history-rag) ubuntu@SKTech-Shanghai:/var/www/history_rag$ python cli.py --cfg cfgs/config_qwen.yaml
Traceback (most recent call last):
File "/var/www/history_rag/cli.py", line 1, in
from executor import MilvusExecutor
File "/var/www/history_rag/executor.py", line 12, in
from llama_index import ServiceContext, StorageContext
ImportError: cannot import name 'ServiceContext' from 'llama_index' (unknown location)

[Feature Requests] 关于WebUI与返回检索内容的需求

  1. 后期有打算提供web ui嘛?目前在wsl环境会出现ANSI 转义序列的问题,可以通过import readline解决,但是还是不够好看
  2. 能否只返回topk的chunk(检索得到的原文内容),不进行llm具体调用?
  3. 可以在FAQ里列一下一般一个问题的价格?我个人实测GPT4 turbo的价格在每个问题0.05$左右

小白遇到Milvus服务器的问题,恳请解答

大神你好,在执行python cli.py后,遇到如下问题,感觉是Milvus服务器没有运行,但自己在这方面知识储备几乎为0,请大神指教,多谢:
(rag) 选择[milvus|pipeline]方案
(rag) milvus
(rag) milvus模式已选择
1.使用build data/history_24/baihuasanguozhi.txt来进行知识库构建。
2.已有索引可以使用ask进行提问, -d参数以debug模式进入。
3.删除已有索引可以使用remove baihuasanguozhi.txt
(rag) ask
Failed to create new connection using: b1afc9fc359640d19a58706da83db8a4
Traceback (most recent call last):
File "/app/cli.py", line 120, in
cli.run()
File "/app/cli.py", line 53, in run
self.parse_input(command_text)
File "/app/cli.py", line 74, in parse_input
self.question_answer()
File "/app/cli.py", line 99, in question_answer
self._executor.build_query_engine()
File "/app/executor.py", line 196, in build_query_engine
self._get_index()
File "/app/executor.py", line 186, in _get_index
vector_store = MilvusVectorStore(
^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/llama_index/vector_stores/milvus.py", line 137, in init
self.milvusclient = MilvusClient(
^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/pymilvus/milvus_client/milvus_client.py", line 59, in init
self._using = self._create_connection(
^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/pymilvus/milvus_client/milvus_client.py", line 551, in _create_connection
raise ex from ex
File "/usr/local/lib/python3.11/site-packages/pymilvus/milvus_client/milvus_client.py", line 548, in _create_connection
connections.connect(using, user, password, db_name, token, uri=uri, **kwargs)
File "/usr/local/lib/python3.11/site-packages/pymilvus/orm/connections.py", line 414, in connect
connect_milvus(**kwargs, user=user, password=password, token=token, db_name=db_name)
File "/usr/local/lib/python3.11/site-packages/pymilvus/orm/connections.py", line 365, in connect_milvus
gh._wait_for_channel_ready(timeout=timeout)
File "/usr/local/lib/python3.11/site-packages/pymilvus/client/grpc_handler.py", line 146, in _wait_for_channel_ready
raise MilvusException(
pymilvus.exceptions.MilvusException: <MilvusException: (code=2, message=Fail connecting to server on localhost:19530. Timeout)>

是否可以更换文本

大佬好,这是提的第二个Issue,之前提的已经解决了,史先生部署成功了,很有意义的一个项目。再次感谢!

问题:如何用您的项目代码构建一个新的知识库?

背景:我想更换为其他的语料,是不是意味着:我需要重新做一个milvus库?而不是:直接把txt文件丢到文件夹,build就好?

因为我这么做过,问相关的问题,答案就是:不知道。

所以想请教您:如何用您的项目代码构建一个新的知识库?谢谢!

ZS

知识库构建索引出错

#32 情况不一样,服务器资源充足。

milvus 版本 2.3.3 , 使用 docker 部署。

存储情况如下:

[root@server volumes]# du ./ --max-depth=1 -h
367M	./etcd
8.9M	./minio
888M	./milvus
1.3G	./

运行情况如下:

[root@gpu-server milvus]# docker-compose ps
NAME                IMAGE                                      COMMAND                   SERVICE      CREATED       STATUS                 PORTS
attu                zilliz/attu:v2.3.2                         "docker-entrypoint.s…"   attu         6 hours ago   Up 6 hours             0.0.0.0:8000->3000/tcp, :::8000->3000/tcp
milvus-etcd         quay.io/coreos/etcd:v3.5.5                 "etcd -advertise-cli…"   etcd         6 hours ago   Up 6 hours (healthy)   2379-2380/tcp
milvus-minio        minio/minio:RELEASE.2023-03-20T20-16-18Z   "/usr/bin/docker-ent…"   minio        6 hours ago   Up 6 hours (healthy)   0.0.0.0:9000-9001->9000-9001/tcp, :::9000-9001->9000-9001/tcp
milvus-standalone   milvusdb/milvus:v2.3.3                     "/tini -- milvus run…"   standalone   6 hours ago   Up 6 hours (healthy)   0.0.0.0:19530->19530/tcp, :::19530->19530/tcp

错误日志如下:

[2024-03-21 20:43:06,020: ERROR/MainProcess] RPC error: [insert_rows], <DataNotMatchException: (code=1, message=Attempt to insert an unexpected field to collection without enabling dynamic field)>, <Time:{'RPC start': '2024-03-21 20:43:06.017347', 'RPC error': '2024-03-21 20:43:06.020646'}>
[2024-03-21 20:43:06,021: ERROR/MainProcess] Failed to insert batch starting at entity: 0/11
[2024-03-21 20:43:06,021: ERROR/MainProcess] Failed to insert batch starting at entity: 0/11
[2024-03-21 20:43:06,021: ERROR/MainProcess] consume document failed
Traceback (most recent call last):
  File "/app/api/core/indexing_runner.py", line 70, in run
    self._load(
  File "/app/api/core/indexing_runner.py", line 667, in _load
    index_processor.load(dataset, chunk_documents)
  File "/app/api/core/rag/index_processor/processor/paragraph_index_processor.py", line 59, in load
    vector.create(documents)
  File "/app/api/core/rag/datasource/vdb/vector_factory.py", line 121, in create
    self._vector_processor.create(
  File "/app/api/core/rag/datasource/vdb/milvus/milvus_vector.py", line 75, in create
    self.add_texts(texts, embeddings)
  File "/app/api/core/rag/datasource/vdb/milvus/milvus_vector.py", line 101, in add_texts
    raise e
  File "/app/api/core/rag/datasource/vdb/milvus/milvus_vector.py", line 95, in add_texts
    ids = self._client.insert(collection_name=self._collection_name, data=batch_insert_list)
  File "/usr/local/lib/python3.10/site-packages/pymilvus/milvus_client/milvus_client.py", line 206, in insert
    raise ex from ex
  File "/usr/local/lib/python3.10/site-packages/pymilvus/milvus_client/milvus_client.py", line 198, in insert
    res = conn.insert_rows(collection_name, insert_batch, timeout=timeout)
  File "/usr/local/lib/python3.10/site-packages/pymilvus/decorators.py", line 127, in handler
    raise e from e
  File "/usr/local/lib/python3.10/site-packages/pymilvus/decorators.py", line 123, in handler
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/pymilvus/decorators.py", line 162, in handler
    return func(self, *args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/pymilvus/decorators.py", line 102, in handler
    raise e from e
  File "/usr/local/lib/python3.10/site-packages/pymilvus/decorators.py", line 68, in handler
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/pymilvus/client/grpc_handler.py", line 501, in insert_rows
    request = self._prepare_row_insert_request(
  File "/usr/local/lib/python3.10/site-packages/pymilvus/client/grpc_handler.py", line 482, in _prepare_row_insert_request
    return Prepare.row_insert_param(
  File "/usr/local/lib/python3.10/site-packages/pymilvus/client/prepare.py", line 422, in row_insert_param
    return cls._parse_row_request(request, fields_info, enable_dynamic, entities)
  File "/usr/local/lib/python3.10/site-packages/pymilvus/client/prepare.py", line 370, in _parse_row_request
    raise DataNotMatchException(message=ExceptionsMessage.InsertUnexpectedField)
pymilvus.exceptions.DataNotMatchException: <DataNotMatchException: (code=1, message=Attempt to insert an unexpected field to collection without enabling dynamic field)>
[2024-03-21 20:43:06,028: INFO/MainProcess] Processed dataset: bd66a1d2-d871-42c4-8fe7-4275be32a591 latency: 6.201149852946401
[2024-03-21 20:43:06,064: INFO/MainProcess] Task tasks.document_indexing_task.document_indexing_task[0df93ed7-9cae-4670-842d-8032b3d5852b] succeeded in 6.23699377477169s: None

想使用代理的openai,该怎么办

请问如果我i使用的API不是直接连接到openai api而是经过中转的接口,调用前需要转换,在你的程序里需要修改哪里呢?

下面是中转站给的示例:
from openai import OpenAI

api_key = "xxx"
api_base = "https://one.aiskt.com/v1"
client = OpenAI(api_key=api_key, base_url=api_base)

completion = client.chat.completions.create(
model="gpt-3.5-turbo",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello!"}
]
)

print(completion.choices[0].message)

下载本地模型后依旧报错Connection error. OSError: [Errno 101] Network is unreachable

发生异常: APIConnectionError
Connection error.
OSError: [Errno 101] Network is unreachable
During handling of the above exception, another exception occurred:
httpcore.ConnectError: [Errno 101] Network is unreachable
The above exception was the direct cause of the following exception:
httpx.ConnectError: [Errno 101] Network is unreachable
During handling of the above exception, another exception occurred:
OSError: [Errno 101] Network is unreachable
During handling of the above exception, another exception occurred:
httpcore.ConnectError: [Errno 101] Network is unreachable
The above exception was the direct cause of the following exception:
httpx.ConnectError: [Errno 101] Network is unreachable
During handling of the above exception, another exception occurred:
OSError: [Errno 101] Network is unreachable
During handling of the above exception, another exception occurred:
httpcore.ConnectError: [Errno 101] Network is unreachable
The above exception was the direct cause of the following exception:
httpx.ConnectError: [Errno 101] Network is unreachable
During handling of the above exception, another exception occurred:
OSError: [Errno 101] Network is unreachable
During handling of the above exception, another exception occurred:
httpcore.ConnectError: [Errno 101] Network is unreachable
The above exception was the direct cause of the following exception:
httpx.ConnectError: [Errno 101] Network is unreachable
The above exception was the direct cause of the following exception:
File "/home/ureka/history_rag-master/executor.py", line 241, in query
response = self.query_engine.query(question)
File "/home/ureka/history_rag-master/cli.py", line 89, in query
ans = self._executor.query(question)
File "/home/ureka/history_rag-master/cli.py", line 112, in question_answer
self.query(question)
File "/home/ureka/history_rag-master/cli.py", line 77, in parse_input
self.question_answer()
File "/home/ureka/history_rag-master/cli.py", line 56, in run
self.parse_input(command_text)
File "/home/ureka/history_rag-master/cli.py", line 123, in
cli.run()
openai.APIConnectionError: Connection error.

[bug]关于比较大的文本输入构建索引失败

用2MB左右的文本已经成功构建了一个索引
但是在使用一个15MB左右的文本构建索引的时候连那个读条都没出来,就一直维持什么都没有的状态三个小时
所以是不是过于大的文本需要先分割好呢?

运行时提示ImportError: ('Cannot import sentence-transformers or torch package,', 'please `pip install torch sentence-transformers`')

已经安装了sentence-transformers==2.5.0torch==2.2.1但是仍然提示无法导入

('Cannot import sentence-transformers or torch package,', 'please pip install torch sentence-transformers')
ModuleNotFoundError: No module named 'sentence_transformers'
During handling of the above exception, another exception occurred:
File "/home/ureka/history_rag-master/executor.py", line 145, in init
self.rerank_postprocessor = SentenceTransformerRerank(
File "/home/ureka/history_rag-master/cli.py", line 30, in run
self._executor = MilvusExecutor(conf)
File "/home/ureka/history_rag-master/cli.py", line 120, in
cli.run()
ImportError: ('Cannot import sentence-transformers or torch package,', 'please pip install torch sentence-transformers')

ValueError

选择milvus方案后出现:ValueError: Unrecognized model identifier in BAAI/bge-base-zh-v1.5. Should contains one of 'bert', 'openai-gpt', 'gpt2', 'transfo-xl', 'xlnet', 'xlm', 'roberta, 'ctrl'并直接退出
PixPin_2024-02-16_23-50-56

关于非历史文本的输入

我想利用这个模型做一个别的知识领域的rag。但是我改了提示词和build的文本。如下:

文本:
When Madison was growing up, she was a difficult child. “She was very

intense and moody. She would flip at the switch of the light—unpre�dictable. When she was good, she was very good, but when she would

have those episodes of in-your-face hostility, living with her was very

hard.” Madison, as described by her mother, was very intelligent and was

in the gifted and talented program. She excelled in high school and

但是ask后显示Empty Response,debug后发现这个文本没有build上。故想请问如何操作能build上。

win启动不了

win启动的时候报错:ImportError: cannot import name 'LLM' from 'llama_index.core.llms' (C:\ProgramData\Miniconda3\envs\history_rag-master\lib\site-packages\llama_index\core\llms_init_.py)
换了llama_index的版本还是不行

milvus连接出错

我已经配置了数据库连接地址和端口,并且测试过都是通的,通过自己写的连接工具可以连接上,但是这里到最后就会出现连接本地错误
image
刚开始以为是配置文件没有读取到,就打印出来,地址是对的,但还是显示连接localhost失败
image
下面是我的配置文件
image

Unknow Model 的问题

在运行
python cli.py
(rag) milvus
后就会出现这样的问题
wrong_1
wrong_2
图1是报错的信息,图2是获取的OPEN_AI_KEY
我在想是不是OPEN_AI_KEY的问题
请大佬解答

Empty Response

image

我提出了问题,但返回Empty Response,这是为什么呢?

想知道怎么转换txt到json

大佬好,我现在想从头clone你的项目,但是我难在第一步也就是数据导入上了,折腾了两个晚上仍然没有进展
zilliz要求文件是json格式但是你的数据全部是txt格式,想知道你是怎么转换的呢?

我按照官方给的教程运行了一遍,报错为primary_key is null也就是主键为空,以及调用的BulkWiter包报错,某个attribute不存在,不知道出了什么问题?

{BB60A83B-DACA-47ba-8DF0-87FBEBA63A2A}

非常期待你的回复!

Error Code 429

各位好,我尝试在Windows环境下搭设,其他都已经部署完毕,但到提问环节时就会出现如图问题。已经修改gpt4为3.5,且能查询到API Key。因为没有任何计算机基础,所以万望不吝赐教!
image
image
image

文档分个模块和向量化

我这个地方很多的库的报错问题。请问您这里的文档分割是用的啥方法 在哪里可以看到呢。另外文本向量化的模型是啥 我这里报错的地方我都进不去看源码 期待回复
image

构建索引时报错,先前没有问题

image
已经建立过一次索引,后来想载入更多数据的时候,发现建立索引报错。
运行指令build https://raw.githubusercontent.com/wxywb/history_rag/master/data/history_24/baihuasanguozhi.txt
将zilliz上已经建立的表history_rag删除也依然无法添加
image
想问下RuntimeError: {'code': 90019, 'message': 'Pipeline server error: call server failed, msg=internal error'}
服务器这个状态码是什么意思,官方文档没有提及错误码的相关含义(国际版zilliz)

运行 `python cli.py`时发生错误

你好。我的环境信息:操作系统:Windows 11
开发工具:VSCode
Python 版本:python-3.11.8
llama-index 版本:0.9.39

Issue: 在命令行模式下(powershell和cmd都是)运行 python cli.py时发生错误
ImportError: cannot import name 'ChatMessage' from 'llama_index.core.llms' (C:\Users\zhaos\AppData\Roaming\Python\Python311\site-packages\llama_index\core\llms_init_.py)

谢谢!
ZS

使用zilliz构建数据库失败

PixPin_2024-02-11_13-49-32
我想构建一个基于三体小说的问答机器人,使用命令build https://raw.githubusercontent.com/PaperPlaneDeemo/santi/main/santi.txt后半段为我自己上传到GitHub的三体小说全文
执行一段时间后报错
Traceback (most recent call last):
File "D:\Program\history_rag\cli.py", line 120, in
cli.run()
File "D:\Program\history_rag\cli.py", line 53, in run
self.parse_input(command_text)
File "D:\Program\history_rag\cli.py", line 65, in parse_input
self.build_index(path=commands[1], overwrite=False)
File "D:\Program\history_rag\cli.py", line 92, in build_index
self._executor.build_index(path, overwrite)
File "D:\Program\history_rag\executor.py", line 324, in build_index
self.index.insert_doc_url(
File "D:\Program\history_rag\custom\zilliz\base.py", line 132, in insert_doc_url
raise RuntimeError(response.text)
RuntimeError: {
"message":"The upstream server is timing out"
}
查看zilliz数据库中只构建了几百字的向量数据库,请问是网络连接的问题吗?还是上传文件或构建数据库有时间或空间限制?

知识库构建索引出错,提示pymilvus.exceptions.DataNotMatchException: <DataNotMatchException: (code=1, message=Attempt to insert an unexpected field to collection without enabling dynamic field)>

当我成功连上milvus,并且执行 build data/history_24/baihuasanguozhi.txt命令后,进度条达到100%,报错

image
数据库不停的在报一个我不知道的错误
image
前面还报了一个好像是找不到索引的错误
image
数据库还有最上面的一堆错误
[2024/02/05 05:29:10.209 +00:00] [WARN] [grpcclient/client.go:516] ["ClientBase Call grpc call get error"] [role=proxy-2] [address=172.18.0.4:19529] [error="stack trace: /go/src/github.com/milvus-io/milvus/pkg/tracer/stack_trace.go:51 github.com/milvus-io/milvus/pkg/tracer.StackTrace\n/go/src/github.com/milvus-io/milvus/internal/util/grpcclient/client.go:515 github.com/milvus-io/milvus/internal/util/grpcclient.(*ClientBase[...]).Call\n/go/src/github.com/milvus-io/milvus/internal/util/grpcclient/client.go:529 github.com/milvus-io/milvus/internal/util/grpcclient.(*ClientBase[...]).ReCall\n/go/src/github.com/milvus-io/milvus/internal/distributed/proxy/client/client.go:76 github.com/milvus-io/milvus/internal/distributed/proxy/client.wrapGrpcCall[...]\n/go/src/github.com/milvus-io/milvus/internal/distributed/proxy/client/client.go:142 github.com/milvus-io/milvus/internal/distributed/proxy/client.(*Client).RefreshPolicyInfoCache\n/go/src/github.com/milvus-io/milvus/internal/rootcoord/proxy_client_manager.go:242 github.com/milvus-io/milvus/internal/rootcoord.(*proxyClientManager).RefreshPolicyInfoCache.func1\n/go/pkg/mod/golang.org/x/[email protected]/errgroup/errgroup.go:75 golang.org/x/sync/errgroup.(*Group).Go.func1\n/usr/local/go/src/runtime/asm_amd64.s:1598 runtime.goexit: attempt #0: rpc error: code = Unknown desc = expectedNodeID=2, actualNodeID=3: node not match: attempt #1: rpc error: code = Unknown desc = expectedNodeID=2, actualNodeID=3: node not match: attempt #2: rpc error: code = Unknown desc = expectedNodeID=2, actualNodeID=3: node not match: attempt #3: rpc error: code = Unknown desc = expectedNodeID=2, actualNodeID=3: node not match: attempt #4: rpc error: code = Unknown desc = expectedNodeID=2, actualNodeID=3: node not match: attempt #5: rpc error: code = Unknown desc = expectedNodeID=2, actualNodeID=3: node not match: attempt #6: rpc error: code = Unknown desc = expectedNodeID=2, actualNodeID=3: node not match: attempt #7: rpc error: code = Unknown desc = expectedNodeID=2, actualNodeID=3: node not match: attempt #8: rpc error: code = Unknown desc = expectedNodeID=2, actualNodeID=3: node not match: attempt #9: rpc error: code = Unknown desc = expectedNodeID=2, actualNodeID=3: node not match"] [errorVerbose="stack trace: /go/src/github.com/milvus-io/milvus/pkg/tracer/stack_trace.go:51 github.com/milvus-io/milvus/pkg/tracer.StackTrace: attempt #0: rpc error: code = Unknown desc = expectedNodeID=2, actualNodeID=3: node not match: attempt #1: rpc error: code = Unknown desc = expectedNodeID=2, actualNodeID=3: node not match: attempt #2: rpc error: code = Unknown desc = expectedNodeID=2, actualNodeID=3: node not match: attempt #3: rpc error: code = Unknown desc = expectedNodeID=2, actualNodeID=3: node not match: attempt #4: rpc error: code = Unknown desc = expectedNodeID=2, actualNodeID=3: node not match: attempt #5: rpc error: code = Unknown desc = expectedNodeID=2, actualNodeID=3: node not match: attempt #6: rpc error: code = Unknown desc = expectedNodeID=2, actualNodeID=3: node not match: attempt #7: rpc error: code = Unknown desc = expectedNodeID=2, actualNodeID=3: node not match: attempt #8: rpc error: code = Unknown desc = expectedNodeID=2, actualNodeID=3: node not match: attempt #9: rpc error: code = Unknown desc = expectedNodeID=2, actualNodeID=3: node not match\n(1) attached stack trace\n -- stack trace:\n | github.com/milvus-io/milvus/internal/util/grpcclient.(*ClientBase[...]).Call\n | \t/go/src/github.com/milvus-io/milvus/internal/util/grpcclient/client.go:515\n | [...repeated from below...]\nWraps: (2) stack trace: /go/src/github.com/milvus-io/milvus/pkg/tracer/stack_trace.go:51 github.com/milvus-io/milvus/pkg/tracer.StackTrace\n | /go/src/github.com/milvus-io/milvus/internal/util/grpcclient/client.go:515 github.com/milvus-io/milvus/internal/util/grpcclient.(*ClientBase[...]).Call\n | /go/src/github.com/milvus-io/milvus/internal/util/grpcclient/client.go:529 github.com/milvus-io/milvus/internal/util/grpcclient.(*ClientBase[...]).ReCall\n | /go/src/github.com/milvus-io/milvus/internal/distributed/proxy/client/client.go:76 github.com/milvus-io/milvus/internal/distributed/proxy/client.wrapGrpcCall[...]\n | /go/src/github.com/milvus-io/milvus/internal/distributed/proxy/client/client.go:142 github.com/milvus-io/milvus/internal/distributed/proxy/client.(*Client).RefreshPolicyInfoCache\n | /go/src/github.com/milvus-io/milvus/internal/rootcoord/proxy_client_manager.go:242 github.com/milvus-io/milvus/internal/rootcoord.(*proxyClientManager).RefreshPolicyInfoCache.func1\n | /go/pkg/mod/golang.org/x/[email protected]/errgroup/errgroup.go:75 golang.org/x/sync/errgroup.(*Group).Go.func1\n | /usr/local/go/src/runtime/asm_amd64.s:1598 runtime.goexit\nWraps: (3) attempt #0: rpc error: code = Unknown desc = expectedNodeID=2, actualNodeID=3: node not match: attempt #1: rpc error: code = Unknown desc = expectedNodeID=2, actualNodeID=3: node not match: attempt #2: rpc error: code = Unknown desc = expectedNodeID=2, actualNodeID=3: node not match: attempt #3: rpc error: code = Unknown desc = expectedNodeID=2, actualNodeID=3: node not match: attempt #4: rpc error: code = Unknown desc = expectedNodeID=2, actualNodeID=3: node not match: attempt #5: rpc error: code = Unknown desc = expectedNodeID=2, actualNodeID=3: node not match: attempt #6: rpc error: code = Unknown desc = expectedNodeID=2, actualNodeID=3: node not match: attempt #7: rpc error: code = Unknown desc = expectedNodeID=2, actualNodeID=3: node not match: attempt #8: rpc error: code = Unknown desc = expectedNodeID=2, actualNodeID=3: node not match\nWraps: (4) attached stack trace\n -- stack trace:\n | github.com/milvus-io/milvus/pkg/util/retry.Do\n | \t/go/src/github.com/milvus-io/milvus/pkg/util/retry/retry.go:49\n | github.com/milvus-io/milvus/internal/util/grpcclient.(*ClientBase[...]).call\n | \t/go/src/github.com/milvus-io/milvus/internal/util/grpcclient/client.go:429\n | github.com/milvus-io/milvus/internal/util/grpcclient.(*ClientBase[...]).Call\n | \t/go/src/github.com/milvus-io/milvus/internal/util/grpcclient/client.go:513\n | github.com/milvus-io/milvus/internal/util/grpcclient.(*ClientBase[...]).ReCall\n | \t/go/src/github.com/milvus-io/milvus/internal/util/grpcclient/client.go:529\n | github.com/milvus-io/milvus/internal/distributed/proxy/client.wrapGrpcCall[...]\n | \t/go/src/github.com/milvus-io/milvus/internal/distributed/proxy/client/client.go:76\n | github.com/milvus-io/milvus/internal/distributed/proxy/client.(*Client).RefreshPolicyInfoCache\n | \t/go/src/github.com/milvus-io/milvus/internal/distributed/proxy/client/client.go:142\n | github.com/milvus-io/milvus/internal/rootcoord.(*proxyClientManager).RefreshPolicyInfoCache.func1\n | \t/go/src/github.com/milvus-io/milvus/internal/rootcoord/proxy_client_manager.go:242\n | golang.org/x/sync/errgroup.(*Group).Go.func1\n | \t/go/pkg/mod/golang.org/x/[email protected]/errgroup/errgroup.go:75\n | runtime.goexit\n | \t/usr/local/go/src/runtime/asm_amd64.s:1598\nWraps: (5) attempt #9\nWraps: (6) rpc error: code = Unknown desc = expectedNodeID=2, actualNodeID=3: node not match\nError types: (1) *withstack.withStack (2) *errutil.withPrefix (3) merr.multiErrors (4) *withstack.withStack (5) *errutil.withPrefix (6) *status.Error"]
[2024/02/05 05:29:10.217 +00:00] [INFO] [rootcoord/root_coord.go:674] ["fail to refresh policy info cache"] [error="RefreshPolicyInfoCache failed, proxyID = 2, err = stack trace: /go/src/github.com/milvus-io/milvus/pkg/tracer/stack_trace.go:51 github.com/milvus-io/milvus/pkg/tracer.StackTrace\n/go/src/github.com/milvus-io/milvus/internal/util/grpcclient/client.go:515 github.com/milvus-io/milvus/internal/util/grpcclient.(*ClientBase[...]).Call\n/go/src/github.com/milvus-io/milvus/internal/util/grpcclient/client.go:529 github.com/milvus-io/milvus/internal/util/grpcclient.(*ClientBase[...]).ReCall\n/go/src/github.com/milvus-io/milvus/internal/distributed/proxy/client/client.go:76 github.com/milvus-io/milvus/internal/distributed/proxy/client.wrapGrpcCall[...]\n/go/src/github.com/milvus-io/milvus/internal/distributed/proxy/client/client.go:142 github.com/milvus-io/milvus/internal/distributed/proxy/client.(*Client).RefreshPolicyInfoCache\n/go/src/github.com/milvus-io/milvus/internal/rootcoord/proxy_client_manager.go:242 github.com/milvus-io/milvus/internal/rootcoord.(*proxyClientManager).RefreshPolicyInfoCache.func1\n/go/pkg/mod/golang.org/x/[email protected]/errgroup/errgroup.go:75 golang.org/x/sync/errgroup.(*Group).Go.func1\n/usr/local/go/src/runtime/asm_amd64.s:1598 runtime.goexit: attempt #0: rpc error: code = Unknown desc = expectedNodeID=2, actualNodeID=3: node not match: attempt #1: rpc error: code = Unknown desc = expectedNodeID=2, actualNodeID=3: node not match: attempt #2: rpc error: code = Unknown desc = expectedNodeID=2, actualNodeID=3: node not match: attempt #3: rpc error: code = Unknown desc = expectedNodeID=2, actualNodeID=3: node not match: attempt #4: rpc error: code = Unknown desc = expectedNodeID=2, actualNodeID=3: node not match: attempt #5: rpc error: code = Unknown desc = expectedNodeID=2, actualNodeID=3: node not match: attempt #6: rpc error: code = Unknown desc = expectedNodeID=2, actualNodeID=3: node not match: attempt #7: rpc error: code = Unknown desc = expectedNodeID=2, actualNodeID=3: node not match: attempt #8: rpc error: code = Unknown desc = expectedNodeID=2, actualNodeID=3: node not match: attempt #9: rpc error: code = Unknown desc = expectedNodeID=2, actualNodeID=3: node not match"]
[2024/02/05 05:29:10.225 +00:00] [ERROR] [rootcoord/root_coord.go:670] ["retry func failed"] ["retry time"=0] [error="RefreshPolicyInfoCache failed, proxyID = 2, err = stack trace: /go/src/github.com/milvus-io/milvus/pkg/tracer/stack_trace.go:51 github.com/milvus-io/milvus/pkg/tracer.StackTrace\n/go/src/github.com/milvus-io/milvus/internal/util/grpcclient/client.go:515 github.com/milvus-io/milvus/internal/util/grpcclient.(*ClientBase[...]).Call\n/go/src/github.com/milvus-io/milvus/internal/util/grpcclient/client.go:529 github.com/milvus-io/milvus/internal/util/grpcclient.(*ClientBase[...]).ReCall\n/go/src/github.com/milvus-io/milvus/internal/distributed/proxy/client/client.go:76 github.com/milvus-io/milvus/internal/distributed/proxy/client.wrapGrpcCall[...]\n/go/src/github.com/milvus-io/milvus/internal/distributed/proxy/client/client.go:142 github.com/milvus-io/milvus/internal/distributed/proxy/client.(*Client).RefreshPolicyInfoCache\n/go/src/github.com/milvus-io/milvus/internal/rootcoord/proxy_client_manager.go:242 github.com/milvus-io/milvus/internal/rootcoord.(*proxyClientManager).RefreshPolicyInfoCache.func1\n/go/pkg/mod/golang.org/x/[email protected]/errgroup/errgroup.go:75 golang.org/x/sync/errgroup.(*Group).Go.func1\n/usr/local/go/src/runtime/asm_amd64.s:1598 runtime.goexit: attempt #0: rpc error: code = Unknown desc = expectedNodeID=2, actualNodeID=3: node not match: attempt #1: rpc error: code = Unknown desc = expectedNodeID=2, actualNodeID=3: node not match: attempt #2: rpc error: code = Unknown desc = expectedNodeID=2, actualNodeID=3: node not match: attempt #3: rpc error: code = Unknown desc = expectedNodeID=2, actualNodeID=3: node not match: attempt #4: rpc error: code = Unknown desc = expectedNodeID=2, actualNodeID=3: node not match: attempt #5: rpc error: code = Unknown desc = expectedNodeID=2, actualNodeID=3: node not match: attempt #6: rpc error: code = Unknown desc = expectedNodeID=2, actualNodeID=3: node not match: attempt #7: rpc error: code = Unknown desc = expectedNodeID=2, actualNodeID=3: node not match: attempt #8: rpc error: code = Unknown desc = expectedNodeID=2, actualNodeID=3: node not match: attempt #9: rpc error: code = Unknown desc = expectedNodeID=2, actualNodeID=3: node not match"] [stack="github.com/milvus-io/milvus/internal/rootcoord.(*Core).startInternal.func1\n\t/go/src/github.com/milvus-io/milvus/internal/rootcoord/root_coord.go:670"]
[2024/02/05 05:29:10.230 +00:00] [INFO] [rootcoord/proxy_client_manager.go:120] ["succeed to create proxy client"] [address=172.18.0.4:19529] [serverID=3]
[2024/02/05 05:29:10.230 +00:00] [INFO] [rootcoord/timeticksync.go:241] ["Remove session from timeticksync"] [serverID=2]
[2024/02/05 05:29:10.230 +00:00] [INFO] [rootcoord/proxy_client_manager.go:135] ["remove proxy client"] ["proxy address"=172.18.0.4:19529] ["proxy id"=2]
[2024/02/05 05:29:10.239 +00:00] [WARN] [rootcoord/quota_center.go:146] ["quotaCenter sync metrics failed"] [error="GetMetrics failed, proxyID = 3, err = context deadline exceeded"]
[2024/02/05 05:29:12.597 +00:00] [INFO] [datacoord/meta.go:1287] ["UpdateChannelCheckpoint done"] [vChannel=by-dev-rootcoord-dml_0_447391822218951197v0] [ts=447508892842983425] [msgID="\u0001\u0000dS\ufffd\ufffd5\u0006"] [time=2024/02/05 05:29:09.871 +00:00]
看起来好像是节点识别有问题,有没有遇到过的大佬帮忙解答下

能有一个从零部署的说明吗?

可以增加一个windows从零开始部署的说明吗?我用了一天总算勉强把milvus搞出来了。现在按命令看是有milvus-etcd、milvus-minio、milvus-standalone,也安装了最新的python,但是其他的步骤应该怎么操作?
Clip_2024-01-29_13-31-50

pipeline方案使用qwen作为LLM时,无法正常使用

用qwen作为LLM,用命令python cli.py --cfg cfgs/config_qwen.yaml启动,使用mlivus方案是正常的,但是使用pipeline方案的时候调用的模型却是LlamaIndex默认的gpt-3.5-turbo。请问这个问题怎么解决呢,期待您的回复,谢谢您。
image

[bug]ValueError:Cannot use llm_chat_callback on an instance without a callback_manager attribute.

问题描述

按照项目中的 Windows 说明按步骤执行过程中,遇到了问题。

环境信息

  • 操作系统:Windows 11
  • 开发工具:VSCode
  • Python 版本:3.9.12
  • llama-index 版本:0.9.39

执行步骤列表

  1. clone项目到本地。

  2. 使用 .venv 创建虚拟环境——Python 版本是 3.9.12。

  3. pip——过程中,会自动安装最新版本的 llama-index(版本是 0.10.x)。

  4. pip——我手动升级为 0.9.39。

  5. 首次运行前——在 VSCode 下遇到了模块与文件名重名的情况,需要修改 3 处才能运行 python cli.py。修改的地方分别是:

    • from llama_index.core.query_pipeline.components import (...) (components模块下的components.py无法识别)

    • from llama_index.core.llms.llm import LLM(llm 模块下的llm.py无法识别)

    • from llama_index.core.llms.llm import ChatMessage, MessageRole

    • from llama_index.core import global_handler(llama_index.core模块下没有global_handler)

  6. build txt 过程没有遇到问题。

  7. 在执行 ask -d 过程中可以正确返回结果,但随后产生了 ValueError。

Traceback (most recent call last):
  File "C:\Users\A\VscodeProjects\history_rag\cli.py", line 120, in <module>
    cli.run()
  File "C:\Users\A\VscodeProjects\history_rag\cli.py", line 53, in run
    self.parse_input(command_text)
  File "C:\Users\A\VscodeProjects\history_rag\cli.py", line 74, in parse_input
    self.question_answer()
  File "C:\Users\A\VscodeProjects\history_rag\cli.py", line 109, in question_answer
    self.query(question)
  File "C:\Users\A\VscodeProjects\history_rag\cli.py", line 86, in query
    ans = self._executor.query(question)
  File "C:\Users\A\VscodeProjects\history_rag\executor.py", line 237, in query
    response = self.query_engine.query(question)
  File "c:\Users\A\VscodeProjects\history_rag\.venv\lib\site-packages\llama_index\core\base_query_engine.py", line 40, in query
    return self._query(str_or_query_bundle)
  File "c:\Users\A\VscodeProjects\history_rag\.venv\lib\site-packages\llama_index\query_engine\retriever_query_engine.py", line 172, in _query 
    response = self._response_synthesizer.synthesize(
  File "c:\Users\A\VscodeProjects\history_rag\.venv\lib\site-packages\llama_index\response_synthesizers\base.py", line 168, in synthesize      
    response_str = self.get_response(
  File "c:\Users\A\VscodeProjects\history_rag\.venv\lib\site-packages\llama_index\response_synthesizers\compact_and_refine.py", line 38, in get_response
    return super().get_response(
  File "c:\Users\A\VscodeProjects\history_rag\.venv\lib\site-packages\llama_index\response_synthesizers\refine.py", line 146, in get_response  
    response = self._give_response_single(
  File "c:\Users\A\VscodeProjects\history_rag\.venv\lib\site-packages\llama_index\response_synthesizers\refine.py", line 202, in _give_response_single
    program(
  File "c:\Users\A\VscodeProjects\history_rag\.venv\lib\site-packages\llama_index\response_synthesizers\refine.py", line 64, in __call__       
    answer = self._llm.predict(
  File "c:\Users\A\VscodeProjects\history_rag\.venv\lib\site-packages\llama_index\core\llms\llm_.py", line 239, in predict
    chat_response = self.chat(messages)
  File "c:\Users\A\VscodeProjects\history_rag\.venv\lib\site-packages\llama_index\core\llms\callbacks.py", line 84, in wrapped_llm_chat        
    with wrapper_logic(_self) as callback_manager:
  File "C:\Users\A\AppData\Local\Programs\Python\Python39\lib\contextlib.py", line 119, in __enter__
    return next(self.gen)
  File "c:\Users\A\VscodeProjects\history_rag\.venv\lib\site-packages\llama_index\core\llms\callbacks.py", line 30, in wrapper_logic
    raise ValueError(
ValueError: Cannot use llm_chat_callback on an instance without a callback_manager attribute.

输入ask后报错

索引已经生成过了,报错如下

`python3 cli.py
___ ___ _____ _ _ _ _____ _____ _____ _____ __ __
/ |/ | | _ \ | | | | | | / / | | / _ \ | _ \ \ \ / /
/ /| /| | | |
| | | |
| | | | | |
__ | | | | | | | || | \ / /
/ / |/ | | | _ / | _ | | | _ \ | | | | | | | _ / \ /
/ / | | | | \ \ | | | | | | | | | | | || | | | \ \ / /
/
/ |
| |
| _\ || || || /_____/ || ___/ || _\ //


  • Version:2.0 *

  • Author:Bruce Young *

(rag) 选择[milvus|pipeline]方案
(rag) milvus
(rag) milvus模式已选择
1.使用build data/history_24/baihuasanguozhi.txt来进行知识库构建。
2.已有索引可以使用ask进行提问, -d参数以debug模式进入。
3.删除已有索引可以使用remove baihuasanguozhi.txt
(rag) ask -d
Traceback (most recent call last):
File "/home/pushsoft/cywTest/history_rag/cli.py", line 120, in
cli.run()
File "/home/pushsoft/cywTest/history_rag/cli.py", line 53, in run
self.parse_input(command_text)
File "/home/pushsoft/cywTest/history_rag/cli.py", line 74, in parse_input
self.question_answer()
File "/home/pushsoft/cywTest/history_rag/cli.py", line 99, in question_answer
self._executor.build_query_engine()
File "/home/pushsoft/cywTest/history_rag/executor.py", line 201, in build_query_engine
self.query_engine = self.index.as_query_engine(node_postprocessors=[
File "/home/pushsoft/.local/lib/python3.10/site-packages/llama_index/indices/base.py", line 350, in as_query_engine
from llama_index.query_engine.retriever_query_engine import RetrieverQueryEngine
File "/home/pushsoft/.local/lib/python3.10/site-packages/llama_index/query_engine/init.py", line 27, in
from llama_index.query_engine.router_query_engine import (
File "/home/pushsoft/.local/lib/python3.10/site-packages/llama_index/query_engine/router_query_engine.py", line 24, in
from llama_index.selectors.utils import get_selector_from_context
File "/home/pushsoft/.local/lib/python3.10/site-packages/llama_index/selectors/init.py", line 3, in
from llama_index.selectors.pydantic_selectors import (
File "/home/pushsoft/.local/lib/python3.10/site-packages/llama_index/selectors/pydantic_selectors.py", line 10, in
from llama_index.program.openai_program import OpenAIPydanticProgram
File "/home/pushsoft/.local/lib/python3.10/site-packages/llama_index/program/init.py", line 5, in
from llama_index.program.openai_program import OpenAIPydanticProgram
File "/home/pushsoft/.local/lib/python3.10/site-packages/llama_index/program/openai_program.py", line 4, in
from llama_index.agent.openai.utils import resolve_tool_choice
File "/home/pushsoft/.local/lib/python3.10/site-packages/llama_index/agent/init.py", line 2, in
from llama_index.agent.custom.pipeline_worker import QueryPipelineAgentWorker
File "/home/pushsoft/.local/lib/python3.10/site-packages/llama_index/agent/custom/pipeline_worker.py", line 27, in
from llama_index.query_pipeline.components.agent import (
File "/home/pushsoft/.local/lib/python3.10/site-packages/llama_index/query_pipeline/init.py", line 24, in
from llama_index.query_pipeline.query import InputKeys, OutputKeys, QueryPipeline
File "/home/pushsoft/.local/lib/python3.10/site-packages/llama_index/query_pipeline/query.py", line 7, in
import networkx
File "/usr/local/lib/python3.10/dist-packages/networkx/init.py", line 20, in
from networkx.utils.backends import _dispatch
File "/usr/local/lib/python3.10/dist-packages/networkx/utils/backends.py", line 132, in
backends = _get_backends("networkx.plugins")
File "/usr/local/lib/python3.10/dist-packages/networkx/utils/backends.py", line 106, in _get_backends
items = entry_points(group=group)
File "/usr/lib/python3.10/importlib/metadata/init.py", line 1021, in entry_points
return SelectableGroups.load(eps).select(**params)
File "/usr/lib/python3.10/importlib/metadata/init.py", line 459, in load
ordered = sorted(eps, key=by_group)
File "/usr/lib/python3.10/importlib/metadata/init.py", line 1018, in
eps = itertools.chain.from_iterable(
File "/usr/lib/python3.10/importlib/metadata/_itertools.py", line 16, in unique_everseen
k = key(element)
File "/usr/lib/python3.10/importlib/metadata/init.py", line 943, in _normalized_name
or super().normalized_name
File "/usr/lib/python3.10/importlib/metadata/init.py", line 622, in normalized_name
return Prepared.normalize(self.name)
File "/usr/lib/python3.10/importlib/metadata/init.py", line 871, in normalize
return re.sub(r"[-
.]+", "-", name).lower().replace('-', '
')
File "/usr/lib/python3.10/re.py", line 209, in sub
return _compile(pattern, flags).sub(repl, string, count)
TypeError: expected string or bytes-like objec`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.