Skip to content

Commit 9f08238

Browse files
author
Jet Xu
committed
fix bugs for generate repo from pool by using Github_install_id
1 parent d1639eb commit 9f08238

File tree

5 files changed

+42
-16
lines changed

5 files changed

+42
-16
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8-
## [0.1.9] - 2024-10-31
8+
## [0.2.0] - 2024-11-16
9+
10+
### Optimized
11+
- fix bugs for generate repo from pool by using Github_install_id
12+
13+
## [0.1.9] - 2024-11-04
914

1015
### Optimized
1116
- fix bugs for get pr content

llama_github/data_retrieval/github_entities.py

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ def get_readme(self) -> str:
9898
@property
9999
def repo(self):
100100
return self.get_repo()
101+
102+
def set_github(self, github_instance: ExtendedGithub):
103+
self._github = github_instance
104+
with self._repo_lock: # Locking for write action
105+
self._repo = self._github.get_repo(self.full_name)
101106

102107
def get_repo(self):
103108
"""
@@ -118,8 +123,8 @@ def get_repo(self):
118123
self.default_branch = self._repo.default_branch
119124
self.updated_at = self._repo.updated_at
120125
except GithubException as e:
121-
logger.exception(
122-
f"Error retrieving repository '{self.full_name}':")
126+
logger.error(
127+
f"Error retrieving repository '{self.full_name}':{str(e)}")
123128
return None
124129
self.update_last_read_time()
125130
return self._repo
@@ -303,8 +308,8 @@ def extract_related_issues(self, pr_data: Dict[str, Any]) -> List[int]:
303308
# Full GitHub issue/PR URL pattern
304309
rf'(?:https?://)?github\.com/{re.escape(self.full_name)}/(?:issues|pull)/(\d+)',
305310

306-
# Standard #123 reference with proper boundaries
307-
r'(?:^|[^\w/])#(\d+)(?=[^\w/]|$)',
311+
# # Standard #123 reference with proper boundaries
312+
# r'(?:^|[^\w/])#(\d+)(?=[^\w/]|$)',
308313

309314
# Closing keywords (fixes #123)
310315
fr'(?:^|[^\w/])(?:{"|".join(closing_keywords)}):?\s+#(\d+)(?=[^\w/]|$)',
@@ -377,7 +382,7 @@ def to_isoformat(self, dt: datetime) -> Optional[str]:
377382
return dt.astimezone(timezone.utc).replace(microsecond=0).isoformat().replace('+00:00', 'Z')
378383
return None
379384

380-
def get_pr_content(self, number, pr=None, context_lines=10) -> Dict[str, Any]:
385+
def get_pr_content(self, number, pr=None, context_lines=10, force_update=False) -> Dict[str, Any]:
381386
"""
382387
Retrieves and processes the content of a pull request.
383388
@@ -386,9 +391,9 @@ def get_pr_content(self, number, pr=None, context_lines=10) -> Dict[str, Any]:
386391
:param context_lines: Number of context lines for diffs.
387392
:return: A dictionary containing detailed PR information.
388393
"""
389-
if number not in self._prs: # Check if issue has already been fetched
394+
if number not in self._prs or force_update: # Check if issue has already been fetched
390395
with self._pr_lock: # Locking for write action
391-
if number not in self._prs: # Check if issue has already been fetched after get lock
396+
if number not in self._prs or force_update: # Check if issue has already been fetched after get lock
392397
try:
393398
logger.debug(f"Processing PR #{number}")
394399
if pr is None:
@@ -691,13 +696,29 @@ def _get_repo_lock(self, full_name):
691696
self._locks_registry[full_name] = Lock()
692697
return self._locks_registry[full_name]
693698

694-
def get_repository(self, full_name, **kwargs) -> Repository:
695-
"""Retrieve a repository from the pool or create a new one if it doesn't exist."""
699+
def get_repository(self, full_name, github_instance=None, **kwargs) -> Repository:
700+
"""
701+
Retrieve a repository from the pool or create a new one if it doesn't exist.
702+
703+
If you are using github_install_id to generate a new repository object, you should pass new github_instance to the function.
704+
Otherwise the default github_instance within the pool might not fit to the new repository object.
705+
"""
706+
696707
if full_name in self._pool:
708+
# repo = self._pool[full_name]
709+
# repo.update_last_read_time()
710+
# if github_instance is not None:
711+
# repo.set_github(github_instance)
712+
# return repo
697713
return self._pool[full_name]
714+
698715
repo_lock = self._get_repo_lock(full_name)
699716
with repo_lock:
700717
if full_name not in self._pool:
701-
self._pool[full_name] = Repository(
702-
full_name, self.github_instance, **kwargs)
703-
return self._pool[full_name]
718+
if github_instance is not None:
719+
repo = Repository(full_name, github_instance, **kwargs)
720+
else:
721+
repo = Repository(full_name, self.github_instance, **kwargs)
722+
self._pool[full_name] = repo
723+
724+
return self._pool[full_name]

llama_github/llm_integration/initial_load.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def __init__(self,
6969
elif mistral_api_key is not None and mistral_api_key != "" and self.llm is None:
7070
logger.info("Initializing Mistral API...")
7171
self.llm = ChatMistralAI(mistral_api_key=mistral_api_key, model="mistral-large-latest")
72-
self.llm_simple = ChatMistralAI(mistral_api_key=mistral_api_key, model="open-mistral-nemo")
72+
self.llm_simple = ChatMistralAI(mistral_api_key=mistral_api_key, model="open-codestral-mamba")
7373
self.model_type = "OpenAI"
7474
elif openai_api_key is not None and openai_api_key != "" and self.llm is None:
7575
logger.info("Initializing OpenAI API...")

llama_github/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '0.1.9'
1+
__version__ = '0.2.0'

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = llama-github
3-
version = 0.1.9
3+
version = 0.2.0
44
author = Jet Xu
55
author_email = [email protected]
66
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.

0 commit comments

Comments
 (0)