34 lines
1.1 KiB
PHP
34 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\Cache;
|
|
|
|
/**
|
|
* Frontend POSTet die letzten POI-Treffer hierher. Backend speichert sie in
|
|
* Redis-Cache, damit FoxAgent::think() sie als Kontext ans LLM mitgeben kann.
|
|
* So kann Fox auf "empfehl mir eins" eine konkrete Stelle aus der Liste nennen.
|
|
*/
|
|
class FoxPoiContextController
|
|
{
|
|
public function __invoke(Request $request): JsonResponse
|
|
{
|
|
$data = $request->validate([
|
|
'category' => 'nullable|string|max:60',
|
|
'label' => 'nullable|string|max:120',
|
|
'city' => 'nullable|string|max:120',
|
|
'pois' => 'nullable|array|max:50',
|
|
'pois.*.name' => 'string|max:160',
|
|
'pois.*.address' => 'nullable|string|max:200',
|
|
'pois.*.lat' => 'numeric',
|
|
'pois.*.lng' => 'numeric',
|
|
]);
|
|
|
|
Cache::put('fox.last_pois', $data, now()->addHours(2));
|
|
|
|
return response()->json(['ok' => true, 'count' => count($data['pois'] ?? [])]);
|
|
}
|
|
}
|