Production Monitoring
Opik has been designed from the ground up to support high volumes of traces making it the ideal tool for monitoring your production LLM applications.
You can use the Opik dashboard to review your feedback scores, trace count and tokens over time at both a daily and hourly granularity.
In addition to viewing scores over time, you can also view the average feedback scores for all the traces in your project from the traces table.
Logging feedback scores
To monitor the performance of your LLM application, you can log feedback scores using the Python SDK and through the UI.
Logging feedback scores alongside traces
Feedback scores can be logged while you are logging traces:
from opik import track, opik_context
@track
def llm_chain(input_text):
# LLM chain code
# ...
# Update the trace
opik_context.update_current_trace(
feedback_scores=[
{"name": "user_feedback", "value": 1.0, "reason": "The response was helpful and accurate."}
]
)
Updating traces with feedback scores
You can also update traces with feedback scores after they have been logged. For this we are first going to fetch all the traces using the search API and then update the feedback scores for the traces we want to annotate.
Fetching traces using the search API
You can use the Opik.search_traces
method to fetch all the traces you want to annotate.
import opik
opik_client = opik.Opik()
traces = opik_client.search_traces(
project_name="Default Project",
start_time="2024-01-01",
end_time="2025-01-01",
)
The search_traces
method allows you to fetch traces based on any of trace attributes, you can learn more about the different search parameters in the search traces documentation.
Updating feedback scores
Once you have fetched the traces you want to annotate, you can update the feedback scores using the Opik.log_traces_feedback_scores
method.
for trace in traces:
opik_client.log_traces_feedback_scores(
project_name="Default Project",
trace_ids=[i.id],
feedback_scores=[{"name": "user_feedback", "value": 1.0, "reason": "The response was helpful and accurate."}],
)
You will now be able to see the feedback scores in the Opik dashboard and track the changes over time.