Files
Jeremy 8c67d51ced feat: multi-provider AI settings and provider foundation
Introduce the AI provider layer: laravel/ai SDK integration, AiService
and AiExtractionService, the AiProvider enum (OpenAI, Gemini, Ollama)
and supporting DTOs/agents.

- Encrypt stored API keys; per-provider test-connection action
- Ollama model dropdown with reachability-based connection test
- Multi-provider settings UI with per-row test and auto-migration of
  the legacy single-provider shape into the multi-provider structure
- Resolve active config through AiProviderConfigDto
2026-06-09 15:07:40 +10:00

38 lines
887 B
PHP

<?php
namespace App\Services;
use Illuminate\Support\Facades\Http;
class OllamaService
{
public const int DEFAULT_TIMEOUT = 10;
public static function new(): self
{
return resolve(static::class);
}
/**
* Fetch the list of model names available on an Ollama server via /api/tags.
*
* @return array<int, string>
*
* @throws \Illuminate\Http\Client\ConnectionException
* @throws \Illuminate\Http\Client\RequestException
*/
public function listModels(string $baseUrl, int $timeout = self::DEFAULT_TIMEOUT): array
{
$response = Http::baseUrl(rtrim($baseUrl, '/'))
->timeout($timeout)
->throw()
->get('/api/tags');
return collect($response->json('models', []))
->pluck('name')
->filter()
->values()
->all();
}
}