Using Opik with Predibase
This notebook demonstrates how to use Predibase as an LLM provider with LangChain, and how to integrate Opik for tracking and logging.
Setup
First, let’s install the necessary packages and set up our environment variables.
We will now configure Opik and Predibase:
Creating the Opik Tracer
In order to log traces to Opik, we will be using the OpikTracer from the LangChain integration.
Initial Call
Let’s set up our Predibase model and make an initial call.
In addition to passing the OpikTracer to the invoke method, you can also define it during the creation of the Predibase
object:
SequentialChain
Now, let’s create a more complex chain and run it with Opik tracing.
Accessing Logged Traces
We can access the trace IDs collected by the Opik tracer.
Fine-tuned LLM Example
Finally, let’s use a fine-tuned model with Opik tracing.
Note: In order to use a fine-tuned model, you will need to have access to the model and the correct model ID. The code below will return a NotFoundError
unless the model
and adapter_id
are updated.