Skip to content

Commit 982d4fa

Browse files
authored
Merge pull request #111 from Integration-Automation/dev
Dev
2 parents 703d8cb + c4231a5 commit 982d4fa

13 files changed

Lines changed: 314 additions & 109 deletions

File tree

automation_ide/automation_editor_ui/extend_ai_gui/ai_gui_global_variable.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
FIRST_CODE_REVIEW_TEMPLATE
55
from automation_ide.automation_editor_ui.extend_ai_gui.prompt_edit_gui.cot_code_review_prompt_templates.first_summary_prompt import \
66
FIRST_SUMMARY_TEMPLATE
7-
from automation_ide.automation_editor_ui.extend_ai_gui.prompt_edit_gui.cot_code_review_prompt_templates.global_rule import \
8-
GLOBAL_RULE_TEMPLATE
97
from automation_ide.automation_editor_ui.extend_ai_gui.prompt_edit_gui.cot_code_review_prompt_templates.linter import \
108
LINTER_TEMPLATE
119
from automation_ide.automation_editor_ui.extend_ai_gui.prompt_edit_gui.cot_code_review_prompt_templates.total_summary import \
@@ -16,7 +14,6 @@
1614
CODE_REVIEW_SKILL_TEMPLATE
1715

1816
COT_TEMPLATE_FILES = [
19-
"global_rule.md",
2017
"first_summary_prompt.md",
2118
"first_code_review.md",
2219
"linter.md",
@@ -25,7 +22,6 @@
2522
]
2623

