Start the interactive REPL loop.
(self)
| 346 | logger.debug("Session save failed.", exc_info=True) |
| 347 | |
| 348 | async def run(self) -> None: |
| 349 | """Start the interactive REPL loop.""" |
| 350 | if self._provider == "anthropic" and not self._api_key: |
| 351 | _print_error( |
| 352 | "ANTHROPIC_API_KEY is not set.\n" |
| 353 | " Export it: [bold]export ANTHROPIC_API_KEY=sk-ant-...[/]\n" |
| 354 | " Or use a local model: [bold]openosint --provider ollama[/]" |
| 355 | ) |
| 356 | sys.exit(1) |
| 357 | |
| 358 | _print_banner(self._provider, self._display_model) |
| 359 | |
| 360 | from openosint.session_history import count_sessions |
| 361 | |
| 362 | n = count_sessions() |
| 363 | if n > 0: |
| 364 | s = "s" if n != 1 else "" |
| 365 | console.print(f" [dim]💾 {n} session{s} saved — type 'history' to browse[/]\n") |
| 366 | |
| 367 | try: |
| 368 | while True: |
| 369 | try: |
| 370 | raw = await self._session.prompt_async( |
| 371 | self._get_prompt_tokens, |
| 372 | style=PROMPT_STYLE, |
| 373 | ) |
| 374 | except (EOFError, KeyboardInterrupt): |
| 375 | console.print("\n[dim]Goodbye.[/]\n") |
| 376 | break |
| 377 | |
| 378 | user_input = raw.strip() |
| 379 | if not user_input: |
| 380 | continue |
| 381 | |
| 382 | if user_input.lower() in ("exit", "quit", "q"): |
| 383 | console.print("\n[dim]Goodbye.[/]\n") |
| 384 | break |
| 385 | |
| 386 | if user_input.lower() == "help": |
| 387 | _print_help() |
| 388 | continue |
| 389 | |
| 390 | if user_input.lower() == "tools": |
| 391 | _print_tools() |
| 392 | continue |
| 393 | |
| 394 | if user_input.lower() == "clear": |
| 395 | self._agent.clear_history() |
| 396 | console.print(" [dim]Conversation memory cleared.[/]\n") |
| 397 | continue |
| 398 | |
| 399 | if user_input.lower() == "config": |
| 400 | _print_config( |
| 401 | self._api_key, |
| 402 | self._provider, |
| 403 | self._display_model, |
| 404 | self._ollama_host, |
| 405 | self._is_pdf_disabled, |
no test coverage detected