36 lines
1.1 KiB
PowerShell
36 lines
1.1 KiB
PowerShell
# Memory Embeddings Cron Job
|
|
# Processes memory files and stores with embeddings
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
$pythonPath = "python"
|
|
$scriptPath = "$env:USERPROFILE\.openclaw\workspace\tools\memory_embedding_worker.py"
|
|
|
|
Write-Host "Starting Memory Embedding Worker..."
|
|
|
|
# Check if Ollama is running
|
|
try {
|
|
$response = Invoke-RestMethod -Uri "http://localhost:11434/api/tags" -TimeoutSec 5
|
|
Write-Host "[OK] Ollama is running"
|
|
} catch {
|
|
Write-Host "[ERROR] Ollama not available. Cannot generate embeddings." -ForegroundColor Red
|
|
exit 1
|
|
}
|
|
|
|
# Check if nomic-embed-text is available
|
|
$hasModel = $response.models | Where-Object { $_.name -like "*nomic-embed-text*" }
|
|
if (-not $hasModel) {
|
|
Write-Host "[WARNING] nomic-embed-text model not found. Pulling..." -ForegroundColor Yellow
|
|
& $pythonPath -c "import requests; requests.post('http://localhost:11434/api/pull', json={'model': 'nomic-embed-text'}).json()"
|
|
}
|
|
|
|
# Run the worker
|
|
& $pythonPath $scriptPath
|
|
|
|
if ($LASTEXITCODE -ne 0) {
|
|
Write-Host "[ERROR] Worker failed with exit code $LASTEXITCODE" -ForegroundColor Red
|
|
exit $LASTEXITCODE
|
|
}
|
|
|
|
Write-Host "[OK] Memory embeddings complete"
|