ultralytics-actions 0.0.25__tar.gz → 0.0.27__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (20) hide show
  1. {ultralytics_actions-0.0.25 → ultralytics_actions-0.0.27}/PKG-INFO +1 -1
  2. {ultralytics_actions-0.0.25 → ultralytics_actions-0.0.27}/actions/__init__.py +1 -1
  3. {ultralytics_actions-0.0.25 → ultralytics_actions-0.0.27}/actions/first_interaction.py +2 -2
  4. {ultralytics_actions-0.0.25 → ultralytics_actions-0.0.27}/actions/summarize_pr.py +56 -9
  5. {ultralytics_actions-0.0.25 → ultralytics_actions-0.0.27}/ultralytics_actions.egg-info/PKG-INFO +1 -1
  6. {ultralytics_actions-0.0.25 → ultralytics_actions-0.0.27}/LICENSE +0 -0
  7. {ultralytics_actions-0.0.25 → ultralytics_actions-0.0.27}/README.md +0 -0
  8. {ultralytics_actions-0.0.25 → ultralytics_actions-0.0.27}/actions/summarize_release.py +0 -0
  9. {ultralytics_actions-0.0.25 → ultralytics_actions-0.0.27}/actions/update_markdown_code_blocks.py +0 -0
  10. {ultralytics_actions-0.0.25 → ultralytics_actions-0.0.27}/actions/utils/__init__.py +0 -0
  11. {ultralytics_actions-0.0.25 → ultralytics_actions-0.0.27}/actions/utils/common_utils.py +0 -0
  12. {ultralytics_actions-0.0.25 → ultralytics_actions-0.0.27}/actions/utils/github_utils.py +0 -0
  13. {ultralytics_actions-0.0.25 → ultralytics_actions-0.0.27}/actions/utils/openai_utils.py +0 -0
  14. {ultralytics_actions-0.0.25 → ultralytics_actions-0.0.27}/pyproject.toml +0 -0
  15. {ultralytics_actions-0.0.25 → ultralytics_actions-0.0.27}/setup.cfg +0 -0
  16. {ultralytics_actions-0.0.25 → ultralytics_actions-0.0.27}/ultralytics_actions.egg-info/SOURCES.txt +0 -0
  17. {ultralytics_actions-0.0.25 → ultralytics_actions-0.0.27}/ultralytics_actions.egg-info/dependency_links.txt +0 -0
  18. {ultralytics_actions-0.0.25 → ultralytics_actions-0.0.27}/ultralytics_actions.egg-info/entry_points.txt +0 -0
  19. {ultralytics_actions-0.0.25 → ultralytics_actions-0.0.27}/ultralytics_actions.egg-info/requires.txt +0 -0
  20. {ultralytics_actions-0.0.25 → ultralytics_actions-0.0.27}/ultralytics_actions.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ultralytics-actions
3
- Version: 0.0.25
3
+ Version: 0.0.27
4
4
  Summary: Ultralytics Actions for GitHub automation and PR management.
5
5
  Author-email: Glenn Jocher <glenn.jocher@ultralytics.com>
6
6
  Maintainer-email: Ultralytics <hello@ultralytics.com>
@@ -22,4 +22,4 @@
22
22
  # ├── test_summarize_pr.py
23
23
  # └── ...
24
24
 
25
- __version__ = "0.0.25"
25
+ __version__ = "0.0.27"
@@ -335,7 +335,7 @@ INSTRUCTIONS:
335
335
  - Adapt the example {issue_type} response below as appropriate, keeping all badges, links and references provided
336
336
  - For bug reports, specifically request a minimum reproducible example (MRE) if not provided
337
337
  - INCLUDE ALL LINKS AND INSTRUCTIONS IN THE EXAMPLE BELOW, customized as appropriate
338
- - In your response, mention to the user that this is an automated response and that an Ultralytics engineer will also assist soon
338
+ - Mention to the user that this is an automated response and that an Ultralytics engineer will also assist soon
339
339
  - Do not add a sign-off or valediction like "best regards" at the end of your response
340
340
  - Do not add spaces between bullet points or numbered lists
341
341
  - Only link to files or URLs in the example below, do not add external links
@@ -359,7 +359,7 @@ YOUR {issue_type.upper()} RESPONSE:
359
359
  messages = [
360
360
  {
361
361
  "role": "system",
362
- "content": f"You are a helpful assistant responding to GitHub {issue_type}s for the {org_name} organization.",
362
+ "content": f"You are a helpful assistant responding to GitHub {issue_type}s for {org_name}.",
363
363
  },
364
364
  {"role": "user", "content": prompt},
365
365
  ]
@@ -13,12 +13,34 @@ from .utils import (
13
13
  get_pr_diff,
14
14
  )
15
15
 
16
- # Action settings
16
+ # Constants
17
17
  SUMMARY_START = (
18
18
  "## 🛠️ PR Summary\n\n<sub>Made with ❤️ by [Ultralytics Actions](https://github.com/ultralytics/actions)<sub>\n\n"
19
19
  )
20
20
 
21
21
 
