From 2e1858c18ee296f11af1359972f7cd3b4b34f142 Mon Sep 17 00:00:00 2001 From: NagaprasadNaik Date: Fri, 20 Jun 2025 21:38:59 +0530 Subject: [PATCH 1/5] issue35 --- .DS_Store | Bin 0 -> 8196 bytes .gitignore | 1 + GEN_AI_PR_DESC/.gitignore | 17 ++++ GEN_AI_PR_DESC/.python-version | 1 + GEN_AI_PR_DESC/app.py | 161 +++++++++++++++++++++++++++++++++ 5 files changed, 180 insertions(+) create mode 100644 .DS_Store create mode 100644 .gitignore create mode 100644 GEN_AI_PR_DESC/.gitignore create mode 100644 GEN_AI_PR_DESC/.python-version create mode 100644 GEN_AI_PR_DESC/app.py diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..b6e3da614d553465dbe54f1a53a70b979bea4307 GIT binary patch literal 8196 zcmeHM&ubGw6n>MY?WV=jLn{F<3!a2hQyZ(rOGsNmuqa0Kpc3<|ZFIXEl8v#1NY3@( z(VKsV;N3sLKf}8x{oc%^%p@D=MJse>nR&Cb?|bv+n;)CEAtF)i);EZ1-kbLpy;r59s8@fv|sSu(Whj6?UyMuY8wjg!4+w=hPSQ`!j`iTdas>YxKqc5`earq5J;It|=Jx3^ zm1Mmpk##y48_jq0^~o5`HE6fN#0KSQlWtQEl6hf!HCYR(i95cJ(VobW_&ni}Y4r|m z(Ke88fR8A&JxUz{YtHV9<&nac=>T2?@PR!@v?G3v*;z8|@gSD?rA4b@7 z`e4}^`EZVP#vEGfEUW#uv1RIkiI|RzSxTN0J}c~X+rf;s= min_score: + section_header = None + for j in range(i, max(i - 10, 0), -1): + m = re.match(r'(Section|chapter|Clause)?\s*([0-9.]+)', lines[j], re.IGNORECASE) + if m: + section_header = m.group(2) + break + if section_header: + candidates.append((match_score, section_header, lines[i].strip())) + + if candidates: + candidates.sort(reverse=True) + return candidates[0][1] + return "N/A" + +def summarize_patch(patch, section_text): + prompt = f""" + You are reviewing a GitHub pull request. Below is the code patch and a relevant specification section. + + Summarize the purpose of this pull request, explaining what functionality it adds, changes, or fixes. + Be concise and clear. + + Patch: + {patch} + + Relevant Spec Section: + {section_text} + """ + response = client.chat.completions.create( + model=MODEL_NAME, + messages=[{"role": "user", "content": prompt}], + temperature=0.7, + max_tokens=1024, + ) + return response.choices[0].message.content + +# ---------------------------- +# GUI Integration +# ---------------------------- +def run_analysis(): + pr_number = entry.get().strip() + output_text.delete(1.0, END) + + if not pr_number.isdigit(): + messagebox.showerror("Input Error", "Please enter a valid numeric PR number.") + return + + try: + output_text.insert(END, f"Fetching PR #{pr_number}...\n") + patch_path, title_path = fetch_and_save_pr_data(pr_number) + patches = load_patches(patch_path) + filenames = [p['filename'] for p in patches] + title_lookup = load_titles(title_path, filenames) + spec_text = load_spec_text(PDF_PATH) + + for i, patch_item in enumerate(patches): + filename = patch_item.get('filename', 'unknown') + patch = patch_item.get('patch', '') + title = title_lookup.get(filename, "") + + title_keywords = extract_keywords(title) + patch_keywords = extract_keywords(patch) + + section_id = find_spec_section_by_keywords(spec_text, title_keywords) + if section_id == "N/A": + section_id = find_spec_section_by_keywords(spec_text, patch_keywords) + + section_info = f"Section {section_id}" if section_id != "N/A" else "No relevant section found" + summary = summarize_patch(patch, section_info) + + output_text.insert(END, f"\n--- Patch {i+1}: {filename} ---\n") + output_text.insert(END, f"{summary}\n") + output_text.insert(END, "-" * 60 + "\n") + + output_text.insert(END, "Done.\n") + + except Exception as e: + messagebox.showerror("Error", str(e)) + +# ---------------------------- +# Build GUI +# ---------------------------- +root = Tk() +root.title("OpenMP PR Analyzer") + +Label(root, text="Enter GitHub PR Number:").grid(row=0, column=0, padx=10, pady=10, sticky="w") +entry = Entry(root, width=30) +entry.grid(row=0, column=1, padx=10, pady=10) + +Button(root, text="Summarize", command=run_analysis, bg="lightblue").grid(row=0, column=2, padx=10, pady=10) + +output_text = ScrolledText(root, width=100, height=30, wrap="word") +output_text.grid(row=1, column=0, columnspan=3, padx=10, pady=10) + +root.mainloop() From 73140bc1fc628a91edf173bad7de40e09e26fce7 Mon Sep 17 00:00:00 2001 From: NagaprasadNaik Date: Fri, 20 Jun 2025 21:43:08 +0530 Subject: [PATCH 2/5] issue35 --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 50a6e8bf3da71..e3222e826a474 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -CDEL \ No newline at end of file +CDEL + From c844215b64ce1ff500a762065e0d3167b8d3bb47 Mon Sep 17 00:00:00 2001 From: NagaprasadNaik Date: Fri, 20 Jun 2025 22:02:40 +0530 Subject: [PATCH 3/5] Issue35 --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index e3222e826a474..f58a10afbcae5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1 @@ CDEL - From fcac4db44affa12f73b1ef87e7acadeb90e0bc67 Mon Sep 17 00:00:00 2001 From: NagaprasadNaik <115172166+NagaprasadNaik@users.noreply.github.com> Date: Fri, 20 Jun 2025 22:42:18 +0530 Subject: [PATCH 4/5] Update app.py --- GEN_AI_PR_DESC/app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GEN_AI_PR_DESC/app.py b/GEN_AI_PR_DESC/app.py index e9ff37ca75a35..0449febefc594 100644 --- a/GEN_AI_PR_DESC/app.py +++ b/GEN_AI_PR_DESC/app.py @@ -10,7 +10,7 @@ REPO = "llvm/llvm-project" MODEL_NAME = "llama3-70b-8192" PDF_PATH = "OpenMPSpec.pdf" -# API = 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 + # ============================ client = Groq() From 94b6d5a11db0aab8e65d25248c63afb4c3b0e8b1 Mon Sep 17 00:00:00 2001 From: NagaprasadNaik <115172166+NagaprasadNaik@users.noreply.github.com> Date: Fri, 20 Jun 2025 22:46:27 +0530 Subject: [PATCH 5/5] Update app.py --- GEN_AI_PR_DESC/app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GEN_AI_PR_DESC/app.py b/GEN_AI_PR_DESC/app.py index 0449febefc594..b9d161cfb69a6 100644 --- a/GEN_AI_PR_DESC/app.py +++ b/GEN_AI_PR_DESC/app.py @@ -9,7 +9,7 @@ # ========== CONFIG ========== REPO = "llvm/llvm-project" MODEL_NAME = "llama3-70b-8192" -PDF_PATH = "OpenMPSpec.pdf" +#PDF_PATH = "OpenMPSpec.pdf" The file OpenMPSpec.pdf should be included in the directory. # ============================ client = Groq()