Helicone / helicone

🧊 Open source LLM-Observability Platform for Developers. One-line integration for monitoring, metrics, evals, agent tracing, prompt management, playground, etc. Supports OpenAI SDK, Vercel AI SDK, Anthropic SDK, LiteLLM, LLamaIndex, LangChain, and more. 🍓 YC W23
https://www.helicone.ai
Apache License 2.0
1.97k stars 220 forks source link

[Bug]: Unable to Access Helicon Localhost URL - SyntaxError in clickhouse-migration-runner #2965

Open mohilmakwana3107 opened 1 week ago

mohilmakwana3107 commented 1 week ago

What happened?

I'm attempting to self-host Helicon on my local machine, but I can't access http://localhost:8989/project/default/auth/users. The console logs show the following error:

clickhouse-migration-runner      |   File "ch_hcone.py", line 35
clickhouse-migration-runner      |     curl_cmd = f"cat \"{migration_file}\" | curl '{
clickhouse-migration-runner      |                                                   ^
clickhouse-migration-runner      | SyntaxError: EOL while scanning string literal
clickhouse-migration-runner exited with code 1

I've checked the documentation and can't find any steps I might have missed.

Edit :

Relevant log output

No response

Twitter / LinkedIn details

No response

thiagoscodelerae commented 1 week ago

@mohilmakwana3107 You can access the Supabase auth users here: http://localhost:54323/project/default/auth/users

thiagoscodelerae commented 1 week ago

Due to the lack of migration execution, the logs are showing missing tables on Clickhouse:

helicone-web-local               |   2024-11-15T14:28:36.531Z
helicone-web-local               | ]
helicone-web-local               | ClickHouseError: Table default.request_response_rmt doesn't exist.
helicone-web-local               |     at parseError (/app/web/node_modules/@clickhouse/client/dist/error/parse_error.js:32:16)
helicone-web-local               |     at ClientRequest.onResponse (/app/web/node_modules/@clickhouse/client/dist/connection/adapter/base_http_adapter.js:127:51)
helicone-web-local               |     at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
helicone-web-local               |   code: '60',
helicone-web-local               |   type: 'UNKNOWN_TABLE'
helicone-web-local               | }
mohilmakwana3107 commented 1 week ago

@thiagoscodelerae How to solve it?

thiagoscodelerae commented 1 week ago

@mohilmakwana3107 I'm trying that right now (also want to setup self hosted Helicone). I saw some people reporting the same error on Discord.

thiagoscodelerae commented 1 week ago

Here is how I solved that.

1 - Change code ch_hcone.py from:

def run_curl_command(query, host, port, user=None, password=None, migration_file=None):

    if not query:
        curl_cmd = f"cat \"{migration_file}\" | curl '{
            get_host(host)}:{port}/' --data-binary @-"
        if user and password:
            curl_cmd = f"cat \"{migration_file}\" | curl --user '{user}:{
                password}' '{get_host(host)}:{port}/' --data-binary @-"
    else:
        curl_cmd = f"echo \"{query}\" | curl '{
            get_host(host)}:{port}/' --data-binary @-"
        if user and password:
            curl_cmd = f"echo \"{
                query}\" | curl --user '{user}:{password}' '{get_host(host)}:{port}/' --data-binary @-"

    result = subprocess.run(curl_cmd, shell=True,
                            capture_output=True, text=True)
    if (result.returncode != 0):
        print("Error running query")
        print("STDOUT:", result.stdout)
        print("STDERR:", result.stderr)
        sys.exit(1)
    return result

To:

def run_curl_command(query, host, port, user=None, password=None, migration_file=None):
    if not query:
        curl_cmd = f"cat \"{migration_file}\" | curl '{get_host(host)}:{port}/' --data-binary @-"
        if user and password:
            curl_cmd = f"cat \"{migration_file}\" | curl --user '{user}:{password}' '{get_host(host)}:{port}/' --data-binary @-"
    else:
        curl_cmd = f"echo \"{query}\" | curl '{get_host(host)}:{port}/' --data-binary @-"
        if user and password:
            curl_cmd = f"echo \"{query}\" | curl --user '{user}:{password}' '{get_host(host)}:{port}/' --data-binary @-"

    result = subprocess.run(curl_cmd, shell=True,
                            capture_output=True, text=True)
    if (result.returncode != 0):
        print("Error running query")
        print("STDOUT:", result.stdout)
        print("STDERR:", result.stderr)
        sys.exit(1)
    return result

2 - Add tabulate package as part of Dockerfile installation. I created a requirements.txt file here "helicone/clickhouse/requirements.txt" with tabulate package only.

And add the following instruction "helicone/docker/dockerfiles/dockerfile_clickhouse_migration_runner"

:::
COPY . /app
RUN find /app -name ".env.*" -exec rm {} \;

RUN pip3 install --no-cache-dir -r requirements.txt
:::

3 - Run docker compose:

docker compose up --build
mohilmakwana3107 commented 1 week ago

Ok, Thanks @thiagoscodelerae And I was the one who created that issue in discord chat.

thiagoscodelerae commented 1 week ago

@mohilmakwana3107 one more step :)

Add MINIO env vars to .env file:

MINIO_ROOT_USER=minioadminuser
MINIO_ROOT_PASSWORD=minioadminuser

You can change the value as well.

mohilmakwana3107 commented 4 days ago

Ok thanks @thiagoscodelerae

thiagoscodelerae commented 4 days ago

@mohilmakwana3107 there is now a new issue happening when sending a request to OpenAI/Helicone:

Error parsing default response: SyntaxError: Unexpected token '!', "!