github-haystack 1.2.1__py3-none-any.whl → 2.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: github-haystack
3
- Version: 1.2.1
3
+ Version: 2.0.0
4
4
  Summary: Haystack components for interacting with GitHub repositories
5
5
  Project-URL: Source, https://github.com/deepset-ai/haystack-core-integrations/github
6
6
  Project-URL: Documentation, https://github.com/deepset-ai/haystack-core-integrations/blob/main/integrations/github/README.md
@@ -11,15 +11,14 @@ License-File: LICENSE.txt
11
11
  Classifier: Development Status :: 4 - Beta
12
12
  Classifier: License :: OSI Approved :: Apache Software License
13
13
  Classifier: Programming Language :: Python
14
- Classifier: Programming Language :: Python :: 3.9
15
14
  Classifier: Programming Language :: Python :: 3.10
16
15
  Classifier: Programming Language :: Python :: 3.11
17
16
  Classifier: Programming Language :: Python :: 3.12
18
17
  Classifier: Programming Language :: Python :: 3.13
19
18
  Classifier: Programming Language :: Python :: Implementation :: CPython
20
19
  Classifier: Programming Language :: Python :: Implementation :: PyPy
21
- Requires-Python: >=3.9
22
- Requires-Dist: haystack-ai>=2.12.0
20
+ Requires-Python: >=3.10
21
+ Requires-Dist: haystack-ai>=2.22.0
23
22
  Description-Content-Type: text/markdown
24
23
 
25
24
  # github-haystack
@@ -1,11 +1,11 @@
1
1
  haystack_integrations/components/connectors/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  haystack_integrations/components/connectors/github/__init__.py,sha256=aRIkCcJ_ogsyt67cwjZQu8rqP7yIQu8jRzK6TAYRGx4,557
3
- haystack_integrations/components/connectors/github/file_editor.py,sha256=OEhcp5vViF0kjbIb4jYNkl3jHj3t1m2dY836y1cESBQ,11802
4
- haystack_integrations/components/connectors/github/issue_commenter.py,sha256=Uwlm6NNOsgHgcLXxZgZkRcxZXbHUsevTmx93GV6vsfs,5688
5
- haystack_integrations/components/connectors/github/issue_viewer.py,sha256=w_E2rW8uAO2B-ndIDnvv9yW3g9T5C3D5PxICpMo17Cg,7438
6
- haystack_integrations/components/connectors/github/pr_creator.py,sha256=o0zu7xDY3yd6nYBHOWl7LU7wZGSZg2O4ZAel1D6BkVc,11498
7
- haystack_integrations/components/connectors/github/repo_forker.py,sha256=tGhz77kSC1t3C-XteMsXqE55fDCcktmmZkh3X1JPxM0,11592
8
- haystack_integrations/components/connectors/github/repo_viewer.py,sha256=lEhjet13k1IKNbLyzvRflzLIGdiG_HkEwgmfH70OAhs,9269
3
+ haystack_integrations/components/connectors/github/file_editor.py,sha256=4bRBaFIQO8MPWrrLr6_W11bDbaNRQC7-fcMJpWhO2Pw,11752
4
+ haystack_integrations/components/connectors/github/issue_commenter.py,sha256=G_jtdzNwOr5qEnRy-GR888qo25oKwX-_e6yQWNZTMH4,5682
5
+ haystack_integrations/components/connectors/github/issue_viewer.py,sha256=CJ3MFHpx_Ix0_p6ogCf5Lp8Si-HZxIKczstbk8uptzU,7413
6
+ haystack_integrations/components/connectors/github/pr_creator.py,sha256=m3jMxGBaiw6EoYhYSFeEFBwGvZTXUaO_tJh5Iw-7o3U,11479
7
+ haystack_integrations/components/connectors/github/repo_forker.py,sha256=DXw8GHRVXlvqs9s24XTW6Z0uAIuzhSb8lTKx-NgLi28,11573
8
+ haystack_integrations/components/connectors/github/repo_viewer.py,sha256=DK_zStASIt7p5xX_SRd8l8WypsL3R1v5FoNBcx1cakQ,9232
9
9
  haystack_integrations/prompts/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
10
  haystack_integrations/prompts/github/__init__.py,sha256=cs_w-7RycC2C9q35pN0jY-McAHWbTIM-j_O2S-AIM7Q,882
11
11
  haystack_integrations/prompts/github/context_prompt.py,sha256=RSzISqtaBHaC7v6rcyyxt2vxmbBVp5OHsWR6Z2wp5pk,8783
@@ -18,14 +18,14 @@ haystack_integrations/prompts/github/repo_viewer_prompt.py,sha256=JkU2ODn06Vs_YQ
18
18
  haystack_integrations/prompts/github/system_prompt.py,sha256=xiOEAbENJiLHL8M1qrgSdUxrfguAphI_6B0kqelxDok,4209
19
19
  haystack_integrations/tools/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
20
  haystack_integrations/tools/github/__init__.py,sha256=ZJKLyVZRXcg5mU-AdH_Xk1rNLeiItlPqgmY6eTqFSTA,611
