Files
actions-api/app/Services/Google/EndpointBuilderService.php
Jurgis Sakalauskas 6df493fab3 initial commit
2025-01-08 12:45:00 +02:00

29 lines
787 B
PHP

<?php
namespace App\Services\Google;
class EndpointBuilderService
{
public function buildPredictionEndpoint(string $model): string
{
return $this->buildEndpoint($model, 'predict');
}
public function buildGenerationEndpoint(string $model): string
{
return $this->buildEndpoint($model, 'generateContent');
}
private function buildEndpoint(string $model, string $action): string
{
$projectId = env('GOOGLE_CLOUD_PROJECT');
$location = env('GOOGLE_LOCATION');
$modelPath = 'projects/' . $projectId .
'/locations/' . $location .
'/publishers/google/models/' . $model .
':' . $action;
return 'https://' . $location . '-aiplatform.googleapis.com/v1/' . $modelPath;
}
}