import pandas as pd
# Prepare spans DataFrame
spans_df = pd.DataFrame([
{
"context.span_id": "span-1",
"context.trace_id": "trace-1",
"name": "llm_call",
"span_kind": "LLM",
"start_time": "2024-01-15T10:00:00Z",
"end_time": "2024-01-15T10:00:02Z",
"attributes.llm.model_name": "gpt-4",
"attributes.llm.input_messages": [...],
"attributes.llm.output_messages": [...],
},
])
# Optional: include evaluations
evals_df = pd.DataFrame([
{
"context.span_id": "span-1",
"name": "Correctness",
"label": "correct",
"score": 1.0,
},
])
# Log spans
response = client.spans.log(
space_id="your-space-id",
project_name="my-llm-app",
dataframe=spans_df,
evals_dataframe=evals_df, # Optional
)
print(f"Logged {response.record_count} spans")