Feature: Add configurable LLM model name

This commit is contained in:
WLTBAgent
2026-02-16 17:18:31 +00:00
parent 3c2d356eb0
commit 69dfdc5f87
6 changed files with 125 additions and 5 deletions

View File

@@ -45,6 +45,7 @@ class LLMService {
try {
$apiKey = $this->config->getAppValue('anthropic_api_key', 'analyticshub');
$apiEndpoint = $this->config->getAppValue('llm_api_endpoint', 'analyticshub', '');
$model = $this->config->getAppValue('llm_model', 'analyticshub', 'claude-sonnet-4-5-20250929');
if (empty($apiKey)) {
throw new \Exception('API key not configured');
@@ -58,7 +59,7 @@ class LLMService {
$userPrompt = $this->buildUserPrompt($processedData);
// Call with retry
$response = $this->callWithRetry($systemPrompt, $userPrompt, $apiKey, $endpoint);
$response = $this->callWithRetry($systemPrompt, $userPrompt, $apiKey, $endpoint, $model);
return $response;
@@ -124,12 +125,12 @@ PROMPT;
/**
* Call Claude API with retry logic
*/
private function callWithRetry(string $systemPrompt, string $userPrompt, string $apiKey, string $endpoint): string {
private function callWithRetry(string $systemPrompt, string $userPrompt, string $apiKey, string $endpoint, string $model): string {
for ($attempt = 0; $attempt < self::MAX_RETRIES; $attempt++) {
$this->logger->info("LLM API call attempt {$attempt}/" . self::MAX_RETRIES);
try {
$response = $this->makeLLMRequest($systemPrompt, $userPrompt, $apiKey, $endpoint);
$response = $this->makeLLMRequest($systemPrompt, $userPrompt, $apiKey, $endpoint, $model);
// Validate response
$this->validateResponse($response);
@@ -186,11 +187,11 @@ PROMPT;
/**
* Make HTTP request to LLM API
*/
private function makeLLMRequest(string $systemPrompt, string $userPrompt, string $apiKey, string $endpoint): string {
private function makeLLMRequest(string $systemPrompt, string $userPrompt, string $apiKey, string $endpoint, string $model): string {
$ch = curl_init();
$payload = [
'model' => 'claude-sonnet-4-5-20250929',
'model' => $model,
'max_tokens' => 2000,
'system' => $systemPrompt,
'messages' => [