Skip to main content

Redis Chatgpt

This package is a useful tool specifically developed for effectively handling chat message history. This Python package's primary goal is to provide a reliable, efficient, and simple method to store chat logs in a Redis database.

redis_chatgpt makes use of Redis, a fast, efficient, and highly scalable in-memory data structure store. By organizing and preserving the chat message history in Redis, users can retrieve message history promptly and easily with the best performance.

This package is the perfect solution if you need to store and recover chat histories effortlessly from the Redis Database. With redis_chatgpt, you can streamline your chat log management tasks while becoming more productive and efficient with your resources.

Getting started

pip install redis-chatgpt

To build a simple data store:

from redis_chatgpt.manager import RedisManager

redis_db = RedisManager(host="localhost", port=6379)

Set data

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)

Get data

chat_history = redis_db.get_data(redis_key)

Truncate history(conversation)

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

Use with FastAPI Swagger

cd examples/chatbot

  1. Get your OpenAI API key here.
  2. Copy env.example .env (set fastapi webserver workers and openai api key) cp env.example .env
  3. docker-compose up -d
  4. check out : http://0.0.0.0:8012/docs

Release files for redis-chatgpt 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for redis-chatgpt 0.1.2
File Size Uploaded
redis_chatgpt-0.1.2.tar.gz 3.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for redis-chatgpt 0.1.2
File Interpreter ABI Platform
redis_chatgpt-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 7.8 kB

Release files / redis_chatgpt-0.1.2.tar.gz

Download URL redis_chatgpt-0.1.2.tar.gz
Size 3.6 kB
Tags Source
SHA-256 checksum
How to use checksums
4c1d4bcac788fc0bf2acbce9b4dd1f2def6cefd8bd6b7b403f6e876221b004c1
BLAKE2b-256 checksum
How to use checksums
82a1ec3d93147b751d437f05ca38f0cf4e7999d16e1476a086d5e2e4f431965a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.3

Release files / redis_chatgpt-0.1.2-py3-none-any.whl

Download URL redis_chatgpt-0.1.2-py3-none-any.whl
Size 4.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3b83a81c9fbeaf514f04b55c8706f4a0c57c0693906ec2ee6d7b3146010fb793
BLAKE2b-256 checksum
How to use checksums
83fdd1198b768872dfe03eeb26dea3d60c8c6a70ae37357a8a3fd781b01ca915
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.3

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page