feat: add chatgpt oauth client for codex routing (#8774)
* base * refresh * use default model fallback * patch * streaming * generate
This commit is contained in:
@@ -2,6 +2,9 @@ import json
|
||||
from typing import AsyncGenerator, List
|
||||
|
||||
from letta.adapters.letta_llm_stream_adapter import LettaLLMStreamAdapter
|
||||
from letta.log import get_logger
|
||||
|
||||
logger = get_logger(__name__)
|
||||
from letta.helpers.datetime_helpers import get_utc_timestamp_ns
|
||||
from letta.interfaces.anthropic_parallel_tool_call_streaming_interface import SimpleAnthropicStreamingInterface
|
||||
from letta.interfaces.gemini_streaming_interface import SimpleGeminiStreamingInterface
|
||||
@@ -75,12 +78,22 @@ class SimpleLLMStreamAdapter(LettaLLMStreamAdapter):
|
||||
run_id=self.run_id,
|
||||
step_id=step_id,
|
||||
)
|
||||
elif self.llm_config.model_endpoint_type in [ProviderType.openai, ProviderType.deepseek, ProviderType.zai]:
|
||||
elif self.llm_config.model_endpoint_type in [
|
||||
ProviderType.openai,
|
||||
ProviderType.deepseek,
|
||||
ProviderType.zai,
|
||||
ProviderType.chatgpt_oauth,
|
||||
]:
|
||||
# Decide interface based on payload shape
|
||||
use_responses = "input" in request_data and "messages" not in request_data
|
||||
# No support for Responses API proxy
|
||||
is_proxy = self.llm_config.provider_name == "lmstudio_openai"
|
||||
|
||||
# ChatGPT OAuth always uses Responses API format
|
||||
if self.llm_config.model_endpoint_type == ProviderType.chatgpt_oauth:
|
||||
use_responses = True
|
||||
is_proxy = False
|
||||
|
||||
if use_responses and not is_proxy:
|
||||
self.interface = SimpleOpenAIResponsesStreamingInterface(
|
||||
is_openai_proxy=False,
|
||||
@@ -109,9 +122,6 @@ class SimpleLLMStreamAdapter(LettaLLMStreamAdapter):
|
||||
else:
|
||||
raise ValueError(f"Streaming not supported for provider {self.llm_config.model_endpoint_type}")
|
||||
|
||||
# Extract optional parameters
|
||||
# ttft_span = kwargs.get('ttft_span', None)
|
||||
|
||||
# Start the streaming request (map provider errors to common LLMError types)
|
||||
try:
|
||||
# Gemini uses async generator pattern (no await) to maintain connection lifecycle
|
||||
|
||||
Reference in New Issue
Block a user