21
- haystack_integrations/tools/github/file_editor_tool.py,sha256=ETvDnSqjaXgzHyo8nNtqhxgZf0RiM4Z7k82TDyOLPTo,5178
22
- haystack_integrations/tools/github/issue_commenter_tool.py,sha256=AVlto9NxLLJcnmW-U2PZhOoeagICh7STQR5_paXfY2Y,5125
23
- haystack_integrations/tools/github/issue_viewer_tool.py,sha256=mEiDxyx9xuttOR3LEq29eETt4UYF8zBd8uAtWE3TuiI,5065
24
- haystack_integrations/tools/github/pr_creator_tool.py,sha256=Bfqn1gSsnfkzJg69Dk4DuICnjkviHYIw7vTX9zsaQa4,4824
25
- haystack_integrations/tools/github/repo_forker_tool.py,sha256=gd50C3Scfl-KZyJySWMrBq_d-HeAU38rMIQZCBHHI84,4834
26
- haystack_integrations/tools/github/repo_viewer_tool.py,sha256=QWnbpQS3XrmxJ3qbBIjTUR9eOXfHR_MfQgd1ClDS5qE,5883
27
- haystack_integrations/tools/github/utils.py,sha256=iSIEFulC3KqZvAY1QcrE2rTZJSkCp49SSqC62BTpcs8,3312
28
- github_haystack-1.2.1.dist-info/METADATA,sha256=RMkJ0sLH47n1QLRdgXdjkqpUM-DpHga_1Azncpr66RQ,1771
29
- github_haystack-1.2.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
30
- github_haystack-1.2.1.dist-info/licenses/LICENSE.txt,sha256=B05uMshqTA74s-0ltyHKI6yoPfJ3zYgQbvcXfDVGFf8,10280
31
- github_haystack-1.2.1.dist-info/RECORD,,
21
+ haystack_integrations/tools/github/file_editor_tool.py,sha256=BBc0a6gqoQLcsYXUnDwaoqvjFWagNmTpOP8hul99AZw,5149
22
+ haystack_integrations/tools/github/issue_commenter_tool.py,sha256=NDZCE3ZQlJ9qhyfStF8plbHy0jI8wsNtg3dmlPvwX3A,5099
23
+ haystack_integrations/tools/github/issue_viewer_tool.py,sha256=-CWpyX1hl4BREMOjOPnvX0skeHIupdyltHNCBE5PpLc,5036
24
+ haystack_integrations/tools/github/pr_creator_tool.py,sha256=Xx5HSswLuVorum5Hizlj_IW3_Wl9eXN3yb5J5ZMtirw,4798
25
+ haystack_integrations/tools/github/repo_forker_tool.py,sha256=3Lv9ukJnSSs-5rlw1iW82ftr407yuuSVTHtfQPv7d0I,4808
26
+ haystack_integrations/tools/github/repo_viewer_tool.py,sha256=YmyKqXQJLF1xU8-ZuFf03xcZfNILYnqVn_O_DQ1zOL0,5851
27
+ haystack_integrations/tools/github/utils.py,sha256=5j9AASDRg7lB01njb7Z7Y2Hlu6gVa5oYJoh1-6IG3TY,3292
28
+ github_haystack-2.0.0.dist-info/METADATA,sha256=lgM-n9sEIc7nXDc9LGWrU8KFf6hqchhx9qyrSqo_JO0,1722
29
+ github_haystack-2.0.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
30
+ github_haystack-2.0.0.dist-info/licenses/LICENSE.txt,sha256=B05uMshqTA74s-0ltyHKI6yoPfJ3zYgQbvcXfDVGFf8,10280
31
+ github_haystack-2.0.0.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: hatchling 1.27.0
2
+ Generator: hatchling 1.28.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -3,7 +3,7 @@
3
3
  # SPDX-License-Identifier: Apache-2.0
4
4
  from base64 import b64decode, b64encode
5
5
  from enum import Enum
6
- from typing import Any, Dict, Optional, Union
6
+ from typing import Any
7
7
 
8
8
  import requests
9
9
  from haystack import component, default_from_dict, default_to_dict, logging
@@ -79,7 +79,7 @@ class GitHubFileEditor:
79
79
  self,
80
80
  *,
81
81
  github_token: Secret = Secret.from_env_var("GITHUB_TOKEN"),
82
- repo: Optional[str] = None,
82
+ repo: str | None = None,
83
83
  branch: str = "main",
84
84
  raise_on_failure: bool = True,
85
85
  ):
@@ -145,7 +145,7 @@ class GitHubFileEditor:
145
145
  def _check_last_commit(self, owner: str, repo: str, branch: str) -> bool:
146
146
  """Check if last commit was made by the current token user."""
147
147
  url = f"https://api.github.com/repos/{owner}/{repo}/commits"
148
- params: Dict[str, Union[str, int]] = {"per_page": 1, "sha": branch}
148
+ params: dict[str, str | int] = {"per_page": 1, "sha": branch}
149
149
  response = requests.get(url, headers=self._get_request_headers(), params=params, timeout=10)
150
150
  response.raise_for_status()
151
151
  last_commit = response.json()[0]
@@ -158,7 +158,7 @@ class GitHubFileEditor:
158
158
 
159
159
  return commit_author == current_user
160
160
 
161
- def _edit_file(self, owner: str, repo: str, payload: Dict[str, str], branch: str) -> str:
161
+ def _edit_file(self, owner: str, repo: str, payload: dict[str, str], branch: str) -> str:
162
162
  """Handle file editing."""
163
163
  try:
