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.4.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.4-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: craydel_database_wrapper-0.0.4.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.4.tar.gz
Algorithm Hash digest
SHA256 08bfcc32def79ab776522fa95dadf69422b9cbec6170ae34292c4cbef871de82
MD5 7630e05feadba703d5e5136c03165dde
BLAKE2b-256 775fee6e6fc1b61edbf8dee70d84bb6bdd96f0c261bd09b603452c6ebfc96a08

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for craydel_database_wrapper-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 e629fde2e538b9b5007d1abdcc4b6859d80c19acab0c9382d1558bd1e35ba421
MD5 1917dabce075ed5a47b550512c914d9d
BLAKE2b-256 0ec28b194829df58c4812bf9408c795b93004833d99798a27bf2399d98fdf1bf

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