Log conversations

You can log chat conversations to the Opik platform and track the full conversations your users are having with your chatbot.

Logging conversations

You can log chat conversations by specifying the thread_id parameter when using either the low level SDK or Python decorators:

1import opik
2from opik import opik_context
3
4@opik.track
5def chat_message(input, thread_id):
6 opik_context.update_current_trace(
7 thread_id=thread_id
8 )
9 return "Opik is an Open Source GenAI platform"
10
11thread_id = "f174a"
12chat_message("What is Opik ?", thread_id)
13chat_message("Repeat the previous message", thread_id)

The input to each trace will be displayed as the user message while the output will be displayed as the AI assistant response.

Reviewing conversations

Conversations can be viewed at a project level in the threads tab. All conversations are tracked and by clicking on the thread ID you will be able to view the full conversation.

The thread view supports markdown making it easier for you to review the content that was returned to the user. If you would like to dig in deeper, you can click on the View trace button to deepdive into how the AI assistant response was generated.

By clicking on the thumbs up or thumbs down icons, you can quickly rate the AI assistant response. This feedback score will be logged and associated to the relevant trace. By switching to the trace view, you can review the full trace as well as add additional feedback scores through the annotation functionality.