llama-github 0.1.2__tar.gz → 0.1.3__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.
Files changed (40) hide show
  1. {llama_github-0.1.2 → llama_github-0.1.3}/CHANGELOG.md +16 -0
  2. {llama_github-0.1.2/llama_github.egg-info → llama_github-0.1.3}/PKG-INFO +17 -1
  3. {llama_github-0.1.2 → llama_github-0.1.3}/llama_github/github_rag.py +23 -9
  4. {llama_github-0.1.2 → llama_github-0.1.3}/llama_github/llm_integration/initial_load.py +29 -23
  5. llama_github-0.1.3/llama_github/version.py +1 -0
  6. {llama_github-0.1.2 → llama_github-0.1.3/llama_github.egg-info}/PKG-INFO +17 -1
  7. {llama_github-0.1.2 → llama_github-0.1.3}/setup.cfg +1 -1
  8. llama_github-0.1.2/llama_github/version.py +0 -1
  9. {llama_github-0.1.2 → llama_github-0.1.3}/LICENSE +0 -0
  10. {llama_github-0.1.2 → llama_github-0.1.3}/MANIFEST.in +0 -0
  11. {llama_github-0.1.2 → llama_github-0.1.3}/README.md +0 -0
  12. {llama_github-0.1.2 → llama_github-0.1.3}/llama_github/__init__.py +0 -0
  13. {llama_github-0.1.2 → llama_github-0.1.3}/llama_github/config/__init__.py +0 -0
  14. {llama_github-0.1.2 → llama_github-0.1.3}/llama_github/config/config.json +0 -0
  15. {llama_github-0.1.2 → llama_github-0.1.3}/llama_github/config/config.py +0 -0
  16. {llama_github-0.1.2 → llama_github-0.1.3}/llama_github/data_retrieval/__init__.py +0 -0
  17. {llama_github-0.1.2 → llama_github-0.1.3}/llama_github/data_retrieval/github_api.py +0 -0
  18. {llama_github-0.1.2 → llama_github-0.1.3}/llama_github/data_retrieval/github_entities.py +0 -0
  19. {llama_github-0.1.2 → llama_github-0.1.3}/llama_github/features/__init__.py +0 -0
  20. {llama_github-0.1.2 → llama_github-0.1.3}/llama_github/features/feature_flags.py +0 -0
  21. {llama_github-0.1.2 → llama_github-0.1.3}/llama_github/features/insider_features.py +0 -0
  22. {llama_github-0.1.2 → llama_github-0.1.3}/llama_github/github_integration/__init__.py +0 -0
  23. {llama_github-0.1.2 → llama_github-0.1.3}/llama_github/github_integration/github_auth_manager.py +0 -0
  24. {llama_github-0.1.2 → llama_github-0.1.3}/llama_github/llm_integration/__init__.py +0 -0
  25. {llama_github-0.1.2 → llama_github-0.1.3}/llama_github/llm_integration/llm_handler.py +0 -0
  26. {llama_github-0.1.2 → llama_github-0.1.3}/llama_github/logger.py +0 -0
  27. {llama_github-0.1.2 → llama_github-0.1.3}/llama_github/rag_processing/__init__.py +0 -0
  28. {llama_github-0.1.2 → llama_github-0.1.3}/llama_github/rag_processing/rag_processor.py +0 -0
  29. {llama_github-0.1.2 → llama_github-0.1.3}/llama_github/utils.py +0 -0
  30. {llama_github-0.1.2 → llama_github-0.1.3}/llama_github.egg-info/SOURCES.txt +0 -0
  31. {llama_github-0.1.2 → llama_github-0.1.3}/llama_github.egg-info/dependency_links.txt +0 -0
  32. {llama_github-0.1.2 → llama_github-0.1.3}/llama_github.egg-info/requires.txt +0 -0
  33. {llama_github-0.1.2 → llama_github-0.1.3}/llama_github.egg-info/top_level.txt +0 -0
  34. {llama_github-0.1.2 → llama_github-0.1.3}/setup.py +0 -0
  35. {llama_github-0.1.2 → llama_github-0.1.3}/tests/test_data_retrieval.py +0 -0
  36. {llama_github-0.1.2 → llama_github-0.1.3}/tests/test_github_auth_manager.py +0 -0
  37. {llama_github-0.1.2 → llama_github-0.1.3}/tests/test_initial_load.py +0 -0
  38. {llama_github-0.1.2 → llama_github-0.1.3}/tests/test_llm_handler.py +0 -0
  39. {llama_github-0.1.2 → llama_github-0.1.3}/tests/test_logger.py +0 -0
  40. {llama_github-0.1.2 → llama_github-0.1.3}/tests/test_rag_processor.py +0 -0
