update select_language()

This commit is contained in:
Jeffrey Chu 2025-10-23 18:06:57 +08:00
parent ea944f860c
commit 349ac8f2fe
1 changed files with 41 additions and 21 deletions

View File

@ -1,5 +1,6 @@
from typing import List
import questionary import questionary
from typing import List, Optional, Tuple, Dict
from cli.models import AnalystType from cli.models import AnalystType
@ -48,7 +49,7 @@ def get_analysis_date() -> str:
date = questionary.text( date = questionary.text(
"Enter the analysis date (YYYY-MM-DD):", "Enter the analysis date (YYYY-MM-DD):",
validate=lambda x: validate_date(x.strip()) validate=lambda x: validate_date(x.strip())
or "Please enter a valid date in YYYY-MM-DD format.", or "Please enter a valid date in YYYY-MM-DD format.",
style=questionary.Style( style=questionary.Style(
[ [
("text", "fg:green"), ("text", "fg:green"),
@ -146,8 +147,10 @@ def select_shallow_thinking_agent(provider) -> str:
], ],
"openrouter": [ "openrouter": [
("Meta: Llama 4 Scout", "meta-llama/llama-4-scout:free"), ("Meta: Llama 4 Scout", "meta-llama/llama-4-scout:free"),
("Meta: Llama 3.3 8B Instruct - A lightweight and ultra-fast variant of Llama 3.3 70B", "meta-llama/llama-3.3-8b-instruct:free"), ("Meta: Llama 3.3 8B Instruct - A lightweight and ultra-fast variant of Llama 3.3 70B",
("google/gemini-2.0-flash-exp:free - Gemini Flash 2.0 offers a significantly faster time to first token", "google/gemini-2.0-flash-exp:free"), "meta-llama/llama-3.3-8b-instruct:free"),
("google/gemini-2.0-flash-exp:free - Gemini Flash 2.0 offers a significantly faster time to first token",
"google/gemini-2.0-flash-exp:free"),
], ],
"ollama": [ "ollama": [
("llama3.1 local", "llama3.1"), ("llama3.1 local", "llama3.1"),
@ -212,7 +215,8 @@ def select_deep_thinking_agent(provider) -> str:
], ],
"openrouter": [ "openrouter": [
("DeepSeek V3 - a 685B-parameter, mixture-of-experts model", "deepseek/deepseek-chat-v3-0324:free"), ("DeepSeek V3 - a 685B-parameter, mixture-of-experts model", "deepseek/deepseek-chat-v3-0324:free"),
("Deepseek - latest iteration of the flagship chat model family from the DeepSeek team.", "deepseek/deepseek-chat-v3-0324:free"), ("Deepseek - latest iteration of the flagship chat model family from the DeepSeek team.",
"deepseek/deepseek-chat-v3-0324:free"),
], ],
"ollama": [ "ollama": [
("llama3.1 local", "llama3.1"), ("llama3.1 local", "llama3.1"),
@ -245,6 +249,7 @@ 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 the OpenAI api url using interactive selection."""
# Define OpenAI api options with their corresponding endpoints # Define OpenAI api options with their corresponding endpoints
@ -283,16 +288,31 @@ def select_llm_provider() -> tuple[str, str]:
return display_name, url return display_name, url
def select_language() -> str: def select_language() -> int:
"""Select output language for agent responses.""" """Select output language for agent responses."""
choices = [ LANGUAGE_OPTIONS = [
questionary.Choice("English (default)", "en"), ("English", "en"),
questionary.Choice("Traditional Chinese", "zh-tw"), ("Traditional Chinese", "zh-tw"),
questionary.Choice("Simplified Chinese", "zh-cn"), ("Simplified Chinese", "zh-cn"),
] ]
return questionary.select(
choice = questionary.select(
"Select Output Language for Agents:", "Select Output Language for Agents:",
choices=choices, choices=[
default="en", questionary.Choice(display, value=value) for display, value in LANGUAGE_OPTIONS
style=questionary.Style([("selected", "fg:cyan noinherit")]) ],
).ask() or "en" # Default to 'en' if None instruction="\n- Use arrow keys to navigate\n- Press Enter to select",
style=questionary.Style(
[
("selected", "fg:yellow noinherit"),
("highlighted", "fg:yellow noinherit"),
("pointer", "fg:yellow noinherit"),
]
),
).ask()
if choice is None:
console.print("\n[red]No langauge selected. Exiting...[/red]")
exit(1)
return choice