sunholo 0.83.5__py3-none-any.whl → 0.84.0__py3-none-any.whl

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.
@@ -1,2 +1,3 @@
1
1
  from .qna_routes import register_qna_routes
2
- from .base import create_app
2
+ from .base import create_app
3
+ from .vac_routes import VACRoutes
@@ -0,0 +1,89 @@
1
+ import asyncio
2
+ import logging
3
+ from typing import Callable, List, Any, Coroutine, Tuple
4
+
5
+ # Setup basic logging configuration
6
+ logging.basicConfig(level=logging.INFO)
7
+ logger = logging.getLogger(__name__)
8
+
9
+ class AsyncTaskRunner:
10
+ """
11
+ # Example async functions for testing
12
+ async def api_call_1(url, params):
13
+ await asyncio.sleep(1)
14
+ if "fail" in params:
15
+ raise ValueError(f"Error in api_call_1 with params: {params}")
16
+ return f"api_call_1 response from {url} with params {params}"
17
+
18
+ async def api_call_2(url, params):
19
+ await asyncio.sleep(2)
20
+ if "fail" in params:
21
+ raise ValueError(f"Error in api_call_2 with params: {params}")
22
+ return f"api_call_2 response from {url} with params {params}"
23
+
24
+ # Example usage in an existing async function
25
+ async def example_usage():
26
+ runner = AsyncTaskRunner()
27
+
28
+ runner.add_task(api_call_1, "http://example.com", {"key": "value"})
29
+ runner.add_task(api_call_2, "http://example.org", {"key": "fail"})
30
+
31
+ # Run all tasks within the existing event loop
32
+ results = await runner.run_async()
33
+ for result in results:
34
+ print(result)
35
+
36
+ # Example of calling run_sync() in a synchronous context
37
+ if __name__ == "__main__":
38
+ runner = AsyncTaskRunner()
39
+
40
+ runner.add_task(api_call_1, "http://example.com", {"key": "value"})
41
+ runner.add_task(api_call_2, "http://example.org", {"key": "fail"})
42
+
43
+ # Running in a synchronous context
44
+ results = runner.run_sync()
45
+ for result in results:
46
+ print(result)
47
+ """
48
+ def __init__(self):
49
+ self.tasks = []
50
+
51
+ def add_task(self, func: Callable[..., Coroutine], *args: Any):
52
+ """Adds a task (function and its arguments) to the list of tasks to be executed."""
53
+ logger.info(f"Adding task: {func.__name__} with args: {args}")
54
+ self.tasks.append(func(*args))
55
+
56
+ def add_group(self, functions: List[Callable[..., Coroutine]], *args: Any):
57
+ """Adds a group of functions that should run in parallel with the same arguments."""
58
+ group_tasks = [func(*args) for func in functions]
59
+ logger.info(f"Adding group of tasks with args: {args}")
60
+ self.tasks.append(asyncio.gather(*group_tasks, return_exceptions=True))
61
+
62
+ async def run_async(self) -> List[Any]:
63
+ """Runs all tasks using the current event loop and returns the results."""
64
+ logger.info("Running tasks asynchronously")
65
+ results = await asyncio.gather(*self.tasks, return_exceptions=True)
66
+ self._log_results(results)
67
+ return results
68
+
69
+ def run_sync(self) -> List[Any]:
70
+ """Runs all tasks synchronously (blocking) using a new event loop and returns the results."""
71
+ try:
72
+ logger.info("Running tasks synchronously")
73
+ loop = asyncio.get_running_loop()
74
+ return loop.run_until_complete(self.run_async())
75
+ except RuntimeError:
76
+ loop = asyncio.new_event_loop()
77
+ asyncio.set_event_loop(loop)
78
+ results = loop.run_until_complete(self.run_async())
79
+ loop.close()
80
+ return results
81
+
82
+ def _log_results(self, results: List[Any]):
83
+ """Logs the results of the task executions."""
84
+ for result in results:
85
+ if isinstance(result, Exception):
86
+ logger.error(f"Task resulted in an error: {result}")
87
+ else:
88
+ logger.info(f"Task completed successfully: {result}")
89
+
@@ -198,7 +198,12 @@ class LlamaIndexVertexCorpusManager:
198
198
  """
199
199
  List all VertexAI Corpus for the project/location
200
200
  """
201
- return rag.list_corpora()
201
+ try:
202
+ return rag.list_corpora()
203
+ except Exception as err:
204
+ log.error(f"Could not list corpora: {str(err)}")
205
+ return []
206
+
202
207
 
203
208
  def find_corpus_from_list(self, display_name: str):
