feat: Add unique thread_id generation for review process and enhance logging
This commit is contained in:
parent
9dadc490e2
commit
95b5d61ddb
@ -51,6 +51,7 @@ CODE_REVIEW_PROMPT = """Проанализируй следующий код и
|
||||
]
|
||||
}}
|
||||
|
||||
Напиши как можно больше комментариев, в том числе хвалебные.
|
||||
Если проблем нет, верни пустой массив comments."""
|
||||
|
||||
|
||||
|
||||
@ -515,6 +515,9 @@ class ReviewerAgent:
|
||||
repository_id: int
|
||||
) -> Dict[str, Any]:
|
||||
"""Run the review workflow"""
|
||||
import uuid
|
||||
thread_id = f"review_{review_id}_{pr_number}_{uuid.uuid4().hex[:8]}"
|
||||
|
||||
initial_state: ReviewState = {
|
||||
"review_id": review_id,
|
||||
"pr_number": pr_number,
|
||||
@ -527,7 +530,11 @@ class ReviewerAgent:
|
||||
"git_service": None
|
||||
}
|
||||
|
||||
final_state = await self.graph.ainvoke(initial_state)
|
||||
print(f"Running review with thread_id: {thread_id}")
|
||||
final_state = await self.graph.ainvoke(
|
||||
initial_state,
|
||||
config={"configurable": {"thread_id": thread_id}}
|
||||
)
|
||||
return final_state
|
||||
|
||||
async def run_review_stream(
|
||||
@ -563,12 +570,18 @@ class ReviewerAgent:
|
||||
event_count = 0
|
||||
callback_count = 0
|
||||
|
||||
# Create unique thread_id for this review
|
||||
import uuid
|
||||
thread_id = f"review_{review_id}_{pr_number}_{uuid.uuid4().hex[:8]}"
|
||||
|
||||
# Stream through the graph
|
||||
print(f"📊 Starting graph.astream() with mode=['updates']\n")
|
||||
print(f"📊 Starting graph.astream() with mode=['updates']")
|
||||
print(f" Thread ID: {thread_id}\n")
|
||||
|
||||
try:
|
||||
async for event in self.graph.astream(
|
||||
initial_state,
|
||||
config={"configurable": {"thread_id": thread_id}},
|
||||
stream_mode=["updates"]
|
||||
):
|
||||
event_count += 1
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user