GitHubIssueViewer
GitHubIssueViewer
GitHub 이슈를 가져와 Haystack 문서로 파싱하는 구성 요소예요.
출처: 문서
본문
GitHubIssueViewer는 GitHub 이슈 URL을 받아 문서 리스트를 반환해요:
- 첫 번째 문서는 주요 이슈 콘텐츠를 담아요.
- 이후 문서는 이슈 댓글(있을 경우)을 담아요.
각 문서에는 이슈 제목, 번호, 상태, 생성일, 작성자 등의 풍부한 메타데이터가 포함돼요.
Authorization
공개 저장소의 경우 인증 없이 작동할 수 있지만, 비공개 저장소이거나 rate limiting을 피하려면 GitHub 개인 액세스 토큰을 제공할 수 있어요. 초기화 시점에 github_token 파라미터로 전달하세요, 예: github_token=Secret.from_env_var("GITHUB_TOKEN"). 이 컴포넌트에는 토큰의 기본 환경 변수가 없어요. 개인 액세스 토큰을 만들려면 GitHub의 토큰 설정 페이지를 방문하세요.
Installation
pip install github-haystack
- 대표적인 파이프라인 위치: 파이프라인의 맨 시작, 그리고 GitHub 이슈 콘텐츠를 입력으로 기대하는
ChatPromptBuilder앞 - 필수 run 변수:
url— GitHub 이슈 URL - 출력 변수:
documents— 주요 이슈와 그 댓글을 담은 문서 리스트 - API reference: GitHub
- 패키지명:
github-haystack
Usage
저장소 플레이스홀더: 아래 코드 스니펫을 실행하려면 owner/repo를 자신의 GitHub 저장소 이름으로 바꿔야 해요.
On its own
인증 없는 기본 사용법:
from haystack_integrations.components.connectors.github import GitHubIssueViewer
viewer = GitHubIssueViewer()
result = viewer.run(url="https://github.com/deepset-ai/haystack/issues/123")
print(result)
{'documents': [Document(id=3989459bbd8c2a8420a9ba7f3cd3cf79bb41d78bd0738882e57d509e1293c67a, content: 'sentence-transformers = 0.2.6.1haystack = latestfarm = 0.4.3 latest branchIn the call to Emb...', meta: {'type': 'issue', 'title': 'SentenceTransformer no longer accepts \'gpu" as argument', 'number': 123, 'state': 'closed', 'created_at': '2020-05-28T04:49:31Z', 'updated_at': '2020-05-28T07:11:43Z', 'author': 'predoctech', 'url': 'https://github.com/deepset-ai/haystack/issues/123'}), Document(id=a8a56b9ad119244678804d5873b13da0784587773d8f839e07f644c4d02c167a, content: 'Thanks for reporting!Fixed with #124 ', meta: {'type': 'comment', 'issue_number': 123, 'created_at': '2020-05-28T07:11:42Z', 'updated_at': '2020-05-28T07:11:42Z', 'author': 'tholor', 'url': 'https://github.com/deepset-ai/haystack/issues/123#issuecomment-635153940'})]}
In a pipeline
다음 파이프라인은 GitHub 이슈를 가져와 관련 정보를 추출하고 요약을 생성해요:
from haystack import Pipeline
from haystack.components.builders.chat_prompt_builder import ChatPromptBuilder
from haystack.components.generators.chat import OpenAIChatGenerator
from haystack.dataclasses import ChatMessage
from haystack_integrations.components.connectors.github import GitHubIssueViewer
# Initialize components
issue_viewer = GitHubIssueViewer()
prompt_template = [
ChatMessage.from_system("You are a helpful assistant that analyzes GitHub issues."),
ChatMessage.from_user(
"Based on the following GitHub issue and comments:\n"
"{% for document in documents %}"
"{% if document.meta.type == 'issue' %}"
"**Issue Title:** {{ document.meta.title }}\n"
"**Issue Description:** {{ document.content }}\n"
"{% else %}"
"**Comment by {{ document.meta.author }}:** {{ document.content }}\n"
"{% endif %}"
"{% endfor %}\n"
"Please provide a summary of the issue and suggest potential solutions."
),
]
prompt_builder = ChatPromptBuilder(template=prompt_template, required_variables="*")
llm = OpenAIChatGenerator(model="gpt-4o-mini")
# Create pipeline
pipeline = Pipeline()
pipeline.add_component("issue_viewer", issue_viewer)
pipeline.add_component("prompt_builder", prompt_builder)
pipeline.add_component("llm", llm)
# Connect components
pipeline.connect("issue_viewer.documents", "prompt_builder.documents")
pipeline.connect("prompt_builder.prompt", "llm.messages")
# Run pipeline
issue_url = "https://github.com/deepset-ai/haystack/issues/123"
result = pipeline.run(data={"issue_viewer": {"url": issue_url}})
print(result["llm"]["replies"][0])