Download deployment/Prepare-Gallery.ps1 from Wizzas/DefectRAG: direct link, hf CLI and curl.
- Browser
- Download file 1.58 kB
-
https://huggingface.co/Wizzas/DefectRAG/resolve/main/deployment/Prepare-Gallery.ps1
- Command line
-
hf download hf://Wizzas/DefectRAG/deployment/Prepare-Gallery.ps1
-
curl -L -o Prepare-Gallery.ps1 https://huggingface.co/Wizzas/DefectRAG/resolve/main/deployment/Prepare-Gallery.ps1
1.58 kB
| param() | |
| $ErrorActionPreference='Stop' | |
| $galleryRoot=Split-Path $PSScriptRoot -Parent | |
| $galleryFolder=Join-Path $galleryRoot 'runtime/gallery-setup' | |
| New-Item -ItemType Directory -Force -Path $galleryFolder | Out-Null | |
| $galleryKeyFile=Join-Path $galleryFolder 'gallery-key.txt' | |
| if(Test-Path -LiteralPath $galleryKeyFile){ | |
| $galleryKey=[IO.File]::ReadAllText($galleryKeyFile).Trim() | |
| if($galleryKey -notmatch '^[a-f0-9]{64}$'){throw 'Existing gallery key is invalid. It was preserved.'} | |
| }else{ | |
| $galleryBytes=New-Object byte[] 32 | |
| $galleryRandom=[Security.Cryptography.RandomNumberGenerator]::Create() | |
| try{$galleryRandom.GetBytes($galleryBytes)}finally{$galleryRandom.Dispose()} | |
| $galleryKey=([BitConverter]::ToString($galleryBytes)).Replace('-','').ToLowerInvariant() | |
| [IO.File]::WriteAllText($galleryKeyFile,$galleryKey) | |
| } | |
| $gallerySql=[IO.File]::ReadAllText((Join-Path $PSScriptRoot 'supabase_public_gallery.sql')) | |
| $gallerySql+="`nselect public.defectrag_gallery_configure('$galleryKey');`n" | |
| $gallerySqlFile=Join-Path $galleryFolder 'gallery-setup.sql' | |
| [IO.File]::WriteAllText($gallerySqlFile,$gallerySql) | |
| Write-Output "Prepared local setup SQL: $gallerySqlFile" | |
| Write-Output "Private gallery key file: $galleryKeyFile" | |
| Write-Output 'Review the SQL and execute it manually in Supabase SQL Editor.' | |
| Write-Output 'Set HF Space secret DEFECTRAG_GALLERY_KEY to the key file content, and variable DEFECTRAG_GALLERY_ENABLED to 1.' | |
| Write-Output 'Keep runtime/ private. No database, deployment settings or existing staff records were changed.' | |