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

Uploaded Python 3

File details

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

File metadata

  • Download URL: craydel_database_wrapper-0.0.3.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.3.tar.gz
Algorithm Hash digest
SHA256 d439396671647c5e987916f1f4ab7afec87e595af85e60efd739475822c6f5d8
MD5 94d3347753d85deac22a93e130da39ac
BLAKE2b-256 bca53e0359d98f95d299dc28708cdaa1f704342e8648010b8feb276b50ba9876

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for craydel_database_wrapper-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 48f3e177f1ba86457fc0016a1ce5010fd0b4c92739b3d82898acdc5db894dfc4
MD5 f749bf38c528d8a2711e95f9f7990088
BLAKE2b-256 bb5802a774b584c2d08d48aab7f8df1fbbf0e92ed06a32cbc04845a136430701

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