Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion anton/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "2.0.4"
__version__ = "2.0.5"
60 changes: 49 additions & 11 deletions anton/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,27 +263,65 @@ async def _handle_connect(
# (silenced: was printing "Testing LLM endpoints..." and "not available" messages)
llm_ok = test_llm(minds_url, api_key, verify=ssl_verify)

if llm_ok:
console.print(
"[anton.success]LLM endpoints available — using Minds server as LLM provider.[/]"
)
def _has_configured_byok() -> bool:
if settings.planning_provider == "anthropic":
return bool(
settings.anthropic_api_key
or os.environ.get("ANTHROPIC_API_KEY")
or os.environ.get("ANTON_ANTHROPIC_API_KEY")
)
if settings.planning_provider == "openai":
Comment thread
tino097 marked this conversation as resolved.
return bool(
settings.openai_api_key
or os.environ.get("OPENAI_API_KEY")
or os.environ.get("ANTON_OPENAI_API_KEY")
)
if settings.planning_provider == "openai-compatible":
# ANTON_OPENAI_API_KEY is only persisted by explicit BYOK setup; Minds-as-LLM
# derives openai_api_key at runtime in model_post_init without persisting it.
return bool(os.environ.get("ANTON_OPENAI_API_KEY"))
return False

def _switch_to_minds_as_llm() -> None:
settings.planning_provider = "openai-compatible"
settings.coding_provider = "openai-compatible"
settings.planning_model = "_reason_"
settings.coding_model = "_code_"
# openai_api_key and openai_base_url are derived at runtime from
# minds_api_key and minds_url via model_post_init — no need to persist them.
settings.model_post_init(None)
global_ws.set_secret("ANTON_PLANNING_PROVIDER", "openai-compatible")
global_ws.set_secret("ANTON_CODING_PROVIDER", "openai-compatible")
global_ws.set_secret("ANTON_PLANNING_MODEL", "_reason_")
global_ws.set_secret("ANTON_CODING_MODEL", "_code_")

if llm_ok:
use_minds_as_llm = True
if _has_configured_byok():
current_label = f"{settings.planning_provider} / {settings.planning_model}"
console.print()
console.print("[anton.cyan]Minds server also supports LLM endpoints.[/]")
console.print(" [bold]1[/] Use Minds server as LLM provider")
console.print(
f" [bold]2[/] Keep current LLM provider ([anton.muted]{current_label}[/])"
)
console.print()
choice = await prompt_or_cancel(
"(anton) Select LLM provider",
choices=["1", "2"],
default="2",
)
use_minds_as_llm = choice == "1"

if use_minds_as_llm:
console.print(
"[anton.success]Using Minds server as LLM provider.[/]"
)
_switch_to_minds_as_llm()
else:
console.print(
f"[anton.muted]Keeping current LLM provider: {settings.planning_provider} / {settings.planning_model}[/]"
)
else:
# Check if Anthropic key is already configured
has_anthropic = settings.anthropic_api_key or os.environ.get(
"ANTHROPIC_API_KEY"
)
if not has_anthropic:
if not _has_configured_byok():
anthropic_key = Prompt.ask("Anthropic API key (for LLM)", console=console)
if anthropic_key.strip():
anthropic_key = anthropic_key.strip()
Expand Down
4 changes: 2 additions & 2 deletions anton/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -759,9 +759,9 @@ def _setup_other_provider(settings, ws) -> None:
)
_setup_anthropic(settings, ws)

settings.minds_url = None
settings.minds_url = "https://mdb.ai"
Comment thread
tino097 marked this conversation as resolved.
settings.minds_api_key = None
ws.set_secret("ANTON_MINDS_URL", "")
ws.set_secret("ANTON_MINDS_URL", "https://mdb.ai")
ws.set_secret("ANTON_MINDS_API_KEY", "")


Expand Down
1 change: 0 additions & 1 deletion anton/commands/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class Command:
COMMANDS = [
"LLM Provider",
Command("/llm", "Change LLM provider or API key"),
Command("/minds", "Connect to Minds server"),
None,
"Data Connections",
Command("/connect", "Connect a database or API to your Local Vault"),
Expand Down
8 changes: 5 additions & 3 deletions anton/minds_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,12 @@ def minds_request(
return resp.read()


def normalize_minds_url(url: str) -> str:
"""Add https:// if no scheme present, strip trailing slash."""
def normalize_minds_url(url: str | None) -> str:
"""Add https:// if no scheme present, strip trailing slash. Falls back to the default when empty."""
if not url or not url.strip():
return "https://mdb.ai"
url = url.strip()
if url and not url.startswith("http://") and not url.startswith("https://"):
if not url.startswith("http://") and not url.startswith("https://"):
url = "https://" + url
return url.rstrip("/")

Expand Down
Loading