GraphRAG4OpenWebUI搭建

git clone https://github.com/your-username/GraphRAG4OpenWebUI.git
cd GraphRAG4OpenWebUI

conda create -n GraphRAG4OpenWebUI -y python=3.11
conda activate GraphRAG4OpenWebUI

Open WebUI安装

pip install open-webui

open-webui serve

Tavily AI API申请

https://app.tavily.com/home

初始化graphrag

mkdir ragtest
mkdir -p ragtest/input
然后传入一个1.txt(自己找一个txt)的文本到ragtest/input目录下

初始化目录

python -m graphrag.index --init --root ./ragtest

vim ./ragtest/settings.yaml
image.png

开启covariates(协变量)

claim_extraction:
  ## llm: override the global llm settings for this task
  ## parallelization: override the global parallelization settings for this task
  ## async_mode: override the global async_mode settings for this task
  enabled: true
  prompt: "prompts/claim_extraction.txt"
  description: "Any claims or facts that could be relevant to information discovery."
  max_gleanings: 1

##Just uncomment the enabled line in your settings.yaml file.
##I'll resolve the issue, but please reopen if this doesn't work

去掉注释,如下图
image.png

vim ./ragtest/.env
image.png

prompt_tune 由于我找到的中文的,要执行下面命令

python -m graphrag.prompt_tune --root ./ragtest --config ./ragtest/settings.yaml --no-entity-types --language Chinese --output ./ragtest/prompts

运行截图如下:
image.png

构建索引

python -m graphrag.index --root ./ragtest

运行后,显卡情况如下
image.png

执行过程中截图如下
image.png
成功截图如下
image.png

启动GraphRAG4OpenWebUI

export INPUT_DIR="/xxxxxx/workspace/GraphRAG4OpenWebUI/ragtest/output/20240907-225340/artifacts/"
export TAVILY_API_KEY="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"  
export GRAPHRAG_API_KEY="ollama"
export GRAPHRAG_API_KEY_EMBEDDING="ollama"
export GRAPHRAG_LLM_MODEL="qwen2:latest"
export API_BASE="http://localhost:11434/v1"
export API_BASE_EMBEDDING="http://localhost:11434/v1"
export GRAPHRAG_EMBEDDING_MODEL="nomic-embed-text:latest"

上面的 INPUT_DIR可能会频繁修改

启动

python main-cn.py

启动成功,如下图
image.png

配置open-webui

浏览器访问 http://yourip:8080/admin/settings
image.png
上面的左边红色框,好像不能填127.0.0.1和localhost,报网络错误,不知道是open-webui还是GraphRAG4OpenWebUI的问题,不去细究。填自己IP就行,记得端口号防火墙开放。

可以关掉ollama。

测试

image.png

下面的再问一个问题进行对比,local回答的是原文

image.png

后来测试了一把使用非本地的大模型,上面的文本,4个文本,4章节西游记的txt,跑一次,就把我积分耗完了。。。乖乖用本地大模型吧。
image.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值