22
+ def generate_issue_comment(pr_url, pr_body):
23
+ """Generates a personalized issue comment using AI based on the PR context."""
24
+ messages = [
25
+ {
26
+ "role": "system",
27
+ "content": "You are the Ultralytics AI assistant. Generate friendly GitHub issue comments. No @ mentions or direct addressing.",
28
+ },
29
+ {
30
+ "role": "user",
31
+ "content": f"Write a comment for a fixed GitHub issue using this merged PR context:\n\n{pr_body}\n\n"
32
+ f"Include:\n"
33
+ f"1. Reference to fix PR: {pr_url}\n"
34
+ f"2. Key changes in the PR and instructions to test the fix with:\n"
35
+ f" - pip install git+https://github.com/ultralytics/ultralytics.git@main # immediate testing\n"
36
+ f" - or await next release\n"
37
+ f"3. Request verification that PR fix works\n"
38
+ f"4. Thank 🙏 for reporting the issue and encourage reporting any new issues in the future\n\n",
39
+ },
40
+ ]
41
+ return get_completion(messages)
42
+
43
+
22
44
  def generate_pr_summary(repo_name, diff_text):
23
45
  """Generates a concise, professional summary of a PR using OpenAI's API for Ultralytics repositories."""
24
46
  if not diff_text:
@@ -72,8 +94,7 @@ def update_pr_description(repo_name, pr_number, new_summary, max_retries=2):
72
94
 
73
95
 
74
96
  def label_fixed_issues(pr_number):
75
- """Labels issues that are closed by this PR when it's merged."""
76
- # GraphQL query to get closing issues
97
+ """Labels issues closed by this PR when merged and notifies users about the fix with AI-generated comments."""
77
98
  query = """
78
99
  query($owner: String!, $repo: String!, $pr_number: Int!) {
79
100
  repository(owner: $owner, name: $repo) {
@@ -83,6 +104,8 @@ query($owner: String!, $repo: String!, $pr_number: Int!) {
83
104
  number
84
105
  }
85
106
  }
107
+ url
108
+ body
86
109
  }
87
110
  }
88
111
  }
@@ -97,26 +120,48 @@ query($owner: String!, $repo: String!, $pr_number: Int!) {
97
120
  return
98
121
 
99
122
  try:
100
- issues = response.json()["data"]["repository"]["pullRequest"]["closingIssuesReferences"]["nodes"]
123
+ data = response.json()["data"]["repository"]["pullRequest"]
124
+ issues = data["closingIssuesReferences"]["nodes"]
125
+
126
+ # Generate personalized comment
127
+ comment = generate_issue_comment(pr_url=data["url"], pr_body=data["body"])
128
+
101
129
  for issue in issues:
102
130
  issue_number = issue["number"]
131
+ # Add fixed label
103
132
  label_url = f"{GITHUB_API_URL}/repos/{GITHUB_REPOSITORY}/issues/{issue_number}/labels"
104
133
  label_response = requests.post(label_url, json={"labels": ["fixed"]}, headers=GITHUB_HEADERS)
105
- if label_response.status_code == 200:
106
- print(f"Added 'fixed' label to issue #{issue_number}")
134
+
135
+ # Add AI-generated comment
136
+ comment_url = f"{GITHUB_API_URL}/repos/{GITHUB_REPOSITORY}/issues/{issue_number}/comments"
137
+ comment_response = requests.post(comment_url, json={"body": comment}, headers=GITHUB_HEADERS)
138
+
139
+ if label_response.status_code == 200 and comment_response.status_code == 201:
140
+ print(f"Added 'fixed' label and comment to issue #{issue_number}")
107
141
  else:
108
- print(f"Failed to add label to issue #{issue_number}. Status: {label_response.status_code}")
142
+ print(
143
+ f"Failed to update issue #{issue_number}. Label status: {label_response.status_code}, "
144
+ f"Comment status: {comment_response.status_code}"
145
+ )
109
146
  except KeyError as e:
110
147
  print(f"Error parsing GraphQL response: {e}")
111
148
  return
112
149
 
113
150
 
151
+ def remove_todos_on_merge(pr_number):
152
+ """Removes specified labels from PR."""
153
+ for label in ["TODO"]: # Can be extended with more labels in the future
154
+ requests.delete(
155
+ f"{GITHUB_API_URL}/repos/{GITHUB_REPOSITORY}/issues/{pr_number}/labels/{label}", headers=GITHUB_HEADERS
156
+ )
157
+
158
+
114
159
  def main():
115
160
  """Summarize a pull request and update its description with an AI-generated summary."""
116
161
  pr_number = PR["number"]
117
162
 
118
163
  print(f"Retrieving diff for PR {pr_number}")
119
- diff = get_pr_diff(PR["number"])
164
+ diff = get_pr_diff(pr_number)
120
165
 
121
166
  # Generate PR summary
122
167
  print("Generating PR summary...")
@@ -133,7 +178,9 @@ def main():
133
178
  # Update linked issues
134
179
  if PR.get("merged"):
135
180
  print("PR is merged, labeling fixed issues...")
136
- label_fixed_issues(PR["number"])
181
+ label_fixed_issues(pr_number)
182
+ print("Removing TODO label from PR...")
183
+ remove_todos_on_merge(pr_number)
137
184
 
138
185
 
139
186
  if __name__ == "__main__":
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ultralytics-actions
3
- Version: 0.0.25
3
+ Version: 0.0.27
4
4
  Summary: Ultralytics Actions for GitHub automation and PR management.
5
5
  Author-email: Glenn Jocher <glenn.jocher@ultralytics.com>
6
6
  Maintainer-email: Ultralytics <hello@ultralytics.com>