-
Notifications
You must be signed in to change notification settings - Fork 2
Github: Issue Formatter #93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,124 @@ | ||
| 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@v9 | ||
| 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', | ||
| 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@v9 | ||
| 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', | ||
| 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@v9 | ||
| 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>` | ||
| }); | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is just one issue with this and it is that no matter if the issue is a feature/enhancement/bug issue, it fits all into the feature template. this is not that big of a problem but if there is a solution for this, then maybe we consider that? or we can merge this for now and later on do enhancements accordingly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah that crossed my mind in past, i was thinking to make kick off this only after tag and then we can be consious of what tag we put. But for now since this is first version we can keep it as it is and then update across repos