164
164
  content, sha = self._get_file_content(owner, repo, payload["path"], branch)
@@ -180,7 +180,7 @@ class GitHubFileEditor:
180
180
  raise
181
181
  return f"Error: {e!s}"
182
182
 
183
- def _undo_changes(self, owner: str, repo: str, payload: Dict[str, Any], branch: str) -> str:
183
+ def _undo_changes(self, owner: str, repo: str, payload: dict[str, Any], branch: str) -> str:
184
184
  """Handle undoing changes."""
185
185
  try:
186
186
  if not self._check_last_commit(owner, repo, branch):
@@ -191,7 +191,7 @@ class GitHubFileEditor:
191
191
  commits_url = f"https://api.github.com/repos/{owner}/{repo}/commits"
192
192
 
193
193
  # Get the previous commit SHA
194
- params: Dict[str, Union[str, int]] = {"per_page": 2, "sha": branch}
194
+ params: dict[str, str | int] = {"per_page": 2, "sha": branch}
195
195
  commits = requests.get(commits_url, headers=self._get_request_headers(), params=params, timeout=10).json()
196
196
  previous_sha = commits[1]["sha"]
197
197
 
@@ -207,7 +207,7 @@ class GitHubFileEditor:
207
207
  raise
208
208
  return f"Error: {e!s}"
209
209
 
210
- def _create_file(self, owner: str, repo: str, payload: Dict[str, str], branch: str) -> str:
210
+ def _create_file(self, owner: str, repo: str, payload: dict[str, str], branch: str) -> str:
211
211
  """Handle file creation."""
212
212
  try:
213
213
  url = f"https://api.github.com/repos/{owner}/{repo}/contents/{payload['path']}"
@@ -224,7 +224,7 @@ class GitHubFileEditor:
224
224
  raise
225
225
  return f"Error: {e!s}"
226
226
 
227
- def _delete_file(self, owner: str, repo: str, payload: Dict[str, str], branch: str) -> str:
227
+ def _delete_file(self, owner: str, repo: str, payload: dict[str, str], branch: str) -> str:
228
228
  """Handle file deletion."""
229
229
  try:
230
230
  _, sha = self._get_file_content(owner, repo, payload["path"], branch)
@@ -244,11 +244,11 @@ class GitHubFileEditor:
244
244
  @component.output_types(result=str)
245
245
  def run(
246
246
  self,
247
- command: Union[Command, str],
248
- payload: Dict[str, Any],
249
- repo: Optional[str] = None,
250
- branch: Optional[str] = None,
251
- ) -> Dict[str, str]:
247
+ command: Command | str,
248
+ payload: dict[str, Any],
249
+ repo: str | None = None,
250
+ branch: str | None = None,
251
+ ) -> dict[str, str]:
252
252
  """
253
253
  Process GitHub file operations.
254
254
 
@@ -287,7 +287,7 @@ class GitHubFileEditor:
287
287
  result = command_handlers[command](owner, repo_name, payload, working_branch)
288
288
  return {"result": result}
289
289
 
290
- def to_dict(self) -> Dict[str, Any]:
290
+ def to_dict(self) -> dict[str, Any]:
291
291
  """Serialize the component to a dictionary."""
292
292
  return default_to_dict(
293
293
  self,
@@ -298,7 +298,7 @@ class GitHubFileEditor:
298
298
  )
299
299
 
300
300
  @classmethod
301
- def from_dict(cls, data: Dict[str, Any]) -> "GitHubFileEditor":
301
+ def from_dict(cls, data: dict[str, Any]) -> "GitHubFileEditor":
302
302
  """Deserialize the component from a dictionary."""
303
303
  init_params = data["init_parameters"]
304
304
  deserialize_secrets_inplace(init_params, keys=["github_token"])
@@ -2,7 +2,7 @@
2
2
  #
3
3
  # SPDX-License-Identifier: Apache-2.0
4
4
  import re
5
- from typing import Any, Dict
5
+ from typing import Any
6
6
 
7
7
  import requests
8
8
  from haystack import component, default_from_dict, default_to_dict, logging
@@ -115,7 +115,7 @@ class GitHubIssueCommenter:
115
115
 
116
116
  return False
117
117
 
118
- def to_dict(self) -> Dict[str, Any]:
118
+ def to_dict(self) -> dict[str, Any]:
119
119
  """
120
120
  Serialize the component to a dictionary.
121
121
 
@@ -129,7 +129,7 @@ class GitHubIssueCommenter:
129
129
  )
130
130
 
131
131
  @classmethod
132
- def from_dict(cls, data: Dict[str, Any]) -> "GitHubIssueCommenter":
132
+ def from_dict(cls, data: dict[str, Any]) -> "GitHubIssueCommenter":
133
133
  """
134
134
  Deserialize the component from a dictionary.
135
135
 
@@ -2,7 +2,7 @@
2
2
  #
3
3
  # SPDX-License-Identifier: Apache-2.0
4
4
  import re
5
- from typing import Any, Dict, List, Optional
5
+ from typing import Any
6
6
 
7
7
  import requests
8
8
  from haystack import Document, component, default_from_dict, default_to_dict, logging
@@ -37,7 +37,7 @@ class GitHubIssueViewer:
37
37
  def __init__(
38
38
  self,
39
39
  *,
40
- github_token: Optional[Secret] = None,
40
+ github_token: Secret | None = None,
41
41
  raise_on_failure: bool = True,
42
42
  retry_attempts: int = 2,
43
43
  ):
@@ -154,7 +154,7 @@ class GitHubIssueViewer:
154
154
  },
155
155
  )
156
156
 
157
- def to_dict(self) -> Dict[str, Any]:
157
+ def to_dict(self) -> dict[str, Any]:
158
158
  """
