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):