GitHubIssueCommenterTool

GitHubIssueCommenterTool

Agent가 GitHub 이슈에 댓글을 게시할 수 있게 해 주는 Tool이에요.

출처: 문서

본문

GitHubIssueCommenterTool은 GitHubIssueCommenter 구성 요소를 감싸서, 에이전트 워크플로와 tool 기반 파이프라인에서 쓸 수 있는 tool 인터페이스를 제공해요. GitHub 이슈 URL과 댓글 텍스트를 받아 GitHub API로 해당 이슈에 댓글을 게시해요. 댓글 게시는 인증이 필요한 작업이므로 인증이 필요해요.

Parameters ​

  • name — 선택. 기본값 "issue_commenter". tool의 이름.
  • description — 선택. tool이 무엇을 하는지 LLM에 알려주는 설명.
  • github_token — 필수. API 인증을 위한 GitHub 개인 액세스 토큰. 기본은 GITHUB_TOKEN 환경 변수 사용.
  • raise_on_failure — 선택. 기본값 True. False면 예외를 던지는 대신 에러를 반환.
  • retry_attempts — 선택. 기본값 2. 실패한 요청의 재시도 횟수.

Usage ​

pip install github-haystack

저장소 플레이스홀더: 아래 코드 스니펫을 실행하려면 owner/repo를 자신의 GitHub 저장소 이름으로 바꿔야 해요.

On its own ​

이슈에 댓글을 다는 기본 사용법:

from haystack_integrations.tools.github import GitHubIssueCommenterTool

tool = GitHubIssueCommenterTool()
result = tool.invoke(
    url="https://github.com/owner/repo/issues/123",
    comment="Thanks for reporting this issue! We'll look into it.",
)
print(result)
{'success': True}

With an Agent ​

GitHubIssueCommenterTool을 Agent 구성 요소와 함께 사용할 수 있어요. Agent는 필요할 때 자동으로 tool을 호출해 GitHub 이슈에 댓글을 게시해요.

from haystack.components.generators.chat import OpenAIChatGenerator
from haystack.dataclasses import ChatMessage
from haystack.components.agents import Agent
from haystack_integrations.tools.github import GitHubIssueCommenterTool

comment_tool = GitHubIssueCommenterTool(name="github_issue_commenter")
agent = Agent(
    chat_generator=OpenAIChatGenerator(),
    tools=[comment_tool],
    exit_conditions=["text"],
)
response = agent.run(
    messages=[
        ChatMessage.from_user(
            "Please post a helpful comment on this GitHub issue: https://github.com/owner/repo/issues/123 acknowledging the bug report and mentioning that we're investigating"
        ),
    ],
)
print(response["last_message"].text)
I have posted the comment on the GitHub issue, acknowledging the bug report and mentioning that the team is investigating the problem. If you need anything else, feel free to ask!