llama-github 0.1.4__tar.gz → 0.1.5__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 (41) hide show
  1. {llama_github-0.1.4 → llama_github-0.1.5}/CHANGELOG.md +5 -0
  2. {llama_github-0.1.4/llama_github.egg-info → llama_github-0.1.5}/PKG-INFO +11 -1
  3. {llama_github-0.1.4 → llama_github-0.1.5}/llama_github/github_rag.py +131 -28
  4. {llama_github-0.1.4 → llama_github-0.1.5}/llama_github/llm_integration/initial_load.py +0 -2
  5. llama_github-0.1.5/llama_github/logger.py +15 -0
  6. llama_github-0.1.5/llama_github/version.py +1 -0
  7. {llama_github-0.1.4 → llama_github-0.1.5/llama_github.egg-info}/PKG-INFO +11 -1
  8. {llama_github-0.1.4 → llama_github-0.1.5}/llama_github.egg-info/requires.txt +5 -0
  9. {llama_github-0.1.4 → llama_github-0.1.5}/setup.cfg +1 -1
  10. llama_github-0.1.4/llama_github/logger.py +0 -28
  11. llama_github-0.1.4/llama_github/version.py +0 -1
  12. {llama_github-0.1.4 → llama_github-0.1.5}/LICENSE +0 -0
  13. {llama_github-0.1.4 → llama_github-0.1.5}/MANIFEST.in +0 -0
  14. {llama_github-0.1.4 → llama_github-0.1.5}/README.md +0 -0
  15. {llama_github-0.1.4 → llama_github-0.1.5}/llama_github/__init__.py +0 -0
  16. {llama_github-0.1.4 → llama_github-0.1.5}/llama_github/config/__init__.py +0 -0
  17. {llama_github-0.1.4 → llama_github-0.1.5}/llama_github/config/config.json +0 -0
  18. {llama_github-0.1.4 → llama_github-0.1.5}/llama_github/config/config.py +0 -0
  19. {llama_github-0.1.4 → llama_github-0.1.5}/llama_github/data_retrieval/__init__.py +0 -0
  20. {llama_github-0.1.4 → llama_github-0.1.5}/llama_github/data_retrieval/github_api.py +0 -0
  21. {llama_github-0.1.4 → llama_github-0.1.5}/llama_github/data_retrieval/github_entities.py +0 -0
  22. {llama_github-0.1.4 → llama_github-0.1.5}/llama_github/features/__init__.py +0 -0
  23. {llama_github-0.1.4 → llama_github-0.1.5}/llama_github/features/feature_flags.py +0 -0
  24. {llama_github-0.1.4 → llama_github-0.1.5}/llama_github/features/insider_features.py +0 -0
  25. {llama_github-0.1.4 → llama_github-0.1.5}/llama_github/github_integration/__init__.py +0 -0
  26. {llama_github-0.1.4 → llama_github-0.1.5}/llama_github/github_integration/github_auth_manager.py +0 -0
  27. {llama_github-0.1.4 → llama_github-0.1.5}/llama_github/llm_integration/__init__.py +0 -0
  28. {llama_github-0.1.4 → llama_github-0.1.5}/llama_github/llm_integration/llm_handler.py +0 -0
  29. {llama_github-0.1.4 → llama_github-0.1.5}/llama_github/rag_processing/__init__.py +0 -0
  30. {llama_github-0.1.4 → llama_github-0.1.5}/llama_github/rag_processing/rag_processor.py +0 -0
  31. {llama_github-0.1.4 → llama_github-0.1.5}/llama_github/utils.py +0 -0
  32. {llama_github-0.1.4 → llama_github-0.1.5}/llama_github.egg-info/SOURCES.txt +0 -0
  33. {llama_github-0.1.4 → llama_github-0.1.5}/llama_github.egg-info/dependency_links.txt +0 -0
  34. {llama_github-0.1.4 → llama_github-0.1.5}/llama_github.egg-info/top_level.txt +0 -0
  35. {llama_github-0.1.4 → llama_github-0.1.5}/setup.py +0 -0
  36. {llama_github-0.1.4 → llama_github-0.1.5}/tests/test_data_retrieval.py +0 -0
  37. {llama_github-0.1.4 → llama_github-0.1.5}/tests/test_github_auth_manager.py +0 -0
  38. {llama_github-0.1.4 → llama_github-0.1.5}/tests/test_initial_load.py +0 -0
  39. {llama_github-0.1.4 → llama_github-0.1.5}/tests/test_llm_handler.py +0 -0
  40. {llama_github-0.1.4 → llama_github-0.1.5}/tests/test_logger.py +0 -0
  41. {llama_github-0.1.4 → llama_github-0.1.5}/tests/test_rag_processor.py +0 -0
@@ -5,6 +5,11 @@ 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.5] - 2024-10-14
9
+
10
+ ### Optimized
11
+ - requirements.txt updated to more precise list
12
+
8
13
  ## [0.1.4] - 2024-10-14
9
14
 
10
15
  ### Improved
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: llama-github
3
- Version: 0.1.4
3
+ Version: 0.1.5
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
@@ -22,6 +22,11 @@ Requires-Dist: requests
22
22
  Requires-Dist: torch
23
23
  Requires-Dist: transformers
24
24
  Requires-Dist: urllib3
25
+ Requires-Dist: pydantic_core
26
+ Requires-Dist: langchain_openai
27
+ Requires-Dist: langchain_mistralai
28
+ Requires-Dist: httpx_sse
29
+ Requires-Dist: tokenizers
25
30
  Provides-Extra: dev
26
31
  Requires-Dist: pytest; extra == "dev"
27
32
  Requires-Dist: black; extra == "dev"
@@ -133,6 +138,11 @@ All notable changes to this project will be documented in this file.
133
138
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
134
139
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
135
140
 
141
+ ## [0.1.5] - 2024-10-14
142
+
143
+ ### Optimized
144
+ - requirements.txt updated to more precise list
145
+
136
146
  ## [0.1.4] - 2024-10-14
137
147
 
138
148
  ### Improved
@@ -46,24 +46,26 @@ class GithubRAG:
46
46
  """
47
47
  Initialize the GithubRAG with the provided credentials and configuration.
48
48
 
49
- Parameters:
50
- - github_access_token (Optional[str]): GitHub access token for authentication.
51
- - github_app_credentials (Optional[GitHubAppCredentials]): Credentials for GitHub App authentication.
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.
54
- - huggingface_token (Optional[str]): Token for Hugging Face services -- recommend to fill.
55
- - jina_api_key (Optional[str]): API key for Jina AI services -- s.jina.ai API will be used
56
- - open_source_models_hg_dir (Optional[str]): Name of open-source models from Hugging Face to replace OpenAI.
57
- - embedding_model (Optional[str]): Name of Embedding model from Hugging Face, if you have preferred embedding model to be used.
58
- - rerank_model (Optional[str]): Name of Rerank model from Hugging Face, if you have preferred rerank model to be used.
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.
61
- - **kwargs:
62
- :param repo_cleanup_interval (Optional[int]): How often to run repo cleanup in seconds within RepositoryPool.
63
- :param repo_max_idle_time (Optional[int]): Keep a repo in cache until max idle time if not used.
49
+ This constructor sets up the necessary components for GitHub integration,
50
+ RAG processing, and LLM capabilities. It handles authentication, initializes
51
+ the repository pool, and sets up the LLM manager.
64
52
 
65
- Returns:
66
- - None
53
+ Args:
54
+ github_access_token (Optional[str]): GitHub access token for authentication.
55
+ github_app_credentials (Optional[GitHubAppCredentials]): Credentials for GitHub App authentication.
56
+ openai_api_key (Optional[str]): API key for OpenAI services (GPT-4-turbo will be used).
57
+ mistral_api_key (Optional[str]): API key for Mistral AI services.
58
+ huggingface_token (Optional[str]): Token for Hugging Face services (recommended).
59
+ jina_api_key (Optional[str]): API key for Jina AI services (s.jina.ai API will be used).
60
+ open_source_models_hg_dir (Optional[str]): Directory for open-source models from Hugging Face.
61
+ embedding_model (Optional[str]): Name of the preferred embedding model from Hugging Face.
62
+ rerank_model (Optional[str]): Name of the preferred rerank model from Hugging Face.
63
+ llm (Any): Any LangChain LLM chat object to replace OpenAI or open-source models.
64
+ simple_mode (bool): If True, skip embedding and rerank model initialization in LLMManager.
65
+ **kwargs: Additional keyword arguments for repository pool configuration.
66
+
67
+ Raises:
68
+ Exception: If there's an error during initialization.
67
69
  """
68
70
  try:
69
71
  logger.info("Initializing GithubRAG...")
@@ -111,10 +113,23 @@ class GithubRAG:
111
113
  raise
112
114
 
113
115
  async def async_retrieve_context(self, query, simple_mode: Optional[bool] = None) -> List[str]:
114
- # Implementation of the context retrieval process
115
- # This will involve using the GitHub API to search for relevant information,
116
- # augmenting the retrieved data through the RAG methodology, and
117
- # enhancing it with LLM capabilities.
116
+ """
117
+ Asynchronously retrieve context based on the given query.
118
+
119
+ This method orchestrates the context retrieval process, including Google search,
120
+ code search, issue search, and repository search. It uses the RAG processor to
121
+ analyze the query and retrieve the most relevant contexts.
122
+
123
+ Args:
124
+ query (str): The query to retrieve context for.
125
+ simple_mode (Optional[bool]): If provided, overrides the instance's simple_mode setting.
126
+
127
+ Returns:
128
+ List[str]: A list of the most relevant context strings.
129
+
130
+ Raises:
131
+ Exception: If there's an error during context retrieval.
132
+ """
118
133
 
119
134
  if simple_mode is None:
120
135
  simple_mode = self.simple_mode
@@ -191,6 +206,10 @@ class GithubRAG:
191
206
  """
192
207
  Retrieve context from GitHub code, issue and repo search based on the input query.
193
208
 
209
+ This method serves as a wrapper for the async_retrieve_context method,
210
+ handling the asynchronous call in different runtime environments (e.g., Jupyter notebook,
211
+ asyncio event loop).
212
+
194
213
  Args:
195
214
  query (str): The query or question to retrieve context for.
196
215
  simple_mode (Optional[bool]): If provided, overrides the instance's simple_mode setting.
@@ -212,6 +231,24 @@ class GithubRAG:
212
231
  return self.loop.run_until_complete(self.async_retrieve_context(query, simple_mode=effective_simple_mode))
213
232
 
214
233
  async def code_search_retrieval(self, query, draft_answer: Optional[str] = None):
234
+ """
235
+ Perform a code search on GitHub based on the given query and draft answer.
236
+
237
+ This method uses the RAG processor to generate search criteria, then performs
238
+ a code search using the GitHub API. It filters and deduplicates the results
239
+ based on star count and relevance.
240
+
241
+ Args:
242
+ query (str): The main query for the code search.
243
+ draft_answer (Optional[str]): A draft answer to refine the search criteria.
244
+
245
+ Returns:
246
+ list: A list of unique, relevant code search results.
247
+
248
+ Raises:
249
+ Exception: If there's an error during the code search retrieval.
250
+ """
251
+
215
252
  result = []
216
253
  try:
217
254
  logger.info("Retrieving code search...")
@@ -238,6 +275,24 @@ class GithubRAG:
238
275
  return result
239
276
 
240
277
  async def issue_search_retrieval(self, query, draft_answer: Optional[str] = None):
278
+ """
279
+ Perform an issue search on GitHub based on the given query and draft answer.
280
+
281
+ This method uses the RAG processor to generate search criteria, then performs
282
+ an issue search using the GitHub API. It deduplicates the results and transforms
283
+ the API URLs to official GitHub issue webpage URLs.
284
+
285
+ Args:
286
+ query (str): The main query for the issue search.
287
+ draft_answer (Optional[str]): A draft answer to refine the search criteria.
288
+
289
+ Returns:
290
+ list: A list of unique, relevant issue search results with transformed URLs.
291
+
292
+ Raises:
293
+ Exception: If there's an error during the issue search retrieval.
294
+ """
295
+
241
296
  result = []
242
297
  try:
243
298
  logger.info("Retrieving issue search...")
@@ -268,6 +323,23 @@ class GithubRAG:
268
323
  return result
269
324
 
270
325
  async def google_search_retrieval(self, query):
326
+ """
327
+ Perform a Google search for GitHub-related content based on the given query.
328
+
329
+ This method uses the Jina AI search API to perform a Google search limited to
330
+ GitHub.com. It then retrieves the content of the resulting GitHub URLs using
331
+ the GitHub API.
332
+
333
+ Args:
334
+ query (str): The query to search for on Google.
335
+
336
+ Returns:
337
+ list: A list of dictionaries containing the GitHub URL and its content.
338
+
339
+ Raises:
340
+ Exception: If there's an error during the Google search retrieval.
341
+ """
342
+
271
343
  result = []
272
344
  try:
273
345
  logger.info("Retrieving google search...")
@@ -304,15 +376,39 @@ class GithubRAG:
304
376
 
305
377
  def _get_repository_rag_info(self, repository: Repository):
306
378
  """
307
- Helper method to get file content through a Repository object.
379
+ Retrieve RAG-related information for a given repository.
380
+
381
+ This helper method fetches the README content and a simple structure
382
+ of the repository using the Repository object.
383
+
384
+ Args:
385
+ repository (Repository): The Repository object to get information from.
308
386
 
309
- :param code_search_result: A single code search result.
310
- :return: Tuple containing the Repository object and the file content.
387
+ Returns:
388
+ tuple: A tuple containing the repository's README content and simple structure.
311
389
  """
312
- # Assuming RepositoryPool is accessible and initialized somewhere in this class
390
+
313
391
  return repository.get_readme(), self.rag_processor.get_repo_simple_structure(repository)
314
392
 
315
393
  async def repo_search_retrieval(self, query, draft_answer: Optional[str] = None):
394
+ """
395
+ Perform a repository search on GitHub based on the given query and draft answer.
396
+
397
+ This method uses the RAG processor to generate search criteria, then performs
398
+ a repository search using the GitHub API. It retrieves README content and
399
+ simple structure for each relevant repository concurrently.
400
+
401
+ Args:
402
+ query (str): The main query for the repository search.
403
+ draft_answer (Optional[str]): A draft answer to refine the search criteria.
404
+
405
+ Returns:
406
+ list: A list of dictionaries containing repository information and content.
407
+
408
+ Raises:
409
+ Exception: If there's an error during the repository search retrieval.
410
+ """
411
+
316
412
  result = []
317
413
  results_with_index = []
318
414
  try:
@@ -370,18 +466,20 @@ class GithubRAG:
370
466
  """
371
467
  Generate an answer based on the given query and optional contexts.
372
468
 
373
- This method can be called in different environments (Jupyter notebook,
374
- synchronous Python program, asynchronous Python program) and will
375
- handle the async call appropriately.
469
+ This method serves as a wrapper for the async_answer_with_context method,
470
+ handling the asynchronous call in different runtime environments (e.g., Jupyter notebook,
471
+ asyncio event loop).
376
472
 
377
473
  Args:
378
474
  query (str): The user's query.
379
475
  contexts (Optional[List[Dict[str, Any]]]): Optional list of context dictionaries.
380
476
  Each dictionary should contain 'content' and 'url' keys.
477
+ simple_mode (bool): Whether to use simple mode for context retrieval.
381
478
 
382
479
  Returns:
383
480
  str: The generated answer.
384
481
  """
482
+
385
483
  self.loop = asyncio.get_event_loop()
386
484
  ipython = get_ipython()
387
485
  if ipython and ipython.has_trait('kernel'):
@@ -397,14 +495,19 @@ class GithubRAG:
397
495
  """
398
496
  Asynchronously generate an answer based on the given query and optional contexts.
399
497
 
498
+ This method retrieves contexts if not provided, extracts relevant information,
499
+ and uses the RAG processor's LLM handler to generate an answer.
500
+
400
501
  Args:
401
502
  query (str): The user's query.
402
503
  contexts (Optional[List[Dict[str, Any]]]): Optional list of context dictionaries.
403
504
  Each dictionary should contain 'content' and 'url' keys.
505
+ simple_mode (bool): Whether to use simple mode for context retrieval.
404
506
 
405
507
  Returns:
406
508
  str: The generated answer.
407
509
  """
510
+
408
511
  if contexts is None:
409
512
  contexts = await self.async_retrieve_context(query, simple_mode)
410
513
  logger.debug(f"Retrieved contexts: {contexts}")
@@ -2,8 +2,6 @@
2
2
  from typing import Optional, Any
3
3
  from threading import Lock
4
4
  from langchain_openai import ChatOpenAI
5
- from langchain_community.embeddings import HuggingFaceEmbeddings
6
- from langchain_community.cross_encoders import HuggingFaceCrossEncoder
7
5
  from langchain_mistralai.chat_models import ChatMistralAI
8
6
 
9
7
  from llama_github.config.config import config
@@ -0,0 +1,15 @@
1
+ import logging
2
+
3
+ logger = logging.getLogger('llama_github')
4
+
5
+ def configure_logging(level=logging.INFO, handler=None):
6
+ logger.setLevel(level)
7
+ if handler:
8
+ logger.addHandler(handler)
9
+ else:
10
+ # default handler output to console
11
+ ch = logging.StreamHandler()
12
+ ch.setLevel(level)
13
+ formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
14
+ ch.setFormatter(formatter)
15
+ logger.addHandler(ch)
@@ -0,0 +1 @@
1
+ __version__ = '0.1.5'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: llama-github
3
- Version: 0.1.4
3
+ Version: 0.1.5
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
@@ -22,6 +22,11 @@ Requires-Dist: requests
22
22
  Requires-Dist: torch
23
23
  Requires-Dist: transformers
24
24
  Requires-Dist: urllib3
25
+ Requires-Dist: pydantic_core
26
+ Requires-Dist: langchain_openai
27
+ Requires-Dist: langchain_mistralai
28
+ Requires-Dist: httpx_sse
29
+ Requires-Dist: tokenizers
25
30
  Provides-Extra: dev
26
31
  Requires-Dist: pytest; extra == "dev"
27
32
  Requires-Dist: black; extra == "dev"
@@ -133,6 +138,11 @@ All notable changes to this project will be documented in this file.
133
138
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
134
139
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
135
140
 
141
+ ## [0.1.5] - 2024-10-14
142
+
143
+ ### Optimized
144
+ - requirements.txt updated to more precise list
145
+
136
146
  ## [0.1.4] - 2024-10-14
137
147
 
138
148
  ### Improved
@@ -9,6 +9,11 @@ requests
9
9
  torch
10
10
  transformers
11
11
  urllib3
12
+ pydantic_core
13
+ langchain_openai
14
+ langchain_mistralai
15
+ httpx_sse
16
+ tokenizers
12
17
 
13
18
  [dev]
14
19
  pytest
@@ -1,6 +1,6 @@
1
1
  [metadata]
2
2
  name = llama-github
3
- version = 0.1.4
3
+ version = 0.1.5
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,28 +0,0 @@
1
- import logging
2
-
3
- logger = logging.getLogger('llama_github')
4
-
5
- def configure_logging(level=logging.INFO, handler=None):
6
- logger.setLevel(level)
7
- if handler:
8
- logger.addHandler(handler)
9
- else:
10
- # default handler output to console
11
- ch = logging.StreamHandler()
12
- ch.setLevel(level)
13
- formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
14
- ch.setFormatter(formatter)
15
- logger.addHandler(ch)
16
-
17
- ## Logging Configuration
18
- # By default, `llama_github` does not configure logging to avoid interfering with your application's logging settings. If you want to see log outputs from `llama_github`, you can configure logging as follows:
19
-
20
- # ```python
21
- # import logging
22
- # import llama_github
23
-
24
- # # Configure the library's logger
25
- # llama_github.configure_logging(level=logging.INFO)
26
-
27
- # # Now you can see log outputs
28
- # logger = logging.getLogger('llama_github')
@@ -1 +0,0 @@
1
- __version__ = '0.1.4'
File without changes
File without changes
File without changes
File without changes