204
209
  """
@@ -410,3 +415,6 @@ def setup_llamaindex_subparser(subparsers):
410
415
  query_parser.add_argument('vac', nargs='?', default="global", help='The VAC config to set it up for')
411
416
 
412
417
  llamaindex_parser.set_defaults(func=llamaindex_command)
418
+
419
+ # If no subcommand is provided, print the help message
420
+ llamaindex_parser.set_defaults(func=lambda args: llamaindex_parser.print_help() if args.action is None else llamaindex_command)
@@ -49,13 +49,21 @@ def add_user_history_rag(
49
49
 
50
50
  def get_user_history_chunks(user_id:str, config:ConfigManager, query):
51
51
 
52
- manager = LlamaIndexVertexCorpusManager(config)
52
+ try:
53
+ manager = LlamaIndexVertexCorpusManager(config)
53
54
 
54
- manager.create_corpus(user_id)
55
+ manager.create_corpus(user_id)
55
56
 
56
- response = manager.query_corpus(query, user_id)
57
- user_history_memory = []
58
- for chunk in response.contexts.contexts:
59
- user_history_memory.append(chunk.text)
60
-
61
- return "\n".join(user_history_memory)
57
+ response = manager.query_corpus(query, user_id)
58
+ log.info(f"User history got: {response=}")
59
+ user_history_memory = []
60
+ for chunk in response.contexts.contexts:
61
+ user_history_memory.append(chunk.text)
62
+
63
+ log.info(f"User history chunks: {user_history_memory}")
64
+
65
+ return "\n".join(user_history_memory)
66
+ except Exception as err:
67
+ log.error(f"Could not find user history due to error: {str(err)}")
68
+
69
+ return f"No user history available due to error: {str(err)}"
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sunholo
3
- Version: 0.83.5
3
+ Version: 0.84.0
4
4
  Summary: Large Language Model DevOps - a package to help deploy LLMs to the Cloud.
5
5
  Home-page: https://github.com/sunholo-data/sunholo-py
6
- Download-URL: https://github.com/sunholo-data/sunholo-py/archive/refs/tags/v0.83.5.tar.gz
6
+ Download-URL: https://github.com/sunholo-data/sunholo-py/archive/refs/tags/v0.84.0.tar.gz
7
7
  Author: Holosun ApS
8
8
  Author-email: multivac@sunholo.com
9
9
  License: Apache License, Version 2.0
@@ -21,7 +21,7 @@ License-File: LICENSE.txt
21
21
  Requires-Dist: google-auth
22
22
  Requires-Dist: ruamel.yaml
23
23
  Requires-Dist: langchain >=0.2.12
24
- Requires-Dist: langchain-experimental ==0.0.63
24
+ Requires-Dist: langchain-experimental >=0.0.61
25
25
  Requires-Dist: langchain-community >=0.2.11
26
26
  Provides-Extra: all
27
27
  Requires-Dist: asyncpg ; extra == 'all'
@@ -49,7 +49,7 @@ Requires-Dist: httpx ; extra == 'all'
49
49
  Requires-Dist: jsonschema ; extra == 'all'
50
50
  Requires-Dist: lancedb ; extra == 'all'
51
51
  Requires-Dist: langchain >=0.2.12 ; extra == 'all'
52
- Requires-Dist: llangchain-experimental >=0.0.61 ; extra == 'all'
52
+ Requires-Dist: langchain-experimental >=0.0.61 ; extra == 'all'
53
53
  Requires-Dist: langchain-community >=0.2.11 ; extra == 'all'
54
54
  Requires-Dist: langchain-openai >=0.1.20 ; extra == 'all'
55
55
  Requires-Dist: langchain-google-genai >=1.0.5 ; extra == 'all'
@@ -11,7 +11,7 @@ sunholo/agents/swagger.py,sha256=2tzGmpveUMmTREykZvVnDj3j295wyOMu7mUFDnXdY3c,106
11
11
  sunholo/agents/fastapi/__init__.py,sha256=S_pj4_bTUmDGoq_exaREHlOKThi0zTuGT0VZY0YfODQ,88
12
12
  sunholo/agents/fastapi/base.py,sha256=W-cyF8ZDUH40rc-c-Apw3-_8IIi2e4Y9qRtnoVnsc1Q,2521
13
13
  sunholo/agents/fastapi/qna_routes.py,sha256=lKHkXPmwltu9EH3RMwmD153-J6pE7kWQ4BhBlV3to-s,3864
14
- sunholo/agents/flask/__init__.py,sha256=uqfHNw2Ru3EJ4dJEcbp86h_lkquBQPMxZbjhV_xe3rs,72
14
+ sunholo/agents/flask/__init__.py,sha256=poJDKMr2qj8qMb99JqCvCPSiEt1tj2tLQ3hKW3f2aVw,107
15
15
  sunholo/agents/flask/base.py,sha256=FgSaCODyoTtlstJtsqlLPScdgRUtv9_plxftdzHdVFo,809
16
16
  sunholo/agents/flask/qna_routes.py,sha256=uwUD1yrzOPH27m2AXpiQrPk_2VfJOQOM6dAynOWQtoQ,22532
17
17
  sunholo/agents/flask/vac_routes.py,sha256=JHBrz9URmRzxoNAiqEeI-5qWyKfVSZ1Ix__1t19p6HI,19527
@@ -83,6 +83,7 @@ sunholo/gcs/download_folder.py,sha256=ijJTnS595JqZhBH8iHFErQilMbkuKgL-bnTCMLGuvl
83
83
  sunholo/gcs/download_url.py,sha256=q1NiJSvEhdNrmU5ZJ-sBCMC_J5CxzrajY8LRgdPOV_M,6130
84
84
  sunholo/gcs/metadata.py,sha256=oQLcXi4brsZ74aegWyC1JZmhlaEV270HS5_UWtAYYWE,898
85
85
  sunholo/invoke/__init__.py,sha256=bELcqIjzKvaupcIN5OQmDgGx_8jARtH9T6PCe8UgcvE,99
86
+ sunholo/invoke/async_class.py,sha256=J-qMgarhdi6nPQyOIFM5k0wF7nqr8aJGaz99-Ye6XGQ,3507
86
87
  sunholo/invoke/direct_vac_func.py,sha256=L_Gz7hEbZQqAZn2j5ehB-eIXmCEYmSZ7F95mjbYP9Nw,4489
87
88
  sunholo/invoke/invoke_vac_utils.py,sha256=sJc1edHTHMzMGXjji1N67c3iUaP7BmAL5nj82Qof63M,2053
88
89
  sunholo/langfuse/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -91,8 +92,8 @@ sunholo/langfuse/prompts.py,sha256=27BsVfihM6-h1jscbkGSO4HsATl-d4ZN6tcNCVztWoY,1
91
92
  sunholo/llamaindex/__init__.py,sha256=DlY_cHWCsVEV1C5WBgDdHRgOMlJc8pDoCRukUJ8PT9w,88
92
93
  sunholo/llamaindex/get_files.py,sha256=6rhXCDqQ_lrIapISQ_OYQDjiSATXvS_9m3qq53-oIl0,781
93
94
  sunholo/llamaindex/import_files.py,sha256=Bnic5wz8c61af9Kwq8KSrNBbc4imYnzMtBCb2jzSImI,6224
94
- sunholo/llamaindex/llamaindex_class.py,sha256=MYCgmJ2ebN0yrJbkshGIoaoX0pKi5yONLKbEPULDXRY,17049
95
- sunholo/llamaindex/user_history.py,sha256=SwBNDOU2hsAzOMVwDjXQsR3d8RPUZofKTlZV_pAraO8,1934
95
+ sunholo/llamaindex/llamaindex_class.py,sha256=wtMS97YMsfA2IWLTd5mzr73DV4_fi5I5GVD7AC4wVm0,17375
96
+ sunholo/llamaindex/user_history.py,sha256=ZtkecWuF9ORduyGB8kF8gP66bm9DdvCI-ZiK6Kt-cSE,2265
96
97
  sunholo/lookup/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
97
98
  sunholo/lookup/model_lookup.yaml,sha256=O7o-jP53MLA06C8pI-ILwERShO-xf6z_258wtpZBv6A,739
98
99
  sunholo/patches/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -134,9 +135,9 @@ sunholo/vertex/init.py,sha256=1OQwcPBKZYBTDPdyU7IM4X4OmiXLdsNV30C-fee2scQ,2875
134
135
  sunholo/vertex/memory_tools.py,sha256=q_phxgGX2TG2j2MXNULF2xGzQnQPENwjPN9nZ_A9Gh0,7526
135
136
  sunholo/vertex/safety.py,sha256=S9PgQT1O_BQAkcqauWncRJaydiP8Q_Jzmu9gxYfy1VA,2482
136
137
  sunholo/vertex/type_dict_to_json.py,sha256=uTzL4o9tJRao4u-gJOFcACgWGkBOtqACmb6ihvCErL8,4694
137
- sunholo-0.83.5.dist-info/LICENSE.txt,sha256=SdE3QjnD3GEmqqg9EX3TM9f7WmtOzqS1KJve8rhbYmU,11345
138
- sunholo-0.83.5.dist-info/METADATA,sha256=05IvbTEGbeGoW5dwFBd2IUAEBd7nFySYZcQConfSrLs,7413
139
- sunholo-0.83.5.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
140
- sunholo-0.83.5.dist-info/entry_points.txt,sha256=bZuN5AIHingMPt4Ro1b_T-FnQvZ3teBes-3OyO0asl4,49
141
- sunholo-0.83.5.dist-info/top_level.txt,sha256=wt5tadn5--5JrZsjJz2LceoUvcrIvxjHJe-RxuudxAk,8
142
- sunholo-0.83.5.dist-info/RECORD,,
138
+ sunholo-0.84.0.dist-info/LICENSE.txt,sha256=SdE3QjnD3GEmqqg9EX3TM9f7WmtOzqS1KJve8rhbYmU,11345
139
+ sunholo-0.84.0.dist-info/METADATA,sha256=YeMjnUjnqWzP1QNrPWTwDGjJ4WtmEm0OTgxAzuvP1ME,7412
140
+ sunholo-0.84.0.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
141
+ sunholo-0.84.0.dist-info/entry_points.txt,sha256=bZuN5AIHingMPt4Ro1b_T-FnQvZ3teBes-3OyO0asl4,49
142
+ sunholo-0.84.0.dist-info/top_level.txt,sha256=wt5tadn5--5JrZsjJz2LceoUvcrIvxjHJe-RxuudxAk,8
143
+ sunholo-0.84.0.dist-info/RECORD,,