alita-sdk 0.3.161__py3-none-any.whl → 0.3.162__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.
@@ -23,6 +23,7 @@ def _get_toolkit(tool) -> BaseToolkit:
23
23
  github_app_id=tool['settings'].get('app_id', None),
24
24
  github_app_private_key=tool['settings'].get('app_private_key', None),
25
25
  llm=tool['settings'].get('llm', None),
26
+ alita=tool['settings'].get('alita', None),
26
27
  connection_string=tool['settings'].get('connection_string', None),
27
28
  collection_name=str(tool['id']),
28
29
  doctype='code',
@@ -51,7 +51,9 @@ class AlitaGitHubAPIWrapper(BaseCodeToolApiWrapper):
51
51
 
52
52
  # Add LLM instance
53
53
  llm: Optional[Any] = None
54
-
54
+ # Alita instance
55
+ alita: Optional[Any] = None
56
+
55
57
  # Vector store configuration
56
58
  connection_string: Optional[SecretStr] = None
57
59
  collection_name: Optional[str] = None
@@ -109,7 +111,7 @@ class AlitaGitHubAPIWrapper(BaseCodeToolApiWrapper):
109
111
  )
110
112
 
111
113
  # Initialize GitHub client with keyword arguments
112
- github_client = GitHubClient(auth_config=auth_config, repo_config=repo_config)
114
+ github_client = GitHubClient(auth_config=auth_config, repo_config=repo_config, alita=values.get("alita"))
113
115
  # Initialize GraphQL client with keyword argument
114
116
  graphql_client = GraphQLClientWrapper(github_graphql_instance=github_client.github_api._Github__requester)
115
117
  # Set client attributes on the class (renamed from _github_client to github_client_instance)