159
159
  Serialize the component to a dictionary.
160
160
 
@@ -168,7 +168,7 @@ class GitHubIssueViewer:
168
168
  )
169
169
 
170
170
  @classmethod
171
- def from_dict(cls, data: Dict[str, Any]) -> "GitHubIssueViewer":
171
+ def from_dict(cls, data: dict[str, Any]) -> "GitHubIssueViewer":
172
172
  """
173
173
  Deserialize the component from a dictionary.
174
174
 
@@ -179,7 +179,7 @@ class GitHubIssueViewer:
179
179
  deserialize_secrets_inplace(init_params, keys=["github_token"])
180
180
  return default_from_dict(cls, data)
181
181
 
182
- @component.output_types(documents=List[Document])
182
+ @component.output_types(documents=list[Document])
183
183
  def run(self, url: str) -> dict:
184
184
  """
185
185
  Process a GitHub issue URL and return documents.
@@ -2,7 +2,7 @@
2
2
  #
3
3
  # SPDX-License-Identifier: Apache-2.0
4
4
  import re
5
- from typing import Any, Dict, Optional
5
+ from typing import Any
6
6
 
7
7
  import requests
8
8
  from haystack import component, default_from_dict, default_to_dict, logging
@@ -102,7 +102,7 @@ class GitHubPRCreator:
102
102
  except requests.RequestException:
103
103
  return False
104
104
 
105
- def _create_fork(self, owner: str, repo: str) -> Optional[str]:
105
+ def _create_fork(self, owner: str, repo: str) -> str | None:
106
106
  """Create a fork of the repository."""
107
107
  url = f"https://api.github.com/repos/{owner}/{repo}/forks"
108
108
  try:
@@ -215,7 +215,7 @@ class GitHubPRCreator:
215
215
  @component.output_types(result=str)
216
216
  def run(
217
217
  self, issue_url: str, title: str, branch: str, base: str, body: str = "", draft: bool = False
218
- ) -> Dict[str, str]:
218
+ ) -> dict[str, str]:
219
219
  """
220
220
  Create a new pull request from your fork to the original repository, linked to the specified issue.
221
221
 
@@ -263,7 +263,7 @@ class GitHubPRCreator:
263
263
  raise
264
264
  return {"result": f"Error: {e!s}"}
265
265
 
266
- def to_dict(self) -> Dict[str, Any]:
266
+ def to_dict(self) -> dict[str, Any]:
267
267
  """Serialize the component to a dictionary."""
268
268
  return default_to_dict(
269
269
  self,
@@ -272,7 +272,7 @@ class GitHubPRCreator:
272
272
  )
273
273
 
274
274
  @classmethod
275
- def from_dict(cls, data: Dict[str, Any]) -> "GitHubPRCreator":
275
+ def from_dict(cls, data: dict[str, Any]) -> "GitHubPRCreator":
276
276
  """Deserialize the component from a dictionary."""
277
277
  init_params = data["init_parameters"]
278
278
  deserialize_secrets_inplace(init_params, keys=["github_token"])
@@ -3,7 +3,7 @@
3
3
  # SPDX-License-Identifier: Apache-2.0
4
4
  import re
5
5
  import time
6
- from typing import Any, Dict, Optional
6
+ from typing import Any
7
7
 
8
8
  import requests
9
9
  from haystack import component, default_from_dict, default_to_dict, logging
@@ -137,7 +137,7 @@ class GitHubRepoForker:
137
137
  response.raise_for_status()
138
138
  return response.json()["login"]
139
139
 
140
- def _get_existing_repository(self, repo_name: str) -> Optional[str]:
140
+ def _get_existing_repository(self, repo_name: str) -> str | None:
141
141
  """
142
142
  Check if a repository with the given name already exists in the authenticated user's account.
143
143
 
@@ -221,7 +221,7 @@ class GitHubRepoForker:
221
221
  fork_data = response.json()
222
222
  return f"{fork_data['owner']['login']}/{fork_data['name']}"
223
223
 
224
- def to_dict(self) -> Dict[str, Any]:
224
+ def to_dict(self) -> dict[str, Any]:
225
225
  """
226
226
  Serialize the component to a dictionary.
227
227
 
@@ -239,7 +239,7 @@ class GitHubRepoForker:
239
239
  )
240
240
 
241
241
  @classmethod
242
- def from_dict(cls, data: Dict[str, Any]) -> "GitHubRepoForker":
242
+ def from_dict(cls, data: dict[str, Any]) -> "GitHubRepoForker":
243
243
  """
244
244
  Deserialize the component from a dictionary.
245
245
 
@@ -3,7 +3,7 @@
3
3
  # SPDX-License-Identifier: Apache-2.0
4
4
  import base64
5
5
  from dataclasses import dataclass
6
- from typing import Any, Dict, List, Optional
6
+ from typing import Any
7
7
 
8
8
  import requests
9
9
  from haystack import Document, component, default_from_dict, default_to_dict, logging
