-
Notifications
You must be signed in to change notification settings - Fork 110
Expand file tree
/
Copy pathquery.py
More file actions
29 lines (22 loc) · 944 Bytes
/
query.py
File metadata and controls
29 lines (22 loc) · 944 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from datasets import load_dataset
import requests
# Hugging Face dataset name for the index
INDEX_DATASET = "your_username/agent_traces_index"
# Function to query traces based on LLM and benchmark
def query_traces(llm=None, benchmark=None):
dataset = load_dataset(INDEX_DATASET, split="train")
df = dataset.to_pandas()
if llm:
df = df[df["llm"] == llm]
if benchmark:
df = df[df["benchmark"] == benchmark]
return df[["exp_id", "study_name", "trace_pointer"]].to_dict(orient="records")
# Function to download a trace based on exp_id
def download_trace(exp_id: str, save_path: str):
dataset = load_dataset(INDEX_DATASET, split="train")
df = dataset.to_pandas()
trace_url = df[df["exp_id"] == exp_id]["trace_pointer"].values[0]
response = requests.get(trace_url)
with open(save_path, "wb") as f:
f.write(response.content)
print(f"Downloaded trace {exp_id} to {save_path}")