mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-07-03 04:10:49 +08:00
Set LiteLLMAIHandler as default AI handler in all PR tools and simplify AI handler injection in PRAgent
This commit is contained in:
@ -16,7 +16,6 @@ from pr_agent.tools.pr_questions import PRQuestions
|
||||
from pr_agent.tools.pr_reviewer import PRReviewer
|
||||
from pr_agent.tools.pr_similar_issue import PRSimilarIssue
|
||||
from pr_agent.tools.pr_update_changelog import PRUpdateChangelog
|
||||
import inspect
|
||||
|
||||
command2class = {
|
||||
"auto_review": PRReviewer,
|
||||
@ -41,13 +40,6 @@ command2class = {
|
||||
|
||||
commands = list(command2class.keys())
|
||||
|
||||
def has_ai_handler_param(cls: object):
|
||||
constructor = getattr(cls, "__init__", None)
|
||||
if constructor is not None:
|
||||
parameters = inspect.signature(constructor).parameters
|
||||
return "ai_handler" in parameters
|
||||
return False
|
||||
|
||||
class PRAgent:
|
||||
def __init__(self, ai_handler: BaseAiHandler = LiteLLMAIHandler()):
|
||||
self.ai_handler = ai_handler
|
||||
@ -80,10 +72,7 @@ class PRAgent:
|
||||
notify()
|
||||
|
||||
get_logger().info(f"Class: {command2class[action]}")
|
||||
if(not has_ai_handler_param(cls=command2class[action])):
|
||||
await command2class[action](pr_url, args=args).run()
|
||||
else:
|
||||
await command2class[action](pr_url, ai_handler=self.ai_handler, args=args).run()
|
||||
await command2class[action](pr_url, ai_handler=self.ai_handler, args=args).run()
|
||||
else:
|
||||
return False
|
||||
return True
|
||||
|
Reference in New Issue
Block a user