llama-github 0.1.5__tar.gz → 0.1.7__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.
- {llama_github-0.1.5 → llama_github-0.1.7}/CHANGELOG.md +17 -0
- {llama_github-0.1.5/llama_github.egg-info → llama_github-0.1.7}/PKG-INFO +21 -2
- {llama_github-0.1.5 → llama_github-0.1.7}/llama_github/data_retrieval/github_entities.py +132 -20
- {llama_github-0.1.5 → llama_github-0.1.7}/llama_github/llm_integration/initial_load.py +78 -13
- llama_github-0.1.7/llama_github/version.py +1 -0
- {llama_github-0.1.5 → llama_github-0.1.7/llama_github.egg-info}/PKG-INFO +21 -2
- {llama_github-0.1.5 → llama_github-0.1.7}/llama_github.egg-info/requires.txt +3 -1
- {llama_github-0.1.5 → llama_github-0.1.7}/setup.cfg +1 -1
- llama_github-0.1.5/llama_github/version.py +0 -1
- {llama_github-0.1.5 → llama_github-0.1.7}/LICENSE +0 -0
- {llama_github-0.1.5 → llama_github-0.1.7}/MANIFEST.in +0 -0
- {llama_github-0.1.5 → llama_github-0.1.7}/README.md +0 -0
- {llama_github-0.1.5 → llama_github-0.1.7}/llama_github/__init__.py +0 -0
- {llama_github-0.1.5 → llama_github-0.1.7}/llama_github/config/__init__.py +0 -0
- {llama_github-0.1.5 → llama_github-0.1.7}/llama_github/config/config.json +0 -0
- {llama_github-0.1.5 → llama_github-0.1.7}/llama_github/config/config.py +0 -0
- {llama_github-0.1.5 → llama_github-0.1.7}/llama_github/data_retrieval/__init__.py +0 -0
- {llama_github-0.1.5 → llama_github-0.1.7}/llama_github/data_retrieval/github_api.py +0 -0
- {llama_github-0.1.5 → llama_github-0.1.7}/llama_github/features/__init__.py +0 -0
- {llama_github-0.1.5 → llama_github-0.1.7}/llama_github/features/feature_flags.py +0 -0
- {llama_github-0.1.5 → llama_github-0.1.7}/llama_github/features/insider_features.py +0 -0
- {llama_github-0.1.5 → llama_github-0.1.7}/llama_github/github_integration/__init__.py +0 -0
- {llama_github-0.1.5 → llama_github-0.1.7}/llama_github/github_integration/github_auth_manager.py +0 -0
- {llama_github-0.1.5 → llama_github-0.1.7}/llama_github/github_rag.py +0 -0
- {llama_github-0.1.5 → llama_github-0.1.7}/llama_github/llm_integration/__init__.py +0 -0
- {llama_github-0.1.5 → llama_github-0.1.7}/llama_github/llm_integration/llm_handler.py +0 -0
- {llama_github-0.1.5 → llama_github-0.1.7}/llama_github/logger.py +0 -0
- {llama_github-0.1.5 → llama_github-0.1.7}/llama_github/rag_processing/__init__.py +0 -0
- {llama_github-0.1.5 → llama_github-0.1.7}/llama_github/rag_processing/rag_processor.py +0 -0
- {llama_github-0.1.5 → llama_github-0.1.7}/llama_github/utils.py +0 -0
- {llama_github-0.1.5 → llama_github-0.1.7}/llama_github.egg-info/SOURCES.txt +0 -0
- {llama_github-0.1.5 → llama_github-0.1.7}/llama_github.egg-info/dependency_links.txt +0 -0
- {llama_github-0.1.5 → llama_github-0.1.7}/llama_github.egg-info/top_level.txt +0 -0
- {llama_github-0.1.5 → llama_github-0.1.7}/setup.py +0 -0
- {llama_github-0.1.5 → llama_github-0.1.7}/tests/test_data_retrieval.py +0 -0
- {llama_github-0.1.5 → llama_github-0.1.7}/tests/test_github_auth_manager.py +0 -0
- {llama_github-0.1.5 → llama_github-0.1.7}/tests/test_initial_load.py +0 -0
- {llama_github-0.1.5 → llama_github-0.1.7}/tests/test_llm_handler.py +0 -0
- {llama_github-0.1.5 → llama_github-0.1.7}/tests/test_logger.py +0 -0
- {llama_github-0.1.5 → llama_github-0.1.7}/tests/test_rag_processor.py +0 -0
|
@@ -5,6 +5,23 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.1.7] - 2024-10-31
|
|
9
|
+
|
|
10
|
+
### Optimized
|
|
11
|
+
- fix bugs for get pr content
|
|
12
|
+
|
|
13
|
+
## [0.1.6] - 2024-10-30
|
|
14
|
+
|
|
15
|
+
### New Features
|
|
16
|
+
- Enhanced PR content analysis with detailed commit information extraction
|
|
17
|
+
- Improved issue linking detection with support for multiple reference formats
|
|
18
|
+
- Full GitHub URLs, #references, and keyword-based references
|
|
19
|
+
- Added validation for issue numbers
|
|
20
|
+
|
|
21
|
+
### Improvements
|
|
22
|
+
- Added detailed commit metadata extraction including stats and file changes
|
|
23
|
+
- Enhanced error handling for commit fetching
|
|
24
|
+
|
|
8
25
|
## [0.1.5] - 2024-10-14
|
|
9
26
|
|
|
10
27
|
### Optimized
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: llama-github
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.7
|
|
4
4
|
Summary: Llama-github is an open-source Python library that empowers LLM Chatbots, AI Agents, and Auto-dev Agents to conduct Retrieval from actively selected GitHub public projects. It Augments through LLMs and Generates context for any coding question, in order to streamline the development of sophisticated AI-driven applications.
|
|
5
5
|
Home-page: https://github.com/JetXu-LLM/llama-github
|
|
6
6
|
Author: Jet Xu
|
|
@@ -19,9 +19,11 @@ Requires-Dist: langchain
|
|
|
19
19
|
Requires-Dist: numpy
|
|
20
20
|
Requires-Dist: pydantic
|
|
21
21
|
Requires-Dist: requests
|
|
22
|
-
Requires-Dist: torch
|
|
23
22
|
Requires-Dist: transformers
|
|
24
23
|
Requires-Dist: urllib3
|
|
24
|
+
Requires-Dist: sys
|
|
25
|
+
Requires-Dist: platform
|
|
26
|
+
Requires-Dist: subprocess
|
|
25
27
|
Requires-Dist: pydantic_core
|
|
26
28
|
Requires-Dist: langchain_openai
|
|
27
29
|
Requires-Dist: langchain_mistralai
|
|
@@ -138,6 +140,23 @@ All notable changes to this project will be documented in this file.
|
|
|
138
140
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
139
141
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
140
142
|
|
|
143
|
+
## [0.1.7] - 2024-10-31
|
|
144
|
+
|
|
145
|
+
### Optimized
|
|
146
|
+
- fix bugs for get pr content
|
|
147
|
+
|
|
148
|
+
## [0.1.6] - 2024-10-30
|
|
149
|
+
|
|
150
|
+
### New Features
|
|
151
|
+
- Enhanced PR content analysis with detailed commit information extraction
|
|
152
|
+
- Improved issue linking detection with support for multiple reference formats
|
|
153
|
+
- Full GitHub URLs, #references, and keyword-based references
|
|
154
|
+
- Added validation for issue numbers
|
|
155
|
+
|
|
156
|
+
### Improvements
|
|
157
|
+
- Added detailed commit metadata extraction including stats and file changes
|
|
158
|
+
- Enhanced error handling for commit fetching
|
|
159
|
+
|
|
141
160
|
## [0.1.5] - 2024-10-14
|
|
142
161
|
|
|
143
162
|
### Optimized
|
|
@@ -13,6 +13,7 @@ import json
|
|
|
13
13
|
from dateutil import parser
|
|
14
14
|
from datetime import timezone
|
|
15
15
|
import base64
|
|
16
|
+
import requests
|
|
16
17
|
|
|
17
18
|
from llama_github.utils import DiffGenerator, CodeAnalyzer
|
|
18
19
|
|
|
@@ -153,6 +154,16 @@ class Repository:
|
|
|
153
154
|
"""
|
|
154
155
|
file_key = f"{file_path}/{sha}" if sha is not None else file_path
|
|
155
156
|
|
|
157
|
+
# Skip binary and system files
|
|
158
|
+
if any(file_path.endswith(ext) for ext in [
|
|
159
|
+
'.exe', '.dll', '.so', '.dylib', '.bin',
|
|
160
|
+
'.png', '.jpg', '.jpeg', '.gif', '.ico',
|
|
161
|
+
'.mp3', '.mp4', '.avi', '.mov', '.pdf',
|
|
162
|
+
'.DS_Store'
|
|
163
|
+
]) or '/.' in file_path:
|
|
164
|
+
logger.debug(f"Skipping binary or system file: {file_path}")
|
|
165
|
+
return None
|
|
166
|
+
|
|
156
167
|
if file_key not in self._file_contents: # Check if file content has already been fetched
|
|
157
168
|
with self._file_contents_lock: # Locking for thread-safe write action
|
|
158
169
|
if file_key not in self._file_contents: # Double-check after acquiring the lock
|
|
@@ -162,9 +173,26 @@ class Repository:
|
|
|
162
173
|
else:
|
|
163
174
|
file_content = self.repo.get_contents(file_path)
|
|
164
175
|
|
|
176
|
+
# Handle directory case
|
|
177
|
+
if isinstance(file_content, list):
|
|
178
|
+
logger.debug(f"Path {file_path} is a directory")
|
|
179
|
+
return None
|
|
180
|
+
|
|
165
181
|
# Improved encoding handling
|
|
166
182
|
if file_content.encoding == 'base64':
|
|
167
183
|
decoded_content = base64.b64decode(file_content.content).decode('utf-8')
|
|
184
|
+
elif (file_content.encoding is None or file_content.encoding == 'none') and hasattr(file_content, 'download_url') and file_content.download_url:
|
|
185
|
+
try:
|
|
186
|
+
response = requests.get(
|
|
187
|
+
file_content.download_url,
|
|
188
|
+
timeout=30,
|
|
189
|
+
headers={'Accept': 'application/vnd.github.v3.raw'}
|
|
190
|
+
)
|
|
191
|
+
response.raise_for_status()
|
|
192
|
+
decoded_content = response.text
|
|
193
|
+
except requests.RequestException as e:
|
|
194
|
+
logger.error(f"Failed to download file {file_path}: {str(e)}")
|
|
195
|
+
return None
|
|
168
196
|
else:
|
|
169
197
|
decoded_content = file_content.decoded_content.decode('utf-8')
|
|
170
198
|
|
|
@@ -180,7 +208,8 @@ class Repository:
|
|
|
180
208
|
|
|
181
209
|
self.update_last_read_time()
|
|
182
210
|
return self._file_contents.get(file_key)
|
|
183
|
-
|
|
211
|
+
|
|
212
|
+
|
|
184
213
|
def get_issue_content(self, number, issue=None) -> str:
|
|
185
214
|
"""
|
|
186
215
|
Retrieves the content of a issue using a singleton design pattern.
|
|
@@ -200,8 +229,8 @@ class Repository:
|
|
|
200
229
|
"\nComment amount: " + \
|
|
201
230
|
str(comments_amount) + \
|
|
202
231
|
"\nIssue body:\n" + \
|
|
203
|
-
re.sub(r'\n+\s*\n+', '\n',
|
|
204
|
-
|
|
232
|
+
(re.sub(r'\n+\s*\n+', '\n',
|
|
233
|
+
(issue.body or "").replace('\r', '\n').strip()) if issue.body else "No issue body provided")
|
|
205
234
|
else:
|
|
206
235
|
comments_amount = issue['comments']
|
|
207
236
|
body_content = "This is a Github Issue related to repo \"" + (self.full_name or "") + "\". Repo description:" + (self.description or "") +\
|
|
@@ -236,30 +265,87 @@ class Repository:
|
|
|
236
265
|
logger.exception(
|
|
237
266
|
f"Error getting issue content for {number} in repository {self.full_name}:")
|
|
238
267
|
return None
|
|
268
|
+
except Exception as e:
|
|
269
|
+
logger.error(f"Unexpected error processing : {str(e)}")
|
|
270
|
+
return None
|
|
239
271
|
self.update_last_read_time()
|
|
240
272
|
return self._issues[number]
|
|
241
273
|
|
|
242
274
|
def extract_related_issues(self, pr_data: Dict[str, Any]) -> List[int]:
|
|
243
275
|
"""
|
|
244
|
-
Extracts related issue numbers from
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
276
|
+
Extracts related issue numbers from all PR data following GitHub's reference syntax.
|
|
277
|
+
|
|
278
|
+
This function implements GitHub's official autolink reference formats to find:
|
|
279
|
+
1. Full GitHub issue/PR URLs
|
|
280
|
+
2. Numeric references (#123)
|
|
281
|
+
3. Keywords + issue references (fixes #123)
|
|
282
|
+
4. Repository cross-references (owner/repo#123)
|
|
283
|
+
|
|
284
|
+
See: https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/autolinked-references-and-urls
|
|
285
|
+
|
|
286
|
+
Args:
|
|
287
|
+
pr_data: Dict[str, Any] - The complete pull request data dictionary
|
|
288
|
+
|
|
289
|
+
Returns:
|
|
290
|
+
List[int] - A sorted list of unique issue numbers found in the PR data
|
|
248
291
|
"""
|
|
292
|
+
# GitHub's official closing keywords
|
|
293
|
+
closing_keywords = (
|
|
294
|
+
'close', 'closes', 'closed',
|
|
295
|
+
'fix', 'fixes', 'fixed',
|
|
296
|
+
'resolve', 'resolves', 'resolved'
|
|
297
|
+
)
|
|
298
|
+
|
|
299
|
+
# Regex patterns for GitHub issue references
|
|
249
300
|
patterns = [
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
301
|
+
# Full GitHub issue/PR URL pattern
|
|
302
|
+
rf'(?:https?://)?github\.com/{re.escape(self.full_name)}/(?:issues|pull)/(\d+)',
|
|
303
|
+
|
|
304
|
+
# Standard #123 reference with proper boundaries
|
|
305
|
+
r'(?:^|[^\w/])#(\d+)(?=[^\w/]|$)',
|
|
306
|
+
|
|
307
|
+
# Closing keywords (fixes #123)
|
|
308
|
+
fr'(?:^|[^\w/])(?:{"|".join(closing_keywords)}):?\s+#(\d+)(?=[^\w/]|$)',
|
|
309
|
+
|
|
310
|
+
# Cross-repo reference (owner/repo#123)
|
|
311
|
+
rf'{re.escape(self.full_name)}#(\d+)',
|
|
312
|
+
|
|
313
|
+
# Issue keyword reference (issue #123 or issue: #123)
|
|
314
|
+
r'(?:^|[^\w/])(?:issue|bug|ticket|todo|task)s?:?\s+#?(\d+)(?=[^\w/]|$)'
|
|
253
315
|
]
|
|
316
|
+
|
|
254
317
|
issues = set()
|
|
255
|
-
# Convert PR data to JSON string for pattern matching
|
|
256
|
-
pr_description = json.dumps(pr_data, default=str)
|
|
257
318
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
319
|
+
def extract_from_text(text: str) -> None:
|
|
320
|
+
"""Helper function to extract issue numbers from text"""
|
|
321
|
+
if not isinstance(text, str):
|
|
322
|
+
return
|
|
323
|
+
|
|
324
|
+
for pattern in patterns:
|
|
325
|
+
matches = re.findall(pattern, text, re.IGNORECASE | re.MULTILINE)
|
|
326
|
+
# Validate issue numbers (reasonable length and positive values)
|
|
327
|
+
valid_matches = [
|
|
328
|
+
int(match) for match in matches
|
|
329
|
+
if match.isdigit() and len(match) <= 7 and int(match) > 0
|
|
330
|
+
]
|
|
331
|
+
issues.update(valid_matches)
|
|
332
|
+
|
|
333
|
+
def process_value(value: Any) -> None:
|
|
334
|
+
"""Recursively process dictionary values and extract issue numbers"""
|
|
335
|
+
if isinstance(value, dict):
|
|
336
|
+
for v in value.values():
|
|
337
|
+
process_value(v)
|
|
338
|
+
elif isinstance(value, (list, tuple)):
|
|
339
|
+
for item in value:
|
|
340
|
+
process_value(item)
|
|
341
|
+
elif isinstance(value, str):
|
|
342
|
+
extract_from_text(value)
|
|
343
|
+
|
|
344
|
+
# Process all data in pr_data recursively
|
|
345
|
+
process_value(pr_data)
|
|
261
346
|
|
|
262
|
-
return list(issues)
|
|
347
|
+
return sorted(list(issues))
|
|
348
|
+
|
|
263
349
|
|
|
264
350
|
def get_issue_contents(self, issue_numbers: List[int], pr_number: int) -> List[Dict[str, Any]]:
|
|
265
351
|
"""
|
|
@@ -324,11 +410,16 @@ class Repository:
|
|
|
324
410
|
"head_branch": pr.head.ref,
|
|
325
411
|
},
|
|
326
412
|
"related_issues": [],
|
|
413
|
+
"commits": [],
|
|
327
414
|
"file_changes": [],
|
|
328
415
|
"ci_cd_results": [],
|
|
329
416
|
"interactions": []
|
|
330
417
|
}
|
|
331
418
|
|
|
419
|
+
# Extract related issues from PR description and comments
|
|
420
|
+
related_issues = self.extract_related_issues(pr_data)
|
|
421
|
+
pr_data['related_issues'] = self.get_issue_contents(related_issues, pr.number)
|
|
422
|
+
|
|
332
423
|
# Fetch CI/CD results
|
|
333
424
|
try:
|
|
334
425
|
last_commit = pr.get_commits().reversed[0]
|
|
@@ -412,9 +503,27 @@ class Repository:
|
|
|
412
503
|
pr_interactions.sort(key=lambda x: parser.isoparse(x["created_at"]))
|
|
413
504
|
pr_data["interactions"] = pr_interactions
|
|
414
505
|
|
|
415
|
-
#
|
|
416
|
-
|
|
417
|
-
|
|
506
|
+
# Fetch and process commits
|
|
507
|
+
try:
|
|
508
|
+
commits = pr.get_commits()
|
|
509
|
+
for commit in commits:
|
|
510
|
+
commit_data = {
|
|
511
|
+
"sha": commit.sha,
|
|
512
|
+
"message": commit.commit.message,
|
|
513
|
+
"author": commit.commit.author.name,
|
|
514
|
+
"date": self.to_isoformat(commit.commit.author.date),
|
|
515
|
+
"stats": {
|
|
516
|
+
"additions": commit.stats.additions,
|
|
517
|
+
"deletions": commit.stats.deletions,
|
|
518
|
+
"total": commit.stats.total
|
|
519
|
+
},
|
|
520
|
+
"files": [f.filename for f in commit.files] # Just keep changed file names
|
|
521
|
+
}
|
|
522
|
+
pr_data["commits"].append(commit_data)
|
|
523
|
+
except GithubException as e:
|
|
524
|
+
logger.exception(f"Error fetching commits for PR #{number}")
|
|
525
|
+
pr_data["commits"] = []
|
|
526
|
+
pr_data["commit_stats"] = {}
|
|
418
527
|
|
|
419
528
|
# Process file changes
|
|
420
529
|
dependency_files = ['requirements.txt', 'Pipfile', 'Pipfile.lock', 'setup.py']
|
|
@@ -439,7 +548,10 @@ class Repository:
|
|
|
439
548
|
head_content = self.get_file_content(file_path=file_path, sha=pr.head.sha)
|
|
440
549
|
|
|
441
550
|
# Generate custom diff with specified context lines
|
|
442
|
-
|
|
551
|
+
if base_content is None and head_content is None:
|
|
552
|
+
custom_diff = ''
|
|
553
|
+
else:
|
|
554
|
+
custom_diff = DiffGenerator.generate_custom_diff(base_content, head_content, context_lines)
|
|
443
555
|
|
|
444
556
|
# Categorize code changes
|
|
445
557
|
change_categories = CodeAnalyzer.categorize_change(custom_diff)
|
|
@@ -8,6 +8,11 @@ from llama_github.config.config import config
|
|
|
8
8
|
from llama_github.logger import logger
|
|
9
9
|
|
|
10
10
|
class LLMManager:
|
|
11
|
+
"""
|
|
12
|
+
Singleton class for managing Language Models and related components.
|
|
13
|
+
This class handles initialization and access to various models including LLMs,
|
|
14
|
+
embedding models, and reranking models.
|
|
15
|
+
"""
|
|
11
16
|
_instance_lock = Lock()
|
|
12
17
|
_instance = None
|
|
13
18
|
llm = None
|
|
@@ -18,6 +23,9 @@ class LLMManager:
|
|
|
18
23
|
embedding_model = None
|
|
19
24
|
|
|
20
25
|
def __new__(cls, *args, **kwargs):
|
|
26
|
+
"""
|
|
27
|
+
Ensure only one instance of LLMManager is created (Singleton pattern).
|
|
28
|
+
"""
|
|
21
29
|
if cls._instance is None: # First check (unlocked)
|
|
22
30
|
with cls._instance_lock: # Acquire lock
|
|
23
31
|
if cls._instance is None: # Second check (locked)
|
|
@@ -34,6 +42,19 @@ class LLMManager:
|
|
|
34
42
|
rerank_model: Optional[str] = config.get("default_reranker"),
|
|
35
43
|
llm: Any = None,
|
|
36
44
|
simple_mode: bool = False):
|
|
45
|
+
"""
|
|
46
|
+
Initialize the LLMManager with specified models and API keys.
|
|
47
|
+
|
|
48
|
+
Args:
|
|
49
|
+
openai_api_key (Optional[str]): API key for OpenAI.
|
|
50
|
+
mistral_api_key (Optional[str]): API key for Mistral AI.
|
|
51
|
+
huggingface_token (Optional[str]): Token for Hugging Face.
|
|
52
|
+
open_source_models_hg_dir (Optional[str]): Directory for open-source models.
|
|
53
|
+
embedding_model (Optional[str]): Name or path of the embedding model.
|
|
54
|
+
rerank_model (Optional[str]): Name or path of the reranking model.
|
|
55
|
+
llm (Any): Custom LLM instance if provided.
|
|
56
|
+
simple_mode (bool): If True, skip initialization of embedding and reranking models.
|
|
57
|
+
"""
|
|
37
58
|
with self._instance_lock: # Prevent re-initialization
|
|
38
59
|
if self._initialized:
|
|
39
60
|
return
|
|
@@ -41,7 +62,7 @@ class LLMManager:
|
|
|
41
62
|
|
|
42
63
|
self.simple_mode = simple_mode
|
|
43
64
|
|
|
44
|
-
# Initialize
|
|
65
|
+
# Initialize LLM based on provided API keys or custom LLM
|
|
45
66
|
if llm is not None:
|
|
46
67
|
self.llm = llm
|
|
47
68
|
self.model_type = "Custom_langchain_llm"
|
|
@@ -59,33 +80,47 @@ class LLMManager:
|
|
|
59
80
|
# Initialize for Open Source Models
|
|
60
81
|
elif open_source_models_hg_dir is not None and open_source_models_hg_dir != "" and self.llm is None:
|
|
61
82
|
logger.info(f"Initializing {open_source_models_hg_dir}...")
|
|
62
|
-
# load
|
|
83
|
+
# load huggingface models
|
|
63
84
|
self.model_type = "Hubgingface"
|
|
64
85
|
elif self.llm is None:
|
|
65
86
|
# default model is phi3_mini_128k
|
|
66
87
|
self.model_type = "Hubgingface"
|
|
67
88
|
|
|
68
89
|
if not self.simple_mode:
|
|
69
|
-
import
|
|
90
|
+
import sys
|
|
91
|
+
import platform
|
|
92
|
+
import subprocess
|
|
93
|
+
|
|
94
|
+
def get_device():
|
|
95
|
+
if sys.platform.startswith('darwin'): # macOS
|
|
96
|
+
# Check for Apple Silicon (M1/M2)
|
|
97
|
+
if platform.machine() == 'arm64':
|
|
98
|
+
return 'mps'
|
|
99
|
+
elif sys.platform.startswith('linux') or sys.platform.startswith('win'):
|
|
100
|
+
# Check for NVIDIA GPU
|
|
101
|
+
try:
|
|
102
|
+
subprocess.run(['nvidia-smi'], check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
|
103
|
+
return 'cuda'
|
|
104
|
+
except (subprocess.CalledProcessError, FileNotFoundError):
|
|
105
|
+
pass
|
|
106
|
+
|
|
107
|
+
# Default to CPU
|
|
108
|
+
return 'cpu'
|
|
109
|
+
|
|
110
|
+
# Usage
|
|
111
|
+
self.device = get_device()
|
|
112
|
+
|
|
70
113
|
from transformers import AutoModel
|
|
71
114
|
from transformers import AutoModelForSequenceClassification
|
|
72
115
|
from transformers import AutoTokenizer
|
|
73
|
-
#
|
|
74
|
-
if torch.cuda.is_available():
|
|
75
|
-
self.device = torch.device('cuda')
|
|
76
|
-
elif torch.backends.mps.is_available():
|
|
77
|
-
self.device = torch.device('mps')
|
|
78
|
-
else:
|
|
79
|
-
self.device = torch.device('cpu')
|
|
80
|
-
|
|
81
|
-
# initial embedding_model
|
|
116
|
+
# Initialize embedding model
|
|
82
117
|
if self.tokenizer is None:
|
|
83
118
|
logger.info(f"Initializing {embedding_model}...")
|
|
84
119
|
self.tokenizer = AutoTokenizer.from_pretrained(embedding_model)
|
|
85
120
|
self.embedding_model = AutoModel.from_pretrained(
|
|
86
121
|
embedding_model, trust_remote_code=True).to(self.device)
|
|
87
122
|
|
|
88
|
-
#
|
|
123
|
+
# Initialize reranking model
|
|
89
124
|
if self.rerank_model is None:
|
|
90
125
|
logger.info(f"Initializing {rerank_model}...")
|
|
91
126
|
self.rerank_model = AutoModelForSequenceClassification.from_pretrained(
|
|
@@ -95,16 +130,46 @@ class LLMManager:
|
|
|
95
130
|
logger.info("Simple mode enabled. Skipping embedding and rerank model initialization.")
|
|
96
131
|
|
|
97
132
|
def get_llm(self):
|
|
133
|
+
"""
|
|
134
|
+
Get the main Language Model.
|
|
135
|
+
|
|
136
|
+
Returns:
|
|
137
|
+
The initialized Language Model.
|
|
138
|
+
"""
|
|
98
139
|
return self.llm
|
|
99
140
|
|
|
100
141
|
def get_llm_simple(self):
|
|
142
|
+
"""
|
|
143
|
+
Get the simplified Language Model.
|
|
144
|
+
|
|
145
|
+
Returns:
|
|
146
|
+
The initialized simplified Language Model.
|
|
147
|
+
"""
|
|
101
148
|
return self.llm_simple
|
|
102
149
|
|
|
103
150
|
def get_tokenizer(self):
|
|
151
|
+
"""
|
|
152
|
+
Get the tokenizer for the embedding model.
|
|
153
|
+
|
|
154
|
+
Returns:
|
|
155
|
+
The initialized tokenizer.
|
|
156
|
+
"""
|
|
104
157
|
return self.tokenizer
|
|
105
158
|
|
|
106
159
|
def get_rerank_model(self):
|
|
160
|
+
"""
|
|
161
|
+
Get the reranking model.
|
|
162
|
+
|
|
163
|
+
Returns:
|
|
164
|
+
The initialized reranking model.
|
|
165
|
+
"""
|
|
107
166
|
return self.rerank_model
|
|
108
167
|
|
|
109
168
|
def get_embedding_model(self):
|
|
169
|
+
"""
|
|
170
|
+
Get the embedding model.
|
|
171
|
+
|
|
172
|
+
Returns:
|
|
173
|
+
The initialized embedding model.
|
|
174
|
+
"""
|
|
110
175
|
return self.embedding_model
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = '0.1.7'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: llama-github
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.7
|
|
4
4
|
Summary: Llama-github is an open-source Python library that empowers LLM Chatbots, AI Agents, and Auto-dev Agents to conduct Retrieval from actively selected GitHub public projects. It Augments through LLMs and Generates context for any coding question, in order to streamline the development of sophisticated AI-driven applications.
|
|
5
5
|
Home-page: https://github.com/JetXu-LLM/llama-github
|
|
6
6
|
Author: Jet Xu
|
|
@@ -19,9 +19,11 @@ Requires-Dist: langchain
|
|
|
19
19
|
Requires-Dist: numpy
|
|
20
20
|
Requires-Dist: pydantic
|
|
21
21
|
Requires-Dist: requests
|
|
22
|
-
Requires-Dist: torch
|
|
23
22
|
Requires-Dist: transformers
|
|
24
23
|
Requires-Dist: urllib3
|
|
24
|
+
Requires-Dist: sys
|
|
25
|
+
Requires-Dist: platform
|
|
26
|
+
Requires-Dist: subprocess
|
|
25
27
|
Requires-Dist: pydantic_core
|
|
26
28
|
Requires-Dist: langchain_openai
|
|
27
29
|
Requires-Dist: langchain_mistralai
|
|
@@ -138,6 +140,23 @@ All notable changes to this project will be documented in this file.
|
|
|
138
140
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
139
141
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
140
142
|
|
|
143
|
+
## [0.1.7] - 2024-10-31
|
|
144
|
+
|
|
145
|
+
### Optimized
|
|
146
|
+
- fix bugs for get pr content
|
|
147
|
+
|
|
148
|
+
## [0.1.6] - 2024-10-30
|
|
149
|
+
|
|
150
|
+
### New Features
|
|
151
|
+
- Enhanced PR content analysis with detailed commit information extraction
|
|
152
|
+
- Improved issue linking detection with support for multiple reference formats
|
|
153
|
+
- Full GitHub URLs, #references, and keyword-based references
|
|
154
|
+
- Added validation for issue numbers
|
|
155
|
+
|
|
156
|
+
### Improvements
|
|
157
|
+
- Added detailed commit metadata extraction including stats and file changes
|
|
158
|
+
- Enhanced error handling for commit fetching
|
|
159
|
+
|
|
141
160
|
## [0.1.5] - 2024-10-14
|
|
142
161
|
|
|
143
162
|
### Optimized
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[metadata]
|
|
2
2
|
name = llama-github
|
|
3
|
-
version = 0.1.
|
|
3
|
+
version = 0.1.7
|
|
4
4
|
author = Jet Xu
|
|
5
5
|
author_email = Voldemort.xu@foxmail.com
|
|
6
6
|
description = Llama-github is an open-source Python library that empowers LLM Chatbots, AI Agents, and Auto-dev Agents to conduct Retrieval from actively selected GitHub public projects. It Augments through LLMs and Generates context for any coding question, in order to streamline the development of sophisticated AI-driven applications.
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = '0.1.5'
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{llama_github-0.1.5 → llama_github-0.1.7}/llama_github/github_integration/github_auth_manager.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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|