-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Add GPT-5 to Code Eval #180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -6,10 +6,10 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
# Available models | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
AVAILABLE_MODELS = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"Claude Sonnet 4": "openrouter/anthropic/claude-sonnet-4", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"Claude Opus 4.1": "openrouter/anthropic/claude-opus-4.1", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"Qwen3-Coder": "openrouter/qwen/qwen3-coder", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"Gemini 2.5 Flash": "openrouter/google/gemini-2.5-flash", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"GPT-4.1": "openrouter/openai/gpt-4.1", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"GPT-5": "gpt-5", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -46,13 +46,22 @@ async def get_model_response_async( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
try: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
# Get streaming response from the model using LiteLLM asynchronously. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
response = await acompletion( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
model=model_mapping, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
messages=messages, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
api_key=os.getenv("OPENROUTER_API_KEY"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
max_tokens=2000, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
stream=True, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if "GPT" in model_name: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
response = await acompletion( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
model=model_mapping, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
messages=messages, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
api_key=os.getenv("OPENAI_API_KEY"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
max_completion_tokens=2000, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
stream=True, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
else: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
response = await acompletion( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
model=model_mapping, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
messages=messages, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
api_key=os.getenv("OPENROUTER_API_KEY"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
max_tokens=2000, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
stream=True, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+49
to
+64
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use max_tokens for LiteLLM acompletion; align params across routes. The GPT branch passes max_completion_tokens, which acompletion may not accept. Use max_tokens in both branches to avoid parameter mismatch and parity issues. Apply this minimal diff: - if "GPT" in model_name:
- response = await acompletion(
- model=model_mapping,
- messages=messages,
- api_key=os.getenv("OPENAI_API_KEY"),
- max_completion_tokens=2000,
- stream=True,
- )
+ if "GPT" in model_name:
+ response = await acompletion(
+ model=model_mapping,
+ messages=messages,
+ api_key=os.getenv("OPENAI_API_KEY"),
+ max_tokens=2000,
+ stream=True,
+ ) Optionally, dedupe branches by deriving api_key and calling acompletion once: - if "GPT" in model_name:
- response = await acompletion(
- model=model_mapping,
- messages=messages,
- api_key=os.getenv("OPENAI_API_KEY"),
- max_tokens=2000,
- stream=True,
- )
- else:
- response = await acompletion(
- model=model_mapping,
- messages=messages,
- api_key=os.getenv("OPENROUTER_API_KEY"),
- max_tokens=2000,
- stream=True,
- )
+ is_gpt = "GPT" in model_name
+ response = await acompletion(
+ model=model_mapping,
+ messages=messages,
+ api_key=os.getenv("OPENAI_API_KEY") if is_gpt else os.getenv("OPENROUTER_API_KEY"),
+ max_tokens=2000,
+ stream=True,
+ ) 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if not response: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
yield "Error: No response received from model" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Model catalog updates look consistent, but verify identifiers exist upstream.
"Claude Opus 4.1" and "GPT-5" entries look fine. Ensure LiteLLM recognizes these identifiers and providers as configured.
Run web checks to confirm model IDs and parameter support:
If needed, I can adjust the mapping to provider-qualified IDs (e.g., openai/gpt-5) or add a fallback route.
🌐 Web query:
💡 Result:
Short answer: Yes — LiteLLM supports GPT‑5 model IDs (e.g. "openai/gpt-5" or "azure/gpt-5") for its completion APIs, and for GPT‑5 you should use max_completion_tokens to control the streamed completion length (LiteLLM will also accept max_tokens and map it to max_completion_tokens for GPT‑5, but passing max_completion_tokens is clearer/explicit). (docs.litellm.ai)
Quick notes and example:
Example (Python):
from litellm import completion
resp = completion(
model="openai/gpt-5",
messages=[{"role":"user","content":"Write a short summary of X."}],
stream=True,
max_completion_tokens=250
)
for chunk in resp:
print(chunk.choices[0].delta)
If you want, tell me which provider/model string you’re using (openai/…, azure/…, or bare "gpt-5") and I’ll give a tailored snippet and confirm the exact param mapping for your LiteLLM version.
Citations:
🌐 Web query:
💡 Result:
Short answer: No. The valid Anthropic Opus identifier on OpenRouter via LiteLLM uses the Claude 3 naming, e.g., openrouter/anthropic/claude-3-opus-20240229, not “claude-opus-4.1.”[1][3]
Details:
Recommendation:
Citations:
Fix invalid LiteLLM model identifiers and use explicit max_completion_tokens
Please update the model mapping in
code-model-comparison/model_service.py
and streaming calls as follows:In the AVAILABLE_MODELS mapping (lines 9–13):
In your GPT-5 streaming completion branches (around lines 49–64):
• Replace any usage of
max_tokens
withmax_completion_tokens
to explicitly set the streamed token cap (LiteLLM will mapmax_tokens
→max_completion_tokens
but explicit is clearer).These changes ensure LiteLLM recognizes both model IDs and correctly applies the streaming token limit.
🤖 Prompt for AI Agents