Spaces:
Running
Running
Download scripts/audit_native_budget.py from Leon4gr45/needle: direct link, hf CLI and curl.
- Browser
- Download file 1.03 kB
-
https://huggingface.co/spaces/Leon4gr45/needle/resolve/main/scripts/audit_native_budget.py
- Command line
-
hf download hf://spaces/Leon4gr45/needle/scripts/audit_native_budget.py
-
curl -L -o audit_native_budget.py https://huggingface.co/spaces/Leon4gr45/needle/resolve/main/scripts/audit_native_budget.py
1.03 kB
| """Replay the captured pre-change native prompt; never execute returned calls.""" | |
| import argparse,json,time | |
| from pathlib import Path | |
| import needle | |
| def main(): | |
| p=argparse.ArgumentParser();p.add_argument('--output',default='/tmp/needle-budget-replay.json');a=p.parse_args() | |
| recorded=json.loads(Path('benchmarks/workflow/results/before-budget-probe.json').read_text()) | |
| prompt=recorded['effective_prompt'];rows=[] | |
| for budget in (512,1024,2048): | |
| agent=needle.Needle(tools=prompt['tools'],system=prompt['system'],generation=3) | |
| start=time.perf_counter();result=agent.complete(prompt['text'],max_new_tokens=budget) | |
| rows.append({'public_sdk_max_new_tokens':budget,'latency_ms':(time.perf_counter()-start)*1000,'native':result}) | |
| Path(a.output).write_text(json.dumps({'methodology':'Exact recorded pre-change native prompt; official Needle 3.0.1 default cache. Host output-budget probe, no tool execution.','effective_prompt':prompt,'rows':rows},indent=2)+'\n') | |
| if __name__=='__main__':main() | |