@@ -21,7 +21,7 @@ class GitHubItem:
21
21
  path: str
22
22
  size: int
23
23
  url: str
24
- content: Optional[str] = None
24
+ content: str | None = None
25
25
 
26
26
 
27
27
  @component
@@ -71,10 +71,10 @@ class GitHubRepoViewer:
71
71
  def __init__(
72
72
  self,
73
73
  *,
74
- github_token: Optional[Secret] = None,
74
+ github_token: Secret | None = None,
75
75
  raise_on_failure: bool = True,
76
76
  max_file_size: int = 1_000_000, # 1MB default limit
77
- repo: Optional[str] = None,
77
+ repo: str | None = None,
78
78
  branch: str = "main",
79
79
  ):
80
80
  """
@@ -114,7 +114,7 @@ class GitHubRepoViewer:
114
114
  headers["Authorization"] = f"Bearer {token_value}"
115
115
  return headers
116
116
 
117
- def to_dict(self) -> Dict[str, Any]:
117
+ def to_dict(self) -> dict[str, Any]:
118
118
  """
119
119
  Serialize the component to a dictionary.
120
120
 
@@ -130,7 +130,7 @@ class GitHubRepoViewer:
130
130
  )
131
131
 
132
132
  @classmethod
133
- def from_dict(cls, data: Dict[str, Any]) -> "GitHubRepoViewer":
133
+ def from_dict(cls, data: dict[str, Any]) -> "GitHubRepoViewer":
134
134
  """
135
135
  Deserialize the component from a dictionary.
136
136
 
@@ -181,7 +181,7 @@ class GitHubRepoViewer:
181
181
  },
182
182
  )
183
183
 
184
- def _create_directory_documents(self, items: List[GitHubItem]) -> List[Document]:
184
+ def _create_directory_documents(self, items: list[GitHubItem]) -> list[Document]:
185
185
  """Create a list of Documents from directory contents"""
186
186
  return [
187
187
  Document(
@@ -206,8 +206,8 @@ class GitHubRepoViewer:
206
206
  },
207
207
  )
208
208
 
209
- @component.output_types(documents=List[Document])
210
- def run(self, path: str, repo: Optional[str] = None, branch: Optional[str] = None) -> Dict[str, List[Document]]:
209
+ @component.output_types(documents=list[Document])
210
+ def run(self, path: str, repo: str | None = None, branch: str | None = None) -> dict[str, list[Document]]:
211
211
  """
212
212
  Process a GitHub repository path and return documents.
213
213
 
@@ -1,7 +1,8 @@
1
1
  # SPDX-FileCopyrightText: 2023-present deepset GmbH <info@deepset.ai>
2
2
  #
3
3
  # SPDX-License-Identifier: Apache-2.0
4
- from typing import Any, Callable, Dict, Optional, Union
4
+ from collections.abc import Callable
5
+ from typing import Any
5
6
 
6
7
  from haystack.core.serialization import generate_qualified_class_name
7
8
  from haystack.tools import ComponentTool
@@ -20,16 +21,16 @@ class GitHubFileEditorTool(ComponentTool):
20
21
  def __init__(
21
22
  self,
22
23
  *,
23
- name: Optional[str] = "file_editor",
24
- description: Optional[str] = FILE_EDITOR_PROMPT,
25
- parameters: Optional[Dict[str, Any]] = FILE_EDITOR_SCHEMA,
24
+ name: str | None = "file_editor",
25
+ description: str | None = FILE_EDITOR_PROMPT,
26
+ parameters: dict[str, Any] | None = FILE_EDITOR_SCHEMA,
26
27
  github_token: Secret = Secret.from_env_var("GITHUB_TOKEN"),
27
- repo: Optional[str] = None,
28
+ repo: str | None = None,
28
29
  branch: str = "main",
29
30
  raise_on_failure: bool = True,
30
- outputs_to_string: Optional[Dict[str, Union[str, Callable[[Any], str]]]] = None,
31
- inputs_from_state: Optional[Dict[str, str]] = None,
32
- outputs_to_state: Optional[Dict[str, Dict[str, Union[str, Callable]]]] = None,
31
+ outputs_to_string: dict[str, str | Callable[[Any], str]] | None = None,
32
+ inputs_from_state: dict[str, str] | None = None,
33
+ outputs_to_state: dict[str, dict[str, str | Callable]] | None = None,
33
34
  ):
34
35
  """
35
36
  Initialize the GitHub file editor tool.
@@ -86,7 +87,7 @@ class GitHubFileEditorTool(ComponentTool):
86
87
  outputs_to_state=outputs_to_state,
87
88
  )
88
89
 
89
- def to_dict(self) -> Dict[str, Any]:
90
+ def to_dict(self) -> dict[str, Any]:
90
91
  """
91
92
  Serializes the tool to a dictionary.
92
93
 
@@ -110,7 +111,7 @@ class GitHubFileEditorTool(ComponentTool):
110
111
  return {"type": generate_qualified_class_name(type(self)), "data": serialized}
111
112
 
112
113
  @classmethod
