HEX
Server: LiteSpeed
System: Linux houston.panomity.com 6.8.0-100-generic #100-Ubuntu SMP PREEMPT_DYNAMIC Tue Jan 13 16:40:06 UTC 2026 x86_64
User: nudepix (1011)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /home/panomity.de/vr.panomity.com/api/ollama-generate-context.php
<?php
/**
 * Ollama Context Generator API für CMS4VR
 *
 * Erzeugt und speichert eine Szenenbeschreibung in panos.ollama_context.
 * Fokus: Immobilien-/Maklerperspektive.
 */

header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: POST, OPTIONS');
header('Access-Control-Allow-Headers: Content-Type');
header('Content-Type: application/json');

if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
    http_response_code(200);
    exit;
}

if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
    http_response_code(405);
    echo json_encode(['error' => 'Method not allowed']);
    exit;
}

require_once __DIR__ . '/ollama_context_helper.php';

$dbPath = __DIR__ . '/../admin/data/vrm.db';
if (!file_exists($dbPath)) {
    http_response_code(500);
    echo json_encode(['error' => 'Database not found']);
    exit;
}

$db = new SQLite3($dbPath);
$db->busyTimeout(5000);

$input = file_get_contents('php://input');
$data = json_decode($input, true);

$panoId = isset($data['pano_id']) ? (int)$data['pano_id'] : 0;
$language = isset($data['language']) ? trim((string)$data['language']) : 'en';
$force = !empty($data['force']) && $data['force'] !== '0' && $data['force'] !== 'false';

$result = generate_ollama_context_for_pano($db, $panoId, $language, $force);
$db->close();

if (empty($result['success'])) {
    http_response_code(500);
    echo json_encode($result);
    exit;
}

echo json_encode([
    'success' => true,
    'context' => $result['context'],
    'skipped' => !empty($result['skipped']),
]);