/ docs-website / versioned_docs / version-2.28 / tools / ready-made-tools / githubissueviewertool.mdx
githubissueviewertool.mdx
1 --- 2 title: "GitHubIssueViewerTool" 3 id: githubissueviewertool 4 slug: "/githubissueviewertool" 5 description: "A Tool that allows Agents and ToolInvokers to fetch and parse GitHub issues into documents." 6 --- 7 8 # GitHubIssueViewerTool 9 10 A Tool that allows Agents and ToolInvokers to fetch and parse GitHub issues into documents. 11 12 <div className="key-value-table"> 13 14 | | | 15 | --- | --- | 16 | **API reference** | [Tools](/reference/tools-api) | 17 | **GitHub link** | https://github.com/deepset-ai/haystack-core-integrations/tree/main/integrations/github | 18 19 </div> 20 21 ## Overview 22 23 `GitHubIssueViewerTool` wraps the [`GitHubIssueViewer`](../../pipeline-components/connectors/githubissueviewer.mdx) component, providing a tool interface for use in agent workflows and tool-based pipelines. 24 25 The tool takes a GitHub issue URL and returns a list of documents where: 26 27 - The first document contains the main issue content, 28 - Subsequent documents contain the issue comments (if any). 29 30 Each document includes rich metadata such as the issue title, number, state, creation date, author, and more. 31 32 ### Parameters 33 34 - `name` is _optional_ and defaults to "issue_viewer". Specifies the name of the tool. 35 - `description` is _optional_ and provides context to the LLM about what the tool does. 36 - `github_token` is _optional_ but recommended for private repositories or to avoid rate limiting. 37 - `raise_on_failure` is _optional_ and defaults to `True`. If False, errors are returned as documents instead of raising exceptions. 38 - `retry_attempts` is _optional_ and defaults to `2`. Number of retry attempts for failed requests. 39 40 ## Usage 41 42 Install the GitHub integration to use the `GitHubIssueViewerTool`: 43 44 ```shell 45 pip install github-haystack 46 ``` 47 48 :::info[Repository Placeholder] 49 50 To run the following code snippets, you need to replace the `owner/repo` with your own GitHub repository name. 51 ::: 52 53 ### On its own 54 55 ```python 56 from haystack_integrations.tools.github import GitHubIssueViewerTool 57 58 tool = GitHubIssueViewerTool() 59 result = tool.invoke(url="https://github.com/deepset-ai/haystack/issues/123") 60 61 print(result) 62 ``` 63 64 ```bash 65 {'documents': [Document(id=3989459bbd8c2a8420a9ba7f3cd3cf79bb41d78bd0738882e57d509e1293c67a, content: 'sentence-transformers = 0.2.6.1 66 haystack = latest 67 farm = 0.4.3 latest branch 68 69 In 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! 70 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'})]} 71 ``` 72 73 ### With an Agent 74 75 You can use `GitHubIssueViewerTool` with the [Agent](../../pipeline-components/agents-1/agent.mdx) component. The Agent will automatically invoke the tool when needed to fetch GitHub issue information. 76 77 ```python 78 from haystack.components.generators.chat import OpenAIChatGenerator 79 from haystack.dataclasses import ChatMessage 80 from haystack.components.agents import Agent 81 from haystack_integrations.tools.github import GitHubIssueViewerTool 82 83 issue_tool = GitHubIssueViewerTool(name="github_issue_viewer") 84 85 agent = Agent( 86 chat_generator=OpenAIChatGenerator(), 87 tools=[issue_tool], 88 exit_conditions=["text"], 89 ) 90 91 response = agent.run( 92 messages=[ 93 ChatMessage.from_user( 94 "Please analyze this GitHub issue and summarize the main problem: https://github.com/deepset-ai/haystack/issues/123", 95 ), 96 ], 97 ) 98 99 print(response["last_message"].text) 100 ``` 101 102 ```bash 103 The GitHub issue titled "SentenceTransformer no longer accepts 'gpu' as argument" (issue \#123) discusses a problem encountered when using the `EmbeddingRetriever()` function. The user reports that passing the argument `gpu=True` now causes an error because the method that processes this argument does not accept "gpu" anymore; instead, it previously accepted "cuda" without issues. 104 105 The user indicates that this change is problematic since it prevents users from instantiating the embedding model with GPU support, forcing them to default to using only the CPU for model execution. 106 107 The issue was later closed with a comment indicating it was fixed in another pull request (#124). 108 ```