diff --git a/docker-compose.yml b/docker-compose.yml index 2a73da89..48a97a2a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -29,7 +29,7 @@ services: - "9200:9200" - "9600:9600" volumes: - - ${OPENSEARCH_DATA_PATH:-./opensearch-data}:/usr/share/opensearch/data:Z + - ${OPENSEARCH_DATA_PATH:-$HOME/.openrag/data/opensearch-data}:/usr/share/opensearch/data:Z dashboards: image: opensearchproject/opensearch-dashboards:3.0.0 @@ -80,11 +80,11 @@ services: - AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID} - AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY} volumes: - - ${OPENRAG_DOCUMENTS_PATH:-./openrag-documents}:/app/openrag-documents:Z - - ${OPENRAG_KEYS_PATH:-./keys}:/app/keys:Z - - ${OPENRAG_FLOWS_PATH:-./flows}:/app/flows:U,z - - ${OPENRAG_CONFIG_PATH:-./config}:/app/config:Z - - ${OPENRAG_DATA_PATH:-./data}:/app/data:Z + - ${OPENRAG_DOCUMENTS_PATH:-$HOME/.openrag/documents}:/app/openrag-documents:Z + - ${OPENRAG_KEYS_PATH:-$HOME/.openrag/keys}:/app/keys:Z + - ${OPENRAG_FLOWS_PATH:-$HOME/.openrag/flows}:/app/flows:U,z + - ${OPENRAG_CONFIG_PATH:-$HOME/.openrag/config}:/app/config:Z + - ${OPENRAG_DATA_PATH:-$HOME/.openrag/data}:/app/data:Z openrag-frontend: image: langflowai/openrag-frontend:${OPENRAG_VERSION:-latest} @@ -101,7 +101,7 @@ services: langflow: volumes: - - ${OPENRAG_FLOWS_PATH:-./flows}:/app/flows:U,z + - ${OPENRAG_FLOWS_PATH:-$HOME/.openrag/flows}:/app/flows:U,z image: langflowai/openrag-langflow:${OPENRAG_VERSION:-latest} build: context: . diff --git a/src/tui/main.py b/src/tui/main.py index 5e888f36..85da0a2d 100644 --- a/src/tui/main.py +++ b/src/tui/main.py @@ -457,7 +457,7 @@ def copy_sample_documents(*, force: bool = False) -> None: """Copy sample documents from package to host directory. Uses the first path from OPENRAG_DOCUMENTS_PATHS env var. - Defaults to ~/.openrag/documents/openrag-documents if not configured. + Defaults to ~/.openrag/documents if not configured. """ from .managers.env_manager import EnvManager from pathlib import Path @@ -470,10 +470,12 @@ def copy_sample_documents(*, force: bool = False) -> None: documents_path_str = env_manager.config.openrag_documents_paths if documents_path_str: first_path = documents_path_str.split(',')[0].strip() + # Expand $HOME and ~ + first_path = first_path.replace("$HOME", str(Path.home())) documents_dir = Path(first_path).expanduser() else: # Default fallback - documents_dir = Path.home() / ".openrag" / "documents" / "openrag-documents" + documents_dir = Path.home() / ".openrag" / "documents" documents_dir.mkdir(parents=True, exist_ok=True) @@ -563,7 +565,7 @@ def migrate_legacy_data_directories(): # Define migration mappings: (source_path, target_path, description) migrations = [ - (cwd / "openrag-documents", target_base / "documents" / "openrag-documents", "documents"), + (cwd / "openrag-documents", target_base / "documents", "documents"), (cwd / "flows", target_base / "flows", "flows"), (cwd / "keys", target_base / "keys", "keys"), (cwd / "config", target_base / "config", "config"), @@ -646,16 +648,16 @@ def setup_host_directories(): """Initialize OpenRAG directory structure on the host. Creates directories that will be volume-mounted into containers: - - ~/.openrag/documents/openrag-documents/ (for document ingestion) + - ~/.openrag/documents/ (for document ingestion) - ~/.openrag/flows/ (for Langflow flows) - ~/.openrag/keys/ (for JWT keys) - ~/.openrag/config/ (for configuration) - ~/.openrag/data/ (for backend data: conversations, OAuth tokens, etc.) - - ~/.openrag/data/opensearch-data/ (for OpenSearch data) + - ~/.openrag/data/opensearch-data/ (for OpenSearch index) """ base_dir = Path.home() / ".openrag" directories = [ - base_dir / "documents" / "openrag-documents", + base_dir / "documents", base_dir / "flows", base_dir / "keys", base_dir / "config", diff --git a/src/tui/managers/env_manager.py b/src/tui/managers/env_manager.py index f8186fac..a853ee72 100644 --- a/src/tui/managers/env_manager.py +++ b/src/tui/managers/env_manager.py @@ -65,10 +65,10 @@ class EnvConfig: nudges_flow_id: str = "ebc01d31-1976-46ce-a385-b0240327226c" # Document paths (comma-separated) - use centralized location by default - openrag_documents_paths: str = "$HOME/.openrag/documents/openrag-documents" + openrag_documents_paths: str = "$HOME/.openrag/documents" # Volume mount paths - use centralized location by default - openrag_documents_path: str = "$HOME/.openrag/documents/openrag-documents" # Primary documents path for compose + openrag_documents_path: str = "$HOME/.openrag/documents" # Primary documents path for compose openrag_keys_path: str = "$HOME/.openrag/keys" openrag_flows_path: str = "$HOME/.openrag/flows" openrag_config_path: str = "$HOME/.openrag/config" @@ -524,7 +524,7 @@ class EnvManager: ( "openrag_documents_paths", "Documents Paths", - "./openrag-documents,/path/to/more/docs", + "~/.openrag/documents", False, ), ] @@ -649,12 +649,13 @@ class EnvManager: def generate_compose_volume_mounts(self) -> List[str]: """Generate Docker Compose volume mount strings from documents paths.""" - is_valid, _, validated_paths = validate_documents_paths( - self.config.openrag_documents_paths - ) + # Expand $HOME before validation + paths_str = self.config.openrag_documents_paths.replace("$HOME", str(Path.home())) + is_valid, error_msg, validated_paths = validate_documents_paths(paths_str) if not is_valid: - return ["./openrag-documents:/app/openrag-documents:Z"] # fallback + logger.warning(f"Invalid documents paths: {error_msg}") + return [] volume_mounts = [] for i, path in enumerate(validated_paths): diff --git a/src/tui/screens/config.py b/src/tui/screens/config.py index 0f51532c..57f25d08 100644 --- a/src/tui/screens/config.py +++ b/src/tui/screens/config.py @@ -523,7 +523,7 @@ class ConfigScreen(Screen): yield Label("Documents Paths") current_value = getattr(self.env_manager.config, "openrag_documents_paths", "") input_widget = Input( - placeholder="./openrag-documents,/path/to/more/docs", + placeholder="~/.openrag/documents", value=current_value, validators=[DocumentsPathValidator()], id="input-openrag_documents_paths", @@ -544,9 +544,9 @@ class ConfigScreen(Screen): "Directory to persist OpenSearch indices across upgrades", classes="helper-text", ) - current_value = getattr(self.env_manager.config, "opensearch_data_path", "./opensearch-data") + current_value = getattr(self.env_manager.config, "opensearch_data_path", "$HOME/.openrag/data/opensearch-data") input_widget = Input( - placeholder="./opensearch-data", + placeholder="~/.openrag/data/opensearch-data", value=current_value, id="input-opensearch_data_path", ) diff --git a/src/tui/widgets/flow_backup_warning_modal.py b/src/tui/widgets/flow_backup_warning_modal.py index 5cdb3516..8a4d3d0a 100644 --- a/src/tui/widgets/flow_backup_warning_modal.py +++ b/src/tui/widgets/flow_backup_warning_modal.py @@ -100,9 +100,9 @@ class FlowBackupWarningModal(ModalScreen[tuple[bool, bool]]): with Container(id="dialog"): yield Label("⚠ Flow Backups Detected", id="title") yield Static( - f"Flow backups found in ./flows/backup\n\n" + f"Flow backups found in your flows/backup directory.\n\n" f"Proceeding with {self.operation} will reset custom flows to defaults.\n" - f"Your customizations are backed up in ./flows/backup/\n\n" + f"Your customizations are backed up in the flows/backup/ directory.\n\n" f"Choose whether to keep or delete the backup files:", id="message" ) diff --git a/src/tui/widgets/version_mismatch_warning_modal.py b/src/tui/widgets/version_mismatch_warning_modal.py index 22d94e4e..85c8fc54 100644 --- a/src/tui/widgets/version_mismatch_warning_modal.py +++ b/src/tui/widgets/version_mismatch_warning_modal.py @@ -92,8 +92,8 @@ class VersionMismatchWarningModal(ModalScreen[bool]): f"Current TUI version is {self.tui_version}\n\n" f"Starting services will update containers to version {self.tui_version}.\n" f"This may cause compatibility issues with your flows.\n\n" - f"⚠️ Please backup your flows before continuing:\n" - f" Your flows are in ./flows/ directory\n\n" + f"⚠️ Please backup your flows before continuing.\n" + f" Your flows are in ~/.openrag/flows/\n\n" f"Do you want to continue?", id="message" )