2724
COT_TEMPLATE_RELATION = {
28-
"global_rule.md": GLOBAL_RULE_TEMPLATE,
2925
"first_summary_prompt.md": FIRST_SUMMARY_TEMPLATE,
3026
"first_code_review.md": FIRST_CODE_REVIEW_TEMPLATE,
3127
"linter.md": LINTER_TEMPLATE,

automation_ide/automation_editor_ui/extend_ai_gui/code_review/__init__.py

Whitespace-only changes.

automation_ide/automation_editor_ui/extend_ai_gui/cot_code_review_gui.py renamed to automation_ide/automation_editor_ui/extend_ai_gui/code_review/code_review_thread.py

Lines changed: 3 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,13 @@
1-
import sys
2-
1+
# Worker Thread 負責傳送資料
32
import requests
43
from PySide6.QtCore import QThread, Signal
5-
from PySide6.QtWidgets import (
6-
QApplication, QWidget, QVBoxLayout, QHBoxLayout,
7-
QPushButton, QTextEdit, QLabel, QLineEdit, QComboBox, QMessageBox
8-
)
94
from je_editor import language_wrapper
105

11-
from automation_ide.automation_editor_ui.extend_ai_gui.ai_gui_global_variable import COT_TEMPLATE_FILES, \
12-
COT_TEMPLATE_RELATION
6+
from automation_ide.automation_editor_ui.extend_ai_gui.ai_gui_global_variable import COT_TEMPLATE_RELATION
137
from automation_ide.automation_editor_ui.extend_ai_gui.prompt_edit_gui.cot_code_review_prompt_templates.global_rule import \
148
build_global_rule_template
15-
from automation_ide.automation_editor_ui.extend_multi_language.update_language_dict import update_language_dict
169

1710

18-
# Worker Thread 負責傳送資料
1911
class SenderThread(QThread):
2012
update_response = Signal(str, str) # (filename, response)
2113

@@ -86,80 +78,4 @@ def run(self):
8678
reply_text = f"{language_wrapper.language_word_dict.get("cot_gui_error_sending")} {file} {e}"
8779

8880
# 發送訊號更新 UI
89-
self.update_response.emit(file, reply_text)
90-
91-
92-
class CoTCodeReviewGUI(QWidget):
93-
def __init__(self):
94-
super().__init__()
95-
self.setWindowTitle(language_wrapper.language_word_dict.get("cot_gui_window_title"))
96-
97-
# 檔案清單
98-
self.files = COT_TEMPLATE_FILES
99-
100-
# UI 元件
101-
layout = QVBoxLayout()
102-
103-
# URL 輸入框
104-
url_layout = QHBoxLayout()
105-
url_layout.addWidget(QLabel(language_wrapper.language_word_dict.get("cot_gui_label_api_url")))
106-
self.url_input = QLineEdit()
107-
self.url_input.setPlaceholderText(language_wrapper.language_word_dict.get("cot_gui_placeholder_api_url"))
108-
url_layout.addWidget(self.url_input)
109-
layout.addLayout(url_layout)
110-
111-
# 傳送資料區域
112-
self.code_paste_area = QTextEdit()
113-
self.code_paste_area.setPlaceholderText(
114-
language_wrapper.language_word_dict.get("cot_gui_placeholder_code_paste_area"))
115-
layout.addWidget(QLabel(language_wrapper.language_word_dict.get("cot_gui_label_prompt_area")))
116-
layout.addWidget(self.code_paste_area)
117-
118-
# 回傳區域
119-
self.response_selector = QComboBox() # 改用 ComboBox
120-
self.response_view = QTextEdit()
121-
self.response_view.setReadOnly(True) # 可複製但不可編輯
122-
123-
hbox_layout = QHBoxLayout()
124-
hbox_layout.addWidget(self.response_selector, 2)
125-
hbox_layout.addWidget(self.response_view, 5)
126-
127-
layout.addWidget(QLabel(language_wrapper.language_word_dict.get("cot_gui_label_response_area")))
128-
layout.addLayout(hbox_layout)
129-
130-
# 傳送按鈕
131-
self.send_button = QPushButton(language_wrapper.language_word_dict.get("cot_gui_button_send"))
132-
layout.addWidget(self.send_button)
133-
134-
self.setLayout(layout)
135-
136-
# 綁定事件
137-
self.response_selector.currentTextChanged.connect(self.show_response)
138-
self.send_button.clicked.connect(self.start_sending)
139-
140-
# 儲存回覆
141-
self.responses = {}
142-
143-
def show_response(self, filename):
144-
if filename in self.responses:
145-
self.response_view.setPlainText(self.responses[filename])
146-
147-
def start_sending(self):
148-
# 取得 URL
149-
url = self.url_input.text().strip()
150-
if not url:
151-
message_box = QMessageBox()
152-
message_box.warning(self, "Warning", language_wrapper.language_word_dict.get("cot_gui_error_no_url"))
153-
message_box.exec_()
154-
return
155-
156-
# 啟動傳送 Thread
157-
self.thread = SenderThread(files=self.files, code=self.code_paste_area.toPlainText(), url=url)
158-
self.thread.update_response.connect(self.handle_response)
159-
self.thread.start()
160-
161-
def handle_response(self, filename, response):
162-
self.responses[filename] = response
163-
self.response_selector.addItem(filename) # 加入 ComboBox
164-
# 自動顯示最新回覆
165-
self.response_selector.setCurrentText(filename)
81+
self.update_response.emit(file, reply_text)
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
from PySide6.QtWidgets import QWidget, QVBoxLayout, QHBoxLayout, QLabel, QLineEdit, QTextEdit, QComboBox, QPushButton, \
2+
QMessageBox
3+
from je_editor import language_wrapper
4+
5+
from automation_ide.automation_editor_ui.extend_ai_gui.ai_gui_global_variable import COT_TEMPLATE_FILES
6+
from automation_ide.automation_editor_ui.extend_ai_gui.code_review.code_review_thread import SenderThread
7+
8+
9+
class CoTCodeReviewGUI(QWidget):
10+
def __init__(self):
11+
super().__init__()
12+
self.setWindowTitle(language_wrapper.language_word_dict.get("cot_gui_window_title"))
13+
14+
# 檔案清單
15+
self.files = COT_TEMPLATE_FILES
16+
17+
# UI 元件
18+
layout = QVBoxLayout()
19+
20+
# URL 輸入框
21+
url_layout = QHBoxLayout()
22+
url_layout.addWidget(QLabel(language_wrapper.language_word_dict.get("cot_gui_label_api_url")))
23+
self.url_input = QLineEdit()
24+
self.url_input.setPlaceholderText(language_wrapper.language_word_dict.get("cot_gui_placeholder_api_url"))
25+
url_layout.addWidget(self.url_input)
26+
layout.addLayout(url_layout)
27+
28+
# 傳送資料區域
29+
self.code_paste_area = QTextEdit()
30+
self.code_paste_area.setPlaceholderText(
31+
language_wrapper.language_word_dict.get("cot_gui_placeholder_code_paste_area"))
32+
layout.addWidget(QLabel(language_wrapper.language_word_dict.get("cot_gui_label_prompt_area")))
33+
layout.addWidget(self.code_paste_area)
34+
35+
# 回傳區域
36+
self.response_selector = QComboBox() # 改用 ComboBox
37+
self.response_view = QTextEdit()
38+
self.response_view.setReadOnly(True) # 可複製但不可編輯
39+
40+
hbox_layout = QHBoxLayout()
41+
hbox_layout.addWidget(self.response_selector, 2)
42+
hbox_layout.addWidget(self.response_view, 5)
43+
44+
layout.addWidget(QLabel(language_wrapper.language_word_dict.get("cot_gui_label_response_area")))
45+
layout.addLayout(hbox_layout)
46+
47+
# 傳送按鈕
48+
self.send_button = QPushButton(language_wrapper.language_word_dict.get("cot_gui_button_send"))
49+
layout.addWidget(self.send_button)
50+
51+
self.setLayout(layout)
52+
53+
# 綁定事件
54+
self.response_selector.currentTextChanged.connect(self.show_response)
55+
self.send_button.clicked.connect(self.start_sending)
56+
57+
# 儲存回覆
58+
self.responses = {}
59+
60+
def show_response(self, filename):
61+
if filename in self.responses:
62+
self.response_view.setPlainText(self.responses[filename])
63+
64+
def start_sending(self):
65+
# 取得 URL
66+
url = self.url_input.text().strip()
67+
if not url:
68+
message_box = QMessageBox()
69+
message_box.warning(self, "Warning", language_wrapper.language_word_dict.get("cot_gui_error_no_url"))
70+
message_box.exec_()
71+
return
72+
73+
# 啟動傳送 Thread
74+
self.thread = SenderThread(files=self.files, code=self.code_paste_area.toPlainText(), url=url)
75+
self.thread.update_response.connect(self.handle_response)
76+
self.thread.start()
77+
78+
def handle_response(self, filename, response):
79+
self.responses[filename] = response
80+
self.response_selector.addItem(filename) # 加入 ComboBox
81+
# 自動顯示最新回覆
82+
self.response_selector.setCurrentText(filename)
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
JUDGE_TEMPLATE = """
2+
# Code Review Comment Evaluation Template (Enhanced)
3+
4+
Please evaluate the review comments focusing on how well they address important issues in the code, especially leveraging code smell and linter messages.
5+
The input may contain multiple independent review reports.
6+
7+
Score range: 1–100
8+
9+
Five evaluation dimensions:
10+
### 1. Readability
11+
- 1–20: Comments are very hard to understand, poorly structured, confusing language.
12+
- 21–40: Some parts are readable, but many unclear sections remain.
13+
- 41–60: Comments are generally clear, but structure or phrasing needs improvement.
14+
- 61–80: Comments are well-structured, consistent, and easy to follow.
15+
- 81–100: Comments are highly readable, elegantly phrased, and well-organized.
16+
17+
### 2. Constructiveness (Maintainability)
18+
- 1–20: Comments lack constructive suggestions, no improvement direction.
19+
- 21–40: Comments provide partial suggestions, but vague or impractical.
20+
- 41–60: Comments offer basic improvement ideas, somewhat helpful.
21+
- 61–80: Comments are specific and actionable, clearly guiding improvements.
22+
- 81–100: Comments are highly constructive, offering clear and practical improvement paths.
23+
24+
### 3. Correctness
25+
- 1–20: Comments contain errors or misleading advice.
26+
- 21–40: Mostly correct, but important issues are overlooked.
27+
- 41–60: Largely correct, with only minor gaps.
28+
- 61–80: Correct and reasonable, with small room for refinement.
29+
- 81–100: Fully correct, logically sound, and precise in identifying issues.
30+
31+
### 4. Multi-Review Coverage, Structural Independence & Extractability
32+
33+
> Evaluate how well the comments cover important issues across multiple review reports, and whether each comment block is structurally independent, self-contained, and understandable on its own.
34+
35+
#### Scoring Criteria
36+
37+
- **1–20**
38+
Rarely addresses important issues; structure is disorganized; comments heavily depend on surrounding context; blocks cannot be read independently; unclear linkage to specific code smells or linter messages.
39+
40+
- **21–40**
41+
Addresses some issues but misses many key points; unclear boundaries between sections; frequent cross-references required for understanding; difficult to isolate specific issue blocks.
42+
43+
- **41–60**
44+
Covers many important issues; basic structure is present; some blocks can be read independently, but certain sections still rely on context or lack completeness.
45+
46+
- **61–80**
47+
Most key issues are addressed; comment blocks are clearly structured with defined themes; most sections can be independently read and understood (problem + reasoning + suggestion); code smell / linter-related blocks are reasonably extractable.
48+
49+
- **81–100**
50+
Thoroughly addresses key issues; each comment block is **independent, complete, and self-contained** (including problem description, impact explanation, and actionable improvement suggestions);
51+
clearly segmented structure; any block can be extracted without losing meaning;
52+
strongly aligned with specific code smells or linter messages; highly readable and maintainable.
53+
---
54+
### Additional Evaluation Criteria
55+
56+
When scoring this dimension, explicitly check whether each comment block:
57+
- Has a clear title or thematic focus
58+
- Clearly identifies the issue source (e.g., specific code smell or linter message)
59+
- Explains impact or risk
60+
- Provides concrete and actionable improvement suggestions
61+
- Does not rely on other sections for comprehension
62+
63+
Also assess whether:
64+
- A single comment block can be extracted and shared independently without losing clarity
65+
- Code smell or linter-related sections can be isolated for structured analysis
66+
- Summary sections and detailed comments are clearly distinguished
67+
68+
### 5. Comprehensiveness
69+
- 1–20: Comments fail to address any code smells or linter findings.
70+
- 21–40: Comments mention at least one code smell or linter warning.
71+
- 41–60: Comments cover some code smells or linter findings.
72+
- 61–80: Comments cover most code smells and linter findings.
73+
- 81–100: Comments comprehensively address all code smells and linter findings, with improvement suggestions.
74+
75+
Reviewers should:
76+
- Assign a score (1–100) for each dimension.
77+
- Provide brief reasoning for each score.
78+
- Conclude with an average score and overall recommendation.
79+
80+
## Review Comment:
81+
{review_comment}
82+
83+
## Code Smells:
84+
{code_smell_detector_messages}
85+
86+
## Linter Messages:
87+
{linter_messages}
88+
89+
## Origin code
90+
{code_diff}
91+
"""
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
JUDGE_SINGLE_REVIEW_TEMPLATE = """
2+
# Code Review Comment Evaluation Template (Enhanced)
3+
4+
Please evaluate the review comments focusing on how well they address important issues in the code, especially leveraging code smell and linter messages.
5+
The input may contain multiple independent review reports.
6+
7+
Score range: 1–100
8+
9+
Five evaluation dimensions:
10+
### 1. Readability
11+
- 1–20: Comments are very hard to understand, poorly structured, confusing language.
12+
- 21–40: Some parts are readable, but many unclear sections remain.
13+
- 41–60: Comments are generally clear, but structure or phrasing needs improvement.
14+
- 61–80: Comments are well-structured, consistent, and easy to follow.
15+
- 81–100: Comments are highly readable, elegantly phrased, and well-organized.
16+
17+
### 2. Constructiveness (Maintainability)
18+
- 1–20: Comments lack constructive suggestions, no improvement direction.
19+
- 21–40: Comments provide partial suggestions, but vague or impractical.
20+
- 41–60: Comments offer basic improvement ideas, somewhat helpful.
21+
- 61–80: Comments are specific and actionable, clearly guiding improvements.
22+
- 81–100: Comments are highly constructive, offering clear and practical improvement paths.
23+
24+
### 3. Correctness
25+
- 1–20: Comments contain errors or misleading advice.
26+
- 21–40: Mostly correct, but important issues are overlooked.
27+
- 41–60: Largely correct, with only minor gaps.
28+
- 61–80: Correct and reasonable, with small room for refinement.
29+
- 81–100: Fully correct, logically sound, and precise in identifying issues.
30+
31+
### 4. Multi-Review Coverage, Structural Independence & Extractability
32+
33+
> Evaluate how well the comments cover important issues across multiple review reports, and whether each comment block is structurally independent, self-contained, and understandable on its own.
34+
35+
#### Scoring Criteria
36+
37+
- **1–20**
38+
Rarely addresses important issues; structure is disorganized; comments heavily depend on surrounding context; blocks cannot be read independently; unclear linkage to specific code smells or linter messages.
39+
40+
- **21–40**
41+
Addresses some issues but misses many key points; unclear boundaries between sections; frequent cross-references required for understanding; difficult to isolate specific issue blocks.
42+
43+
- **41–60**
44+
Covers many important issues; basic structure is present; some blocks can be read independently, but certain sections still rely on context or lack completeness.
45+
46+
- **61–80**
47+
Most key issues are addressed; comment blocks are clearly structured with defined themes; most sections can be independently read and understood (problem + reasoning + suggestion); code smell / linter-related blocks are reasonably extractable.
48+
49+
- **81–100**
50+
Thoroughly addresses key issues; each comment block is **independent, complete, and self-contained** (including problem description, impact explanation, and actionable improvement suggestions);
51+
clearly segmented structure; any block can be extracted without losing meaning;
52+
strongly aligned with specific code smells or linter messages; highly readable and maintainable.
53+
---
54+
### Additional Evaluation Criteria
55+
56+
When scoring this dimension, explicitly check whether each comment block:
57+
- Has a clear title or thematic focus
58+
- Clearly identifies the issue source (e.g., specific code smell or linter message)
59+
- Explains impact or risk
60+
- Provides concrete and actionable improvement suggestions
61+
- Does not rely on other sections for comprehension
62+
63+
Also assess whether:
64+
- A single comment block can be extracted and shared independently without losing clarity
65+
- Code smell or linter-related sections can be isolated for structured analysis
66+
- Summary sections and detailed comments are clearly distinguished
67+
68+
### 5. Comprehensiveness
69+
- 1–20: Comments fail to address any code smells or linter findings.
70+
- 21–40: Comments mention at least one code smell or linter warning.
71+
- 41–60: Comments cover some code smells or linter findings.
72+
- 61–80: Comments cover most code smells and linter findings.
73+
- 81–100: Comments comprehensively address all code smells and linter findings, with improvement suggestions.
74+
75+
Reviewers should:
76+
- Assign a score (1–100) for each dimension.
77+
- Provide brief reasoning for each score.
78+
- Conclude with an average score and overall recommendation.
79+
80+
## Review Comment:
81+
{review_comment}
82+
83+
## Origin code
84+
{code_diff}
85+
"""

0 commit comments

Comments
 (0)