@@ -34,10 +34,11 @@ from .schemas import (
34
34
  SearchIssues,
35
35
  CreateIssue,
36
36
  UpdateIssue,
37
- LoaderSchema,
38
37
  GetCommits,
39
38
  GetCommitChanges,
39
+ GetCommitsDiff,
40
40
  ApplyGitPatch,
41
+ ApplyGitPatchFromArtifact,
41
42
  TriggerWorkflow,
42
43
  GetWorkflowStatus,
43
44
  GetWorkflowLogs,
@@ -91,6 +92,9 @@ class GitHubClient(BaseModel):
91
92
  # Adding auth config and repo config as optional fields for initialization
92
93
  auth_config: Optional[GitHubAuthConfig] = Field(default=None, exclude=True)
93
94
  repo_config: Optional[GitHubRepoConfig] = Field(default=None, exclude=True)
95
+
96
+ # Alita instance
97
+ alita: Optional[Any] = Field(default=None, exclude=True)
94
98
 
95
99
  @model_validator(mode='before')
96
100
  def initialize_github_client(cls, values):
@@ -388,6 +392,111 @@ class GitHubClient(BaseModel):
388
392
  except Exception as e:
389
393
  # Return error as JSON instead of plain text
390
394
  return {"error": str(e), "message": f"Unable to retrieve commit changes due to error: {str(e)}"}
395
+
396
+ def get_commits_diff(self, base_sha: str, head_sha: str, repo_name: Optional[str] = None) -> str:
397
+ """
398
+ Retrieves the diff between two commits.
399
+
400
+ Parameters:
401
+ base_sha (str): The base commit SHA to compare from.
402
+ head_sha (str): The head commit SHA to compare to.
403
+ repo_name (Optional[str]): Name of the repository in format 'owner/repo'.
404
+
405
+ Returns:
406
+ str: A detailed diff comparison between the two commits or an error message.
407
+ """
408
+ try:
409
+ # Get the repository
410
+ repo = self.github_api.get_repo(repo_name) if repo_name else self.github_repo_instance
411
+
412
+ # Get the comparison between the two commits
413
+ comparison = repo.compare(base_sha, head_sha)
414
+
415
+ # Extract comparison information
416
+ diff_info = {
417
+ "base_commit": {
418
+ "sha": comparison.base_commit.sha,
419
+ "message": comparison.base_commit.commit.message,
420
+ "author": comparison.base_commit.commit.author.name,
421
+ "date": comparison.base_commit.commit.author.date.isoformat()
422
+ },
423
+ "head_commit": {
424
+ "sha": comparison.head_commit.sha,
425
+ "message": comparison.head_commit.commit.message,
426
+ "author": comparison.head_commit.commit.author.name,
427
+ "date": comparison.head_commit.commit.author.date.isoformat()
428
+ },
429
+ "status": comparison.status, # ahead, behind, identical, or diverged
430
+ "ahead_by": comparison.ahead_by,
431
+ "behind_by": comparison.behind_by,
432
+ "total_commits": comparison.total_commits,
433
+ "commits": [],
434
+ "files": []
435
+ }
436
+
437
+ # Get commits in the comparison
438
+ for commit in comparison.commits:
439
+ commit_info = {
440
+ "sha": commit.sha,
441
+ "message": commit.commit.message,
442
+ "author": commit.commit.author.name,
443
+ "date": commit.commit.author.date.isoformat(),
444
+ "url": commit.html_url
445
+ }
446
+ diff_info["commits"].append(commit_info)
447
+
448
+ # Get changed files information
449
+ for file in comparison.files:
450
+ file_info = {
451
+ "filename": file.filename,
452
+ "status": file.status, # added, modified, removed, renamed
453
+ "additions": file.additions,
454
+ "deletions": file.deletions,
455
+ "changes": file.changes,
456
+ "patch": file.patch if hasattr(file, 'patch') and file.patch else None,
457
+ "blob_url": file.blob_url if hasattr(file, 'blob_url') else None,
458
+ "raw_url": file.raw_url if hasattr(file, 'raw_url') else None
459
+ }
460
+
461
+ # Add previous filename for renamed files
462
+ if file.status == "renamed" and hasattr(file, 'previous_filename'):
463
+ file_info["previous_filename"] = file.previous_filename
464
+
465
+ diff_info["files"].append(file_info)
466
+
467
+ # Add summary statistics
468
+ diff_info["summary"] = {
469
+ "total_files_changed": len(diff_info["files"]),
470
+ "total_additions": sum(f["additions"] for f in diff_info["files"]),
471
+ "total_deletions": sum(f["deletions"] for f in diff_info["files"])
472
+ }
473
+
474
+ return diff_info
475
+
476
+ except Exception as e:
477
+ # Return error as JSON instead of plain text
478
+ return {"error": str(e), "message": f"Unable to retrieve diff between commits due to error: {str(e)}"}
479
+
480
+ def apply_git_patch_from_file(self, bucket_name: str, file_name: str, commit_message: Optional[str] = "Apply git patch", repo_name: Optional[str] = None) -> str:
481
+ """Applies a git patch from a file stored in a specified bucket.
482
+
483
+ Args:
484
+ bucket_name (str): The name of the bucket where the patch file is stored.
485
+ file_name (str): The name of the patch file to apply.
486
+ commit_message (Optional[str], optional): The commit message for the patch application. Defaults to "Apply git patch".
487
+ repo_name (Optional[str], optional): The name of the repository to apply the patch to. Defaults to None.
488
+
489
+ Returns:
490
+ str: A summary of the applied changes or an error message.
491
+ """
492
+ try:
493
+ patch_content = self.alita.download_artifact(bucket_name, file_name)
494
+ if not patch_content or not isinstance(patch_content, str):
495
+ return {"error": "Patch file not found", "message": f"Patch file '{file_name}' not found in bucket '{bucket_name}'."}
496
+ # Apply the git patch using the content
497
+ return self.apply_git_patch(patch_content, commit_message, repo_name)
498
+ except Exception as e:
499
+ return {"error": str(e), "message": f"Unable to download patch file: {str(e)}"}
391
500
 
392
501
  def apply_git_patch(self, patch_content: str, commit_message: Optional[str] = "Apply git patch", repo_name: Optional[str] = None) -> str:
393
502
  """
@@ -1902,6 +2011,13 @@ class GitHubClient(BaseModel):
1902
2011
  "description": self.get_commit_changes.__doc__,
1903
2012
  "args_schema": GetCommitChanges,
1904
2013
  },
2014
+ {
2015
+ "ref": self.get_commits_diff,
2016
+ "name": "get_commits_diff",
2017
+ "mode": "get_commits_diff",
2018
+ "description": self.get_commits_diff.__doc__,
2019
+ "args_schema": GetCommitsDiff,
2020
+ },
1905
2021
  {
1906
2022
  "ref": self.apply_git_patch,
1907
2023
  "name": "apply_git_patch",
@@ -1909,6 +2025,13 @@ class GitHubClient(BaseModel):
1909
2025
  "description": self.apply_git_patch.__doc__,
1910
2026
  "args_schema": ApplyGitPatch,
1911
2027
  },
2028
+ {
2029
+ "ref": self.apply_git_patch_from_file,
2030
+ "name": "apply_git_patch_from_file",
2031
+ "mode": "apply_git_patch_from_file",
2032
+ "description": self.apply_git_patch_from_file.__doc__,
2033
+ "args_schema": ApplyGitPatchFromArtifact,
2034
+ },
1912
2035
  {
1913
2036
  "ref": self.trigger_workflow,
1914
2037
  "name": "trigger_workflow",
@@ -159,6 +159,13 @@ GetCommitChanges = create_model(
159
159
  repo_name=(Optional[str], Field(default=None, description="Name of the repository (e.g., 'owner/repo'). If None, uses the default repository."))
160
160
  )
161
161
 
162
+ GetCommitsDiff = create_model(
163
+ "GetCommitsDiff",
164
+ base_sha=(str, Field(description="The base commit SHA to compare from")),
165
+ head_sha=(str, Field(description="The head commit SHA to compare to")),
166
+ repo_name=(Optional[str], Field(default=None, description="Name of the repository (e.g., 'owner/repo'). If None, uses the default repository."))
167
+ )
168
+
162
169
  ApplyGitPatch = create_model(
163
170
  "ApplyGitPatch",
164
171
  patch_content=(str, Field(description="The git patch content in unified diff format")),
@@ -166,6 +173,14 @@ ApplyGitPatch = create_model(
166
173
  repo_name=(Optional[str], Field(default=None, description="Name of the repository (e.g., 'owner/repo'). If None, uses the default repository."))
167
174
  )
168
175
 
176
+ ApplyGitPatchFromArtifact = create_model(
177
+ "ApplyGitPatchFromArtifact",
178
+ bucket_name=(str, Field(description="Name of the artifact bucket containing the patch file")),
179
+ file_name=(str, Field(description="Name of the patch file to download and apply")),
180
+ commit_message=(Optional[str], Field(description="Commit message for the patch application", default="Apply git patch from artifact")),
181
+ repo_name=(Optional[str], Field(default=None, description="Name of the repository (e.g., 'owner/repo'). If None, uses the default repository."))
182
+ )
183
+
169
184
  TriggerWorkflow = create_model(
170
185
  "TriggerWorkflow",
171
186
  workflow_id=(str, Field(description="The ID or file name of the workflow to trigger (e.g., 'build.yml', '1234567')")),
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: alita_sdk
3
- Version: 0.3.161
3
+ Version: 0.3.162
4
4
  Summary: SDK for building langchain agents using resources from Alita
5
5
  Author-email: Artem Rozumenko <artyom.rozumenko@gmail.com>, Mikalai Biazruchka <mikalai_biazruchka@epam.com>, Roman Mitusov <roman_mitusov@epam.com>, Ivan Krakhmaliuk <lifedjik@gmail.com>
6
6
  License-Expression: Apache-2.0
@@ -220,11 +220,11 @@ alita_sdk/tools/elastic/__init__.py,sha256=iwnSRppRpzvJ1da2K3Glu8Uu41MhBDCYbgubo
220
220
  alita_sdk/tools/elastic/api_wrapper.py,sha256=pl8CqQxteJAGwyOhMcld-ZgtOTFwwbv42OITQVe8rM0,1948
221
221
  alita_sdk/tools/figma/__init__.py,sha256=rtEebf9zj1zUD0bpkN-SupaYpjmHFM01gY8XZNE9TI0,4088
222
222
  alita_sdk/tools/figma/api_wrapper.py,sha256=G96pEp_qUOouwkM5xMqRg-Ywfx_kEey8NV8iO7YLodE,17190
223
- alita_sdk/tools/github/__init__.py,sha256=s-ejtyNXjQ3Wo-QhLMJkOSab-qY5ZJC6V_df0GuS3ro,6337
224
- alita_sdk/tools/github/api_wrapper.py,sha256=-98miPAF_JQMIEDT3g8KS6QJ7bHMUSlj4s38zXyFJ2M,8281
225
- alita_sdk/tools/github/github_client.py,sha256=bzVXim8U-QH6RzlkAzIUiTrhD4MDi3Xs4pKxVdghvhc,79465
223
+ alita_sdk/tools/github/__init__.py,sha256=YPpZPPhRUHWKJ9aaMJnkjl9xrnAij1YB9C2TMRnlaTI,6388
224
+ alita_sdk/tools/github/api_wrapper.py,sha256=qyIrwPg07TFsTB1l95soy1xsJIuxfKOWTWUdLZCmTA4,8365
225
+ alita_sdk/tools/github/github_client.py,sha256=YKhLDMq0VF1KM_Get2JKj-YsipwozeSX8xdcCaM4XvI,85395
226
226
  alita_sdk/tools/github/graphql_client_wrapper.py,sha256=d3AGjzLGH_hdQV2V8HeAX92dJ4dlnE5OXqUlCO_PBr0,71539
227
- alita_sdk/tools/github/schemas.py,sha256=6BAzeGaXkyS-rde2gJDi3xqic161de1PBh-CrlOgK_4,12826
227
+ alita_sdk/tools/github/schemas.py,sha256=9JfJ3nYdFeT30dOwZH6QZyZYMT8v8HrKq1jOv6Xn-Gs,13739
228
228
  alita_sdk/tools/github/tool.py,sha256=Jnnv5lenV5ds8AAdyo2m8hSzyJ117HZBjzHC6T1ck-M,1037
229
229
  alita_sdk/tools/github/tool_prompts.py,sha256=y6ZW_FpUCE87Uop3WuQAZVRnzxO5t7xjBOI5bCqiluw,30194
230
230
  alita_sdk/tools/gitlab/__init__.py,sha256=_nbp3tJviTZxfewyV3Hp9-TK1vCxTmqlxhpwv0f_x4Y,3602
@@ -317,8 +317,8 @@ alita_sdk/tools/zephyr_enterprise/api_wrapper.py,sha256=Ir3zHljhbZQJRJJQOBzS_GL5
317
317
  alita_sdk/tools/zephyr_enterprise/zephyr_enterprise.py,sha256=hV9LIrYfJT6oYp-ZfQR0YHflqBFPsUw2Oc55HwK0H48,6809
318
318
  alita_sdk/tools/zephyr_scale/__init__.py,sha256=2NTcdrfkx4GSegqyXhsPLsEpc4FlACuDy85b0fk6cAo,4572
319
319
  alita_sdk/tools/zephyr_scale/api_wrapper.py,sha256=UHVQUVqcBc3SZvDfO78HSuBzwAsRw2cCDQa-xMOzndE,68663
320
- alita_sdk-0.3.161.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
321
- alita_sdk-0.3.161.dist-info/METADATA,sha256=ybWYeKeLOJiQcnasyPl7i0jE6OTcqEmuVfmid62TT3A,18667
322
- alita_sdk-0.3.161.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
323
- alita_sdk-0.3.161.dist-info/top_level.txt,sha256=0vJYy5p_jK6AwVb1aqXr7Kgqgk3WDtQ6t5C-XI9zkmg,10
324
- alita_sdk-0.3.161.dist-info/RECORD,,
320
+ alita_sdk-0.3.162.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
321
+ alita_sdk-0.3.162.dist-info/METADATA,sha256=rOXYxNG9XRAmQ1BhPz2Fkb3CRmq-I_oaG3atjj67JBg,18667
322
+ alita_sdk-0.3.162.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
323
+ alita_sdk-0.3.162.dist-info/top_level.txt,sha256=0vJYy5p_jK6AwVb1aqXr7Kgqgk3WDtQ6t5C-XI9zkmg,10
324
+ alita_sdk-0.3.162.dist-info/RECORD,,