in yourbench/main.py [0:0]
def create_model_config(existing_models: list[str]) -> dict:
"""Interactive model configuration with smart provider logic."""
console.print("\n[bold cyan]Model Configuration[/bold cyan]")
model_name = Prompt.ask("Model name", default="Qwen/Qwen3-30B-A3B")
# Provider type selection
console.print("\nSelect inference type:")
console.print("1. Hugging Face Inference (default)")
console.print("2. OpenAI Compatible API (vLLM, etc.)")
console.print("3. OpenAI API")
console.print("4. Google Gemini API")
console.print("5. Custom API endpoint")
choice = IntPrompt.ask("Choice", default=1)
config = {"model_name": model_name}
api_keys_to_env = {}
if choice == 1: # Hugging Face
# Only for HF, ask about provider
if Confirm.ask("Use a specific provider?", default=False):
console.print("\nAvailable providers:")
console.print("- fireworks-ai")
console.print("- together-ai")
console.print("- deepinfra")
console.print("- huggingface (default)")
provider = Prompt.ask("Provider", default="huggingface")
if provider != "huggingface":
config["provider"] = provider
elif choice == 2: # OpenAI Compatible
config["base_url"] = Prompt.ask("Base URL", default="http://localhost:8000/v1")
while True:
api_key = Prompt.ask("API key (use $VAR for env variables)", default="$VLLM_API_KEY")
valid, msg = validate_api_key_format(api_key)
if valid:
config["api_key"] = api_key
if api_key.startswith("$"):
api_keys_to_env[api_key[1:]] = "your-vllm-api-key-here"
break
else:
console.print(f"[red]Error: {msg}[/red]")
elif choice == 3: # OpenAI
config["base_url"] = "https://api.openai.com/v1"
config["model_name"] = Prompt.ask("Model name", default="gpt-4")
while True:
api_key = Prompt.ask("API key (use $VAR for env variables)", default="$OPENAI_API_KEY")
valid, msg = validate_api_key_format(api_key)
if valid:
config["api_key"] = api_key
if api_key.startswith("$"):
api_keys_to_env[api_key[1:]] = "sk-..."
break
else:
console.print(f"[red]Error: {msg}[/red]")
elif choice == 4: # Gemini
config["base_url"] = "https://generativelanguage.googleapis.com/v1beta/openai/"
config["model_name"] = Prompt.ask("Model name", default="gemini-2.5-flash-preview")
while True:
api_key = Prompt.ask("API key (use $VAR for env variables)", default="$GEMINI_API_KEY")
valid, msg = validate_api_key_format(api_key)
if valid:
config["api_key"] = api_key
if api_key.startswith("$"):
api_keys_to_env[api_key[1:]] = "your-gemini-api-key-here"
break
else:
console.print(f"[red]Error: {msg}[/red]")
else: # Custom
config["base_url"] = Prompt.ask("Base URL")
while True:
api_key = Prompt.ask("API key (use $VAR for env variables)", default="$API_KEY")
valid, msg = validate_api_key_format(api_key)
if valid:
config["api_key"] = api_key
if api_key.startswith("$"):
api_keys_to_env[api_key[1:]] = "your-api-key-here"
break
else:
console.print(f"[red]Error: {msg}[/red]")
# Write API keys to .env if needed
if api_keys_to_env:
write_env_file(api_keys_to_env)
# Advanced options
if Confirm.ask("\nConfigure advanced options?", default=False):
config["max_concurrent_requests"] = IntPrompt.ask(
"Max concurrent requests", default=DEFAULT_CONCURRENT_REQUESTS_HF
)
if Confirm.ask("Use custom tokenizer?", default=False):
config["encoding_name"] = Prompt.ask("Encoding name", default="cl100k_base")
else:
config["max_concurrent_requests"] = (
DEFAULT_CONCURRENT_REQUESTS_HF if choice == 1 else DEFAULT_CONCURRENT_REQUESTS_API
)
return config