redis chatgpt
v0.1.2
該軟件包是專門為有效處理聊天消息歷史記錄而開發的有用工具。這個Python軟件包的主要目標是提供一種可靠,高效且簡單的方法,以將聊天日誌存儲在REDIS數據庫中。
redis_chatgpt利用了Redis,這是一種快速,高效且高度可擴展的內存數據結構存儲。通過組織和保存REDIS中的聊天消息歷史記錄,用戶可以通過最佳性能及時輕鬆地檢索消息歷史記錄。
如果您需要從REDIS數據庫中毫不費力地存儲和恢復聊天歷史,則此軟件包是完美的解決方案。借助Redis_chatgpt,您可以簡化聊天日誌管理任務,同時對資源提高效率和效率。
pip install redis-chatgpt
構建一個簡單的數據存儲:
from redis_chatgpt.manager import RedisManager
redis_db = RedisManager(host="localhost", port=6379)
設置數據
redis_key = "chat_key"
chat_memory = [
{
"role": "system",
"content": "Assistant is a large language model trained by OpenAI."
},
{
"role": "assistant",
"content": "Hello! How can I assist you today?"
},
{
"role": "user",
"content": "hi"
},
]
redis_db.set_data(redis_key, chat_memory)
獲取數據
chat_history = redis_db.get_data(redis_key)
截斷歷史(對話)
# You can choose whether to update the Redis database or
# not by specifying the 'overwrite' parameter (boolean).
data = redis_db.truncate_conversation(redis_key, overwrite=True)
cd examples/chatbot
OpenAI
API密鑰。cp env.example .env
docker-compose up -d
http://0.0.0.0:8012/docs
8012/docs