Scale3-Labs / langtrace

Langtrace 🔍 is an open-source, Open Telemetry based end-to-end observability tool for LLM applications, providing real-time tracing, evaluations and metrics for popular LLMs, LLM frameworks, vectorDBs and more.. Integrate using Typescript, Python. 🚀💻📊
https://langtrace.ai
GNU Affero General Public License v3.0
555 stars 55 forks source link

User feedback not showing up on UI #346

Open lpearl opened 2 hours ago

lpearl commented 2 hours ago

User feedback is sent to a trace but does not show up in annotations.

The cloud version shows the traces without userid or feedback and self-hosted does not even show the traces.

If it were to work, would it be possible to show the trend of user feedback overall or by user?

When resending user feedback {"error":"Evaluation already exists for this span"} which shows it's being sent successfully.

karthikscale3 commented 2 hours ago

Hi @lpearl - just to double check, could you confirm if you are following the steps in this doc for sending user feedback - https://docs.langtrace.ai/tracing/trace_user_feedback#understanding-user-feedback ?

And regarding showing trends, thats a good idea. we can certainly implement that.

lpearl commented 2 hours ago

Hi @lpearl - just to double check, could you confirm if you are following the steps in this doc for sending user feedback - https://docs.langtrace.ai/tracing/trace_user_feedback#understanding-user-feedback ?

And regarding showing trends, thats a good idea. we can certainly implement that.

Yes, I have followed the documentation, although my implementation is slightly different. Since i'm sending the feedback after the traces is returned. I have tried using the example code in the documentation and got the same result.

Note the traces under annotations are not showing up in selfhosted but they show up in the traces tab. The cloud shows up in annotations but also does not show feedback.

from dotenv import load_dotenv
from openai import OpenAI
from langtrace_python_sdk import langtrace, with_langtrace_root_span, SendUserFeedback

load_dotenv()

# Initialize Langtrace SDK
langtrace.init()
client = OpenAI()

def api(span_id, trace_id):
    response = client.chat.completions.create(
        model="gpt-4o-mini",
        messages=[
            {"role": "user", "content": "What is the best place to live in the US?"},
        ],
        stream=False,
    )

    # Collect user feedback and send it to Langtrace
    user_score = 1  # Example user score
    user_id = 'user_1234'  # Example user ID
    data = {
        "userScore": user_score,
        "userId": user_id,
        "spanId": span_id,
        "traceId": trace_id
    }
    SendUserFeedback().evaluate(data=data)

    # Return the response
    return response.choices[0].message.content

# wrap the API call with the Langtrace root span
wrapped_api = with_langtrace_root_span()(api)

# Call the wrapped API
wrapped_api()

Screenshot 2024-11-15 at 11 53 19 AM