opik
opik copied to clipboard
Local Deployment is wrong
Bug: Trace URL from console output results in a 404 "Trace ID not found" error
Describe the bug
When running code instrumented with opik and using a custom OPIK_URL_OVERRIDE, the trace URL printed to the console leads to a 404 error page stating "Trace id: ... not found" when visited.
To Reproduce Steps to reproduce the behavior:
- Set the
OPIK_URL_OVERRIDEenvironment variable (e.g.,export OPIK_URL_OVERRIDE="http://myserver:9094/api"or set it within the script). - Run the following Python script:
import os, openai import httpx from opik import track import opik # Ensure opik is imported to recognize the env var if set globally # Set the override if not done via environment variable os.environ["OPIK_URL_OVERRIDE"] = "http://myserver:9094/api" client = openai.OpenAI(http_client=httpx.Client( verify=False )) @track def retrieve_context(input_text): return [ "What specific information are you looking for?", "How can I assist you with your interests today?", "Are there any topics you'd like to explore or learn more about?", ] @track def generate_response(input_text, context): full_prompt = f'If the user asks a question that is not specific, use the context to provide a relevant response.\nContext: {", ".join(context)}\nUser: {input_text}\nAI:' response = client.chat.completions.create( model="gpt-3.5-turbo", messages=[{"role": "user", "content": full_prompt}] ) return response.choices[0].message.content context = retrieve_context("Hi how are you?") print(generate_response("Hi how are you?", context)) - The script outputs a message similar to this:
OPIK: Started logging traces to the "Default Project" project at http://myserver:9094/api/v1/session/redirect/projects/?trace_id=0196ebd9-6924-7a0f-a3e8-1b43eba331e2&path=aHR0cDovLzEwLjI0OC4yMzYuNDE6OTA5NC9hcGk=. Hello! I'm here to assist you with any specific information or interests you may have. Let me know how I can help! - Copy the URL provided (e.g.,
http://myserver:9094/api/v1/session/redirect/projects/?trace_id=0196ebd9-6924-7a0f-a3e8-1b43eba331e2&path=...) and open it in a browser.
Expected behavior The URL should open and display the traces for the executed code on the OPIK server.
Actual behavior The browser displays a JSON response indicating a 404 error:
{"code":404,"message":"Trace id: 0196ebd1-0ff9-73db-8d1e-b465bf65f1ce not found"}
Screenshots/Logs
- Console Output:
OPIK: Started logging traces to the "Default Project" project at http://myserver:9094/api/v1/session/redirect/projects/?trace_id=0196ebd9-6924-7a0f-a3e8-1b43eba331e2&path=aHR0cDovLzEwLjI0OC4yMzYuNDE6OTA5NC9hcGk=. Hello! I'm here to assist you with any specific information or interests you may have. Let me know how I can help! - Browser Response (when visiting the link):
{"code":404,"message":"Trace id: 0196ebd1-0ff9-73db-8d1e-b465bf65f1ce not found"}
Important Observation:
It appears the trace_id in the console output (0196ebd9-6924-7a0f-a3e8-1b43eba331e2) is different from the trace_id mentioned in the 404 error message (0196ebd1-0ff9-73db-8d1e-b465bf65f1ce). This might be a key factor in the issue.
Additional context
My OPIK server is running at http://myserver:9094. The API endpoint seems to be /api.
The issue occurs consistently with the provided script.
Thank you for looking into this!
Hey @cuongnguyengit , thanks for reporting this issue, we're looking into it!
Hi @cuongnguyengit!
Instead of setting the environment variable directly, could you please try to run in CLI opik configure (follow the instructions) and then share opik healthcheck output if it doesn't help?
hey @cuongnguyengit has it helped?
Thank you for your question! Since the original query has been answered, we are closing this issue. If you have any further questions or need additional clarification, please feel free to reopen the issue at any time. We're happy to help!