46 lines
1.4 KiB
PHP
46 lines
1.4 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
declare(strict_types=1);
|
||
|
|
|
||
|
|
namespace App\Infrastructure\AI\Agent;
|
||
|
|
|
||
|
|
use App\Infrastructure\AI\OllamaClientInterface;
|
||
|
|
use App\Infrastructure\Search\WebSearchInterface;
|
||
|
|
|
||
|
|
final class SpecsResearchAgent
|
||
|
|
{
|
||
|
|
public function __construct(
|
||
|
|
private readonly WebSearchInterface $webSearch,
|
||
|
|
private readonly OllamaClientInterface $ollama,
|
||
|
|
private readonly string $model,
|
||
|
|
) {
|
||
|
|
}
|
||
|
|
|
||
|
|
public function research(string $modelName): string
|
||
|
|
{
|
||
|
|
$query = "{$modelName} technical specifications full specs";
|
||
|
|
$searchText = $this->webSearch->search($query);
|
||
|
|
|
||
|
|
if ('' === $searchText) {
|
||
|
|
$searchText = $this->webSearch->search("{$modelName} specs datasheet");
|
||
|
|
}
|
||
|
|
|
||
|
|
if ('' === $searchText) {
|
||
|
|
throw new \RuntimeException("No web search results found for model: {$modelName}");
|
||
|
|
}
|
||
|
|
|
||
|
|
$prompt = <<<PROMPT
|
||
|
|
Based on the following search results about "{$modelName}", extract and list all technical specifications.
|
||
|
|
Include: processor, RAM, storage, display, GPU, battery, ports, weight, dimensions, and any other specs found.
|
||
|
|
Be complete and accurate. Use the search results as your source, not general knowledge.
|
||
|
|
|
||
|
|
Search results:
|
||
|
|
{$searchText}
|
||
|
|
|
||
|
|
List all specifications:
|
||
|
|
PROMPT;
|
||
|
|
|
||
|
|
return $this->ollama->generate($this->model, $prompt);
|
||
|
|
}
|
||
|
|
}
|