Skip to main content

Package to manage chat history using PostgreSQL.

Project description



Sinapsis Chat History

Package with templates to store in sql databases the history of AI agents: store, retrieve, and manage context across conversations.

🐍 Installation🚀 Features📚 Usage example📙 Documentation🔍 License

The sinapsis-chat-history module functionality to handle history and context, saving conversations in sql-databases.

🐍 Installation

Install using your package manager of choice. We encourage the use of uv

Example with uv:

  uv pip install sinapsis-chat-history --extra-index-url https://pypi.sinapsis.tech

or with raw pip:

  pip install sinapsis-chat-history --extra-index-url https://pypi.sinapsis.tech

[!IMPORTANT] Templates may require extra dependencies. For development, we recommend installing the package with all the optional dependencies:

with uv:

  uv pip install sinapsis-chat-history[all] --extra-index-url https://pypi.sinapsis.tech

or with raw pip:

  pip install sinapsis-chat-history[all] --extra-index-url https://pypi.sinapsis.tech

🚀 Features

Templates Supported

  • ChatHistoryFetcher: Template for retrieving chat histories from a storage backend.
  • ChatHistoryRemover: Template for deleting chat history records based on filters.
  • ChatHistoryReset: Performs complete reset of chat history by dropping and recreating the table.
  • ChatHistorySaver: Template for saving chat messages into the database.

[!TIP] Use CLI command sinapsis info --all-template-names to show a list with all the available Template names installed with Sinapsis Mem0.

[!TIP] Use CLI command sinapsis info --example-template-config TEMPLATE_NAME to produce an example Agent config for the Template specified in TEMPLATE_NAME.

For example, for Mem0Search use sinapsis info --example-template-config Mem0Search to produce the following example config:

agent:
  name: my_test_agent
templates:
- template_name: InputTemplate
  class_name: InputTemplate
  attributes: {}
- template_name: TextInput
  class_name: TextInput
  template_input: InputTemplate
  attributes:
    text: "this is a test message"
    id: "sinapsis-user"
    source: "1"
- template_name : ChatHistorySaver
  class_name: ChatHistorySaver
  template_input: TextInput
  attributes:
    db_config:
      db_name: "test"
      table: "chat_messages2"

📚 Usage example

The following agent retrieves all entries in the database for the given user_id and session_id

Config
agent:
  name: my_test_agent
templates:
- template_name: InputTemplate
  class_name: InputTemplate
  attributes: {}
- template_name: ChatHistoryRemover
  class_name: ChatHistoryRemover
  template_input: InputTemplate
  attributes:
    provider: postgres
    db_config:
      db_name: "test"
      table: "chat_messages"
    last_n: 10
    filters:
      user_id: Chatbot user
      session_id: 3aa8d1a4-c8a7-4367-8b20-168351f76ab9

📙 Documentation

Documentation for this and other sinapsis packages is available on the sinapsis website

Tutorials for different projects within sinapsis are available at sinapsis tutorials page

🔍 License

This project is licensed under the AGPLv3 license, which encourages open collaboration and sharing. For more details, please refer to the LICENSE file.

For commercial use, please refer to our official Sinapsis website for information on obtaining a commercial license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sinapsis_chat_history-0.1.5.tar.gz (24.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sinapsis_chat_history-0.1.5-py3-none-any.whl (26.8 kB view details)

Uploaded Python 3

File details

Details for the file sinapsis_chat_history-0.1.5.tar.gz.

File metadata

File hashes

Hashes for sinapsis_chat_history-0.1.5.tar.gz
Algorithm Hash digest
SHA256 6e1d6199c1ab5ad2dbacf29a5c05adfcc5f0a5fad263e10d26cfab9d371cb6c3
MD5 62700db9c8e472c6c02cfd6808c8d43a
BLAKE2b-256 11015da7fa61e25060a599d756508e5f178e0c16cc64a42f297eaa5d9490fe84

See more details on using hashes here.

File details

Details for the file sinapsis_chat_history-0.1.5-py3-none-any.whl.

File metadata

File hashes

Hashes for sinapsis_chat_history-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 b4dc296ca7c0aed70b03495d9f1c7fe9e4ca34d4e4d2196184a9b8035893c3b1
MD5 68e82d6e18df69d68e3cd105b6f2b176
BLAKE2b-256 65b8fc097fe8420d5af0953d77add2c7f1466927c8b67edc8ca7d2f4e15d13f4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page