@@ -59,7 +59,7 @@ def interactive_backend_setup() -> bool:
5959 click .echo ("Choose your preferred LLM backend:" )
6060 click .echo ("1. Ollama (local models)" )
6161 click .echo ("2. OpenRouter (cloud models)" )
62-
62+
6363 while True :
6464 try :
6565 choice = click .prompt ("Select backend (1-2)" , type = int )
@@ -71,7 +71,7 @@ def interactive_backend_setup() -> bool:
7171 return False
7272 except (ValueError , TypeError ):
7373 click .echo ("❌ Invalid input. Please enter 1 or 2." )
74-
74+
7575 if choice == 1 :
7676 return setup_ollama_backend ()
7777 else :
@@ -81,21 +81,21 @@ def interactive_backend_setup() -> bool:
8181def setup_ollama_backend () -> bool :
8282 """Setup Ollama backend configuration."""
8383 click .echo ("\n 🦙 Configuring Ollama Backend" )
84-
84+
8585 # Create default settings.yaml if it doesn't exist
8686 if not Path ("settings.yaml" ).exists ():
8787 settings_manager .create_default_settings ()
88-
88+
8989 host = click .prompt ("Ollama host" , default = "localhost" )
9090 port = click .prompt ("Ollama port" , default = 11434 , type = int )
9191 model = click .prompt ("Model name" , default = "gpt-oss:20b" )
92-
92+
9393 # Save settings
9494 settings_manager .set ("backend.provider" , "ollama" )
9595 settings_manager .set ("ollama.host" , host )
9696 settings_manager .set ("ollama.port" , port )
9797 settings_manager .set ("ollama.model" , model )
98-
98+
9999 click .echo ("✅ Ollama backend configured" )
100100 return True
101101
@@ -104,16 +104,16 @@ def setup_openrouter_backend() -> bool:
104104 """Setup OpenRouter backend configuration."""
105105 click .echo ("\n 🌐 Configuring OpenRouter Backend" )
106106 click .echo ("You'll need an OpenRouter API key from: https://openrouter.ai/keys" )
107-
107+
108108 # Create default settings.yaml if it doesn't exist
109109 if not Path ("settings.yaml" ).exists ():
110110 settings_manager .create_default_settings ()
111-
111+
112112 api_key = click .prompt ("OpenRouter API key" , hide_input = True )
113113 if not api_key .strip ():
114114 click .echo ("❌ API key is required for OpenRouter" )
115115 return False
116-
116+
117117 # Show popular models
118118 click .echo ("\n Popular models:" )
119119 models = [
@@ -124,30 +124,27 @@ def setup_openrouter_backend() -> bool:
124124 "google/gemini-pro-1.5" ,
125125 "mistral/mistral-large" ,
126126 ]
127-
127+
128128 for i , model in enumerate (models , 1 ):
129129 click .echo (f"{ i } . { model } " )
130-
130+
131131 try :
132132 choice = click .prompt ("Select model (1-5, or enter custom)" , default = "1" )
133- if choice .isdigit () and 1 <= int (choice ) <= 5 :
134- model = models [int (choice ) - 1 ]
135- else :
136- model = choice
133+ model = models [int (choice ) - 1 ] if choice .isdigit () and 1 <= int (choice ) <= 5 else choice
137134 except (ValueError , IndexError ):
138135 model = "openai/gpt-oss-20b"
139-
136+
140137 site_name = click .prompt ("Site name (optional)" , default = "Red Team Testbed" )
141138 site_url = click .prompt ("Site URL (optional)" , default = "" )
142-
139+
143140 # Save settings
144141 settings_manager .set ("backend.provider" , "openrouter" )
145142 settings_manager .set ("openrouter.api_key" , api_key )
146143 settings_manager .set ("openrouter.model" , model )
147144 settings_manager .set ("openrouter.site_name" , site_name )
148145 if site_url :
149146 settings_manager .set ("openrouter.site_url" , site_url )
150-
147+
151148 click .echo ("✅ OpenRouter backend configured" )
152149 return True
153150
@@ -159,32 +156,33 @@ def test_connection(config: dict[str, Any], verbose: bool = False) -> bool:
159156 if Path ("settings.yaml" ).exists ():
160157 settings = settings_manager .load_settings ()
161158 backend = create_backend (settings )
162- provider = settings [' backend' ][ ' provider' ]
159+ provider = settings [" backend" ][ " provider" ]
163160 click .echo (f"🔗 Testing { provider } connection..." )
164161 else :
165162 # Fallback to default Ollama configuration
166163 from src .utils .model_client import OllamaClient
164+
167165 backend = OllamaClient () # Uses default localhost:11434, gpt-oss:20b
168166 provider = "ollama"
169167 click .echo ("🔗 Testing default Ollama connection..." )
170-
171- if provider == ' ollama' :
168+
169+ if provider == " ollama" :
172170 return test_ollama_connection (backend , verbose )
173171 else :
174172 return test_openrouter_connection (backend , verbose )
175-
173+
176174 except Exception as e :
177175 click .echo (f"❌ Backend setup failed: { e } " )
178176 return False
179177
180178
181- def test_ollama_connection (backend , verbose : bool = False ) -> bool :
179+ def test_ollama_connection (backend : object , verbose : bool = False ) -> bool :
182180 """Test connection to Ollama backend."""
183181 # Check if Ollama is busy before testing
184182 click .echo ("🔍 Checking Ollama status..." )
185183 try :
186184 # Handle both OllamaBackend and OllamaClient
187- if hasattr (backend , ' check_status' ):
185+ if hasattr (backend , " check_status" ):
188186 status = backend .check_status ()
189187 else :
190188 status = backend .check_ollama_status ()
@@ -207,7 +205,7 @@ def test_ollama_connection(backend, verbose: bool = False) -> bool:
207205
208206 try :
209207 # Handle both interfaces for availability check
210- if hasattr (backend , ' is_available' ):
208+ if hasattr (backend , " is_available" ):
211209 model_available = backend .is_available ()
212210 model_name = backend .get_model_name ()
213211 else :
@@ -242,7 +240,7 @@ def test_ollama_connection(backend, verbose: bool = False) -> bool:
242240 return False
243241
244242
245- def test_openrouter_connection (backend , verbose : bool = False ) -> bool :
243+ def test_openrouter_connection (backend : object , verbose : bool = False ) -> bool :
246244 """Test connection to OpenRouter backend."""
247245 try :
248246 if not backend .is_available ():
@@ -282,7 +280,7 @@ def main(config: str, verbose: bool, configure: bool) -> int | None:
282280 This command will:
283281
284282 \b
285- - Configure LLM backend (Ollama or OpenRouter)
283+ - Configure LLM backend (Ollama or OpenRouter)
286284 - Load and validate configuration
287285 - Set up logging and directories
288286 - Test backend connection and model availability
@@ -298,7 +296,7 @@ def main(config: str, verbose: bool, configure: bool) -> int | None:
298296 if not interactive_backend_setup ():
299297 return 1
300298 click .echo ("" )
301-
299+
302300 # Check if settings.yaml exists
303301 if not Path ("settings.yaml" ).exists ():
304302 if configure :
@@ -307,7 +305,7 @@ def main(config: str, verbose: bool, configure: bool) -> int | None:
307305 else :
308306 click .echo ("💡 No settings.yaml found, using default Ollama configuration" )
309307 click .echo (" Run 'uv run setup --configure' to configure different backends" )
310-
308+
311309 # Load configuration (fallback compatibility)
312310 click .echo ("📋 Loading configuration..." )
313311 try :
@@ -317,7 +315,7 @@ def main(config: str, verbose: bool, configure: bool) -> int | None:
317315 # Use minimal config if config.yaml doesn't exist
318316 config_data = {
319317 "output" : {"results_dir" : "results" , "findings_dir" : "findings" },
320- "logging" : {"level" : "INFO" , "file" : "testbed.log" }
318+ "logging" : {"level" : "INFO" , "file" : "testbed.log" },
321319 }
322320
323321 # Setup logging
@@ -358,4 +356,4 @@ def main(config: str, verbose: bool, configure: bool) -> int | None:
358356
359357
360358if __name__ == "__main__" :
361- main ()
359+ main ()
0 commit comments