Skip to main content
POST
/
ragas
/
context_precision
/
evaluate
import langwatch

df = langwatch.datasets.get_dataset("dataset-id").to_pandas()

experiment = langwatch.experiment.init("my-experiment")

for index, row in experiment.loop(df.iterrows()):
# your execution code here
experiment.evaluate(
"ragas/context_precision",
index=index,
data={
"contexts": row["contexts"],
"expected_contexts": row["expected_contexts"],
},
settings={}
)
[
  {
    "status": "processed",
    "score": 123,
    "passed": true,
    "label": "<string>",
    "details": "<string>",
    "cost": {
      "currency": "<string>",
      "amount": 123
    }
  }
]

Authorizations

X-Auth-Token
string
header
required

API key for authentication

Body

application/json
contexts
string[]
required

Array of context strings used for RAG evaluation

expected_contexts
string[]
required

The expected contexts for comparison

settings
object

Response

Successful evaluation

status
enum<string>
Available options:
processed,
skipped,
error
score
number

Numeric score from the evaluation

passed
boolean

Whether the evaluation passed

label
string

Label assigned by the evaluation

details
string

Additional details about the evaluation

cost
object