Skip to content

Collection Module: Enhance smart batching #43

Collection Module: Enhance smart batching

Collection Module: Enhance smart batching #43

name: Format Issue with OpenAI
on:
issues:
types: [opened]
permissions:
issues: write
jobs:
format-issue:
runs-on: ubuntu-latest
steps:
- name: Rewrite issue body
id: body
uses: actions/github-script@v8
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
with:
script: |
const issue = context.payload.issue;
const response = await fetch('https://api.openai.com/v1/chat/completions', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${process.env.OPENAI_API_KEY}`
},
body: JSON.stringify({
model: 'gpt-4o-mini',
max_tokens: 1024,
messages: [{
role: 'user',
content: `Rewrite this GitHub issue body using the exact format below. Keep it short, crisp and easy to understand. Do NOT add any information that wasn't in the original. Output ONLY the formatted markdown, nothing else.
Format:
**Is your feature request related to a problem?**
(Describe the problem in 1-2 sentences. Explain why it matters and what pain it causes.)
**Describe the solution you'd like**
(What should be done. Use bullet points if there are multiple items.)
Here is an example of a well-formatted body:
**Is your feature request related to a problem?**
We currently don't have STT (Speech-to-Text) evaluation capabilities in our platform. NGOs need a way to evaluate transcription quality by comparing model outputs against ground truth.
**Describe the solution you'd like**
Integrate STT evaluation into the platform. We've already benchmarked few providers so for adding scaffolding for STT evaluation we can start with Gemini and use batch API
Original issue title: ${issue.title}
Original issue body:
${issue.body || '(empty)'}`
}]
})
});
const data = await response.json();
if (!data.choices || !data.choices[0]) {
core.setFailed(`OpenAI API error: ${JSON.stringify(data)}`);
return;
}
return data.choices[0].message.content;
- name: Rewrite issue title
id: title
uses: actions/github-script@v8
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
with:
script: |
const formattedBody = ${{ steps.body.outputs.result }};
const response = await fetch('https://api.openai.com/v1/chat/completions', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${process.env.OPENAI_API_KEY}`
},
body: JSON.stringify({
model: 'gpt-4o-mini',
max_tokens: 100,
messages: [{
role: 'user',
content: `Based on the issue body below, generate a short title in this exact format:
"Module Name: 4-5 word summary"
Examples:
- Evaluation: Automated metrics for STT
- Evaluation: Refactoring CRON
- Evaluation: Fix score format
Output ONLY the title, nothing else.
Issue body:
${formattedBody}`
}]
})
});
const data = await response.json();
if (!data.choices || !data.choices[0]) {
core.setFailed(`OpenAI API error: ${JSON.stringify(data)}`);
return;
}
return data.choices[0].message.content.replace(/^["']|["']$/g, '');
- name: Update issue
uses: actions/github-script@v8
with:
script: |
const formattedBody = ${{ steps.body.outputs.result }};
const formattedTitle = ${{ steps.title.outputs.result }};
const original = context.payload.issue.body || '(empty)';
await github.rest.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.issue.number,
title: formattedTitle,
body: `${formattedBody}\n\n<details><summary>Original issue</summary>\n\n${original}\n\n</details>`
});