diff --git a/docker-compose.yml b/docker-compose.yml index 814677735..a42e3a873 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,6 +8,8 @@ services: - "4000:4000" environment: - AZURE_API_KEY=sk-123 + clickhouse: + image: clickhouse/clickhouse-server diff --git a/litellm/integrations/clickhouse.py b/litellm/integrations/clickhouse.py index fde831a36..c4d5f6b08 100644 --- a/litellm/integrations/clickhouse.py +++ b/litellm/integrations/clickhouse.py @@ -27,6 +27,31 @@ import litellm, uuid from litellm._logging import print_verbose, verbose_logger +def _start_clickhouse(): + import clickhouse_connect + + port = os.getenv("CLICKHOUSE_PORT") + clickhouse_host = os.getenv("CLICKHOUSE_HOST") + if clickhouse_host is not None: + print("setting up clickhouse") + if port is not None and isinstance(port, str): + port = int(port) + + client = clickhouse_connect.get_client( + host=os.getenv("CLICKHOUSE_HOST"), + port=port, + username=os.getenv("CLICKHOUSE_USERNAME"), + password=os.getenv("CLICKHOUSE_PASSWORD"), + ) + + response = client.command( + "CREATE TABLE new_table (key UInt32, value String, metric Float64) ENGINE MergeTree ORDER BY key" + ) + + +_start_clickhouse() + + class ClickhouseLogger: # Class variables or attributes def __init__(self, endpoint=None, headers=None):