dbagent-cli 0.1.3__tar.gz → 0.1.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {dbagent_cli-0.1.3 → dbagent_cli-0.1.4}/PKG-INFO +1 -1
- {dbagent_cli-0.1.3 → dbagent_cli-0.1.4}/dbagent/__init__.py +1 -1
- {dbagent_cli-0.1.3 → dbagent_cli-0.1.4}/dbagent/cli.py +96 -22
- {dbagent_cli-0.1.3 → dbagent_cli-0.1.4}/dbagent_cli.egg-info/PKG-INFO +1 -1
- {dbagent_cli-0.1.3 → dbagent_cli-0.1.4}/pyproject.toml +1 -1
- {dbagent_cli-0.1.3 → dbagent_cli-0.1.4}/README.md +0 -0
- {dbagent_cli-0.1.3 → dbagent_cli-0.1.4}/dbagent/agent/generator.py +0 -0
- {dbagent_cli-0.1.3 → dbagent_cli-0.1.4}/dbagent/agent/pipeline.py +0 -0
- {dbagent_cli-0.1.3 → dbagent_cli-0.1.4}/dbagent/agent/validator.py +0 -0
- {dbagent_cli-0.1.3 → dbagent_cli-0.1.4}/dbagent/config.py +0 -0
- {dbagent_cli-0.1.3 → dbagent_cli-0.1.4}/dbagent/connectors/base.py +0 -0
- {dbagent_cli-0.1.3 → dbagent_cli-0.1.4}/dbagent/connectors/factory.py +0 -0
- {dbagent_cli-0.1.3 → dbagent_cli-0.1.4}/dbagent/connectors/mongo.py +0 -0
- {dbagent_cli-0.1.3 → dbagent_cli-0.1.4}/dbagent/connectors/relational.py +0 -0
- {dbagent_cli-0.1.3 → dbagent_cli-0.1.4}/dbagent/llm/auto_setup.py +0 -0
- {dbagent_cli-0.1.3 → dbagent_cli-0.1.4}/dbagent/llm/base.py +0 -0
- {dbagent_cli-0.1.3 → dbagent_cli-0.1.4}/dbagent/llm/factory.py +0 -0
- {dbagent_cli-0.1.3 → dbagent_cli-0.1.4}/dbagent/llm/gemini_provider.py +0 -0
- {dbagent_cli-0.1.3 → dbagent_cli-0.1.4}/dbagent/llm/groq_provider.py +0 -0
- {dbagent_cli-0.1.3 → dbagent_cli-0.1.4}/dbagent/llm/mock_provider.py +0 -0
- {dbagent_cli-0.1.3 → dbagent_cli-0.1.4}/dbagent/llm/ollama_provider.py +0 -0
- {dbagent_cli-0.1.3 → dbagent_cli-0.1.4}/dbagent/llm/openrouter_provider.py +0 -0
- {dbagent_cli-0.1.3 → dbagent_cli-0.1.4}/dbagent/schema/formatter.py +0 -0
- {dbagent_cli-0.1.3 → dbagent_cli-0.1.4}/dbagent/schema/models.py +0 -0
- {dbagent_cli-0.1.3 → dbagent_cli-0.1.4}/dbagent/schema/selector.py +0 -0
- {dbagent_cli-0.1.3 → dbagent_cli-0.1.4}/dbagent/ui/console.py +0 -0
- {dbagent_cli-0.1.3 → dbagent_cli-0.1.4}/dbagent/ui/viewer.py +0 -0
- {dbagent_cli-0.1.3 → dbagent_cli-0.1.4}/dbagent_cli.egg-info/SOURCES.txt +0 -0
- {dbagent_cli-0.1.3 → dbagent_cli-0.1.4}/dbagent_cli.egg-info/dependency_links.txt +0 -0
- {dbagent_cli-0.1.3 → dbagent_cli-0.1.4}/dbagent_cli.egg-info/entry_points.txt +0 -0
- {dbagent_cli-0.1.3 → dbagent_cli-0.1.4}/dbagent_cli.egg-info/requires.txt +0 -0
- {dbagent_cli-0.1.3 → dbagent_cli-0.1.4}/dbagent_cli.egg-info/top_level.txt +0 -0
- {dbagent_cli-0.1.3 → dbagent_cli-0.1.4}/setup.cfg +0 -0
- {dbagent_cli-0.1.3 → dbagent_cli-0.1.4}/tests/test_cli.py +0 -0
- {dbagent_cli-0.1.3 → dbagent_cli-0.1.4}/tests/test_connectors.py +0 -0
- {dbagent_cli-0.1.3 → dbagent_cli-0.1.4}/tests/test_generator.py +0 -0
- {dbagent_cli-0.1.3 → dbagent_cli-0.1.4}/tests/test_schema.py +0 -0
|
@@ -767,26 +767,33 @@ def models_command():
|
|
|
767
767
|
|
|
768
768
|
@app.command(name="setup")
|
|
769
769
|
def setup_command(
|
|
770
|
-
model: str = typer.Option("qwen2.5-coder:1.5b", "--model", "-m", help="Ollama model to install"),
|
|
771
|
-
yes: bool = typer.Option(False, "--yes", "-y", help="Skip
|
|
770
|
+
model: str = typer.Option("qwen2.5-coder:1.5b", "--model", "-m", help="Ollama model to install for local AI"),
|
|
771
|
+
yes: bool = typer.Option(False, "--yes", "-y", help="Skip prompts and install local Ollama automatically"),
|
|
772
772
|
):
|
|
773
|
-
"""
|
|
773
|
+
"""Interactive setup wizard: Configure local offline AI, cloud API keys, or standard DB tools."""
|
|
774
774
|
print_banner()
|
|
775
|
-
console.print("[bold cyan]DB-Agent
|
|
775
|
+
console.print("[bold cyan]DB-Agent Setup & Configuration Wizard[/bold cyan]\n")
|
|
776
776
|
|
|
777
|
-
|
|
778
|
-
if not yes:
|
|
779
|
-
console.print("[bold white]DB-Agent supports two ways to run AI:[/bold white]")
|
|
780
|
-
console.print(" 1. [bold green]Local Offline AI (Ollama)[/bold green]: 100% private, zero-cost, runs on your machine without API keys.")
|
|
781
|
-
console.print(" 2. [bold cyan]Free Cloud AI (Gemini / Groq)[/bold cyan]: Lightweight, runs in the cloud via free API keys.\n")
|
|
777
|
+
chosen_provider = "ollama"
|
|
782
778
|
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
779
|
+
if yes:
|
|
780
|
+
choice = "1"
|
|
781
|
+
else:
|
|
782
|
+
console.print("[bold white]Choose how you would like to setup DB-Agent:[/bold white]")
|
|
783
|
+
console.print(" [bold green]1. Local Offline AI[/bold green] (Ollama + Coding Model) - [italic]100% Free, Private, Zero API Keys[/italic]")
|
|
784
|
+
console.print(" [bold cyan]2. Free Cloud AI[/bold cyan] (Google Gemini / Groq / OpenRouter) - [italic]Fast, requires free API key[/italic]")
|
|
785
|
+
console.print(" [bold yellow]3. Normal Database CLI[/bold yellow] - [italic]No AI, use standard connect, scan & SQL tools only[/italic]\n")
|
|
786
|
+
|
|
787
|
+
choice = Prompt.ask(
|
|
788
|
+
"Select setup mode",
|
|
789
|
+
choices=["1", "2", "3"],
|
|
790
|
+
default="1",
|
|
786
791
|
)
|
|
787
792
|
|
|
788
|
-
|
|
789
|
-
|
|
793
|
+
# --- Mode 1: Local Offline AI ---
|
|
794
|
+
if choice == "1":
|
|
795
|
+
console.print("\n[bold cyan]Setting up Local Offline AI (Ollama)...[/bold cyan]")
|
|
796
|
+
console.print("[dim]Downloading and configuring local AI engine (one-time setup)...[/dim]\n")
|
|
790
797
|
from dbagent.llm.auto_setup import ensure_ollama_ready
|
|
791
798
|
|
|
792
799
|
def _log(msg, level="info"):
|
|
@@ -804,16 +811,83 @@ def setup_command(
|
|
|
804
811
|
success, message = ensure_ollama_ready(model=model, print_fn=_log)
|
|
805
812
|
if success:
|
|
806
813
|
config_mgr.set_setting("default_provider", "ollama")
|
|
807
|
-
|
|
808
|
-
|
|
814
|
+
chosen_provider = "ollama"
|
|
815
|
+
print_success("Local AI engine configured and ready!")
|
|
809
816
|
else:
|
|
810
817
|
print_error(message)
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
console.print("
|
|
816
|
-
|
|
818
|
+
console.print("[yellow]You can still use DB-Agent with cloud AI or standard SQL tools.[/yellow]\n")
|
|
819
|
+
|
|
820
|
+
# --- Mode 2: Cloud AI with API Key ---
|
|
821
|
+
elif choice == "2":
|
|
822
|
+
console.print("\n[bold cyan]Configure Free Cloud AI Provider[/bold cyan]\n")
|
|
823
|
+
prov = Prompt.ask(
|
|
824
|
+
"Select Cloud AI Provider",
|
|
825
|
+
choices=["gemini", "groq", "openrouter"],
|
|
826
|
+
default="gemini",
|
|
827
|
+
)
|
|
828
|
+
if prov == "gemini":
|
|
829
|
+
console.print("[dim]Get a free Gemini API key at: [bold]https://aistudio.google.com/apikey[/bold][/dim]")
|
|
830
|
+
key = Prompt.ask("Enter GEMINI_API_KEY").strip()
|
|
831
|
+
if key:
|
|
832
|
+
config_mgr.set_setting("gemini_api_key", key)
|
|
833
|
+
config_mgr.set_setting("default_provider", "gemini")
|
|
834
|
+
chosen_provider = "gemini"
|
|
835
|
+
print_success("Google Gemini Free Tier configured successfully!")
|
|
836
|
+
elif prov == "groq":
|
|
837
|
+
console.print("[dim]Get a free Groq API key at: [bold]https://console.groq.com[/bold][/dim]")
|
|
838
|
+
key = Prompt.ask("Enter GROQ_API_KEY").strip()
|
|
839
|
+
if key:
|
|
840
|
+
config_mgr.set_setting("groq_api_key", key)
|
|
841
|
+
config_mgr.set_setting("default_provider", "groq")
|
|
842
|
+
chosen_provider = "groq"
|
|
843
|
+
print_success("Groq Ultra-Fast Free Tier configured successfully!")
|
|
844
|
+
elif prov == "openrouter":
|
|
845
|
+
console.print("[dim]Get an OpenRouter API key at: [bold]https://openrouter.ai[/bold][/dim]")
|
|
846
|
+
key = Prompt.ask("Enter OPENROUTER_API_KEY").strip()
|
|
847
|
+
if key:
|
|
848
|
+
config_mgr.set_setting("openrouter_api_key", key)
|
|
849
|
+
config_mgr.set_setting("default_provider", "openrouter")
|
|
850
|
+
chosen_provider = "openrouter"
|
|
851
|
+
print_success("OpenRouter configured successfully!")
|
|
852
|
+
|
|
853
|
+
# --- Mode 3: Normal Database CLI ---
|
|
854
|
+
elif choice == "3":
|
|
855
|
+
chosen_provider = "normal (no AI)"
|
|
856
|
+
print_info("Configured in Normal mode. You can use connect, scan, and run commands.")
|
|
857
|
+
console.print("[dim]To add AI later, simply run [bold]db-agent setup[/bold] or [bold]db-agent config[/bold].[/dim]\n")
|
|
858
|
+
|
|
859
|
+
# --- Optional Database Connection Setup ---
|
|
860
|
+
console.print("")
|
|
861
|
+
if not yes and Confirm.ask("Would you like to connect and save a database profile now?", default=True):
|
|
862
|
+
db_url = Prompt.ask("Enter Database URL (e.g. postgresql://user:pass@host:5432/dbname or sqlite:///mydb.db)").strip()
|
|
863
|
+
if db_url:
|
|
864
|
+
alias = Prompt.ask("Enter alias name (e.g. devdb, prod, myapp)", default="default_db").strip()
|
|
865
|
+
with console.status("[bold cyan]Testing connection credentials...[/bold cyan]"):
|
|
866
|
+
try:
|
|
867
|
+
connector = create_connector(db_url)
|
|
868
|
+
success, msg = connector.test_connection()
|
|
869
|
+
if success:
|
|
870
|
+
config_mgr.save_profile(name=alias, connection_url=db_url, description=f"Profile for {alias}")
|
|
871
|
+
print_success(f"Successfully connected and saved profile as alias '[bold cyan]{alias}[/bold cyan]'!")
|
|
872
|
+
else:
|
|
873
|
+
print_warning(f"Connection test failed: {msg}")
|
|
874
|
+
if Confirm.ask("Save profile anyway?", default=True):
|
|
875
|
+
config_mgr.save_profile(name=alias, connection_url=db_url, description=f"Profile for {alias}")
|
|
876
|
+
print_success(f"Saved profile as alias '[bold cyan]{alias}[/bold cyan]'.")
|
|
877
|
+
connector.close()
|
|
878
|
+
except Exception as e:
|
|
879
|
+
print_error(f"Error testing connection: {str(e)}")
|
|
880
|
+
|
|
881
|
+
# --- Final Summary ---
|
|
882
|
+
console.print("\n" + "=" * 70)
|
|
883
|
+
console.print("[bold green][OK] DB-Agent Setup Complete![/bold green]")
|
|
884
|
+
console.print(f"AI Mode: [bold cyan]{chosen_provider}[/bold cyan]")
|
|
885
|
+
console.print("=" * 70)
|
|
886
|
+
console.print("\n[bold white]Quick Commands:[/bold white]")
|
|
887
|
+
console.print(" * [bold]db-agent ask \"your question\" --db <alias>[/bold] -> Ask questions & get live results")
|
|
888
|
+
console.print(" * [bold]db-agent chat --db <alias>[/bold] -> Interactive CLI shell")
|
|
889
|
+
console.print(" * [bold]db-agent scan --db <alias>[/bold] -> Introspect database schema")
|
|
890
|
+
console.print(" * [bold]db-agent guide[/bold] -> View full command reference\n")
|
|
817
891
|
|
|
818
892
|
|
|
819
893
|
if __name__ == "__main__":
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|