chatWeb
1.0.0
英语文档中文文档
CHATWEB可以从PDF,DOCX,TXT文件中爬网或提取文本,并生成嵌入式摘要。它还可以根据文本的内容回答您的问题。它是基于gpt3.5以及向量数据库的chatapi和embeddingapi实现的。
基本原则类似于现有项目,例如CHATPDF和自动化客户服务AI。
爬网网页提取文本内容使用gpt3.5的嵌入API来生成每个段落的向量,每个段落计算每个段落的向量和整个文本的矢量之间的相似性得分,以生成摘要存储的摘要存储,以生成vector-text映射vector中的vector-text映射从用户输入中生成关键字从关键字生成向量GPT3.5的聊天API设计提示,该提示基于列表中最相似的文本回答用户的问题。这个想法是从大量文本中提取相关内容,然后根据该内容回答问题,这与破坏令牌限制的效果相似。
进行了改进,以基于关键字而不是用户的问题生成向量,这增加了搜索相关文本的准确性。
git clone https://github.com/SkywalkerDarren/chatWeb.git下载此存储库cd chatWeb导航到目录config.example.json到config.jsonconfig.json并将open_ai_key设置为OpenAI API密钥pip3 install -r requirements.txt安装依赖项python3 main.py启动应用程序如果您愿意,也可以使用Docker运行此项目:
docker-compose build构建容器(仅当您不打算与此仓库相关时需要一次)config.example.json复制到config.json ,并设置所有需要的东西。示例配置已经可以使用Docker运行,无需在此处更改任何内容,如果您在Env变量中没有Open_AI_KEY,则可以在此处设置它,或者以后运行此应用程序。http://localhost:7860 config.json ,将language设置为English或其他语言config.json和设置mode到console , api或webui选择启动模式。console模式下,键入/help查看命令。api模式下,可以向外界提供API服务。可以在config.json中设置api_port和api_host 。webui模式下,可以提供Web用户界面服务。可以在config.json中设置webui_port ,默认为http://127.0.0.1:7860 7860。 config.json并将use_stream设置为true 。 config.json并将temperature设置为0到1之间的值。config.json并为您的代理地址添加open_ai_proxy ,例如: "open_ai_proxy": {
"http": "socks5://127.0.0.1:1081",
"https": "socks5://127.0.0.1:1081"
}
config.json并将use_postgres设置为true 。postgresql://localhost:5432/mydb ,或者您可以在config.json中进行设置。编译并安装扩展名(支持Postgres 11+)。
git clone --branch v0.4.0 https://github.com/pgvector/pgvector.git
cd pgvector
make
make install # may need sudo然后将其加载到数据库中,您要在
CREATE EXTENSION vector;
pip3 install psycopg2Please enter the link to the article or the file path of the PDF/TXT/DOCX document: https://gutenberg.ca/ebooks/hemingwaye-oldmanandthesea/hemingwaye-oldmanandthesea-00-e.html
Please wait for 10 seconds until the webpage finishes loading.
The article has been retrieved, and the number of text fragments is: 663
...
=====================================
Query fragments used tokens: 7219, cost: $ 0.0028876
Query fragments used tokens: 7250, cost: $ 0.0029000000000000002
Query fragments used tokens: 7188, cost: $ 0.0028752
Query fragments used tokens: 7177, cost: $ 0.0028708
Query fragments used tokens: 2378, cost: $ 0.0009512000000000001
Embeddings have been created with 663 embeddings, using 31212 tokens, costing $ 0.0124848
The embeddings have been saved.
=====================================
Please enter your query (/help to view commands):