Skip to main content

ClickHouse chat storage + optional AI summarizer

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

# Use your custom ClickHouse helper
db = MyClickhouseHelper()
chat = ChatService(db)

# Insert a new 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(),
)

# Retrieve last messages in the session
last_messages = chat.get_last_messages(session_id="12345")
print("Last messages:", last_messages)

Summarize a conversation

from craydel_database_wrapper.services.chat_summarizer import StudentConversationProcessor

summarizer = StudentConversationProcessor()

# Run summarizer for a given session
summarizer.process("12345")

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

env

CLICKHOUSE_DATABASE=
CLICKHOUSE_HOST=
CLICKHOUSE_USER=
CLICKHOUSE_PASSWORD=
CLICKHOUSE_PORT=8123

GOOGLE_APPLICATION_CREDENTIALS=(google credential 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.2.tar.gz (10.0 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.2-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: craydel_database_wrapper-0.0.2.tar.gz
  • Upload date:
  • Size: 10.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for craydel_database_wrapper-0.0.2.tar.gz
Algorithm Hash digest
SHA256 443d095190360e125fac26233d86b3e728700a11ffbfbab437d74fa2ccdf9af7
MD5 651edd8dd6d8460ce9c51a86a3cfe92d
BLAKE2b-256 25f150efce235cd0ca0fa9a86a63ece478ffbc3a650edffc90a1a564ce51ff1f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for craydel_database_wrapper-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1e23f5ec8769bdf68a7ce0449c0190ac197344a2e4ef9fde20632712cccbbedc
MD5 f1f55679b7d9c05ee6c795c314c54593
BLAKE2b-256 a2330d40c1326fcb58d1e67ecd7a063e2472b29aa882b16c5ace992e9a8cd93c

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