github-haystack 1.2.1__tar.gz → 2.0.0__tar.gz
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.
- {github_haystack-1.2.1 → github_haystack-2.0.0}/CHANGELOG.md +3 -1
- {github_haystack-1.2.1 → github_haystack-2.0.0}/PKG-INFO +3 -4
- github_haystack-2.0.0/pydoc/config_docusaurus.yml +33 -0
- {github_haystack-1.2.1 → github_haystack-2.0.0}/pyproject.toml +5 -11
- {github_haystack-1.2.1 → github_haystack-2.0.0}/src/haystack_integrations/components/connectors/github/file_editor.py +15 -15
- {github_haystack-1.2.1 → github_haystack-2.0.0}/src/haystack_integrations/components/connectors/github/issue_commenter.py +3 -3
- {github_haystack-1.2.1 → github_haystack-2.0.0}/src/haystack_integrations/components/connectors/github/issue_viewer.py +5 -5
- {github_haystack-1.2.1 → github_haystack-2.0.0}/src/haystack_integrations/components/connectors/github/pr_creator.py +5 -5
- {github_haystack-1.2.1 → github_haystack-2.0.0}/src/haystack_integrations/components/connectors/github/repo_forker.py +4 -4
- {github_haystack-1.2.1 → github_haystack-2.0.0}/src/haystack_integrations/components/connectors/github/repo_viewer.py +9 -9
- {github_haystack-1.2.1 → github_haystack-2.0.0}/src/haystack_integrations/tools/github/file_editor_tool.py +11 -10
- {github_haystack-1.2.1 → github_haystack-2.0.0}/src/haystack_integrations/tools/github/issue_commenter_tool.py +10 -9
- {github_haystack-1.2.1 → github_haystack-2.0.0}/src/haystack_integrations/tools/github/issue_viewer_tool.py +11 -10
- {github_haystack-1.2.1 → github_haystack-2.0.0}/src/haystack_integrations/tools/github/pr_creator_tool.py +10 -9
- {github_haystack-1.2.1 → github_haystack-2.0.0}/src/haystack_integrations/tools/github/repo_forker_tool.py +10 -9
- {github_haystack-1.2.1 → github_haystack-2.0.0}/src/haystack_integrations/tools/github/repo_viewer_tool.py +12 -11
- {github_haystack-1.2.1 → github_haystack-2.0.0}/src/haystack_integrations/tools/github/utils.py +7 -6
- {github_haystack-1.2.1 → github_haystack-2.0.0}/tests/test_file_editor_tool.py +7 -5
- {github_haystack-1.2.1 → github_haystack-2.0.0}/tests/test_issue_commenter_tool.py +8 -8
- {github_haystack-1.2.1 → github_haystack-2.0.0}/tests/test_issue_viewer_tool.py +8 -8
- {github_haystack-1.2.1 → github_haystack-2.0.0}/tests/test_pr_creator_tool.py +8 -8
- {github_haystack-1.2.1 → github_haystack-2.0.0}/tests/test_repo_forker_tool.py +9 -9
- {github_haystack-1.2.1 → github_haystack-2.0.0}/tests/test_repo_viewer_tool.py +4 -4
- github_haystack-1.2.1/pydoc/config.yml +0 -34
- {github_haystack-1.2.1 → github_haystack-2.0.0}/.gitignore +0 -0
- {github_haystack-1.2.1 → github_haystack-2.0.0}/LICENSE.txt +0 -0
- {github_haystack-1.2.1 → github_haystack-2.0.0}/README.md +0 -0
- {github_haystack-1.2.1 → github_haystack-2.0.0}/src/haystack_integrations/components/connectors/github/__init__.py +0 -0
- {github_haystack-1.2.1 → github_haystack-2.0.0}/src/haystack_integrations/components/connectors/py.typed +0 -0
- {github_haystack-1.2.1 → github_haystack-2.0.0}/src/haystack_integrations/prompts/github/__init__.py +0 -0
- {github_haystack-1.2.1 → github_haystack-2.0.0}/src/haystack_integrations/prompts/github/context_prompt.py +0 -0
- {github_haystack-1.2.1 → github_haystack-2.0.0}/src/haystack_integrations/prompts/github/file_editor_prompt.py +0 -0
- {github_haystack-1.2.1 → github_haystack-2.0.0}/src/haystack_integrations/prompts/github/issue_commenter_prompt.py +0 -0
- {github_haystack-1.2.1 → github_haystack-2.0.0}/src/haystack_integrations/prompts/github/issue_viewer_prompt.py +0 -0
- {github_haystack-1.2.1 → github_haystack-2.0.0}/src/haystack_integrations/prompts/github/pr_creator_prompt.py +0 -0
- {github_haystack-1.2.1 → github_haystack-2.0.0}/src/haystack_integrations/prompts/github/repo_forker_prompt.py +0 -0
- {github_haystack-1.2.1 → github_haystack-2.0.0}/src/haystack_integrations/prompts/github/repo_viewer_prompt.py +0 -0
- {github_haystack-1.2.1 → github_haystack-2.0.0}/src/haystack_integrations/prompts/github/system_prompt.py +0 -0
- {github_haystack-1.2.1 → github_haystack-2.0.0}/src/haystack_integrations/prompts/py.typed +0 -0
- {github_haystack-1.2.1 → github_haystack-2.0.0}/src/haystack_integrations/tools/github/__init__.py +0 -0
- {github_haystack-1.2.1 → github_haystack-2.0.0}/src/haystack_integrations/tools/py.typed +0 -0
- {github_haystack-1.2.1 → github_haystack-2.0.0}/tests/__init__.py +0 -0
- {github_haystack-1.2.1 → github_haystack-2.0.0}/tests/test_file_editor.py +0 -0
- {github_haystack-1.2.1 → github_haystack-2.0.0}/tests/test_issue_commenter.py +0 -0
- {github_haystack-1.2.1 → github_haystack-2.0.0}/tests/test_issue_viewer.py +0 -0
- {github_haystack-1.2.1 → github_haystack-2.0.0}/tests/test_pr_creator.py +0 -0
- {github_haystack-1.2.1 → github_haystack-2.0.0}/tests/test_repo_forker.py +0 -0
- {github_haystack-1.2.1 → github_haystack-2.0.0}/tests/test_repo_viewer.py +0 -0
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## [integrations/github-v1.2.
|
|
3
|
+
## [integrations/github-v1.2.1] - 2025-10-20
|
|
4
4
|
|
|
5
5
|
### 🚀 Features
|
|
6
6
|
|
|
7
7
|
- Add support for GitHubRepoForkerTool (#1968)
|
|
8
8
|
|
|
9
|
+
|
|
9
10
|
### 🧪 Testing
|
|
10
11
|
|
|
11
12
|
- Fix GitHub test (#2119)
|
|
@@ -17,6 +18,7 @@
|
|
|
17
18
|
### 🌀 Miscellaneous
|
|
18
19
|
|
|
19
20
|
- Chore: Fix linting github (#2255)
|
|
21
|
+
- Fix: handle empty GitHub tokens in authentication headers (#2400)
|
|
20
22
|
|
|
21
23
|
## [integrations/github-v1.1.0] - 2025-07-01
|
|
22
24
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: github-haystack
|
|
3
|
-
Version:
|
|
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.
|
|
22
|
-
Requires-Dist: haystack-ai>=2.
|
|
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
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
loaders:
|
|
2
|
+
- ignore_when_discovered:
|
|
3
|
+
- __init__
|
|
4
|
+
modules:
|
|
5
|
+
- haystack_integrations.components.connectors.github.file_editor
|
|
6
|
+
- haystack_integrations.components.connectors.github.issue_commenter
|
|
7
|
+
- haystack_integrations.components.connectors.github.issue_viewer
|
|
8
|
+
- haystack_integrations.components.connectors.github.pr_creator
|
|
9
|
+
- haystack_integrations.components.connectors.github.repo_viewer
|
|
10
|
+
- haystack_integrations.components.connectors.github.repo_forker
|
|
11
|
+
search_path:
|
|
12
|
+
- ../src
|
|
13
|
+
type: haystack_pydoc_tools.loaders.CustomPythonLoader
|
|
14
|
+
processors:
|
|
15
|
+
- do_not_filter_modules: false
|
|
16
|
+
documented_only: true
|
|
17
|
+
expression: null
|
|
18
|
+
skip_empty_modules: true
|
|
19
|
+
type: filter
|
|
20
|
+
- type: smart
|
|
21
|
+
- type: crossref
|
|
22
|
+
renderer:
|
|
23
|
+
description: GitHub integration for Haystack
|
|
24
|
+
id: integrations-github
|
|
25
|
+
markdown:
|
|
26
|
+
add_member_class_prefix: false
|
|
27
|
+
add_method_class_prefix: true
|
|
28
|
+
classdef_code_block: false
|
|
29
|
+
descriptive_class_title: false
|
|
30
|
+
descriptive_module_title: true
|
|
31
|
+
filename: github.md
|
|
32
|
+
title: GitHub
|
|
33
|
+
type: haystack_pydoc_tools.renderers.DocusaurusRenderer
|
|
@@ -7,7 +7,7 @@ name = "github-haystack"
|
|
|
7
7
|
dynamic = ["version"]
|
|
8
8
|
description = 'Haystack components for interacting with GitHub repositories'
|
|
9
9
|
readme = "README.md"
|
|
10
|
-
requires-python = ">=3.
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
11
|
license = "Apache-2.0"
|
|
12
12
|
keywords = []
|
|
13
13
|
authors = [{ name = "deepset GmbH", email = "info@deepset.ai" }]
|
|
@@ -15,7 +15,6 @@ classifiers = [
|
|
|
15
15
|
"License :: OSI Approved :: Apache Software License",
|
|
16
16
|
"Development Status :: 4 - Beta",
|
|
17
17
|
"Programming Language :: Python",
|
|
18
|
-
"Programming Language :: Python :: 3.9",
|
|
19
18
|
"Programming Language :: Python :: 3.10",
|
|
20
19
|
"Programming Language :: Python :: 3.11",
|
|
21
20
|
"Programming Language :: Python :: 3.12",
|
|
@@ -23,7 +22,7 @@ classifiers = [
|
|
|
23
22
|
"Programming Language :: Python :: Implementation :: CPython",
|
|
24
23
|
"Programming Language :: Python :: Implementation :: PyPy",
|
|
25
24
|
]
|
|
26
|
-
dependencies = ["haystack-ai>=2.
|
|
25
|
+
dependencies = ["haystack-ai>=2.22.0"]
|
|
27
26
|
|
|
28
27
|
[project.urls]
|
|
29
28
|
Source = "https://github.com/deepset-ai/haystack-core-integrations/github"
|
|
@@ -46,8 +45,8 @@ installer = "uv"
|
|
|
46
45
|
dependencies = ["haystack-pydoc-tools", "ruff"]
|
|
47
46
|
|
|
48
47
|
[tool.hatch.envs.default.scripts]
|
|
49
|
-
docs = ["pydoc-markdown pydoc/
|
|
50
|
-
fmt = "ruff check --fix {args}
|
|
48
|
+
docs = ["pydoc-markdown pydoc/config_docusaurus.yml"]
|
|
49
|
+
fmt = "ruff check --fix {args}; ruff format {args}"
|
|
51
50
|
fmt-check = "ruff check {args} && ruff format --check {args}"
|
|
52
51
|
|
|
53
52
|
[tool.hatch.envs.test]
|
|
@@ -64,7 +63,7 @@ dependencies = [
|
|
|
64
63
|
unit = 'pytest -m "not integration" {args:tests}'
|
|
65
64
|
integration = 'pytest -m "integration" {args:tests}'
|
|
66
65
|
all = 'pytest {args:tests}'
|
|
67
|
-
cov-retry = '
|
|
66
|
+
cov-retry = 'pytest --cov=haystack_integrations --reruns 3 --reruns-delay 30 -x {args:tests}'
|
|
68
67
|
|
|
69
68
|
types = """mypy -p haystack_integrations.components.connectors.github \
|
|
70
69
|
-p haystack_integrations.prompts.github \
|
|
@@ -77,7 +76,6 @@ check_untyped_defs = true
|
|
|
77
76
|
disallow_incomplete_defs = true
|
|
78
77
|
|
|
79
78
|
[tool.ruff]
|
|
80
|
-
target-version = "py38"
|
|
81
79
|
line-length = 120
|
|
82
80
|
|
|
83
81
|
[tool.ruff.lint]
|
|
@@ -124,10 +122,6 @@ ignore = [
|
|
|
124
122
|
"B008",
|
|
125
123
|
"S101",
|
|
126
124
|
]
|
|
127
|
-
unfixable = [
|
|
128
|
-
# Don't touch unused imports
|
|
129
|
-
"F401",
|
|
130
|
-
]
|
|
131
125
|
|
|
132
126
|
[tool.ruff.lint.isort]
|
|
133
127
|
known-first-party = ["haystack_integrations"]
|
|
@@ -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
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
248
|
-
payload:
|
|
249
|
-
repo:
|
|
250
|
-
branch:
|
|
251
|
-
) ->
|
|
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) ->
|
|
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:
|
|
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
|
|
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) ->
|
|
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:
|
|
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
|
|
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:
|
|
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) ->
|
|
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:
|
|
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=
|
|
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
|
|
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) ->
|
|
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
|
-
) ->
|
|
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) ->
|
|
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:
|
|
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
|
|
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) ->
|
|
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) ->
|
|
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:
|
|
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
|
|
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:
|
|
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:
|
|
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:
|
|
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) ->
|
|
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:
|
|
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:
|
|
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=
|
|
210
|
-
def run(self, path: str, repo:
|
|
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
|
|
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:
|
|
24
|
-
description:
|
|
25
|
-
parameters:
|
|
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:
|
|
28
|
+
repo: str | None = None,
|
|
28
29
|
branch: str = "main",
|
|
29
30
|
raise_on_failure: bool = True,
|
|
30
|
-
outputs_to_string:
|
|
31
|
-
inputs_from_state:
|
|
32
|
-
outputs_to_state:
|
|
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) ->
|
|
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:
|
|
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
|
|
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:
|
|
24
|
-
description:
|
|
25
|
-
parameters:
|
|
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:
|
|
30
|
-
inputs_from_state:
|
|
31
|
-
outputs_to_state:
|
|
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) ->
|
|
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:
|
|
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
|
|
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:
|
|
24
|
-
description:
|
|
25
|
-
parameters:
|
|
26
|
-
github_token:
|
|
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:
|
|
30
|
-
inputs_from_state:
|
|
31
|
-
outputs_to_state:
|
|
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) ->
|
|
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:
|
|
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
|
|
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:
|
|
24
|
-
description:
|
|
25
|
-
parameters:
|
|
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:
|
|
29
|
-
inputs_from_state:
|
|
30
|
-
outputs_to_state:
|
|
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) ->
|
|
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:
|
|
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
|
|
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:
|
|
24
|
-
description:
|
|
25
|
-
parameters:
|
|
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:
|
|
29
|
-
inputs_from_state:
|
|
30
|
-
outputs_to_state:
|
|
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) ->
|
|
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:
|
|
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
|
|
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:
|
|
24
|
-
description:
|
|
25
|
-
parameters:
|
|
26
|
-
github_token:
|
|
27
|
-
repo:
|
|
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:
|
|
32
|
-
inputs_from_state:
|
|
33
|
-
outputs_to_state:
|
|
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) ->
|
|
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:
|
|
124
|
+
def from_dict(cls, data: dict[str, Any]) -> "GitHubRepoViewerTool":
|
|
124
125
|
"""
|
|
125
126
|
Deserializes the tool from a dictionary.
|
|
126
127
|
|
{github_haystack-1.2.1 → github_haystack-2.0.0}/src/haystack_integrations/tools/github/utils.py
RENAMED
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
#
|
|
3
3
|
# SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
|
|
5
|
-
from
|
|
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:
|
|
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:
|
|
36
|
-
outputs_to_state:
|
|
37
|
-
outputs_to_string:
|
|
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:
|
|
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
|
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# SPDX-FileCopyrightText: 2023-present deepset GmbH <info@deepset.ai>
|
|
2
2
|
#
|
|
3
3
|
# SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
import unittest
|
|
5
|
+
|
|
4
6
|
from haystack import Pipeline
|
|
5
7
|
from haystack.components.agents import Agent
|
|
6
8
|
from haystack.components.generators.chat import OpenAIChatGenerator
|
|
@@ -75,7 +77,7 @@ class TestGitHubFileEditorTool:
|
|
|
75
77
|
tool = GitHubFileEditorTool(
|
|
76
78
|
outputs_to_string={"source": "result", "handler": message_handler},
|
|
77
79
|
inputs_from_state={"repo_state": "repo"},
|
|
78
|
-
outputs_to_state={"file_content": {"source": "
|
|
80
|
+
outputs_to_state={"file_content": {"source": "result", "handler": message_handler}},
|
|
79
81
|
)
|
|
80
82
|
|
|
81
83
|
tool_dict = tool.to_dict()
|
|
@@ -86,7 +88,7 @@ class TestGitHubFileEditorTool:
|
|
|
86
88
|
assert tool_dict["data"]["inputs_from_state"] == {"repo_state": "repo"}
|
|
87
89
|
assert tool_dict["data"]["outputs_to_state"] == {
|
|
88
90
|
"file_content": {
|
|
89
|
-
"source": "
|
|
91
|
+
"source": "result",
|
|
90
92
|
"handler": "haystack_integrations.tools.github.utils.message_handler",
|
|
91
93
|
},
|
|
92
94
|
}
|
|
@@ -111,7 +113,7 @@ class TestGitHubFileEditorTool:
|
|
|
111
113
|
"inputs_from_state": {"repo_state": "repo"},
|
|
112
114
|
"outputs_to_state": {
|
|
113
115
|
"file_content": {
|
|
114
|
-
"source": "
|
|
116
|
+
"source": "result",
|
|
115
117
|
"handler": "haystack_integrations.tools.github.utils.message_handler",
|
|
116
118
|
},
|
|
117
119
|
},
|
|
@@ -122,7 +124,7 @@ class TestGitHubFileEditorTool:
|
|
|
122
124
|
assert tool.outputs_to_string["source"] == "result"
|
|
123
125
|
assert tool.outputs_to_string["handler"] == message_handler
|
|
124
126
|
assert tool.inputs_from_state == {"repo_state": "repo"}
|
|
125
|
-
assert tool.outputs_to_state["file_content"]["source"] == "
|
|
127
|
+
assert tool.outputs_to_state["file_content"]["source"] == "result"
|
|
126
128
|
assert tool.outputs_to_state["file_content"]["handler"] == message_handler
|
|
127
129
|
|
|
128
130
|
def test_pipeline_serialization(self, monkeypatch):
|
|
@@ -161,7 +163,7 @@ class TestGitHubFileEditorTool:
|
|
|
161
163
|
"chat_generator": {
|
|
162
164
|
"type": "haystack.components.generators.chat.openai.OpenAIChatGenerator",
|
|
163
165
|
"init_parameters": {
|
|
164
|
-
"model":
|
|
166
|
+
"model": unittest.mock.ANY,
|
|
165
167
|
"streaming_callback": None,
|
|
166
168
|
"api_base_url": None,
|
|
167
169
|
"organization": None,
|
|
@@ -76,8 +76,8 @@ class TestGitHubIssueCommenterTool:
|
|
|
76
76
|
raise_on_failure=False,
|
|
77
77
|
retry_attempts=3,
|
|
78
78
|
outputs_to_string={"handler": message_handler},
|
|
79
|
-
inputs_from_state={"repository": "
|
|
80
|
-
outputs_to_state={"documents": {"source": "
|
|
79
|
+
inputs_from_state={"repository": "url"},
|
|
80
|
+
outputs_to_state={"documents": {"source": "success", "handler": message_handler}},
|
|
81
81
|
)
|
|
82
82
|
tool_dict = tool.to_dict()
|
|
83
83
|
assert tool_dict["type"] == "haystack_integrations.tools.github.issue_commenter_tool.GitHubIssueCommenterTool"
|
|
@@ -91,8 +91,8 @@ class TestGitHubIssueCommenterTool:
|
|
|
91
91
|
tool_dict["data"]["outputs_to_string"]["handler"]
|
|
92
92
|
== "haystack_integrations.tools.github.utils.message_handler"
|
|
93
93
|
)
|
|
94
|
-
assert tool_dict["data"]["inputs_from_state"] == {"repository": "
|
|
95
|
-
assert tool_dict["data"]["outputs_to_state"]["documents"]["source"] == "
|
|
94
|
+
assert tool_dict["data"]["inputs_from_state"] == {"repository": "url"}
|
|
95
|
+
assert tool_dict["data"]["outputs_to_state"]["documents"]["source"] == "success"
|
|
96
96
|
assert (
|
|
97
97
|
tool_dict["data"]["outputs_to_state"]["documents"]["handler"]
|
|
98
98
|
== "haystack_integrations.tools.github.utils.message_handler"
|
|
@@ -110,10 +110,10 @@ class TestGitHubIssueCommenterTool:
|
|
|
110
110
|
"raise_on_failure": False,
|
|
111
111
|
"retry_attempts": 3,
|
|
112
112
|
"outputs_to_string": {"handler": "haystack_integrations.tools.github.utils.message_handler"},
|
|
113
|
-
"inputs_from_state": {"repository": "
|
|
113
|
+
"inputs_from_state": {"repository": "url"},
|
|
114
114
|
"outputs_to_state": {
|
|
115
115
|
"documents": {
|
|
116
|
-
"source": "
|
|
116
|
+
"source": "success",
|
|
117
117
|
"handler": "haystack_integrations.tools.github.utils.message_handler",
|
|
118
118
|
}
|
|
119
119
|
},
|
|
@@ -127,6 +127,6 @@ class TestGitHubIssueCommenterTool:
|
|
|
127
127
|
assert tool.raise_on_failure is False
|
|
128
128
|
assert tool.retry_attempts == 3
|
|
129
129
|
assert tool.outputs_to_string["handler"] == message_handler
|
|
130
|
-
assert tool.inputs_from_state == {"repository": "
|
|
131
|
-
assert tool.outputs_to_state["documents"]["source"] == "
|
|
130
|
+
assert tool.inputs_from_state == {"repository": "url"}
|
|
131
|
+
assert tool.outputs_to_state["documents"]["source"] == "success"
|
|
132
132
|
assert tool.outputs_to_state["documents"]["handler"] == message_handler
|
|
@@ -72,8 +72,8 @@ class TestGitHubIssueViewerTool:
|
|
|
72
72
|
raise_on_failure=False,
|
|
73
73
|
retry_attempts=3,
|
|
74
74
|
outputs_to_string={"handler": message_handler},
|
|
75
|
-
inputs_from_state={"repository": "
|
|
76
|
-
outputs_to_state={"documents": {"source": "
|
|
75
|
+
inputs_from_state={"repository": "url"},
|
|
76
|
+
outputs_to_state={"documents": {"source": "documents", "handler": message_handler}},
|
|
77
77
|
)
|
|
78
78
|
tool_dict = tool.to_dict()
|
|
79
79
|
assert tool_dict["type"] == "haystack_integrations.tools.github.issue_viewer_tool.GitHubIssueViewerTool"
|
|
@@ -87,8 +87,8 @@ class TestGitHubIssueViewerTool:
|
|
|
87
87
|
tool_dict["data"]["outputs_to_string"]["handler"]
|
|
88
88
|
== "haystack_integrations.tools.github.utils.message_handler"
|
|
89
89
|
)
|
|
90
|
-
assert tool_dict["data"]["inputs_from_state"] == {"repository": "
|
|
91
|
-
assert tool_dict["data"]["outputs_to_state"]["documents"]["source"] == "
|
|
90
|
+
assert tool_dict["data"]["inputs_from_state"] == {"repository": "url"}
|
|
91
|
+
assert tool_dict["data"]["outputs_to_state"]["documents"]["source"] == "documents"
|
|
92
92
|
assert (
|
|
93
93
|
tool_dict["data"]["outputs_to_state"]["documents"]["handler"]
|
|
94
94
|
== "haystack_integrations.tools.github.utils.message_handler"
|
|
@@ -106,10 +106,10 @@ class TestGitHubIssueViewerTool:
|
|
|
106
106
|
"raise_on_failure": False,
|
|
107
107
|
"retry_attempts": 3,
|
|
108
108
|
"outputs_to_string": {"handler": "haystack_integrations.tools.github.utils.message_handler"},
|
|
109
|
-
"inputs_from_state": {"repository": "
|
|
109
|
+
"inputs_from_state": {"repository": "url"},
|
|
110
110
|
"outputs_to_state": {
|
|
111
111
|
"documents": {
|
|
112
|
-
"source": "
|
|
112
|
+
"source": "documents",
|
|
113
113
|
"handler": "haystack_integrations.tools.github.utils.message_handler",
|
|
114
114
|
}
|
|
115
115
|
},
|
|
@@ -123,6 +123,6 @@ class TestGitHubIssueViewerTool:
|
|
|
123
123
|
assert tool.raise_on_failure is False
|
|
124
124
|
assert tool.retry_attempts == 3
|
|
125
125
|
assert tool.outputs_to_string["handler"] == message_handler
|
|
126
|
-
assert tool.inputs_from_state == {"repository": "
|
|
127
|
-
assert tool.outputs_to_state["documents"]["source"] == "
|
|
126
|
+
assert tool.inputs_from_state == {"repository": "url"}
|
|
127
|
+
assert tool.outputs_to_state["documents"]["source"] == "documents"
|
|
128
128
|
assert tool.outputs_to_state["documents"]["handler"] == message_handler
|
|
@@ -73,8 +73,8 @@ class TestGitHubPRCreatorTool:
|
|
|
73
73
|
github_token=Secret.from_env_var("GITHUB_TOKEN"),
|
|
74
74
|
raise_on_failure=False,
|
|
75
75
|
outputs_to_string={"handler": message_handler},
|
|
76
|
-
inputs_from_state={"repository": "
|
|
77
|
-
outputs_to_state={"documents": {"source": "
|
|
76
|
+
inputs_from_state={"repository": "issue_url"},
|
|
77
|
+
outputs_to_state={"documents": {"source": "result", "handler": message_handler}},
|
|
78
78
|
)
|
|
79
79
|
tool_dict = tool.to_dict()
|
|
80
80
|
assert tool_dict["type"] == "haystack_integrations.tools.github.pr_creator_tool.GitHubPRCreatorTool"
|
|
@@ -91,8 +91,8 @@ class TestGitHubPRCreatorTool:
|
|
|
91
91
|
tool_dict["data"]["outputs_to_string"]["handler"]
|
|
92
92
|
== "haystack_integrations.tools.github.utils.message_handler"
|
|
93
93
|
)
|
|
94
|
-
assert tool_dict["data"]["inputs_from_state"] == {"repository": "
|
|
95
|
-
assert tool_dict["data"]["outputs_to_state"]["documents"]["source"] == "
|
|
94
|
+
assert tool_dict["data"]["inputs_from_state"] == {"repository": "issue_url"}
|
|
95
|
+
assert tool_dict["data"]["outputs_to_state"]["documents"]["source"] == "result"
|
|
96
96
|
assert (
|
|
97
97
|
tool_dict["data"]["outputs_to_state"]["documents"]["handler"]
|
|
98
98
|
== "haystack_integrations.tools.github.utils.message_handler"
|
|
@@ -109,10 +109,10 @@ class TestGitHubPRCreatorTool:
|
|
|
109
109
|
"github_token": {"env_vars": ["GITHUB_TOKEN"], "strict": True, "type": "env_var"},
|
|
110
110
|
"raise_on_failure": False,
|
|
111
111
|
"outputs_to_string": {"handler": "haystack_integrations.tools.github.utils.message_handler"},
|
|
112
|
-
"inputs_from_state": {"repository": "
|
|
112
|
+
"inputs_from_state": {"repository": "issue_url"},
|
|
113
113
|
"outputs_to_state": {
|
|
114
114
|
"documents": {
|
|
115
|
-
"source": "
|
|
115
|
+
"source": "result",
|
|
116
116
|
"handler": "haystack_integrations.tools.github.utils.message_handler",
|
|
117
117
|
}
|
|
118
118
|
},
|
|
@@ -125,6 +125,6 @@ class TestGitHubPRCreatorTool:
|
|
|
125
125
|
assert tool.github_token == Secret.from_env_var("GITHUB_TOKEN")
|
|
126
126
|
assert tool.raise_on_failure is False
|
|
127
127
|
assert tool.outputs_to_string["handler"] == message_handler
|
|
128
|
-
assert tool.inputs_from_state == {"repository": "
|
|
129
|
-
assert tool.outputs_to_state["documents"]["source"] == "
|
|
128
|
+
assert tool.inputs_from_state == {"repository": "issue_url"}
|
|
129
|
+
assert tool.outputs_to_state["documents"]["source"] == "result"
|
|
130
130
|
assert tool.outputs_to_state["documents"]["handler"] == message_handler
|
|
@@ -70,9 +70,9 @@ class TestGitHubRepoForkerTool:
|
|
|
70
70
|
tool = GitHubRepoForkerTool(
|
|
71
71
|
github_token=Secret.from_env_var("GITHUB_TOKEN"),
|
|
72
72
|
raise_on_failure=False,
|
|
73
|
-
outputs_to_string={"source": "
|
|
74
|
-
inputs_from_state={"repository": "
|
|
75
|
-
outputs_to_state={"documents": {"source": "
|
|
73
|
+
outputs_to_string={"source": "repo", "handler": message_handler},
|
|
74
|
+
inputs_from_state={"repository": "url"},
|
|
75
|
+
outputs_to_state={"documents": {"source": "repo", "handler": message_handler}},
|
|
76
76
|
)
|
|
77
77
|
tool_dict = tool.to_dict()
|
|
78
78
|
assert tool_dict["type"] == "haystack_integrations.tools.github.repo_forker_tool.GitHubRepoForkerTool"
|
|
@@ -89,8 +89,8 @@ class TestGitHubRepoForkerTool:
|
|
|
89
89
|
tool_dict["data"]["outputs_to_string"]["handler"]
|
|
90
90
|
== "haystack_integrations.tools.github.utils.message_handler"
|
|
91
91
|
)
|
|
92
|
-
assert tool_dict["data"]["inputs_from_state"] == {"repository": "
|
|
93
|
-
assert tool_dict["data"]["outputs_to_state"]["documents"]["source"] == "
|
|
92
|
+
assert tool_dict["data"]["inputs_from_state"] == {"repository": "url"}
|
|
93
|
+
assert tool_dict["data"]["outputs_to_state"]["documents"]["source"] == "repo"
|
|
94
94
|
assert (
|
|
95
95
|
tool_dict["data"]["outputs_to_state"]["documents"]["handler"]
|
|
96
96
|
== "haystack_integrations.tools.github.utils.message_handler"
|
|
@@ -107,10 +107,10 @@ class TestGitHubRepoForkerTool:
|
|
|
107
107
|
"github_token": {"env_vars": ["GITHUB_TOKEN"], "strict": True, "type": "env_var"},
|
|
108
108
|
"raise_on_failure": False,
|
|
109
109
|
"outputs_to_string": {"handler": "haystack_integrations.tools.github.utils.message_handler"},
|
|
110
|
-
"inputs_from_state": {"repository": "
|
|
110
|
+
"inputs_from_state": {"repository": "url"},
|
|
111
111
|
"outputs_to_state": {
|
|
112
112
|
"documents": {
|
|
113
|
-
"source": "
|
|
113
|
+
"source": "repo",
|
|
114
114
|
"handler": "haystack_integrations.tools.github.utils.message_handler",
|
|
115
115
|
}
|
|
116
116
|
},
|
|
@@ -123,6 +123,6 @@ class TestGitHubRepoForkerTool:
|
|
|
123
123
|
assert tool.github_token == Secret.from_env_var("GITHUB_TOKEN")
|
|
124
124
|
assert tool.raise_on_failure is False
|
|
125
125
|
assert tool.outputs_to_string["handler"] == message_handler
|
|
126
|
-
assert tool.inputs_from_state == {"repository": "
|
|
127
|
-
assert tool.outputs_to_state["documents"]["source"] == "
|
|
126
|
+
assert tool.inputs_from_state == {"repository": "url"}
|
|
127
|
+
assert tool.outputs_to_state["documents"]["source"] == "repo"
|
|
128
128
|
assert tool.outputs_to_state["documents"]["handler"] == message_handler
|
|
@@ -83,7 +83,7 @@ class TestGitHubRepoViewerTool:
|
|
|
83
83
|
tool = GitHubRepoViewerTool(
|
|
84
84
|
outputs_to_string={"source": "result", "handler": message_handler},
|
|
85
85
|
inputs_from_state={"repo_state": "repo"},
|
|
86
|
-
outputs_to_state={"file_content": {"source": "
|
|
86
|
+
outputs_to_state={"file_content": {"source": "documents", "handler": message_handler}},
|
|
87
87
|
)
|
|
88
88
|
|
|
89
89
|
tool_dict = tool.to_dict()
|
|
@@ -94,7 +94,7 @@ class TestGitHubRepoViewerTool:
|
|
|
94
94
|
assert tool_dict["data"]["inputs_from_state"] == {"repo_state": "repo"}
|
|
95
95
|
assert tool_dict["data"]["outputs_to_state"] == {
|
|
96
96
|
"file_content": {
|
|
97
|
-
"source": "
|
|
97
|
+
"source": "documents",
|
|
98
98
|
"handler": "haystack_integrations.tools.github.utils.message_handler",
|
|
99
99
|
},
|
|
100
100
|
}
|
|
@@ -120,7 +120,7 @@ class TestGitHubRepoViewerTool:
|
|
|
120
120
|
"inputs_from_state": {"repo_state": "repo"},
|
|
121
121
|
"outputs_to_state": {
|
|
122
122
|
"file_content": {
|
|
123
|
-
"source": "
|
|
123
|
+
"source": "documents",
|
|
124
124
|
"handler": "haystack_integrations.tools.github.utils.message_handler",
|
|
125
125
|
},
|
|
126
126
|
},
|
|
@@ -131,5 +131,5 @@ class TestGitHubRepoViewerTool:
|
|
|
131
131
|
assert tool.outputs_to_string["source"] == "result"
|
|
132
132
|
assert tool.outputs_to_string["handler"] == message_handler
|
|
133
133
|
assert tool.inputs_from_state == {"repo_state": "repo"}
|
|
134
|
-
assert tool.outputs_to_state["file_content"]["source"] == "
|
|
134
|
+
assert tool.outputs_to_state["file_content"]["source"] == "documents"
|
|
135
135
|
assert tool.outputs_to_state["file_content"]["handler"] == message_handler
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
loaders:
|
|
2
|
-
- type: haystack_pydoc_tools.loaders.CustomPythonLoader
|
|
3
|
-
search_path: [../src]
|
|
4
|
-
modules: [
|
|
5
|
-
"haystack_integrations.components.connectors.github.file_editor",
|
|
6
|
-
"haystack_integrations.components.connectors.github.issue_commenter",
|
|
7
|
-
"haystack_integrations.components.connectors.github.issue_viewer",
|
|
8
|
-
"haystack_integrations.components.connectors.github.pr_creator",
|
|
9
|
-
"haystack_integrations.components.connectors.github.repo_viewer",
|
|
10
|
-
"haystack_integrations.components.connectors.github.repo_forker",
|
|
11
|
-
]
|
|
12
|
-
ignore_when_discovered: ["__init__"]
|
|
13
|
-
processors:
|
|
14
|
-
- type: filter
|
|
15
|
-
expression:
|
|
16
|
-
documented_only: true
|
|
17
|
-
do_not_filter_modules: false
|
|
18
|
-
skip_empty_modules: true
|
|
19
|
-
- type: smart
|
|
20
|
-
- type: crossref
|
|
21
|
-
renderer:
|
|
22
|
-
type: haystack_pydoc_tools.renderers.ReadmeIntegrationRenderer
|
|
23
|
-
excerpt: GitHub integration for Haystack
|
|
24
|
-
category_slug: integrations-api
|
|
25
|
-
title: GitHub
|
|
26
|
-
slug: integrations-github
|
|
27
|
-
order: 100
|
|
28
|
-
markdown:
|
|
29
|
-
descriptive_class_title: false
|
|
30
|
-
classdef_code_block: false
|
|
31
|
-
descriptive_module_title: true
|
|
32
|
-
add_method_class_prefix: true
|
|
33
|
-
add_member_class_prefix: false
|
|
34
|
-
filename: _readme_github.md
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{github_haystack-1.2.1 → github_haystack-2.0.0}/src/haystack_integrations/prompts/github/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{github_haystack-1.2.1 → github_haystack-2.0.0}/src/haystack_integrations/tools/github/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|