Cleanlab
Cleanlab’s trustworthiness score is a number from 0 to 1 for a prompt and a response. This page sends that number to cetra as a score on the trace. It is setup only: it was not run, because it needs a Cleanlab key.
Install
Section titled “Install”pip install cetra-sdk cleanlab-tlmSet up
Section titled “Set up”Set your Cleanlab key in the environment for the cleanlab-tlm client. The variable name is not given on this page; use the one the cleanlab-tlm documentation names.
Score the answer inside a span, so that the score has a trace to attach to:
import cetrafrom cleanlab_tlm import TLM
cetra.init()
tlm = TLM()prompt = "What is the capital of France?"response = "Paris."
with cetra.span("answer", input=prompt) as s: s.set_output(response) trustworthiness = tlm.get_trustworthiness_score(prompt, response) cetra.score( trace_id=cetra.current_trace_id(), name="trustworthiness", value=trustworthiness, )
cetra.flush()Set CETRA_API_KEY to your sk-cetra-… key first.
What you get
Section titled “What you get”- One score named
trustworthinesson the trace, with a value from 0 to 1, shown with the other scores of the trace. - The span
answer, with the prompt and the response as its input and output.
Limits
Section titled “Limits”- Not run: no Cleanlab key was used, so the return value is taken from the package’s reading, not observed. A batch of inputs returns a list.
- The score is written only when the span is inside a trace. Outside one, cetra does not queue it.
- Cleanlab calls its own service, so this page does not say that those calls appear as spans in the trace.