feat: add LLM prediction providers with structured output support
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -15,11 +15,10 @@ class PredictionController extends Controller
|
||||
|
||||
public function index(PredictionRequest $request): JsonResponse
|
||||
{
|
||||
$fuelType = $request->fuelType();
|
||||
$lat = $request->filled('lat') ? (float) $request->input('lat') : null;
|
||||
$lng = $request->filled('lng') ? (float) $request->input('lng') : null;
|
||||
|
||||
$result = $this->predictionService->predict($fuelType, $lat, $lng);
|
||||
$result = $this->predictionService->predict($lat, $lng);
|
||||
|
||||
return response()->json($result);
|
||||
}
|
||||
|
||||
@@ -2,9 +2,7 @@
|
||||
|
||||
namespace App\Http\Requests\Api;
|
||||
|
||||
use App\Enums\FuelType;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
class PredictionRequest extends FormRequest
|
||||
{
|
||||
@@ -16,18 +14,8 @@ class PredictionRequest extends FormRequest
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'fuel_type' => ['required', 'string'],
|
||||
'lat' => ['nullable', 'numeric', 'between:-90,90'],
|
||||
'lng' => ['nullable', 'numeric', 'between:-180,180'],
|
||||
];
|
||||
}
|
||||
|
||||
public function fuelType(): FuelType
|
||||
{
|
||||
try {
|
||||
return FuelType::fromAlias($this->string('fuel_type')->toString());
|
||||
} catch (\ValueError) {
|
||||
throw ValidationException::withMessages(['fuel_type' => 'Unknown fuel type. Use: diesel, petrol, e10, e5, hvo, b10.']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user