113
- def from_dict(cls, data: Dict[str, Any]) -> "GitHubFileEditorTool":
114
+ def from_dict(cls, data: dict[str, Any]) -> "GitHubFileEditorTool":
114
115
  """
115
116
  Deserializes the tool from a dictionary.
116
117
 
@@ -1,7 +1,8 @@
1
1
  # SPDX-FileCopyrightText: 2023-present deepset GmbH <info@deepset.ai>
2
2
  #
3
3
  # SPDX-License-Identifier: Apache-2.0
4
- from typing import Any, Callable, Dict, Optional, Union
4
+ from collections.abc import Callable
5
+ from typing import Any
5
6
 
6
7
  from haystack.core.serialization import generate_qualified_class_name
7
8
  from haystack.tools import ComponentTool
@@ -20,15 +21,15 @@ class GitHubIssueCommenterTool(ComponentTool):
20
21
  def __init__(
21
22
  self,
22
23
  *,
23
- name: Optional[str] = "issue_commenter",
24
- description: Optional[str] = ISSUE_COMMENTER_PROMPT,
25
- parameters: Optional[Dict[str, Any]] = ISSUE_COMMENTER_SCHEMA,
24
+ name: str | None = "issue_commenter",
25
+ description: str | None = ISSUE_COMMENTER_PROMPT,
26
+ parameters: dict[str, Any] | None = ISSUE_COMMENTER_SCHEMA,
26
27
  github_token: Secret = Secret.from_env_var("GITHUB_TOKEN"),
27
28
  raise_on_failure: bool = True,
28
29
  retry_attempts: int = 2,
29
- outputs_to_string: Optional[Dict[str, Union[str, Callable[[Any], str]]]] = None,
30
- inputs_from_state: Optional[Dict[str, str]] = None,
31
- outputs_to_state: Optional[Dict[str, Dict[str, Union[str, Callable]]]] = None,
30
+ outputs_to_string: dict[str, str | Callable[[Any], str]] | None = None,
31
+ inputs_from_state: dict[str, str] | None = None,
32
+ outputs_to_state: dict[str, dict[str, str | Callable]] | None = None,
32
33
  ):
33
34
  """
34
35
  Initialize the GitHub issue commenter tool.
@@ -82,7 +83,7 @@ class GitHubIssueCommenterTool(ComponentTool):
82
83
  outputs_to_state=outputs_to_state,
83
84
  )
84
85
 
85
- def to_dict(self) -> Dict[str, Any]:
86
+ def to_dict(self) -> dict[str, Any]:
86
87
  """
87
88
  Serializes the tool to a dictionary.
88
89
 
@@ -105,7 +106,7 @@ class GitHubIssueCommenterTool(ComponentTool):
105
106
  return {"type": generate_qualified_class_name(type(self)), "data": serialized}
106
107
 
107
108
  @classmethod
108
- def from_dict(cls, data: Dict[str, Any]) -> "GitHubIssueCommenterTool":
109
+ def from_dict(cls, data: dict[str, Any]) -> "GitHubIssueCommenterTool":
109
110
  """
110
111
  Deserializes the tool from a dictionary.
111
112
 
@@ -1,7 +1,8 @@
1
1
  # SPDX-FileCopyrightText: 2023-present deepset GmbH <info@deepset.ai>
2
2
  #
3
3
  # SPDX-License-Identifier: Apache-2.0
4
- from typing import Any, Callable, Dict, Optional, Union
4
+ from collections.abc import Callable
5
+ from typing import Any
5
6
 
6
7
  from haystack.core.serialization import generate_qualified_class_name
7
8
  from haystack.tools import ComponentTool
@@ -20,15 +21,15 @@ class GitHubIssueViewerTool(ComponentTool):
20
21
  def __init__(
21
22
  self,
22
23
  *,
23
- name: Optional[str] = "issue_viewer",
24
- description: Optional[str] = ISSUE_VIEWER_PROMPT,
25
- parameters: Optional[Dict[str, Any]] = ISSUE_VIEWER_SCHEMA,
26
- github_token: Optional[Secret] = None,
24
+ name: str | None = "issue_viewer",
25
+ description: str | None = ISSUE_VIEWER_PROMPT,
26
+ parameters: dict[str, Any] | None = ISSUE_VIEWER_SCHEMA,
27
+ github_token: Secret | None = None,
27
28
  raise_on_failure: bool = True,
28
29
  retry_attempts: int = 2,
29
- outputs_to_string: Optional[Dict[str, Union[str, Callable[[Any], str]]]] = None,
30
- inputs_from_state: Optional[Dict[str, str]] = None,
31
- outputs_to_state: Optional[Dict[str, Dict[str, Union[str, Callable]]]] = None,
30
+ outputs_to_string: dict[str, str | Callable[[Any], str]] | None = None,
31
+ inputs_from_state: dict[str, str] | None = None,
32
+ outputs_to_state: dict[str, dict[str, str | Callable]] | None = None,
32
33
  ):
33
34
  """
34
35
  Initialize the GitHub issue viewer tool.
@@ -82,7 +83,7 @@ class GitHubIssueViewerTool(ComponentTool):
82
83
  outputs_to_state=outputs_to_state,
83
84
  )
84
85
 
85
- def to_dict(self) -> Dict[str, Any]:
86
+ def to_dict(self) -> dict[str, Any]:
86
87
  """
87
88
  Serializes the tool to a dictionary.
88
89
 
@@ -105,7 +106,7 @@ class GitHubIssueViewerTool(ComponentTool):
105
106
  return {"type": generate_qualified_class_name(type(self)), "data": serialized}
