Datasets:
Download client/call_server.py from jingene/CMESpectrumBench: direct link, hf CLI and curl.
- Browser
- Download file 1.41 kB
-
https://huggingface.co/datasets/jingene/CMESpectrumBench/resolve/main/client/call_server.py
- Command line
-
hf download hf://datasets/jingene/CMESpectrumBench/client/call_server.py
-
curl -L -o call_server.py https://huggingface.co/datasets/jingene/CMESpectrumBench/resolve/main/client/call_server.py
1.41 kB
| import requests | |
| import time | |
| BASE_URL = # your_URL_here | |
| def run(models, prompts, titles, num_elems, num_repeats=1): | |
| payload = { | |
| "models": models, | |
| "prompts": prompts, | |
| "titles": titles, | |
| "num_elems": num_elems, | |
| "num_repeats": num_repeats | |
| } | |
| r = requests.post(f"{BASE_URL}/run", json=payload) | |
| return r.json() | |
| def run_with_code_interpreter(models, prompts, titles, num_elems, file_paths_per_question, num_repeats=1): | |
| """ | |
| Run queries with code interpreter enabled and file access. | |
| Args: | |
| models: List of model names | |
| prompts: List of prompts/questions | |
| titles: List of question titles | |
| num_elems: List of expected return lengths (0 for scalar, >0 for array) | |
| file_paths_per_question: List of lists - each inner list contains file paths for that question | |
| num_repeats: Number of repeats (int or nested list) | |
| """ | |
| payload = { | |
| "models": models, | |
| "prompts": prompts, | |
| "titles": titles, | |
| "num_elems": num_elems, | |
| "file_paths_per_question": file_paths_per_question, | |
| "num_repeats": num_repeats | |
| } | |
| r = requests.post(f"{BASE_URL}/run_with_code_interpreter", json=payload) | |
| return r.json() | |
| def status(): | |
| r = requests.get(f"{BASE_URL}/status") | |
| return r.json() | |
| def cancel(): | |
| r = requests.post(f"{BASE_URL}/cancel") | |
| return r.json() | |