Files
pr-agent/pr_agent/agent/pr_agent.py

30 lines
1.1 KiB
Python
Raw Normal View History

2023-07-06 00:21:08 +03:00
import re
2023-07-16 15:42:50 +03:00
from pr_agent.tools.pr_code_suggestions import PRCodeSuggestions
from pr_agent.tools.pr_description import PRDescription
2023-07-06 00:21:08 +03:00
from pr_agent.tools.pr_questions import PRQuestions
from pr_agent.tools.pr_reviewer import PRReviewer
class PRAgent:
2023-07-08 08:52:11 +03:00
def __init__(self):
pass
2023-07-06 00:21:08 +03:00
2023-07-16 15:42:50 +03:00
async def handle_request(self, pr_url, request) -> bool:
if any(cmd in request for cmd in ["/review", "/review_pr"]):
await PRReviewer(pr_url).review()
elif any(cmd in request for cmd in ["/describe", "/describe_pr"]):
await PRDescription(pr_url).describe()
elif any(cmd in request for cmd in ["/improve", "/improve_code"]):
await PRCodeSuggestions(pr_url).suggest()
elif any(cmd in request for cmd in ["/ask", "/ask_question"]):
pattern = r'(/ask|/ask_question)\s*(.*)'
matches = re.findall(pattern, request, re.IGNORECASE)
if matches:
question = matches[0][1]
await PRQuestions(pr_url, question).answer()
else:
2023-07-16 15:42:50 +03:00
return False
return True