Skip to content

Commit 04cc833

Browse files
committed
feat: Add environment configuration and GitHub workflows for discussion labeling
- Created a new .env.sample file for environment variable configuration. - Added a discussion labeler workflow to automatically label discussions based on predefined tags. - Implemented a workflow for labeling new discussions upon creation. - Updated .gitignore to exclude additional files and directories. - Enhanced basic.py to include Prompty integration for tagging discussions. - Developed a script to generate discussion questions based on tags. - Created a new script for managing GitHub labels. - Updated requirements.txt to include new dependencies for Azure and Prompty. - Expanded tags.json with additional tags and descriptions for discussions.
1 parent 0bf25a7 commit 04cc833

File tree

13 files changed

+1186
-0
lines changed

13 files changed

+1186
-0
lines changed

#.env sample

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#prompty agent
2+
AZURE_OPENAI_ENDPOINT=
3+
AZURE_OPENAI_KEY=
4+
AZURE_OPENAI_API_VERSION=
5+
GITHUB_TOKEN=
6+
7+
#basic agent
8+
BING_CONNECTION_NAME=
9+
PROJECT_CONNECTION=
10+
MODEL_DEPLOYMENT=

.env.sample

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# GitHub App credentials
2+
GITHUB_APP_ID=your-app-id-here
3+
GITHUB_APP_INSTALLATION_ID=your-installation-id-here
4+
GITHUB_APP_PRIVATE_KEY_PATH=./
5+
6+
# GitHub repo to monitor
7+
DEFAULT_REPO=owner/repo-name
8+
9+
# How often to check for new discussions (in minutes)
10+
RUN_INTERVAL_MINUTES=600
11+
12+
# Request timeout in seconds
13+
REQUEST_TIMEOUT=30
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Discussion Labeler
2+
3+
on:
4+
schedule:
5+
# Run every hour
6+
- cron: '0 * * * *'
7+
workflow_dispatch: # Allow manual triggering
8+
9+
jobs:
10+
label-discussions:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout repository
15+
uses: actions/checkout@v3
16+
17+
- name: Set up Python
18+
uses: actions/setup-python@v4
19+
with:
20+
python-version: '3.10'
21+
22+
- name: Install dependencies
23+
run: |
24+
python -m pip install --upgrade pip
25+
pip install -r requirements.txt
26+
27+
- name: Run discussion labeler
28+
env:
29+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30+
DEFAULT_REPO: ${{ github.repository }}
31+
REQUEST_TIMEOUT: "30"
32+
RUN_INTERVAL_MINUTES: "300"
33+
run: |
34+
# Run once and exit (no need for continuous scheduling in GitHub Actions)
35+
python -c "import basic; basic.process_discussions()"
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Label New Discussion
2+
3+
on:
4+
discussion:
5+
types: [created]
6+
7+
jobs:
8+
label-discussion:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout repository
12+
uses: actions/checkout@v4
13+
14+
- name: Set up Python
15+
uses: actions/setup-python@v5
16+
with:
17+
python-version: '3.11'
18+
19+
- name: Install dependencies
20+
run: |
21+
python -m pip install --upgrade pip
22+
pip install -r requirements.txt
23+
24+
- name: Copy .env file
25+
run: |
26+
if [ -f .env ]; then cp .env .env.workflow; fi
27+
28+
- name: Run discussion labeler
29+
env:
30+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31+
GITHUB_APP_ID: ${{ secrets.GITHUB_APP_ID }}
32+
GITHUB_APP_PRIVATE_KEY_PATH: ${{ secrets.GITHUB_APP_PRIVATE_KEY_PATH }}
33+
GITHUB_APP_INSTALLATION_ID: ${{ secrets.GITHUB_APP_INSTALLATION_ID }}
34+
DEFAULT_REPO: ${{ github.repository }}
35+
run: |
36+
python basic.py

.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.env
2+
3+
# add .run folder
4+
.runs/*
5+
.runs
6+
7+
# gitignore for a python and flask application
8+
__pycache__/
9+
*.py[cod]
10+
./venv/*
11+
venv/
12+
13+
azure-ai-foundry-discussions.2025-05-06.private-key.pem

basic.prompty

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
name: categorize-discussions
3+
description: Automatically tag GitHub discussions using a predefined list of tags.
4+
authors:
5+
- Bethany Jepchumba
6+
model:
7+
api: chat
8+
configuration:
9+
type: azure_openai
10+
azure_endpoint: ${env:AZURE_OPENAI_ENDPOINT}
11+
api_key: ${env:AZURE_OPENAI_KEY}
12+
api_version: ${env:AZURE_OPENAI_API_VERSION}
13+
azure_deployment: gpt-4.1
14+
sample:
15+
title: hello my ai foundry extension is okay
16+
tags: ${file:tags.json}
17+
description: hi, can you help me figure out a problem with Azure AI Foundry? The local extension is okay but it keeps giving me issues when I shift to the browser
18+
19+
---
20+
system:
21+
You are an intelligent GitHub discussion tagging assistant. Available tags: ${inputs}
22+
23+
{% if tags.tags %}
24+
## Available Tags
25+
{% for tag in tags.tags %}
26+
name: {{tag.name}}
27+
28+
description: {{tag.description}}
29+
{% endfor %}
30+
{% endif %}
31+
32+
Guidelines:
33+
1. Only select tags that **exactly match** the provided list above. If you cannot find an exact match, do not add any tags.
34+
2. If no tags apply, **return an empty array `[]`**. Do not guess or add unrelated tags.
35+
3. **Return only a valid JSON array of strings**, nothing else.
36+
4. Do not explain your choices or add any other text. Return the tags only.
37+
5. Strictly use **only** the tags provided in the list above.
38+
39+
Use your understanding of the discussion and refer to documentation at https://learn.microsoft.com/en-us/azure/ai-foundry/ to match appropriate tags.
40+
41+
## Output:
42+
- Only a valid JSON array of tags, like this:
43+
44+
Example 1:
45+
Discussion Title: "App crashes when running in Azure CLI"
46+
Discussion Body: "Running the generated code in Azure CLI throws a Python runtime error."
47+
Tag List: ["bug", "python-sdk"]
48+
Output: [ "bug", "python-sdk" ]
49+
50+
Example 2 (no match):
51+
Discussion Title: "New feature request: Dark mode in Azure"
52+
Discussion Body: "Would love to see dark mode in the Azure portal."
53+
Tag List: ["feature-request", "ui-design"]
54+
Output: []
55+
56+
user:
57+
Discussion Title: {{title}}
58+
Discussion Description: {{description}}
59+
60+
61+

0 commit comments

Comments
 (0)