matrix_chatgpt_bot
v1.8.1:
這是一個簡單的 Matrix 機器人,支援使用 OpenAI API、Langchain 從使用者輸入產生回應。機器人根據提示的第一個單字回應以下指令: !gpt
、 !chat
、 !v
、 !pic
、 !new
、 !lc
和!help
。
Docker方法(推薦):
使用正確的值編輯config.json
或.env
有關說明和完整參數列表,請參閱:https://github.com/hibobmaster/matrix_chatgpt_bot/wiki
建立兩個空文件,僅用於持久性資料庫
touch sync_db context.db manage_db
sudo docker compose up -d
Manage_db(可以忽略)用於langchain代理,sync_db用於矩陣同步資料庫,context.db用於機器人聊天上下文
libolm-dev
git clone https://github.com/hibobmaster/matrix_chatgpt_bot.git
python -m venv venv
source venv/bin/activate
pip install -U pip setuptools wheel
pip install -r requirements.txt
room_id
:機器人將在其所在的房間中工作{
"homeserver" : " YOUR_HOMESERVER " ,
"user_id" : " YOUR_USER_ID " ,
"password" : " YOUR_PASSWORD " ,
"device_id" : " YOUR_DEVICE_ID " ,
"room_id" : " YOUR_ROOM_ID " ,
"openai_api_key" : " YOUR_API_KEY " ,
"gpt_api_endpoint" : " xxxxxxxxx "
}
python src/main.py
要與機器人交互,只需向 Matrix 房間中的機器人發送訊息並顯示以下提示之一:
!help
幫助訊息
!gpt
產生一次性回應:
!gpt What is the meaning of life?
!chat
使用官方 api 進行上下文對話 !chat Can you tell me a joke?
你可以參考截圖
Room Level: quote a image and @bot + {prompt}
Thread Level: quote a image with a {prompt}
!lc
使用 langchain api 端點聊天 !lc All the world is a stage
!pic
使用 openai DALL·E 或 LocalAI 產生圖像 !pic A bridal bouquet made of succulents
!agent
顯示或設定langchain代理 !agent list
!agent use {agent_name}
!new + {chat}
開始新的對話LangChain(flowise) 管理員: https://github.com/hibobmaster/matrix_chatgpt_bot/wiki/Langchain-(flowise)
https://github.com/hibobmaster/matrix_chatgpt_bot/wiki/
房間等級:
線程級別:
透過提示提及機器人,機器人將在帖子中回复。
要保留上下文,只需直接在線程中發送提示而不提及它。