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":
|
if key == "provider":
|
||||||
value = questionary.select(
|
value = questionary.select(
|
||||||
"Select AI Provider:",
|
"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",
|
default=str(current_val) if current_val else "gemini",
|
||||||
style=style,
|
style=style,
|
||||||
).ask()
|
).ask()
|
||||||
@@ -117,7 +124,14 @@ def set_config() -> None:
|
|||||||
# Questions
|
# Questions
|
||||||
provider = questionary.select(
|
provider = questionary.select(
|
||||||
"Select AI Provider:",
|
"Select AI Provider:",
|
||||||
choices=["gemini", "openai", "huggingface", "openrouter", "anthropic"],
|
choices=[
|
||||||
|
"gemini",
|
||||||
|
"openai",
|
||||||
|
"huggingface",
|
||||||
|
"openrouter",
|
||||||
|
"anthropic",
|
||||||
|
"ollama",
|
||||||
|
],
|
||||||
default=config.get("provider", "gemini"),
|
default=config.get("provider", "gemini"),
|
||||||
style=style,
|
style=style,
|
||||||
).ask()
|
).ask()
|
||||||
@@ -151,12 +165,24 @@ def set_config() -> None:
|
|||||||
raise typer.Exit(code=130)
|
raise typer.Exit(code=130)
|
||||||
emoji = emoji_choice == "Yes"
|
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
|
# Save Config
|
||||||
new_config = {
|
new_config = {
|
||||||
"provider": provider,
|
"provider": provider,
|
||||||
"model": model,
|
"model": model,
|
||||||
"api_key": api_key,
|
"api_key": api_key,
|
||||||
"emoji": emoji,
|
"emoji": emoji,
|
||||||
|
"ollama_host": ollama_host,
|
||||||
}
|
}
|
||||||
|
|
||||||
# Merge with existing config to preserve other keys?
|
# Merge with existing config to preserve other keys?
|
||||||
|
|||||||
+20
-1
@@ -33,7 +33,14 @@ def setup_config() -> None:
|
|||||||
# Questions
|
# Questions
|
||||||
provider = questionary.select(
|
provider = questionary.select(
|
||||||
"Select AI Provider:",
|
"Select AI Provider:",
|
||||||
choices=["gemini", "openai", "huggingface", "openrouter", "anthropic"],
|
choices=[
|
||||||
|
"gemini",
|
||||||
|
"openai",
|
||||||
|
"huggingface",
|
||||||
|
"openrouter",
|
||||||
|
"anthropic",
|
||||||
|
"ollama",
|
||||||
|
],
|
||||||
default=current_config.get("provider", "gemini"),
|
default=current_config.get("provider", "gemini"),
|
||||||
style=style,
|
style=style,
|
||||||
).ask()
|
).ask()
|
||||||
@@ -67,12 +74,24 @@ def setup_config() -> None:
|
|||||||
raise typer.Exit(code=130)
|
raise typer.Exit(code=130)
|
||||||
emoji = emoji_choice == "Yes"
|
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
|
# Save Config
|
||||||
new_config = {
|
new_config = {
|
||||||
"provider": provider,
|
"provider": provider,
|
||||||
"model": model,
|
"model": model,
|
||||||
"api_key": api_key,
|
"api_key": api_key,
|
||||||
"emoji": emoji,
|
"emoji": emoji,
|
||||||
|
"ollama_host": ollama_host,
|
||||||
}
|
}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in new issue
Block a user