refactor: streamline API key and configuration handling in generator

This commit is contained in:
2026-06-13 18:51:59 +02:00
parent 002628497e
commit e43c7b9101

View File

@@ -7,6 +7,16 @@ ini_set('error_log', __DIR__ . '/../errors.log');
ini_set('display_errors', '0');
error_reporting(E_ALL);
define('AI_SITE_LLM_API_BASE_URI', 'https://ai.haschek.at');
$pexelsKey = 'Clyqp9i9pewaxiiAdqVya0yZuuedjHtUtJdjRipNltp7wf0dY8K10h4h';
$apiKey = 'sk-Y1FrlvtAV4PWwK40TSVq-Q';
$model = 'llama';
$maxTokens = 32768;
$reasoningEffort = 'medium';
$httpTimeoutSeconds = (float) (getenv('LLAMA_HTTP_TIMEOUT') ?: '600');
$httpMaxDurationSeconds = (float) (getenv('LLAMA_HTTP_MAX_DURATION') ?: '0');
@@ -244,14 +254,6 @@ header('Content-Type: text/html; charset=UTF-8');
$startedAt = microtime(true);
$pexelsKey = 'Clyqp9i9pewaxiiAdqVya0yZuuedjHtUtJdjRipNltp7wf0dY8K10h4h';
$apiKey = getenv('LLAMA_API_KEY') ?: '';
$model = getenv('LLAMA_MODEL') ?: 'local-model';
$maxTokens = (int) (getenv('LLAMA_MAX_TOKENS') ?: 4096);
$reasoningEffort = getenv('LLAMA_REASONING_EFFORT') ?: 'none';
$httpTimeoutSeconds = (float) (getenv('LLAMA_HTTP_TIMEOUT') ?: '600');
$httpMaxDurationSeconds = (float) (getenv('LLAMA_HTTP_MAX_DURATION') ?: '0');
if ($httpTimeoutSeconds <= 0) {
$httpTimeoutSeconds = 600.0;
}
@@ -292,7 +294,7 @@ $bannedTerms = [
];
$bannedTermsList = implode(', ', $bannedTerms);
$factory = OpenAI::factory()->withBaseUri('http://localhost:8080/v1');
$factory = OpenAI::factory()->withBaseUri(AI_SITE_LLM_API_BASE_URI);
$factory = $factory->withHttpClient(new Psr18Client(HttpClient::create([
'timeout' => $httpTimeoutSeconds,
'max_duration' => $httpMaxDurationSeconds,