Skip to content

OpenRAG is a comprehensive, single package Retrieval-Augmented Generation platform built on Langflow, Docling, and Opensearch.

Python

reorganize config, add launch button to modal, improve podman with existing containers

phactbfa7242e4357
diff --git a/src/tui/managers/container_manager.py b/src/tui/managers/container_manager.py
index 6ec36c7dd..e785b2eb7 100644
--- a/src/tui/managers/container_manager.py
+++ b/src/tui/managers/container_manager.py
@@ -1036,11 +1036,28 @@ class ContainerManager:
if not pull_success["value"]:
yield False, "Some images failed to pull; attempting to start services anyway...", False
- yield False, "Creating and starting containers...", False
+ # Check if containers already exist (stopped or otherwise)
+ # Use compose ps -q to check for any existing containers in the project
+ success, stdout, stderr = await self._run_compose_command(["ps", "-q"])
+ containers_exist = success and stdout.strip() != ""
+
+ if containers_exist:
+ yield False, "Starting existing containers...", False
+ if self.runtime_info.runtime_type == RuntimeType.PODMAN:
+ # Podman doesn't support --no-recreate; force-recreate to avoid
+ # "name already in use" and dependency graph errors
+ compose_cmd = ["up", "-d", "--force-recreate"]
+ else:
+ # Use --no-recreate to start existing containers without recreating
+ compose_cmd = ["up", "-d", "--no-recreate"]
+ else:
+ yield False, "Creating and starting containers...", False
+ compose_cmd = ["up", "-d", "--no-build"]
+
up_success = {"value": True}
error_messages = []
-
- async for message, replace_last in self._stream_compose_command(["up", "-d", "--no-build"], up_success, cpu_mode):
+
+ async for message, replace_last in self._stream_compose_command(compose_cmd, up_success, cpu_mode):
# Detect error patterns in the output
lower_msg = message.lower()
diff --git a/src/tui/screens/config.py b/src/tui/screens/config.py
index e62004f59..e3d58d773 100644
--- a/src/tui/screens/config.py
+++ b/src/tui/screens/config.py
@@ -195,12 +195,12 @@ class ConfigScreen(Screen):
def _create_all_fields(self) -> ComposeResult:
"""Create all configuration fields in a single scrollable layout."""
- # Admin Credentials Section
- yield Static("Admin Credentials", classes="tab-header")
+ # ===== OpenSearch Section =====
+ yield Static("OpenSearch", classes="tab-header")
yield Static(" ")
# OpenSearch Admin Password
- yield Label("OpenSearch Admin Password *")
+ yield Label("Admin Password *")
yield Static(
"Validate your password here: https://lowe.github.io/tryzxcvbn/",
classes="helper-text",
@@ -219,9 +219,99 @@ class ConfigScreen(Screen):
yield Button("👁", id="toggle-opensearch-password", variant="default")
yield Static(" ")
+ # OpenSearch Username (optional)
+ yield Label("Admin Username (optional)")
+ yield Static(
+ "OpenSearch admin username (default: admin)",
+ classes="helper-text",
+ )
+ current_value = getattr(self.env_manager.config, "opensearch_username", "")
+ input_widget = Input(
+ placeholder="admin",
+ value=current_value,
+ id="input-opensearch_username",
+ )
+ yield input_widget
+ self.inputs["opensearch_username"] = input_widget
+ yield Static(" ")
+
+ # OpenSearch Host (optional - for remote instances)
+ yield Label("Host (optional)")
+ yield Static(
+ "Override for remote OpenSearch instances (default: opensearch)",
+ classes="helper-text",
+ )
+ current_value = getattr(self.env_manager.config, "opensearch_host", "")
+ input_widget = Input(
+ placeholder="opensearch",
+ value=current_value,
+ id="input-opensearch_host",
+ )
+ yield input_widget
+ self.inputs["opensearch_host"] = input_widget
+ yield Static(" ")
+
+ # OpenSearch Port (optional)
+ yield Label("Port (optional)")
+ yield Static(
+ "Override for remote OpenSearch instances (default: 9200)",
+ classes="helper-text",
+ )
+ current_value = getattr(self.env_manager.config, "opensearch_port", "")
+ input_widget = Input(
+ placeholder="9200",
+ value=current_value,
+ id="input-opensearch_port",
+ )
+ yield input_widget
+ self.inputs["opensearch_port"] = input_widget
+ yield Static(" ")
+
+ # OpenSearch Data Path
+ yield Label("Data Path")
+ yield Static(
+ "Directory to persist OpenSearch indices across upgrades",
+ classes="helper-text",
+ )
+ current_value = getattr(self.env_manager.config, "opensearch_data_path", "$HOME/.openrag/data/opensearch-data")
+ input_widget = Input(
+ placeholder="~/.openrag/data/opensearch-data",
+ value=current_value,
+ id="input-opensearch_data_path",
+ )
+ yield input_widget
+ # Actions row with pick button
+ yield Horizontal(
+ Button("Pick…", id="pick-opensearch-data-btn"),
+ id="opensearch-data-path-actions",
+ classes="controls-row",
+ )
+ self.inputs["opensearch_data_path"] = input_widget
+ yield Static(" ")
+
+ # OpenSearch Index Name
+ yield Label("Index Name")
+ yield Static(
+ "Name of the index to use in OpenSearch",
+ classes="helper-text",
+ )
+ current_value = getattr(self.env_manager.config, "opensearch_index_name", "documents")
+ input_widget = Input(
+ placeholder="documents",
+ value=current_value,
+ id="input-opensearch_index_name",
+ )
+ yield input_widget
+ self.inputs["opensearch_index_name"] = input_widget
+ yield Static(" ")
+
+ # ===== Langflow Section =====
+ yield Static("Langflow", classes="tab-header")
+ yield Static(" ")
+
# Langflow Admin Password
with Horizontal():
- yield Label("Langflow Admin Password (optional)")
+ yield Label("Admin Password (optional)")
yield Checkbox("Generate password", id="generate-langflow-password")
current_value = getattr(
self.env_manager.config, "langflow_superuser_password", ""
@@ -240,7 +330,7 @@ class ConfigScreen(Screen):
# Langflow Admin Username - conditionally displayed based on password
current_password = getattr(self.env_manager.config, "langflow_superuser_password", "")
- yield Label("Langflow Admin Username *", id="langflow-username-label")
+ yield Label("Admin Username *", id="langflow-username-label")
current_value = getattr(self.env_manager.config, "langflow_superuser", "")
input_widget = Input(
placeholder="admin", value=current_value, id="input-langflow_superuser"
@@ -249,10 +339,25 @@ class ConfigScreen(Screen):
self.inputs["langflow_superuser"] = input_widget
yield Static(" ", id="langflow-username-spacer")
- yield Static(" ")
+ # Langflow Public URL (full mode only, but grouped here)
+ if self.mode == "full":
+ yield Label("Public URL (optional)")
+ yield Static(
+ "External URL for Langflow access",
+ classes="helper-text",
+ )
+ current_value = getattr(self.env_manager.config, "langflow_public_url", "")
+ input_widget = Input(
+ placeholder="http://localhost:7860",
+ value=current_value,
+ id="input-langflow_public_url",
+ )
+ yield input_widget
+ self.inputs["langflow_public_url"] = input_widget
+ yield Static(" ")
- # API Keys Section
- yield Static("API Keys", classes="tab-header")
+ # ===== AI Providers Section =====
+ yield Static("AI Providers", classes="tab-header")
yield Static(" ")
# OpenAI API Key
@@ -261,10 +366,6 @@ class ConfigScreen(Screen):
Text("Get a key: https://platform.openai.com/api-keys", style="dim"),
classes="helper-text",
)
- yield Static(
- Text("Can be configured later in the UI", style="dim italic"),
- classes="helper-text",
- )
current_value = getattr(self.env_manager.config, "openai_api_key", "")
with Horizontal(id="openai-key-row"):
input_widget = Input(
@@ -285,10 +386,6 @@ class ConfigScreen(Screen):
Text("Get a key: https://console.anthropic.com/settings/keys", style="dim"),
classes="helper-text",
)
- yield Static(
- Text("Can be configured later in the UI", style="dim italic"),
- classes="helper-text",
- )
current_value = getattr(self.env_manager.config, "anthropic_api_key", "")
with Horizontal(id="anthropic-key-row"):
input_widget = Input(
@@ -309,10 +406,6 @@ class ConfigScreen(Screen):
Text("Endpoint of your Ollama server", style="dim"),
classes="helper-text",
)
- yield Static(
- Text("Can be configured later in the UI", style="dim italic"),
- classes="helper-text",
- )
current_value = getattr(self.env_manager.config, "ollama_endpoint", "")
input_widget = Input(
placeholder="http://localhost:11434",
@@ -330,10 +423,6 @@ class ConfigScreen(Screen):
Text("Get a key: https://cloud.ibm.com/iam/apikeys", style="dim"),
classes="helper-text",
)
- yield Static(
- Text("Can be configured later in the UI", style="dim italic"),
- classes="helper-text",
- )
current_value = getattr(self.env_manager.config, "watsonx_api_key", "")
with Horizontal(id="watsonx-key-row"):
input_widget = Input(
@@ -348,7 +437,7 @@ class ConfigScreen(Screen):
yield Static(" ")
# IBM watsonx.ai Endpoint
- yield Label("IBM watsonx.ai Endpoint")
+ yield Label("IBM watsonx.ai Endpoint (optional)")
yield Static(
Text("Example: https://us-south.ml.cloud.ibm.com", style="dim"),
classes="helper-text",
@@ -365,7 +454,7 @@ class ConfigScreen(Screen):
yield Static(" ")
# IBM watsonx.ai Project ID
- yield Label("IBM watsonx.ai Project ID")
+ yield Label("IBM watsonx.ai Project ID (optional)")
yield Static(
Text("Find in your IBM Cloud project settings", style="dim"),
classes="helper-text",
@@ -380,11 +469,13 @@ class ConfigScreen(Screen):
self.inputs["watsonx_project_id"] = input_widget
yield Static(" ")
- # Add OAuth fields only in full mode
+ # ===== Cloud Connectors Section (full mode only) =====
if self.mode == "full":
+ yield Static("Cloud Connectors", classes="tab-header")
+ yield Static(" ")
+
# Google OAuth Client ID
yield Label("Google OAuth Client ID")
- # Where to create Google OAuth credentials (helper above the box)
yield Static(
Text(
"Create credentials: https://console.cloud.google.com/apis/credentials",
@@ -392,13 +483,9 @@ class ConfigScreen(Screen):
),
classes="helper-text",
)
- # Callback URL guidance for Google OAuth
yield Static(
Text(
- "Important: add an Authorized redirect URI to your Google OAuth app(s):\n"
- " - Local: http://localhost:3000/auth/callback\n"
- " - Prod: https://your-domain.com/auth/callback\n"
- "If you use separate apps for login and connectors, add this URL to BOTH.",
+ "Redirect URI: http://localhost:3000/auth/callback (or your domain)",
style="dim",
),
classes="helper-text",
@@ -434,7 +521,6 @@ class ConfigScreen(Screen):
# Microsoft Graph Client ID
yield Label("Microsoft Graph Client ID")
- # Where to create Microsoft app registrations (helper above the box)
yield Static(
Text(
"Create app: https://portal.azure.com/#view/Microsoft_AAD_RegisteredApps/ApplicationsListBlade",
@@ -442,13 +528,9 @@ class ConfigScreen(Screen):
),
classes="helper-text",
)
- # Callback URL guidance for Microsoft OAuth
yield Static(
Text(
- "Important: configure a Web redirect URI for your Microsoft app(s):\n"
- " - Local: http://localhost:3000/auth/callback\n"
- " - Prod: https://your-domain.com/auth/callback\n"
- "If you use separate apps for login and connectors, add this URI to BOTH.",
+ "Redirect URI: http://localhost:3000/auth/callback (or your domain)",
style="dim",
),
classes="helper-text",
@@ -484,7 +566,6 @@ class ConfigScreen(Screen):
# AWS Access Key ID
yield Label("AWS Access Key ID")
- # Where to create AWS keys (helper above the box)
yield Static(
Text(
"Create keys: https://console.aws.amazon.com/iam/home#/security_credentials",
@@ -515,12 +596,12 @@ class ConfigScreen(Screen):
self.inputs["aws_secret_access_key"] = input_widget
yield Static(" ")
- # Langfuse Section (available in both basic and full mode)
+ # ===== Langfuse Section =====
yield Static("Langfuse (Tracing)", classes="tab-header")
yield Static(" ")
# Langfuse Secret Key
- yield Label("Langfuse Secret Key (optional)")
+ yield Label("Secret Key (optional)")
yield Static(
Text("Get keys from your Langfuse project settings", style="dim"),
classes="helper-text",
@@ -539,7 +620,7 @@ class ConfigScreen(Screen):
yield Static(" ")
# Langfuse Public Key
- yield Label("Langfuse Public Key (optional)")
+ yield Label("Public Key (optional)")
current_value = getattr(self.env_manager.config, "langfuse_public_key", "")
with Horizontal(id="langfuse-public-key-row"):
input_widget = Input(
@@ -553,8 +634,8 @@ class ConfigScreen(Screen):
yield Button("Show", id="toggle-langfuse-public-key", variant="default")
yield Static(" ")
- # Langfuse Base URL
- yield Label("Langfuse Host (optional)")
+ # Langfuse Host
+ yield Label("Host (optional)")
yield Static(
Text("Leave empty for Langfuse Cloud, or set for self-hosted", style="dim"),
classes="helper-text",
@@ -569,12 +650,16 @@ class ConfigScreen(Screen):
self.inputs["langfuse_host"] = input_widget
yield Static(" ")
- # Other Settings Section
- yield Static("Others", classes="tab-header")
+ # ===== Storage Section =====
+ yield Static("Storage", classes="tab-header")
yield Static(" ")
- # Documents Paths (optional) + picker action button on next line
+ # Documents Paths
yield Label("Documents Paths")
+ yield Static(
+ "Directories containing documents to ingest (comma-separated)",
+ classes="helper-text",
+ )
current_value = getattr(self.env_manager.config, "openrag_documents_paths", "")
input_widget = Input(
placeholder="~/.openrag/documents",
@@ -583,7 +668,6 @@ class ConfigScreen(Screen):
id="input-openrag_documents_paths",
)
yield input_widget
- # Actions row with pick button
yield Horizontal(
Button("Pick…", id="pick-docs-btn"),
id="docs-path-actions",
@@ -592,51 +676,17 @@ class ConfigScreen(Screen):
self.inputs["openrag_documents_paths"] = input_widget
yield Static(" ")
- # OpenSearch Data Path
- yield Label("OpenSearch Data Path")
- yield Static(
- "Directory to persist OpenSearch indices across upgrades",
- classes="helper-text",
- )
- current_value = getattr(self.env_manager.config, "opensearch_data_path", "$HOME/.openrag/data/opensearch-data")
- input_widget = Input(
- placeholder="~/.openrag/data/opensearch-data",
- value=current_value,
- id="input-opensearch_data_path",
- )
- yield input_widget
- # Actions row with pick button
- yield Horizontal(
- Button("Pick…", id="pick-opensearch-data-btn"),
- id="opensearch-data-path-actions",
- classes="controls-row",
- )
- self.inputs["opensearch_data_path"] = input_widget
- yield Static(" ")
-
- # OpenSearch Index Name
- yield Label("OpenSearch Index Name")
- yield Static(
- "Name of the index to use in OpenSearch",
- classes="helper-text",
- )
- current_value = getattr(self.env_manager.config, "opensearch_index_name", "documents")
- input_widget = Input(
- placeholder="documents",
- value=current_value,
- id="input-opensearch_index_name",
- )
- yield input_widget
- self.inputs["opensearch_index_name"] = input_widget
- yield Static(" ")
-
- # Langflow Auth Settings - These are automatically configured based on password presence
- # Not shown in UI; set in env_manager.setup_secure_defaults()
-
- # Add optional fields only in full mode
+ # ===== Advanced Section (full mode only) =====
if self.mode == "full":
+ yield Static("Advanced", classes="tab-header")
+ yield Static(" ")
+
# Webhook Base URL
yield Label("Webhook Base URL")
+ yield Static(
+ "External URL for continuous ingestion webhooks",
+ classes="helper-text",
+ )
current_value = getattr(self.env_manager.config, "webhook_base_url", "")
input_widget = Input(
placeholder="https://your-domain.com",
@@ -647,18 +697,6 @@ class ConfigScreen(Screen):
self.inputs["webhook_base_url"] = input_widget
yield Static(" ")
- # Langflow Public URL
- yield Label("Langflow Public URL")
- current_value = getattr(self.env_manager.config, "langflow_public_url", "")
- input_widget = Input(
- placeholder="http://localhost:7860",
- value=current_value,
- id="input-langflow_public_url",
- )
- yield input_widget
- self.inputs["langflow_public_url"] = input_widget
- yield Static(" ")
-
def _create_field(
self,
field_name: str,
diff --git a/src/tui/screens/welcome.py b/src/tui/screens/welcome.py
index 7c85808cc..7b949e91f 100644
--- a/src/tui/screens/welcome.py
+++ b/src/tui/screens/welcome.py
@@ -548,6 +548,7 @@ class WelcomeScreen(Screen):
"Starting Container Services",
command_generator,
on_complete=self._on_containers_started_start_native,
+ show_launch_button=True,
)
self.app.push_screen(modal)
elif self.services_running:
diff --git a/src/tui/widgets/command_modal.py b/src/tui/widgets/command_modal.py
index 39be70375..88ded89f7 100644
--- a/src/tui/widgets/command_modal.py
+++ b/src/tui/widgets/command_modal.py
@@ -2,6 +2,7 @@
import asyncio
import inspect
+import webbrowser
from typing import Callable, Optional, AsyncIterator
from rich.text import Text
@@ -71,6 +72,7 @@ class CommandOutputModal(ModalScreen):
align: center middle;
padding: 1;
margin-top: 1;
+ layout: horizontal;
}
#button-row Button {
@@ -174,6 +176,7 @@ class CommandOutputModal(ModalScreen):
title: str,
command_generator: AsyncIterator[tuple[bool, str]],
on_complete: Optional[Callable] = None,
+ show_launch_button: bool = False,
):
"""Initialize the modal dialog.
@@ -181,11 +184,13 @@ class CommandOutputModal(ModalScreen):
title: Title of the modal dialog
command_generator: Async generator that yields (is_complete, message) or (is_complete, message, replace_last) tuples
on_complete: Optional callback to run when command completes
+ show_launch_button: Whether to show the Launch OpenRAG button on success
"""
super().__init__()
self.title_text = title
self.command_generator = command_generator
self.on_complete = on_complete
+ self.show_launch_button = show_launch_button
self._output_lines: list[str] = []
self._layer_line_map: dict[str, int] = {} # Maps layer ID to line index
self._status_task: Optional[asyncio.Task] = None
@@ -203,7 +208,7 @@ class CommandOutputModal(ModalScreen):
show_line_numbers=False,
id="command-output",
)
- with Container(id="button-row"):
+ with Horizontal(id="button-row"):
yield Button("Copy Output", variant="default", id="copy-btn")
yield Button(
"Close", variant="primary", id="close-btn", disabled=True
@@ -228,6 +233,16 @@ class CommandOutputModal(ModalScreen):
self.dismiss()
elif event.button.id == "copy-btn":
self.copy_to_clipboard()
+ elif event.button.id == "launch-btn":
+ self._launch_openrag()
+
+ def _launch_openrag(self) -> None:
+ """Open the OpenRAG app in the default browser."""
+ try:
+ webbrowser.open("http://localhost:3000")
+ self.notify("Opening OpenRAG app in browser...", severity="information")
+ except Exception as e:
+ self.notify(f"Error opening app: {e}", severity="error")
def action_add_wave(self) -> None:
"""Add a wave to the animation."""
@@ -305,6 +320,15 @@ class CommandOutputModal(ModalScreen):
output.text = "\n".join(self._output_lines)
output.move_cursor((len(self._output_lines), 0))
+ # Add Launch button on success (no errors) if enabled
+ if self.show_launch_button and not self._error_detected:
+ button_row = self.query_one("#button-row", Horizontal)
+ close_btn = self.query_one("#close-btn", Button)
+ launch_btn = Button(
+ "Launch OpenRAG", variant="success", id="launch-btn"
+ )
+ button_row.mount(launch_btn, before=close_btn)
+
# Call the completion callback if provided
if self.on_complete:
await asyncio.sleep(0.5) # Small delay for better UX
@@ -323,11 +347,16 @@ class CommandOutputModal(ModalScreen):
output.text = "\n".join(self._output_lines)
output.move_cursor((len(self._output_lines), 0))
finally:
- # Enable the close button and focus it (if modal still exists)
+ # Enable buttons and focus appropriately (if modal still exists)
try:
close_btn = self.query_one("#close-btn", Button)
close_btn.disabled = False
- close_btn.focus()
+ # Focus launch button if it exists (success), otherwise close
+ try:
+ launch_btn = self.query_one("#launch-btn", Button)
+ launch_btn.focus()
+ except Exception:
+ close_btn.focus()
except Exception:
# Modal was already dismissed
pass