@@ -5,6 +5,20 @@ 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.3] - 2024-10-14
9
+
10
+ ### Added
11
+ - Modified `LLMManager` class to skip loading embedding and reranker models when `simple_mode` is enabled
12
+ - Updated `retrieve_context` method to use instance's `simple_mode` by default, with option to override
13
+
14
+ ### Improved
15
+ - Faster initialization process when `simple_mode` is enabled, skipping embedding and reranker model loading
16
+ - More flexible usage of `simple_mode` in `retrieve_context`, allowing per-call customization
17
+
18
+ ### Developer Notes
19
+ - When using `simple_mode=True` during GithubRAG initialization, be aware that embedding and reranking functionalities will not be available
20
+ - The `retrieve_context` method now uses a late binding approach for `simple_mode` parameter
21
+
8
22
  ## [0.1.2] - 2024-10-09
9
23
 
10
24
  ### Added
@@ -49,5 +63,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
49
63
  - Basic functionality for retrieving context from GitHub repositories
50
64
  - Integration with LLM for processing and generating responses
51
65
 
66
+ [0.1.3]: https://github.com/JetXu-LLM/llama-github/compare/v0.1.2...v0.1.3
67
+ [0.1.2]: https://github.com/JetXu-LLM/llama-github/compare/v0.1.1...v0.1.2
52
68
  [0.1.1]: https://github.com/JetXu-LLM/llama-github/compare/v0.1.0...v0.1.1
53
69
  [0.1.0]: https://github.com/JetXu-LLM/llama-github/releases/tag/v0.1.0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: llama-github
3
- Version: 0.1.2
3
+ Version: 0.1.3
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
@@ -133,6 +133,20 @@ All notable changes to this project will be documented in this file.
133
133
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
134
134
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
135
135
 
136
+ ## [0.1.3] - 2024-10-14
137
+
138
+ ### Added
139
+ - Modified `LLMManager` class to skip loading embedding and reranker models when `simple_mode` is enabled
140
+ - Updated `retrieve_context` method to use instance's `simple_mode` by default, with option to override
141
+
142
+ ### Improved
143
+ - Faster initialization process when `simple_mode` is enabled, skipping embedding and reranker model loading
144
+ - More flexible usage of `simple_mode` in `retrieve_context`, allowing per-call customization
145
+
146
+ ### Developer Notes
147
+ - When using `simple_mode=True` during GithubRAG initialization, be aware that embedding and reranking functionalities will not be available
148
+ - The `retrieve_context` method now uses a late binding approach for `simple_mode` parameter
149
+
136
150
  ## [0.1.2] - 2024-10-09
137
151
 
138
152
  ### Added
@@ -177,5 +191,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
177
191
  - Basic functionality for retrieving context from GitHub repositories
178
192
  - Integration with LLM for processing and generating responses
179
193
 
194
+ [0.1.3]: https://github.com/JetXu-LLM/llama-github/compare/v0.1.2...v0.1.3
195
+ [0.1.2]: https://github.com/JetXu-LLM/llama-github/compare/v0.1.1...v0.1.2
180
196
  [0.1.1]: https://github.com/JetXu-LLM/llama-github/compare/v0.1.0...v0.1.1
181
197
  [0.1.0]: https://github.com/JetXu-LLM/llama-github/releases/tag/v0.1.0
