mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-08 03:01:47 +00:00
fix: use max_completion_tokens for GitHub Copilot
This commit is contained in:
parent
d12be46df8
commit
f648c2e3aa
4 changed files with 38 additions and 3 deletions
12
run_agent.py
12
run_agent.py
|
|
@ -2852,6 +2852,16 @@ class AIAgent:
|
|||
url = getattr(self, "_base_url_lower", "") or ""
|
||||
return "openai.azure.com" in url
|
||||
|
||||
def _is_github_copilot_url(self, base_url: str = None) -> bool:
|
||||
"""Return True when a base URL targets GitHub Copilot's OpenAI-compatible API."""
|
||||
if base_url is not None:
|
||||
hostname = base_url_hostname(base_url)
|
||||
else:
|
||||
hostname = getattr(self, "_base_url_hostname", "") or base_url_hostname(
|
||||
getattr(self, "_base_url_lower", "")
|
||||
)
|
||||
return hostname == "api.githubcopilot.com"
|
||||
|
||||
def _resolved_api_call_timeout(self) -> float:
|
||||
"""Resolve the effective per-call request timeout in seconds.
|
||||
|
||||
|
|
@ -3047,7 +3057,7 @@ class AIAgent:
|
|||
OpenAI-compatible endpoint. OpenRouter, local models, and older
|
||||
OpenAI models use 'max_tokens'.
|
||||
"""
|
||||
if self._is_direct_openai_url() or self._is_azure_openai_url():
|
||||
if self._is_direct_openai_url() or self._is_azure_openai_url() or self._is_github_copilot_url():
|
||||
return {"max_completion_tokens": value}
|
||||
return {"max_tokens": value}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue