fix: update workflow to use HuggingFace for PR description generation

This commit is contained in:
faris Aljohari
2025-07-16 00:05:33 -06:00
parent d62e620828
commit dea942f11e

View File

@ -1,4 +1,4 @@
name: 🤖 AI PR Description Commenter (100% Safe with jq) name: 🤖 AI PR Description with HuggingFace
on: on:
pull_request: pull_request:
@ -27,25 +27,21 @@ jobs:
env: env:
GH_TOKEN: ${{ secrets.GH_PERSONAL_TOKEN }} GH_TOKEN: ${{ secrets.GH_PERSONAL_TOKEN }}
- name: Generate PR Description with OpenAI (Safe JSON with jq) - name: Generate PR Description with HuggingFace (DeepSeek)
run: | run: |
REQUEST_BODY=$(jq -n \ REQUEST_BODY=$(jq -n \
--arg model "gpt-4o" \ --arg inputs "Given the following commit messages:\n\n${commits}\n\nGenerate a clear and professional pull request description." \
--arg content "Given the following commit messages:\n\n${commits}\n\nGenerate a clear and professional pull request description." \ '{ inputs: $inputs }'
'{
model: $model,
messages: [{ role: "user", content: $content }]
}'
) )
RESPONSE=$(curl -s https://api.openai.com/v1/chat/completions \ RESPONSE=$(curl -s https://api-inference.huggingface.co/models/deepseek-ai/deepseek-coder-6.7b-instruct \
-H "Authorization: Bearer $OPENAI_API_KEY" \ -H "Authorization: Bearer $HUGGINGFACE_API_KEY" \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
-d "$REQUEST_BODY") -d "$REQUEST_BODY")
DESCRIPTION=$(echo "$RESPONSE" | jq -r '.choices[0].message.content') DESCRIPTION=$(echo "$RESPONSE" | jq -r '.[0].generated_text')
echo "---------- OpenAI Raw Response ----------" echo "---------- HuggingFace Raw Response ----------"
echo "$RESPONSE" echo "$RESPONSE"
echo "---------- Extracted Description ----------" echo "---------- Extracted Description ----------"
echo "$DESCRIPTION" echo "$DESCRIPTION"
@ -54,7 +50,7 @@ jobs:
echo "$DESCRIPTION" >> $GITHUB_ENV echo "$DESCRIPTION" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV echo "EOF" >> $GITHUB_ENV
env: env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} HUGGINGFACE_API_KEY: ${{ secrets.HUGGINGFACE_API_KEY }}
commits: ${{ env.commits }} commits: ${{ env.commits }}
- name: Post AI Generated Description as Comment - name: Post AI Generated Description as Comment