@@ -27,8 +27,10 @@ class GitHubAppCredentials:
27
27
 
28
28
  class GithubRAG:
29
29
  rag_processor: RAGProcessor = None
30
+ simple_mode: bool = False
30
31
 
31
- def __init__(self, github_access_token: Optional[str] = None,
32
+ def __init__(self,
33
+ github_access_token: Optional[str] = None,
32
34
  github_app_credentials: Optional[GitHubAppCredentials] = None,
33
35
  openai_api_key: Optional[str] = None,
34
36
  mistral_api_key: Optional[str] = None,
@@ -39,6 +41,7 @@ class GithubRAG:
39
41
  "default_embedding"),
40
42
  rerank_model: Optional[str] = config.get("default_reranker"),
41
43
  llm: Any = None,
44
+ simple_mode: bool = False,
42
45
  **kwargs) -> None:
43
46
  """
44
47
  Initialize the GithubRAG with the provided credentials and configuration.
@@ -47,12 +50,14 @@ class GithubRAG:
47
50
  - github_access_token (Optional[str]): GitHub access token for authentication.
48
51
  - github_app_credentials (Optional[GitHubAppCredentials]): Credentials for GitHub App authentication.
49
52
  - openai_api_key (Optional[str]): API key for OpenAI services -- recommend to use, GPT-4-turbo will be used.
53
+ - mistral_api_key (Optional[str]): API key for Mistral AI services.
50
54
  - huggingface_token (Optional[str]): Token for Hugging Face services -- recommend to fill.
51
55
  - jina_api_key (Optional[str]): API key for Jina AI services -- s.jina.ai API will be used
52
56
  - open_source_models_hg_dir (Optional[str]): Name of open-source models from Hugging Face to replace OpenAI.
53
57
  - embedding_model (Optional[str]): Name of Embedding model from Hugging Face, if you have preferred embedding model to be used.
54
58
  - rerank_model (Optional[str]): Name of Rerank model from Hugging Face, if you have preferred rerank model to be used.
55
59
  - llm (Any): Any kind of LangChain llm chat object - to replace OpenAI or open-source models from Hugging Face.
60
+ - simple_mode (bool): If True, skip embedding and rerank model initialization in LLMManager.
56
61
  - **kwargs:
57
62
  :param repo_cleanup_interval (Optional[int]): How often to run repo cleanup in seconds within RepositoryPool.
58
63
  :param repo_max_idle_time (Optional[int]): Keep a repo in cache until max idle time if not used.
@@ -64,6 +69,8 @@ class GithubRAG:
64
69
  logger.info("Initializing GithubRAG...")
65
70
  logger.debug("Initializing Github Instance...")
66
71
 
72
+ self.simple_mode = simple_mode
73
+
67
74
  self.auth_manager = GitHubAuthManager()
68
75
  if github_access_token:
69
76
  self.github_instance = self.auth_manager.authenticate_with_token(
@@ -92,22 +99,26 @@ class GithubRAG:
92
99
  logger.debug(
93
100
  "Initializing llm manager, embedding model & reranker model...")
94
101
  self.llm_manager = LLMManager(
95
- openai_api_key, mistral_api_key, huggingface_token, open_source_models_hg_dir, embedding_model, rerank_model, llm)
102
+ openai_api_key, mistral_api_key, huggingface_token, open_source_models_hg_dir, embedding_model, rerank_model, llm, simple_mode=self.simple_mode)
96
103
  logger.debug(
97
104
  "LLM Manager, Embedding model & Reranker model Initialized.")
98
105
 
99
106
  self.rag_processor = RAGProcessor(
100
107
  self.github_api_handler, self.llm_manager)
108
+ logger.info("GithubRAG initialization completed.")
101
109
  except Exception as e:
102
- logger.error(f"Error initializing GithubRAG: {e}")
103
- raise e
110
+ logger.error(f"Error during GithubRAG initialization: {str(e)}")
111
+ raise
104
112
 
105
- async def async_retrieve_context(self, query, simple_mode=False) -> List[str]:
113
+ async def async_retrieve_context(self, query, simple_mode: Optional[bool] = None) -> List[str]:
106
114
  # Implementation of the context retrieval process
107
115
  # This will involve using the GitHub API to search for relevant information,
108
116
  # augmenting the retrieved data through the RAG methodology, and
109
117
  # enhancing it with LLM capabilities.
110
118
 
119
+ if simple_mode is None:
120
+ simple_mode = self.simple_mode
121
+
111
122
  topn_contexts = [] # This will be the list of context strings
112
123
  try:
113
124
  logger.info("Retrieving context...")
@@ -176,26 +187,29 @@ class GithubRAG:
176
187
  raise e
177
188
  return topn_contexts
178
189
 
179
- def retrieve_context(self, query, simple_mode=False) -> List[str]:
190
+ def retrieve_context(self, query, simple_mode: Optional[bool] = None) -> List[str]:
180
191
  """
