|
|
@@ -29,9 +29,10 @@ class ReviewResult:
|
|
|
class BaseReviewer(ABC):
|
|
|
"""审查器基类"""
|
|
|
|
|
|
- def __init__(self):
|
|
|
+ def __init__(self, review_location_label: str = ""):
|
|
|
self.model_client = generate_model_client
|
|
|
self.prompt_loader = prompt_loader
|
|
|
+ self.review_location_label = review_location_label
|
|
|
|
|
|
#@obverse
|
|
|
async def review(self, name: str, trace_id: str, reviewer_type: str, prompt_name: str, review_content: str, review_references: str = None,
|
|
|
@@ -58,10 +59,8 @@ class BaseReviewer(ABC):
|
|
|
ReviewResult: 审查结果
|
|
|
"""
|
|
|
start_time = time.time()
|
|
|
- name = prompt_name
|
|
|
try:
|
|
|
# 添加进度更新
|
|
|
- progress_message = f"{name}_{prompt_name}"
|
|
|
# 安全检查:确保所有必要参数都存在才执行进度更新
|
|
|
if state and state.get("progress_manager") and stage_name and current_progress is not None:
|
|
|
asyncio.create_task(
|
|
|
@@ -70,7 +69,7 @@ class BaseReviewer(ABC):
|
|
|
stage_name=stage_name,
|
|
|
current=current_progress,
|
|
|
status="processing",
|
|
|
- message=progress_message
|
|
|
+ message=f"开始进行:{name}"
|
|
|
)
|
|
|
)
|
|
|
logger.info(f"开始执行 {name} 审查,trace_id: {trace_id},内容长度: {len(review_content)}")
|
|
|
@@ -78,6 +77,9 @@ class BaseReviewer(ABC):
|
|
|
prompt_kwargs["content"] = review_content
|
|
|
prompt_kwargs["review_content"] = review_content
|
|
|
prompt_kwargs["review_references"] = review_references or ""
|
|
|
+ # 添加审查位置标签到提示词参数中
|
|
|
+ if hasattr(self, 'review_location_label') and self.review_location_label:
|
|
|
+ prompt_kwargs["review_location_label"] = self.review_location_label
|
|
|
task_prompt_info = {
|
|
|
"task_prompt": self.prompt_loader.get_prompt_template(reviewer_type, prompt_name, **prompt_kwargs),
|
|
|
"task_name": name
|
|
|
@@ -93,7 +95,17 @@ class BaseReviewer(ABC):
|
|
|
result = self.format_result(model_response)
|
|
|
result.execution_time = time.time() - start_time
|
|
|
|
|
|
+ asyncio.create_task(
|
|
|
+ state["progress_manager"].update_stage_progress(
|
|
|
+ callback_task_id=state["callback_task_id"],
|
|
|
+ stage_name=stage_name,
|
|
|
+ current=current_progress,
|
|
|
+ status="processing",
|
|
|
+ message=f"{name} 审查完成, 耗时: {result.execution_time:.2f}s"
|
|
|
+ )
|
|
|
+ )
|
|
|
logger.info(f"{name} 审查完成, 耗时: {result.execution_time:.2f}s")
|
|
|
+
|
|
|
return result
|
|
|
|
|
|
except Exception as e:
|