Skip to main content

ClickHouse chat storage + optional summarizer (bring-your-own-LLM)

Project description

Craydel Database Wrapper

Craydel Database Wrapper is a lightweight Python SDK for storing, retrieving, and managing student–counsellor chat data in ClickHouse.
It also includes AI-powered conversation summarization to make student profiles easier to understand and hand over between advisors.


Installation

Install the required dependencies:

pip install craydel-database-wrapper

## With ClickHouse driver
pip install craydel-database-wrapper[clickhouse]

## With LLM summarizer support (Vertex AI + DSPy)
pip install craydel-database-wrapper[llm]

## With both ClickHouse + LLM support
pip install craydel-database-wrapper[clickhouse,llm]

Usage

import os
from clickhouse_connect import get_client

class MyClickhouseHelper:
    def __init__(self):
        self.client = get_client(
            host=os.getenv("CLICKHOUSE_HOST", "localhost"),
            port=int(os.getenv("CLICKHOUSE_PORT", "8123")),
            username=os.getenv("CLICKHOUSE_USER", "default"),
            password=os.getenv("CLICKHOUSE_PASSWORD", ""),
            database=os.getenv("CLICKHOUSE_DATABASE", "default"),
        )

    def insert(self, table, rows, column_names):
        self.client.insert(table, rows, column_names=column_names)

    def query(self, sql, parameters=None):
        q = self.client.query(sql, parameters=parameters)
        return q  # has .result_rows and .column_names

    def command(self, sql, parameters=None):
        self.client.command(sql, parameters=parameters)

Insert and fetch chats

from craydel_database_wrapper import ChatService
from datetime import datetime

db = MyClickhouseHelper()
chat = ChatService(db)

# Insert a chat message
chat.insert_chat_message(
    session_id="12345",
    speaker="Student",
    message="I want to study in Canada",
    chat_details="Web",
    message_id="msg_001",
    created_at=datetime.utcnow(),
)

# Fetch last messages
last_messages = chat.get_last_messages("12345")
print("Last messages:", last_messages)

Summarize a conversation

from craydel_database_wrapper.services.chat_summarizer.summarizer import StudentConversationProcessor

summarizer = StudentConversationProcessor()
summarizer.process("12345")

print("✅ Conversation summarized and saved to ClickHouse")

env

CLICKHOUSE_DATABASE=
CLICKHOUSE_HOST=
CLICKHOUSE_USER=
CLICKHOUSE_PASSWORD=
CLICKHOUSE_PORT=8123

# Only required if using LLM summarizer
GOOGLE_APPLICATION_CREDENTIALS=/path/to/google-credentials.json
VERTEX_MODEL=
VERTEX_PROJECT_ID=
VERTEX_LOCATION=

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

craydel_database_wrapper-0.0.7.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

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

craydel_database_wrapper-0.0.7-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file craydel_database_wrapper-0.0.7.tar.gz.

File metadata

File hashes

Hashes for craydel_database_wrapper-0.0.7.tar.gz
Algorithm Hash digest
SHA256 db6bd5ea202bc314a23dc78a594e8193361c0b5e0cb5c64331a9d86b329550d6
MD5 10e3628ce896ebd1a48e03bc2cd4714c
BLAKE2b-256 e0273d992acd53ae6089174189b85d657e7a13147d5f1bab42c419c9a1054918

See more details on using hashes here.

File details

Details for the file craydel_database_wrapper-0.0.7-py3-none-any.whl.

File metadata

File hashes

Hashes for craydel_database_wrapper-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 53a70d7dfae341fa35c26f71e2e666af665f8b0aa67239a3221cc65fbaabccca
MD5 46feb96a1ee19b09f4d335dfd44df726
BLAKE2b-256 556043f9148d42128b6601af391425c3eb61aeea476ce936b5b8e6fbc9f4a273

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