From d991af9c47beb3ca936c8d6a8bd1270a998b9b89 Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Sat, 6 Jun 2026 16:31:09 +0545 Subject: [PATCH] feat(devgen/cli): introduce Ollamaprovider support and interactive host configuration - Add "ollama" to AI provider choices in config prompts - Prompt user for Ollama server URL when selecting the Ollama provider - Store the configured Ollama host in the config under the "ollama_host" key - Update config saving logic in both edit_config and setup_config functions --- devgen/cli/config.py | 30 ++++++++++++++++++++++++++++-- devgen/cli/setup.py | 21 ++++++++++++++++++++- 2 files changed, 48 insertions(+), 3 deletions(-) diff --git a/devgen/cli/config.py b/devgen/cli/config.py index 62e44ce..762c0a0 100644 --- a/devgen/cli/config.py +++ b/devgen/cli/config.py @@ -62,7 +62,14 @@ def edit_config( if key == "provider": value = questionary.select( "Select AI Provider:", - choices=["gemini", "openai", "huggingface", "openrouter", "anthropic"], + choices=[ + "gemini", + "openai", + "huggingface", + "openrouter", + "anthropic", + "ollama", + ], default=str(current_val) if current_val else "gemini", style=style, ).ask() @@ -117,7 +124,14 @@ def set_config() -> None: # Questions provider = questionary.select( "Select AI Provider:", - choices=["gemini", "openai", "huggingface", "openrouter", "anthropic"], + choices=[ + "gemini", + "openai", + "huggingface", + "openrouter", + "anthropic", + "ollama", + ], default=config.get("provider", "gemini"), style=style, ).ask() @@ -151,12 +165,24 @@ def set_config() -> None: raise typer.Exit(code=130) emoji = emoji_choice == "Yes" + ollama_host = config.get("ollama_host", "http://localhost:11434") + if provider == "ollama": + ollama_host_input = questionary.text( + "Ollama server URL:", + default=ollama_host, + style=style, + ).ask() + if ollama_host_input is None: + raise typer.Exit(code=130) + ollama_host = ollama_host_input.strip() or ollama_host + # Save Config new_config = { "provider": provider, "model": model, "api_key": api_key, "emoji": emoji, + "ollama_host": ollama_host, } # Merge with existing config to preserve other keys? diff --git a/devgen/cli/setup.py b/devgen/cli/setup.py index 630cf01..9d349c1 100644 --- a/devgen/cli/setup.py +++ b/devgen/cli/setup.py @@ -33,7 +33,14 @@ def setup_config() -> None: # Questions provider = questionary.select( "Select AI Provider:", - choices=["gemini", "openai", "huggingface", "openrouter", "anthropic"], + choices=[ + "gemini", + "openai", + "huggingface", + "openrouter", + "anthropic", + "ollama", + ], default=current_config.get("provider", "gemini"), style=style, ).ask() @@ -67,12 +74,24 @@ def setup_config() -> None: raise typer.Exit(code=130) emoji = emoji_choice == "Yes" + ollama_host = current_config.get("ollama_host", "http://localhost:11434") + if provider == "ollama": + ollama_host_input = questionary.text( + "Ollama server URL:", + default=ollama_host, + style=style, + ).ask() + if ollama_host_input is None: + raise typer.Exit(code=130) + ollama_host = ollama_host_input.strip() or ollama_host + # Save Config new_config = { "provider": provider, "model": model, "api_key": api_key, "emoji": emoji, + "ollama_host": ollama_host, } try: