refactor: simplify Codex URL handling by removing unnecessary function
This commit is contained in:
parent
fc67d11da9
commit
51f97efcb8
@ -12,7 +12,7 @@ import httpx
|
|||||||
from oauth_cli_kit import get_token as get_codex_token
|
from oauth_cli_kit import get_token as get_codex_token
|
||||||
from nanobot.providers.base import LLMProvider, LLMResponse, ToolCallRequest
|
from nanobot.providers.base import LLMProvider, LLMResponse, ToolCallRequest
|
||||||
|
|
||||||
DEFAULT_CODEX_BASE_URL = "https://chatgpt.com/backend-api"
|
DEFAULT_CODEX_URL = "https://chatgpt.com/backend-api/codex/responses"
|
||||||
DEFAULT_ORIGINATOR = "nanobot"
|
DEFAULT_ORIGINATOR = "nanobot"
|
||||||
|
|
||||||
|
|
||||||
@ -53,7 +53,7 @@ class OpenAICodexProvider(LLMProvider):
|
|||||||
if tools:
|
if tools:
|
||||||
body["tools"] = _convert_tools(tools)
|
body["tools"] = _convert_tools(tools)
|
||||||
|
|
||||||
url = _resolve_codex_url(DEFAULT_CODEX_BASE_URL)
|
url = DEFAULT_CODEX_URL
|
||||||
|
|
||||||
try:
|
try:
|
||||||
try:
|
try:
|
||||||
@ -84,15 +84,6 @@ def _strip_model_prefix(model: str) -> str:
|
|||||||
return model
|
return model
|
||||||
|
|
||||||
|
|
||||||
def _resolve_codex_url(base_url: str) -> str:
|
|
||||||
raw = base_url.rstrip("/")
|
|
||||||
if raw.endswith("/codex/responses"):
|
|
||||||
return raw
|
|
||||||
if raw.endswith("/codex"):
|
|
||||||
return f"{raw}/responses"
|
|
||||||
return f"{raw}/codex/responses"
|
|
||||||
|
|
||||||
|
|
||||||
def _build_headers(account_id: str, token: str) -> dict[str, str]:
|
def _build_headers(account_id: str, token: str) -> dict[str, str]:
|
||||||
return {
|
return {
|
||||||
"Authorization": f"Bearer {token}",
|
"Authorization": f"Bearer {token}",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user