106
107
 
107
108
  @classmethod
108
- def from_dict(cls, data: Dict[str, Any]) -> "GitHubIssueViewerTool":
109
+ def from_dict(cls, data: dict[str, Any]) -> "GitHubIssueViewerTool":
109
110
  """
110
111
  Deserializes the tool from a dictionary.
111
112
 
@@ -1,7 +1,8 @@
1
1
  # SPDX-FileCopyrightText: 2023-present deepset GmbH <info@deepset.ai>
2
2
  #
3
3
  # SPDX-License-Identifier: Apache-2.0
4
- from typing import Any, Callable, Dict, Optional, Union
4
+ from collections.abc import Callable
5
+ from typing import Any
5
6
 
6
7
  from haystack.core.serialization import generate_qualified_class_name
7
8
  from haystack.tools import ComponentTool
@@ -20,14 +21,14 @@ class GitHubPRCreatorTool(ComponentTool):
20
21
  def __init__(
21
22
  self,
22
23
  *,
23
- name: Optional[str] = "pr_creator",
24
- description: Optional[str] = PR_CREATOR_PROMPT,
25
- parameters: Optional[Dict[str, Any]] = PR_CREATOR_SCHEMA,
24
+ name: str | None = "pr_creator",
25
+ description: str | None = PR_CREATOR_PROMPT,
26
+ parameters: dict[str, Any] | None = PR_CREATOR_SCHEMA,
26
27
  github_token: Secret = Secret.from_env_var("GITHUB_TOKEN"),
27
28
  raise_on_failure: bool = True,
28
- outputs_to_string: Optional[Dict[str, Union[str, Callable[[Any], str]]]] = None,
29
- inputs_from_state: Optional[Dict[str, str]] = None,
30
- outputs_to_state: Optional[Dict[str, Dict[str, Union[str, Callable]]]] = None,
29
+ outputs_to_string: dict[str, str | Callable[[Any], str]] | None = None,
30
+ inputs_from_state: dict[str, str] | None = None,
31
+ outputs_to_state: dict[str, dict[str, str | Callable]] | None = None,
31
32
  ):
32
33
  """
33
34
  Initialize the GitHub PR creator tool.
@@ -78,7 +79,7 @@ class GitHubPRCreatorTool(ComponentTool):
78
79
  outputs_to_state=outputs_to_state,
79
80
  )
80
81
 
81
- def to_dict(self) -> Dict[str, Any]:
82
+ def to_dict(self) -> dict[str, Any]:
82
83
  """
83
84
  Serializes the tool to a dictionary.
84
85
 
@@ -99,7 +100,7 @@ class GitHubPRCreatorTool(ComponentTool):
99
100
  return {"type": generate_qualified_class_name(type(self)), "data": serialized}
100
101
 
101
102
  @classmethod
102
- def from_dict(cls, data: Dict[str, Any]) -> "GitHubPRCreatorTool":
103
+ def from_dict(cls, data: dict[str, Any]) -> "GitHubPRCreatorTool":
103
104
  """
104
105
  Deserializes the tool from a dictionary.
105
106
 
@@ -1,7 +1,8 @@
1
1
  # SPDX-FileCopyrightText: 2023-present deepset GmbH <info@deepset.ai>
2
2
  #
3
3
  # SPDX-License-Identifier: Apache-2.0
4
- from typing import Any, Callable, Dict, Optional, Union
4
+ from collections.abc import Callable
5
+ from typing import Any
5
6
 
6
7
  from haystack.core.serialization import generate_qualified_class_name
7
8
  from haystack.tools import ComponentTool
@@ -20,14 +21,14 @@ class GitHubRepoForkerTool(ComponentTool):
20
21
  def __init__(
21
22
  self,
22
23
  *,
23
- name: Optional[str] = "repo_forker",
24
- description: Optional[str] = REPO_FORKER_PROMPT,
25
- parameters: Optional[Dict[str, Any]] = REPO_FORKER_SCHEMA,
24
+ name: str | None = "repo_forker",
25
+ description: str | None = REPO_FORKER_PROMPT,
26
+ parameters: dict[str, Any] | None = REPO_FORKER_SCHEMA,
26
27
  github_token: Secret = Secret.from_env_var("GITHUB_TOKEN"),
27
28
  raise_on_failure: bool = True,
28
- outputs_to_string: Optional[Dict[str, Union[str, Callable[[Any], str]]]] = None,
29
- inputs_from_state: Optional[Dict[str, str]] = None,
30
- outputs_to_state: Optional[Dict[str, Dict[str, Union[str, Callable]]]] = None,
29
+ outputs_to_string: dict[str, str | Callable[[Any], str]] | None = None,
30
+ inputs_from_state: dict[str, str] | None = None,
31
+ outputs_to_state: dict[str, dict[str, str | Callable]] | None = None,
31
32
  ):
32
33
  """
33
34
  Initialize the GitHub Repo Forker tool.
@@ -79,7 +80,7 @@ class GitHubRepoForkerTool(ComponentTool):
79
80
  outputs_to_state=self.outputs_to_state,
80
81
  )
81
82
 
82
- def to_dict(self) -> Dict[str, Any]:
83
+ def to_dict(self) -> dict[str, Any]:
83
84
  """
84
85
  Serializes the tool to a dictionary.
85
86
 
