feat(cli): 添加Codex OAuth支持并重构LLM提供商选择逻辑
- 在shallow和deep思考代理选项中添加Codex OAuth模型 - 重构select_llm_provider函数以返回提供商名称和URL - 更新错误消息以使用更通用的LLM术语
This commit is contained in:
parent
730cf80c99
commit
22d9d8a64a
38
cli/utils.py
38
cli/utils.py
|
|
@ -127,6 +127,12 @@ def select_shallow_thinking_agent(provider) -> str:
|
||||||
|
|
||||||
# Define shallow thinking llm engine options with their corresponding model names
|
# Define shallow thinking llm engine options with their corresponding model names
|
||||||
SHALLOW_AGENT_OPTIONS = {
|
SHALLOW_AGENT_OPTIONS = {
|
||||||
|
"codex_oauth": [
|
||||||
|
("GPT-5.4", "gpt-5.4"),
|
||||||
|
("GPT-5.2", "gpt-5.2"),
|
||||||
|
("GPT-5.3-Codex", "gpt-5.3-codex"),
|
||||||
|
("GPT-5.2-Codex", "gpt-5.2-codex"),
|
||||||
|
],
|
||||||
"openai": [
|
"openai": [
|
||||||
("GPT-5 Mini - Cost-optimized reasoning", "gpt-5-mini"),
|
("GPT-5 Mini - Cost-optimized reasoning", "gpt-5-mini"),
|
||||||
("GPT-5 Nano - Ultra-fast, high-throughput", "gpt-5-nano"),
|
("GPT-5 Nano - Ultra-fast, high-throughput", "gpt-5-nano"),
|
||||||
|
|
@ -192,6 +198,12 @@ def select_deep_thinking_agent(provider) -> str:
|
||||||
|
|
||||||
# Define deep thinking llm engine options with their corresponding model names
|
# Define deep thinking llm engine options with their corresponding model names
|
||||||
DEEP_AGENT_OPTIONS = {
|
DEEP_AGENT_OPTIONS = {
|
||||||
|
"codex_oauth": [
|
||||||
|
("GPT-5.4", "gpt-5.4"),
|
||||||
|
("GPT-5.2", "gpt-5.2"),
|
||||||
|
("GPT-5.3-Codex", "gpt-5.3-codex"),
|
||||||
|
("GPT-5.2-Codex", "gpt-5.2-codex"),
|
||||||
|
],
|
||||||
"openai": [
|
"openai": [
|
||||||
("GPT-5.2 - Latest flagship", "gpt-5.2"),
|
("GPT-5.2 - Latest flagship", "gpt-5.2"),
|
||||||
("GPT-5.1 - Flexible reasoning", "gpt-5.1"),
|
("GPT-5.1 - Flexible reasoning", "gpt-5.1"),
|
||||||
|
|
@ -253,22 +265,22 @@ def select_deep_thinking_agent(provider) -> str:
|
||||||
return choice
|
return choice
|
||||||
|
|
||||||
def select_llm_provider() -> tuple[str, str]:
|
def select_llm_provider() -> tuple[str, str]:
|
||||||
"""Select the OpenAI api url using interactive selection."""
|
"""Select LLM provider and backend URL using interactive selection."""
|
||||||
# Define OpenAI api options with their corresponding endpoints
|
|
||||||
BASE_URLS = [
|
BASE_URLS = [
|
||||||
("OpenAI", "https://api.openai.com/v1"),
|
("Codex OAuth (ChatGPT Plus/Pro)", "codex_oauth", "https://chatgpt.com/backend-api"),
|
||||||
("Google", "https://generativelanguage.googleapis.com/v1"),
|
("OpenAI", "openai", "https://api.openai.com/v1"),
|
||||||
("Anthropic", "https://api.anthropic.com/"),
|
("Google", "google", "https://generativelanguage.googleapis.com/v1"),
|
||||||
("xAI", "https://api.x.ai/v1"),
|
("Anthropic", "anthropic", "https://api.anthropic.com/"),
|
||||||
("Openrouter", "https://openrouter.ai/api/v1"),
|
("xAI", "xai", "https://api.x.ai/v1"),
|
||||||
("Ollama", "http://localhost:11434/v1"),
|
("Openrouter", "openrouter", "https://openrouter.ai/api/v1"),
|
||||||
|
("Ollama", "ollama", "http://localhost:11434/v1"),
|
||||||
]
|
]
|
||||||
|
|
||||||
choice = questionary.select(
|
choice = questionary.select(
|
||||||
"Select your LLM Provider:",
|
"Select your LLM Provider:",
|
||||||
choices=[
|
choices=[
|
||||||
questionary.Choice(display, value=(display, value))
|
questionary.Choice(display, value=(display, provider, value))
|
||||||
for display, value in BASE_URLS
|
for display, provider, value in BASE_URLS
|
||||||
],
|
],
|
||||||
instruction="\n- Use arrow keys to navigate\n- Press Enter to select",
|
instruction="\n- Use arrow keys to navigate\n- Press Enter to select",
|
||||||
style=questionary.Style(
|
style=questionary.Style(
|
||||||
|
|
@ -281,13 +293,13 @@ def select_llm_provider() -> tuple[str, str]:
|
||||||
).ask()
|
).ask()
|
||||||
|
|
||||||
if choice is None:
|
if choice is None:
|
||||||
console.print("\n[red]no OpenAI backend selected. Exiting...[/red]")
|
console.print("\n[red]No LLM backend selected. Exiting...[/red]")
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
display_name, url = choice
|
display_name, provider_name, url = choice
|
||||||
print(f"You selected: {display_name}\tURL: {url}")
|
print(f"You selected: {display_name}\tURL: {url}")
|
||||||
|
|
||||||
return display_name, url
|
return provider_name, url
|
||||||
|
|
||||||
|
|
||||||
def ask_openai_reasoning_effort() -> str:
|
def ask_openai_reasoning_effort() -> str:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue