llama-github 0.1.2__tar.gz → 0.1.4__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.4}/CHANGELOG.md +26 -0
  2. {llama_github-0.1.2/llama_github.egg-info → llama_github-0.1.4}/PKG-INFO +27 -1
  3. {llama_github-0.1.2 → llama_github-0.1.4}/llama_github/github_rag.py +23 -9
  4. {llama_github-0.1.2 → llama_github-0.1.4}/llama_github/llm_integration/initial_load.py +33 -29
  5. llama_github-0.1.4/llama_github/version.py +1 -0
  6. {llama_github-0.1.2 → llama_github-0.1.4/llama_github.egg-info}/PKG-INFO +27 -1
  7. {llama_github-0.1.2 → llama_github-0.1.4}/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.4}/LICENSE +0 -0
  10. {llama_github-0.1.2 → llama_github-0.1.4}/MANIFEST.in +0 -0
  11. {llama_github-0.1.2 → llama_github-0.1.4}/README.md +0 -0
  12. {llama_github-0.1.2 → llama_github-0.1.4}/llama_github/__init__.py +0 -0
  13. {llama_github-0.1.2 → llama_github-0.1.4}/llama_github/config/__init__.py +0 -0
  14. {llama_github-0.1.2 → llama_github-0.1.4}/llama_github/config/config.json +0 -0
  15. {llama_github-0.1.2 → llama_github-0.1.4}/llama_github/config/config.py +0 -0
  16. {llama_github-0.1.2 → llama_github-0.1.4}/llama_github/data_retrieval/__init__.py +0 -0
  17. {llama_github-0.1.2 → llama_github-0.1.4}/llama_github/data_retrieval/github_api.py +0 -0
  18. {llama_github-0.1.2 → llama_github-0.1.4}/llama_github/data_retrieval/github_entities.py +0 -0
  19. {llama_github-0.1.2 → llama_github-0.1.4}/llama_github/features/__init__.py +0 -0
  20. {llama_github-0.1.2 → llama_github-0.1.4}/llama_github/features/feature_flags.py +0 -0
  21. {llama_github-0.1.2 → llama_github-0.1.4}/llama_github/features/insider_features.py +0 -0
  22. {llama_github-0.1.2 → llama_github-0.1.4}/llama_github/github_integration/__init__.py +0 -0
  23. {llama_github-0.1.2 → llama_github-0.1.4}/llama_github/github_integration/github_auth_manager.py +0 -0
  24. {llama_github-0.1.2 → llama_github-0.1.4}/llama_github/llm_integration/__init__.py +0 -0
  25. {llama_github-0.1.2 → llama_github-0.1.4}/llama_github/llm_integration/llm_handler.py +0 -0
  26. {llama_github-0.1.2 → llama_github-0.1.4}/llama_github/logger.py +0 -0
  27. {llama_github-0.1.2 → llama_github-0.1.4}/llama_github/rag_processing/__init__.py +0 -0
  28. {llama_github-0.1.2 → llama_github-0.1.4}/llama_github/rag_processing/rag_processor.py +0 -0
  29. {llama_github-0.1.2 → llama_github-0.1.4}/llama_github/utils.py +0 -0
  30. {llama_github-0.1.2 → llama_github-0.1.4}/llama_github.egg-info/SOURCES.txt +0 -0
  31. {llama_github-0.1.2 → llama_github-0.1.4}/llama_github.egg-info/dependency_links.txt +0 -0
  32. {llama_github-0.1.2 → llama_github-0.1.4}/llama_github.egg-info/requires.txt +0 -0
  33. {llama_github-0.1.2 → llama_github-0.1.4}/llama_github.egg-info/top_level.txt +0 -0
  34. {llama_github-0.1.2 → llama_github-0.1.4}/setup.py +0 -0
  35. {llama_github-0.1.2 → llama_github-0.1.4}/tests/test_data_retrieval.py +0 -0
  36. {llama_github-0.1.2 → llama_github-0.1.4}/tests/test_github_auth_manager.py +0 -0
  37. {llama_github-0.1.2 → llama_github-0.1.4}/tests/test_initial_load.py +0 -0
  38. {llama_github-0.1.2 → llama_github-0.1.4}/tests/test_llm_handler.py +0 -0
  39. {llama_github-0.1.2 → llama_github-0.1.4}/tests/test_logger.py +0 -0
  40. {llama_github-0.1.2 → llama_github-0.1.4}/tests/test_rag_processor.py +0 -0
@@ -5,6 +5,29 @@ 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.4] - 2024-10-14
9
+
10
+ ### Improved
11
+ - Optimized `simple_mode`:
12
+ - Removed dependencies on `Torch` and `Transformers` libraries
13
+ - Reduced memory footprint
14
+ - Eliminated related imports
15
+ - Enhanced compatibility with AWS Lambda environment
16
+
17
+ ## [0.1.3] - 2024-10-14
18
+
19
+ ### Added
20
+ - Modified `LLMManager` class to skip loading embedding and reranker models when `simple_mode` is enabled
21
+ - Updated `retrieve_context` method to use instance's `simple_mode` by default, with option to override
22
+
23
+ ### Improved
24
+ - Faster initialization process when `simple_mode` is enabled, skipping embedding and reranker model loading
25
+ - More flexible usage of `simple_mode` in `retrieve_context`, allowing per-call customization
26
+
27
+ ### Developer Notes
28
+ - When using `simple_mode=True` during GithubRAG initialization, be aware that embedding and reranking functionalities will not be available
29
+ - The `retrieve_context` method now uses a late binding approach for `simple_mode` parameter
30
+
8
31
  ## [0.1.2] - 2024-10-09
9
32
 
10
33
  ### Added
@@ -49,5 +72,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
49
72
  - Basic functionality for retrieving context from GitHub repositories
50
73
  - Integration with LLM for processing and generating responses
51
74
 
75
+ [0.1.4]: https://github.com/JetXu-LLM/llama-github/compare/v0.1.3...v0.1.4
76
+ [0.1.3]: https://github.com/JetXu-LLM/llama-github/compare/v0.1.2...v0.1.3
77
+ [0.1.2]: https://github.com/JetXu-LLM/llama-github/compare/v0.1.1...v0.1.2
52
78
  [0.1.1]: https://github.com/JetXu-LLM/llama-github/compare/v0.1.0...v0.1.1
53
79
  [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.4
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,29 @@ 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.4] - 2024-10-14
137
+
138
+ ### Improved
139
+ - Optimized `simple_mode`:
140
+ - Removed dependencies on `Torch` and `Transformers` libraries
141
+ - Reduced memory footprint
142
+ - Eliminated related imports
143
+ - Enhanced compatibility with AWS Lambda environment
144
+
145
+ ## [0.1.3] - 2024-10-14
146
+
147
+ ### Added
148
+ - Modified `LLMManager` class to skip loading embedding and reranker models when `simple_mode` is enabled
149
+ - Updated `retrieve_context` method to use instance's `simple_mode` by default, with option to override
150
+
151
+ ### Improved
152
+ - Faster initialization process when `simple_mode` is enabled, skipping embedding and reranker model loading
153
+ - More flexible usage of `simple_mode` in `retrieve_context`, allowing per-call customization
154
+
155
+ ### Developer Notes
156
+ - When using `simple_mode=True` during GithubRAG initialization, be aware that embedding and reranking functionalities will not be available
157
+ - The `retrieve_context` method now uses a late binding approach for `simple_mode` parameter
158
+
136
159
  ## [0.1.2] - 2024-10-09
137
160
 
138
161
  ### Added
@@ -177,5 +200,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
177
200
  - Basic functionality for retrieving context from GitHub repositories
178
201
  - Integration with LLM for processing and generating responses
179
202
 
203
+ [0.1.4]: https://github.com/JetXu-LLM/llama-github/compare/v0.1.3...v0.1.4
204
+ [0.1.3]: https://github.com/JetXu-LLM/llama-github/compare/v0.1.2...v0.1.3
205
+ [0.1.2]: https://github.com/JetXu-LLM/llama-github/compare/v0.1.1...v0.1.2
180
206
  [0.1.1]: https://github.com/JetXu-LLM/llama-github/compare/v0.1.0...v0.1.1
181
207
  [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 = []
@@ -1,5 +1,4 @@
1
1
  # initial_load.py
2
- import torch
3
2
  from typing import Optional, Any
4
3
  from threading import Lock
5
4
  from langchain_openai import ChatOpenAI
@@ -10,20 +9,15 @@ from langchain_mistralai.chat_models import ChatMistralAI
10
9
  from llama_github.config.config import config
11
10
  from llama_github.logger import logger
12
11
 
13
- from transformers import AutoModel
14
- from transformers import AutoModelForSequenceClassification
15
- from transformers import AutoTokenizer
16
-
17
-
18
12
  class LLMManager:
19
13
  _instance_lock = Lock()
20
14
  _instance = None
21
15
  llm = None
22
- # embedding_model = None
23
16
  rerank_model = None
24
17
  _initialized = False
25
18
  llm_simple = None
26
19
  tokenizer = None
20
+ embedding_model = None
27
21
 
28
22
  def __new__(cls, *args, **kwargs):
29
23
  if cls._instance is None: # First check (unlocked)
@@ -40,12 +34,15 @@ class LLMManager:
40
34
  embedding_model: Optional[str] = config.get(
41
35
  "default_embedding"),
42
36
  rerank_model: Optional[str] = config.get("default_reranker"),
43
- llm: Any = None):
37
+ llm: Any = None,
38
+ simple_mode: bool = False):
44
39
  with self._instance_lock: # Prevent re-initialization