@@ -101,7 +102,7 @@ class GitHubRepoForkerTool(ComponentTool):
101
102
  return {"type": generate_qualified_class_name(type(self)), "data": serialized}
102
103
 
103
104
  @classmethod
104
- def from_dict(cls, data: Dict[str, Any]) -> "GitHubRepoForkerTool":
105
+ def from_dict(cls, data: dict[str, Any]) -> "GitHubRepoForkerTool":
105
106
  """
106
107
  Deserializes the tool from a dictionary.
107
108
 
@@ -1,7 +1,8 @@
1
1
  # SPDX-FileCopyrightText: 2023-present deepset GmbH <info@deepset.ai>
2
2
  #
3
3
  # SPDX-License-Identifier: Apache-2.0
4
- from typing import Any, Callable, Dict, Optional, Union
4
+ from collections.abc import Callable
5
+ from typing import Any
5
6
 
6
7
  from haystack.core.serialization import generate_qualified_class_name
7
8
  from haystack.tools import ComponentTool
@@ -20,17 +21,17 @@ class GitHubRepoViewerTool(ComponentTool):
20
21
  def __init__(
21
22
  self,
22
23
  *,
23
- name: Optional[str] = "repo_viewer",
24
- description: Optional[str] = REPO_VIEWER_PROMPT,
25
- parameters: Optional[Dict[str, Any]] = REPO_VIEWER_SCHEMA,
26
- github_token: Optional[Secret] = None,
27
- repo: Optional[str] = None,
24
+ name: str | None = "repo_viewer",
25
+ description: str | None = REPO_VIEWER_PROMPT,
26
+ parameters: dict[str, Any] | None = REPO_VIEWER_SCHEMA,
27
+ github_token: Secret | None = None,
28
+ repo: str | None = None,
28
29
  branch: str = "main",
29
30
  raise_on_failure: bool = True,
30
31
  max_file_size: int = 1_000_000, # 1MB default limit
31
- outputs_to_string: Optional[Dict[str, Union[str, Callable[[Any], str]]]] = None,
32
- inputs_from_state: Optional[Dict[str, str]] = None,
33
- outputs_to_state: Optional[Dict[str, Dict[str, Union[str, Callable]]]] = None,
32
+ outputs_to_string: dict[str, str | Callable[[Any], str]] | None = None,
33
+ inputs_from_state: dict[str, str] | None = None,
34
+ outputs_to_state: dict[str, dict[str, str | Callable]] | None = None,
34
35
  ):
35
36
  """
36
37
  Initialize the GitHub repository viewer tool.
@@ -95,7 +96,7 @@ class GitHubRepoViewerTool(ComponentTool):
95
96
  outputs_to_state=self.outputs_to_state,
96
97
  )
97
98
 
98
- def to_dict(self) -> Dict[str, Any]:
99
+ def to_dict(self) -> dict[str, Any]:
99
100
  """
100
101
  Serializes the tool to a dictionary.
101
102
 
@@ -120,7 +121,7 @@ class GitHubRepoViewerTool(ComponentTool):
120
121
  return {"type": generate_qualified_class_name(type(self)), "data": serialized}
121
122
 
122
123
  @classmethod
123
- def from_dict(cls, data: Dict[str, Any]) -> "GitHubRepoViewerTool":
124
+ def from_dict(cls, data: dict[str, Any]) -> "GitHubRepoViewerTool":
124
125
  """
125
126
  Deserializes the tool from a dictionary.
126
127
 
@@ -2,13 +2,14 @@
2
2
  #
3
3
  # SPDX-License-Identifier: Apache-2.0
4
4
 
5
- from typing import Any, Callable, Dict, List, Optional, Union
5
+ from collections.abc import Callable
6
+ from typing import Any
6
7
 
7
8
  from haystack import Document
8
9
  from haystack.utils.callable_serialization import deserialize_callable, serialize_callable
9
10
 
10
11
 
11
- def message_handler(documents: List[Document], max_length: int = 150_000) -> str:
12
+ def message_handler(documents: list[Document], max_length: int = 150_000) -> str:
12
13
  """
13
14
  Handles the tool output before conversion to ChatMessage.
14
15
 
@@ -32,9 +33,9 @@ def message_handler(documents: List[Document], max_length: int = 150_000) -> str
32
33
 
33
34
 
34
35
  def serialize_handlers(
35
- serialized: Dict[str, Any],
36
- outputs_to_state: Optional[Dict[str, Dict[str, Union[str, Callable]]]],
37
- outputs_to_string: Optional[Dict[str, Union[str, Callable[[Any], str]]]],
36
+ serialized: dict[str, Any],
37
+ outputs_to_state: dict[str, dict[str, str | Callable]] | None,
38
+ outputs_to_string: dict[str, str | Callable[[Any], str]] | None,
38
39
  ) -> None:
39
40
  """
40
41
  Serializes callable handlers in outputs_to_state and outputs_to_string.
@@ -64,7 +65,7 @@ def serialize_handlers(
64
65
  serialized["outputs_to_string"] = serialized_string
65
66
 
66
67
 
67
- def deserialize_handlers(data: Dict[str, Any]) -> None:
68
+ def deserialize_handlers(data: dict[str, Any]) -> None:
68
69
  """
69
70
  Deserializes callable handlers in outputs_to_state and outputs_to_string.
70
71