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
This commit is contained in:
2 files changed
+48
-3
No files matched your search
+28
-2
@@ -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?
|
||||
|
||||
+20
-1
@@ -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:
|
||||
|
||||
Reference in new issue
Block a user