forked from JoelNiklaus/evaluate-idk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_eval.py
More file actions
34 lines (25 loc) · 1.12 KB
/
run_eval.py
File metadata and controls
34 lines (25 loc) · 1.12 KB
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
29
30
31
32
33
import litellm
from lighteval.__main__ import app
# Monkeypatch litellm.completion to handle custom model names with reasoning effort suffixes
# e.g. "model-high" -> model="model", reasoning_effort="high"
original_completion = litellm.completion
def patched_completion(*args, **kwargs):
# Check if model name contains reasoning effort suffix
if "model" in kwargs:
model_name = kwargs["model"]
# Defined reasoning efforts supported by OpenRouter/LiteLLM
efforts = ["high", "medium", "low", "minimal", "none"]
for effort in efforts:
suffix = f"-{effort}"
if model_name.endswith(suffix):
# Strip the suffix to get the real model name
real_model_name = model_name[:-len(suffix)]
# Update kwargs
kwargs["model"] = real_model_name
if "reasoning_effort" not in kwargs:
kwargs["reasoning_effort"] = effort
break # Stop checking other efforts
return original_completion(*args, **kwargs)
litellm.completion = patched_completion
if __name__ == "__main__":
app()