181
192
  Retrieve context from GitHub code, issue and repo search based on the input query.
182
193
 
183
194
  Args:
184
195
  query (str): The query or question to retrieve context for.
196
+ simple_mode (Optional[bool]): If provided, overrides the instance's simple_mode setting.
185
197
 
186
198
  Returns:
187
199
  List[str]: A list of context strings retrieved from the specified GitHub repositories.
188
200
  """
201
+ effective_simple_mode = self.simple_mode if simple_mode is None else simple_mode
202
+
189
203
  self.loop = asyncio.get_event_loop()
190
204
  ipython = get_ipython()
191
205
  if ipython and ipython.has_trait('kernel'):
192
206
  logger.debug("Running in Jupyter notebook, nest_asyncio applied.")
193
207
  import nest_asyncio
194
208
  nest_asyncio.apply()
195
- return asyncio.run(self.async_retrieve_context(query, simple_mode=simple_mode))
209
+ return asyncio.run(self.async_retrieve_context(query, simple_mode=effective_simple_mode))
196
210
  if self.loop.is_running():
197
- return asyncio.ensure_future(self.async_retrieve_context(query, simple_mode=simple_mode))
198
- return self.loop.run_until_complete(self.async_retrieve_context(query, simple_mode=simple_mode))
211
+ return asyncio.ensure_future(self.async_retrieve_context(query, simple_mode=effective_simple_mode))
212
+ return self.loop.run_until_complete(self.async_retrieve_context(query, simple_mode=effective_simple_mode))
199
213
 
200
214
  async def code_search_retrieval(self, query, draft_answer: Optional[str] = None):
201
215
  result = []
@@ -19,11 +19,11 @@ class LLMManager:
19
19
  _instance_lock = Lock()
20
20
  _instance = None
21
21
  llm = None
22
- # embedding_model = None
23
22
  rerank_model = None
24
23
  _initialized = False
25
24
  llm_simple = None
26
25
  tokenizer = None
26
+ embedding_model = None
27
27
 
28
28
  def __new__(cls, *args, **kwargs):
29
29
  if cls._instance is None: # First check (unlocked)
@@ -40,12 +40,15 @@ class LLMManager:
40
40
  embedding_model: Optional[str] = config.get(
41
41
  "default_embedding"),
42
42
  rerank_model: Optional[str] = config.get("default_reranker"),
43
- llm: Any = None):
43
+ llm: Any = None,
44
+ simple_mode: bool = False):
44
45
  with self._instance_lock: # Prevent re-initialization
45
46
  if self._initialized:
46
47
  return
47
48
  self._initialized = True
48
49
 
50
+ self.simple_mode = simple_mode
51
+
49
52
  # Initialize for OpenAI GPT-4
50
53
  if llm is not None:
51
54
  self.llm = llm
@@ -69,28 +72,31 @@ class LLMManager:
69
72
  elif self.llm is None:
70
73
  # default model is phi3_mini_128k
71
74
  self.model_type = "Hubgingface"
75
+
76
+ if not self.simple_mode:
77
+ # initial model_kwargs
78
+ if torch.cuda.is_available():
79
+ self.device = torch.device('cuda')
80
+ elif torch.backends.mps.is_available():
81
+ self.device = torch.device('mps')
82
+ else:
83
+ self.device = torch.device('cpu')
72
84
 
73
- # initial model_kwargs
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
82
- if self.tokenizer is None:
83
- logger.info(f"Initializing {embedding_model}...")
84
- self.tokenizer = AutoTokenizer.from_pretrained(embedding_model)
85
- self.embedding_model = AutoModel.from_pretrained(
86
- embedding_model, trust_remote_code=True).to(self.device)
85
+ # initial embedding_model
86
+ if self.tokenizer is None:
87
+ logger.info(f"Initializing {embedding_model}...")
88
+ self.tokenizer = AutoTokenizer.from_pretrained(embedding_model)
89
+ self.embedding_model = AutoModel.from_pretrained(
90
+ embedding_model, trust_remote_code=True).to(self.device)
87
91
 
88
- # initial rerank_model
89
- if self.rerank_model is None:
90
- logger.info(f"Initializing {rerank_model}...")
91
- self.rerank_model = AutoModelForSequenceClassification.from_pretrained(
92
- rerank_model, num_labels=1, trust_remote_code=True
93
- ).to(self.device)
92
+ # initial rerank_model
93
+ if self.rerank_model is None:
94
+ logger.info(f"Initializing {rerank_model}...")
95
+ self.rerank_model = AutoModelForSequenceClassification.from_pretrained(
96
+ rerank_model, num_labels=1, trust_remote_code=True
97
+ ).to(self.device)
98
+ else:
99
+ logger.info("Simple mode enabled. Skipping embedding and rerank model initialization.")
94
100
 
95
101
  def get_llm(self):
96
102
  return self.llm
@@ -105,4 +111,4 @@ class LLMManager:
105
111
  return self.rerank_model
106
112
 
107
113
  def get_embedding_model(self):
108
- return self.embedding_model
114
+ return self.embedding_model
@@ -0,0 +1 @@
1
+ __version__ = '0.1.3'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: llama-github
3
- Version: 0.1.2
3
+ Version: 0.1.3
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
@@ -133,6 +133,20 @@ All notable changes to this project will be documented in this file.
133
133
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
134
134
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
135
135
 
136
+ ## [0.1.3] - 2024-10-14
137
+
138
+ ### Added
139
+ - Modified `LLMManager` class to skip loading embedding and reranker models when `simple_mode` is enabled
140
+ - Updated `retrieve_context` method to use instance's `simple_mode` by default, with option to override
141
+
142
+ ### Improved
143
+ - Faster initialization process when `simple_mode` is enabled, skipping embedding and reranker model loading
144
+ - More flexible usage of `simple_mode` in `retrieve_context`, allowing per-call customization
145
+
146
+ ### Developer Notes
147
+ - When using `simple_mode=True` during GithubRAG initialization, be aware that embedding and reranking functionalities will not be available
148
+ - The `retrieve_context` method now uses a late binding approach for `simple_mode` parameter
149
+
136
150
  ## [0.1.2] - 2024-10-09
137
151
 
138
152
  ### Added
@@ -177,5 +191,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
177
191
  - Basic functionality for retrieving context from GitHub repositories
178
192
  - Integration with LLM for processing and generating responses
179
193
 
194
+ [0.1.3]: https://github.com/JetXu-LLM/llama-github/compare/v0.1.2...v0.1.3
195
+ [0.1.2]: https://github.com/JetXu-LLM/llama-github/compare/v0.1.1...v0.1.2
180
196
  [0.1.1]: https://github.com/JetXu-LLM/llama-github/compare/v0.1.0...v0.1.1
181
197
  [0.1.0]: https://github.com/JetXu-LLM/llama-github/releases/tag/v0.1.0
@@ -1,6 +1,6 @@
1
1
  [metadata]
2
2
  name = llama-github
3
- version = 0.1.2
3
+ version = 0.1.3
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.2'
File without changes
File without changes
File without changes
File without changes