45
40
  if self._initialized:
46
41
  return
47
42
  self._initialized = True
48
43
 
44
+ self.simple_mode = simple_mode
45
+
49
46
  # Initialize for OpenAI GPT-4
50
47
  if llm is not None:
51
48
  self.llm = llm
@@ -69,28 +66,35 @@ class LLMManager:
69
66
  elif self.llm is None:
70
67
  # default model is phi3_mini_128k
71
68
  self.model_type = "Hubgingface"
69
+
70
+ if not self.simple_mode:
71
+ import torch
72
+ from transformers import AutoModel
73
+ from transformers import AutoModelForSequenceClassification
74
+ from transformers import AutoTokenizer
75
+ # initial model_kwargs
76
+ if torch.cuda.is_available():
77
+ self.device = torch.device('cuda')
78
+ elif torch.backends.mps.is_available():
79
+ self.device = torch.device('mps')
80
+ else:
81
+ self.device = torch.device('cpu')
72
82
 
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)
83
+ # initial embedding_model
84
+ if self.tokenizer is None:
85
+ logger.info(f"Initializing {embedding_model}...")
86
+ self.tokenizer = AutoTokenizer.from_pretrained(embedding_model)
87
+ self.embedding_model = AutoModel.from_pretrained(
88
+ embedding_model, trust_remote_code=True).to(self.device)
87
89
 
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)
90
+ # initial rerank_model
91
+ if self.rerank_model is None:
92
+ logger.info(f"Initializing {rerank_model}...")
93
+ self.rerank_model = AutoModelForSequenceClassification.from_pretrained(
94
+ rerank_model, num_labels=1, trust_remote_code=True
95
+ ).to(self.device)
96
+ else:
97
+ logger.info("Simple mode enabled. Skipping embedding and rerank model initialization.")
94
98
 
95
99
  def get_llm(self):
96
100
  return self.llm
@@ -105,4 +109,4 @@ class LLMManager:
105
109
  return self.rerank_model
106
110
 
107
111
  def get_embedding_model(self):
108
- return self.embedding_model
112
+ return self.embedding_model
@@ -0,0 +1 @@
1
+ __version__ = '0.1.4'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: llama-github
3
- Version: 0.1.2
3
+ Version: 0.1.4
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,29 @@ 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.4] - 2024-10-14
137
+
138
+ ### Improved
139
+ - Optimized `simple_mode`:
140
+ - Removed dependencies on `Torch` and `Transformers` libraries
141
+ - Reduced memory footprint
142
+ - Eliminated related imports
143
+ - Enhanced compatibility with AWS Lambda environment
144
+
145
+ ## [0.1.3] - 2024-10-14
146
+
147
+ ### Added
148
+ - Modified `LLMManager` class to skip loading embedding and reranker models when `simple_mode` is enabled
149
+ - Updated `retrieve_context` method to use instance's `simple_mode` by default, with option to override
150
+
151
+ ### Improved
152
+ - Faster initialization process when `simple_mode` is enabled, skipping embedding and reranker model loading
153
+ - More flexible usage of `simple_mode` in `retrieve_context`, allowing per-call customization
154
+
155
+ ### Developer Notes
156
+ - When using `simple_mode=True` during GithubRAG initialization, be aware that embedding and reranking functionalities will not be available
157
+ - The `retrieve_context` method now uses a late binding approach for `simple_mode` parameter
158
+
136
159
  ## [0.1.2] - 2024-10-09
137
160
 
138
161
  ### Added
@@ -177,5 +200,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
177
200
  - Basic functionality for retrieving context from GitHub repositories
178
201
  - Integration with LLM for processing and generating responses
179
202
 
203
+ [0.1.4]: https://github.com/JetXu-LLM/llama-github/compare/v0.1.3...v0.1.4
204
+ [0.1.3]: https://github.com/JetXu-LLM/llama-github/compare/v0.1.2...v0.1.3
205
+ [0.1.2]: https://github.com/JetXu-LLM/llama-github/compare/v0.1.1...v0.1.2
180
206
  [0.1.1]: https://github.com/JetXu-LLM/llama-github/compare/v0.1.0...v0.1.1
181
207
  [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.4
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