diff --git a/.github/workflows/generate.yml b/.github/workflows/generate.yml index f5db9c3..359060e 100644 --- a/.github/workflows/generate.yml +++ b/.github/workflows/generate.yml @@ -63,6 +63,7 @@ jobs: env: GH_TOKEN: ${{ secrets.MACHINE_USER_TOKEN }} OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} + OPENAI_MODEL: ${{ secrets.OPENAI_MODEL }} run: | set -ex diff --git a/src/Command/GenerateCommitMessage.php b/src/Command/GenerateCommitMessage.php index 08b30a5..09d4482 100644 --- a/src/Command/GenerateCommitMessage.php +++ b/src/Command/GenerateCommitMessage.php @@ -10,6 +10,8 @@ class GenerateCommitMessage extends Command { + public const DefaultModel = 'gpt-oss-120b'; + private OpenAI\Client $client; protected function configure() @@ -46,7 +48,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int } $result = $this->client->chat()->create([ - 'model' => getenv('OPENAI_MODEL') ?: 'gpt-4o-mini', + 'model' => getenv('OPENAI_MODEL') ?: self::DefaultModel, 'messages' => [ ['role' => 'system', 'content' => 'You will be provided a Git diff. Generate a commit message from it, following the conventional commit message format. Provide the output in plain text, without any additional formatting.'], ['role' => 'user', 'content' => $diff], diff --git a/src/Command/GenerateReleaseNotes.php b/src/Command/GenerateReleaseNotes.php index 9eb96e4..de4955e 100644 --- a/src/Command/GenerateReleaseNotes.php +++ b/src/Command/GenerateReleaseNotes.php @@ -29,11 +29,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int $diff = substr($diff, 0, 256 * 1024); } - $yourApiKey = getenv('OPENAI_API_KEY'); - $client = OpenAI::client($yourApiKey); + $client = (new OpenAI\Factory) + ->withBaseUri(getenv('OPENAI_BASE_URL') ?: 'https://llm.aihosting.mittwald.de/v1') + ->withApiKey(getenv('OPENAI_API_KEY')) + ->make(); $result = $client->chat()->create([ - 'model' => 'gpt-4o-mini', + 'model' => getenv('OPENAI_MODEL') ?: GenerateCommitMessage::DefaultModel, 'messages' => [ ['role' => 'system', 'content' => 'You will be provided a Git diff. Generate a Github release notes document, in markdown format. Your response should include ONLY the release notes without any additional start or end markers. Do not include a generic heading or date information; start any intermediate headings at the h2 level. When features are added, also include a high-level summary of said features.'], ['role' => 'user', 'content' => $diff],