sunholo 0.95.2__py3-none-any.whl → 0.95.4__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.
- sunholo/agents/route.py +2 -2
- sunholo/genai/process_funcs_cls.py +6 -6
- sunholo/invoke/async_class.py +7 -19
- sunholo/streaming/streaming.py +10 -0
- sunholo/vertex/memory_tools.py +3 -5
- {sunholo-0.95.2.dist-info → sunholo-0.95.4.dist-info}/METADATA +2 -2
- {sunholo-0.95.2.dist-info → sunholo-0.95.4.dist-info}/RECORD +11 -11
- {sunholo-0.95.2.dist-info → sunholo-0.95.4.dist-info}/LICENSE.txt +0 -0
- {sunholo-0.95.2.dist-info → sunholo-0.95.4.dist-info}/WHEEL +0 -0
- {sunholo-0.95.2.dist-info → sunholo-0.95.4.dist-info}/entry_points.txt +0 -0
- {sunholo-0.95.2.dist-info → sunholo-0.95.4.dist-info}/top_level.txt +0 -0
sunholo/agents/route.py
CHANGED
|
@@ -65,14 +65,14 @@ def route_endpoint(vector_name=None, method = 'post', override_endpoint=None, co
|
|
|
65
65
|
|
|
66
66
|
agents_config = config.agentConfig(agent_type)
|
|
67
67
|
|
|
68
|
-
log.
|
|
68
|
+
log.debug(f"agents_config: {agents_config}")
|
|
69
69
|
if method not in agents_config:
|
|
70
70
|
raise ValueError(f"Invalid method '{method}' for agent configuration.")
|
|
71
71
|
|
|
72
72
|
# 'post' or 'get'
|
|
73
73
|
endpoints_config = agents_config[method]
|
|
74
74
|
|
|
75
|
-
log.
|
|
75
|
+
log.debug(f"endpoints_config: {endpoints_config}")
|
|
76
76
|
# Replace placeholders in the config
|
|
77
77
|
endpoints = {}
|
|
78
78
|
for key, value in endpoints_config.items():
|
|
@@ -351,7 +351,7 @@ class GenAIFunctionProcessor:
|
|
|
351
351
|
log.error(f"Error initializing model: {str(err)}")
|
|
352
352
|
return None
|
|
353
353
|
|
|
354
|
-
def run_agent_loop(self, chat, content, callback, guardrail_max=10):
|
|
354
|
+
def run_agent_loop(self, chat, content, callback, guardrail_max=10, loop_return=3):
|
|
355
355
|
"""
|
|
356
356
|
Runs the agent loop, sending messages to the orchestrator, processing responses, and executing functions.
|
|
357
357
|
|
|
@@ -360,12 +360,13 @@ class GenAIFunctionProcessor:
|
|
|
360
360
|
content: The initial content to send to the agent.
|
|
361
361
|
callback: The callback object for handling intermediate responses.
|
|
362
362
|
guardrail_max (int): The maximum number of iterations for the loop.
|
|
363
|
+
loop_return (int): The number of last loop iterations to return. Default 3 will return last 3 iterations. If loop_return > guardrail_max then all iterations are returned.
|
|
363
364
|
|
|
364
365
|
Returns:
|
|
365
366
|
tuple: (big_text, usage_metadata) from the loop execution.
|
|
366
367
|
"""
|
|
367
368
|
guardrail = 0
|
|
368
|
-
|
|
369
|
+
big_result = []
|
|
369
370
|
usage_metadata = {
|
|
370
371
|
"prompt_token_count": 0,
|
|
371
372
|
"candidates_token_count": 0,
|
|
@@ -422,7 +423,6 @@ class GenAIFunctionProcessor:
|
|
|
422
423
|
if hasattr(chunk, 'text') and isinstance(chunk.text, str):
|
|
423
424
|
token = chunk.text
|
|
424
425
|
token_queue.append(token)
|
|
425
|
-
big_text += token
|
|
426
426
|
this_text += token
|
|
427
427
|
else:
|
|
428
428
|
log.info("skipping chunk with no text")
|
|
@@ -486,18 +486,17 @@ class GenAIFunctionProcessor:
|
|
|
486
486
|
else:
|
|
487
487
|
token += f"{fn_result}\n--- end ---\n"
|
|
488
488
|
|
|
489
|
-
big_text += token
|
|
490
489
|
this_text += token
|
|
491
490
|
token_queue.append(token)
|
|
492
491
|
else:
|
|
493
492
|
token = "\nNo function executions were found\n"
|
|
494
493
|
token_queue.append(token)
|
|
495
|
-
big_text += token
|
|
496
494
|
this_text += token
|
|
497
495
|
|
|
498
496
|
if this_text:
|
|
499
497
|
content.append(f"Agent: {this_text}")
|
|
500
498
|
log.info(f"[{guardrail}] Updated content:\n{this_text}")
|
|
499
|
+
big_result.append(this_text)
|
|
501
500
|
else:
|
|
502
501
|
log.warning(f"[{guardrail}] No content created this loop")
|
|
503
502
|
content.append(f"Agent: No response was found for loop [{guardrail}]")
|
|
@@ -523,7 +522,8 @@ class GenAIFunctionProcessor:
|
|
|
523
522
|
callback.on_llm_new_token(token=token)
|
|
524
523
|
|
|
525
524
|
usage_metadata["functions_called"] = functions_called
|
|
526
|
-
|
|
525
|
+
|
|
526
|
+
big_text = "\n".join(big_result[loop_return:])
|
|
527
527
|
|
|
528
528
|
return big_text, usage_metadata
|
|
529
529
|
|
sunholo/invoke/async_class.py
CHANGED
|
@@ -39,17 +39,13 @@ class AsyncTaskRunner:
|
|
|
39
39
|
async def _task_wrapper(self, name: str, func: Callable[..., Any], args: Any) -> Any:
|
|
40
40
|
"""Wraps the task function to process its output and handle retries."""
|
|
41
41
|
async def run_func():
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
output = ''
|
|
46
|
-
async for chunk in gen:
|
|
47
|
-
output += chunk
|
|
48
|
-
return output
|
|
42
|
+
if asyncio.iscoroutinefunction(func):
|
|
43
|
+
# If the function is async, await it
|
|
44
|
+
return await func(*args)
|
|
49
45
|
else:
|
|
50
|
-
# If it
|
|
51
|
-
return await
|
|
52
|
-
|
|
46
|
+
# If the function is sync, run it in a thread to prevent blocking
|
|
47
|
+
return await asyncio.to_thread(func, *args)
|
|
48
|
+
|
|
53
49
|
if self.retry_enabled:
|
|
54
50
|
retry_kwargs = {
|
|
55
51
|
'wait': wait_random_exponential(multiplier=1, max=60),
|
|
@@ -65,12 +61,4 @@ class AsyncTaskRunner:
|
|
|
65
61
|
return await run_func()
|
|
66
62
|
except Exception as e:
|
|
67
63
|
log.error(f"Error in task {name}: {e}\n{traceback.format_exc()}")
|
|
68
|
-
raise
|
|
69
|
-
|
|
70
|
-
def _log_results(self, results: List[Any]):
|
|
71
|
-
"""Logs the results of the task executions."""
|
|
72
|
-
for result in results:
|
|
73
|
-
if isinstance(result, Exception):
|
|
74
|
-
log.error(f"Task resulted in an error: {result}")
|
|
75
|
-
else:
|
|
76
|
-
log.info(f"Task completed successfully: {result}")
|
|
64
|
+
raise
|
sunholo/streaming/streaming.py
CHANGED
|
@@ -175,6 +175,16 @@ async def start_streaming_chat_async(question, vector_name, qna_func_async, chat
|
|
|
175
175
|
# Run start_chat asynchronously
|
|
176
176
|
chat_task = asyncio.create_task(start_chat())
|
|
177
177
|
|
|
178
|
+
# Allow the event loop to process the scheduled tasks
|
|
179
|
+
await asyncio.sleep(0)
|
|
180
|
+
|
|
181
|
+
# Read and yield any initial content from the content buffer
|
|
182
|
+
content_to_send = content_buffer.read()
|
|
183
|
+
if content_to_send:
|
|
184
|
+
log.info(f"Initial content: {content_to_send}")
|
|
185
|
+
yield content_to_send
|
|
186
|
+
content_buffer.clear()
|
|
187
|
+
|
|
178
188
|
start = time.time()
|
|
179
189
|
|
|
180
190
|
while not chat_callback_handler.stream_finished.is_set() and not stop_event.is_set():
|
sunholo/vertex/memory_tools.py
CHANGED
|
@@ -174,15 +174,11 @@ def print_grounding_response(response):
|
|
|
174
174
|
markdown_text += (
|
|
175
175
|
f"\n**Web Search Queries:** {grounding_metadata.web_search_queries}\n"
|
|
176
176
|
)
|
|
177
|
-
if grounding_metadata.search_entry_point:
|
|
178
|
-
markdown_text += f"\n**Search Entry Point:**\n {grounding_metadata.search_entry_point.rendered_content}\n"
|
|
179
177
|
elif grounding_metadata.retrieval_queries:
|
|
180
178
|
markdown_text += (
|
|
181
179
|
f"\n**Retrieval Queries:** {grounding_metadata.retrieval_queries}\n"
|
|
182
180
|
)
|
|
183
181
|
|
|
184
|
-
markdown_text += "### Grounding Chunks\n"
|
|
185
|
-
|
|
186
182
|
for index, grounding_chunk in enumerate(
|
|
187
183
|
grounding_metadata.grounding_chunks, start=1
|
|
188
184
|
):
|
|
@@ -190,7 +186,9 @@ def print_grounding_response(response):
|
|
|
190
186
|
if not context:
|
|
191
187
|
print(f"Skipping Grounding Chunk {grounding_chunk}")
|
|
192
188
|
continue
|
|
189
|
+
markdown_text += "### Grounding Chunks\n"
|
|
193
190
|
|
|
194
191
|
markdown_text += f"{index}. [{context.title}]({context.uri})\n"
|
|
195
192
|
|
|
196
|
-
return markdown_text
|
|
193
|
+
return {"markdown_text": markdown_text,
|
|
194
|
+
"search_entry_point": grounding_metadata.search_entry_point.rendered_content if grounding_metadata.search_entry_point else ""}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: sunholo
|
|
3
|
-
Version: 0.95.
|
|
3
|
+
Version: 0.95.4
|
|
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.95.
|
|
6
|
+
Download-URL: https://github.com/sunholo-data/sunholo-py/archive/refs/tags/v0.95.4.tar.gz
|
|
7
7
|
Author: Holosun ApS
|
|
8
8
|
Author-email: multivac@sunholo.com
|
|
9
9
|
License: Apache License, Version 2.0
|
|
@@ -5,7 +5,7 @@ sunholo/agents/chat_history.py,sha256=Gph_CdlP2otYnNdR1q1Umyyyvcad2F6K3LxU5yBQ9l
|
|
|
5
5
|
sunholo/agents/dispatch_to_qa.py,sha256=Z2q0ygYxfgBr-EGydq_H5y4Y-bKlY4ZCBCwkGpYwjFY,8766
|
|
6
6
|
sunholo/agents/langserve.py,sha256=C46ph2mnygr6bdHijYWYyfQDI9ylAF0_9Kx2PfcCJpU,4414
|
|
7
7
|
sunholo/agents/pubsub.py,sha256=TscZN_6am6DfaQkC-Yl18ZIBOoLE-0nDSiil6GpQEh4,1344
|
|
8
|
-
sunholo/agents/route.py,sha256=
|
|
8
|
+
sunholo/agents/route.py,sha256=mV8tGABbSqcg3PQL02MgQOs41gKEHLMyIJJJcTuFdbE,2988
|
|
9
9
|
sunholo/agents/special_commands.py,sha256=YhN8_E4cGZVvagN5_fouaxZiVbxr7PEhSzoFcvTKH54,6501
|
|
10
10
|
sunholo/agents/swagger.py,sha256=2tzGmpveUMmTREykZvVnDj3j295wyOMu7mUFDnXdY3c,10671
|
|
11
11
|
sunholo/agents/fastapi/__init__.py,sha256=S_pj4_bTUmDGoq_exaREHlOKThi0zTuGT0VZY0YfODQ,88
|
|
@@ -86,10 +86,10 @@ sunholo/gcs/download_url.py,sha256=q1NiJSvEhdNrmU5ZJ-sBCMC_J5CxzrajY8LRgdPOV_M,6
|
|
|
86
86
|
sunholo/gcs/metadata.py,sha256=oQLcXi4brsZ74aegWyC1JZmhlaEV270HS5_UWtAYYWE,898
|
|
87
87
|
sunholo/genai/__init__.py,sha256=dBl6IA3-Fx6-Vx81r0XqxHlUq6WeW1iDX188dpChu8s,115
|
|
88
88
|
sunholo/genai/init.py,sha256=yG8E67TduFCTQPELo83OJuWfjwTnGZsyACospahyEaY,687
|
|
89
|
-
sunholo/genai/process_funcs_cls.py,sha256=
|
|
89
|
+
sunholo/genai/process_funcs_cls.py,sha256=OCLa_yPjVlE7wY1v54SY0M6b5lpU2l3guRHb-qYOk2A,24359
|
|
90
90
|
sunholo/genai/safety.py,sha256=mkFDO_BeEgiKjQd9o2I4UxB6XI7a9U-oOFjZ8LGRUC4,1238
|
|
91
91
|
sunholo/invoke/__init__.py,sha256=VOpsfhNf98az3at7bMaY1Fiw4UIZAS6zMmSqWd6_ksI,141
|
|
92
|
-
sunholo/invoke/async_class.py,sha256=
|
|
92
|
+
sunholo/invoke/async_class.py,sha256=uvCP8ekUCfTRWk7xwofTzRqFykMAwrRZ4Ce_YUR6PVs,2820
|
|
93
93
|
sunholo/invoke/direct_vac_func.py,sha256=fuTJlH5PsqWhN_yVMaWisHCTZU1JEUz8I8yVbWsNUFE,4268
|
|
94
94
|
sunholo/invoke/invoke_vac_utils.py,sha256=sJc1edHTHMzMGXjji1N67c3iUaP7BmAL5nj82Qof63M,2053
|
|
95
95
|
sunholo/langfuse/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -117,7 +117,7 @@ sunholo/streaming/__init__.py,sha256=MpbydI2UYo_adttPQFkxNM33b-QRyNEbrKJx0C2AGPc
|
|
|
117
117
|
sunholo/streaming/content_buffer.py,sha256=HLj-EJcCxxFwPcEZ4Xu3Ns0tDT6awkTe5QY9S7bMnjg,9162
|
|
118
118
|
sunholo/streaming/langserve.py,sha256=hi7q8WY8DPKrALl9m_dOMxWOdE-iEuk7YW05SVDFIX8,6514
|
|
119
119
|
sunholo/streaming/stream_lookup.py,sha256=hYg1DbdSE_QNJ8ZB-ynXJlWgvFjrGvwoUsGJu_E0pRQ,360
|
|
120
|
-
sunholo/streaming/streaming.py,sha256=
|
|
120
|
+
sunholo/streaming/streaming.py,sha256=Z_M6rn6XZUMfQggiQ79dw5HD7xaodvq0UGS34C5dHbQ,16549
|
|
121
121
|
sunholo/summarise/__init__.py,sha256=MZk3dblUMODcPb1crq4v-Z508NrFIpkSWNf9FIO8BcU,38
|
|
122
122
|
sunholo/summarise/summarise.py,sha256=95A-6PXFGanjona8DvZPnnIHLbzZ2ip5hO0wOAJQhfw,3791
|
|
123
123
|
sunholo/terraform/__init__.py,sha256=yixxEltc3n9UpZaVi05GlgS-YRq_DVGjUc37I9ajeP4,76
|
|
@@ -141,12 +141,12 @@ sunholo/vertex/extensions_call.py,sha256=QeQbL3aAHlc4_-SynOzooZ_3xkQWAlcgNmFBSwL
|
|
|
141
141
|
sunholo/vertex/extensions_class.py,sha256=2QGW28lNjoMEnaoVb3QcqEDwphclIsZthnpLUi5_Ivo,21033
|
|
142
142
|
sunholo/vertex/genai_functions.py,sha256=2z6grM9H0Z79Yzx88l8mE1wXck3bRa0TWvnqZZ9ifDc,2051
|
|
143
143
|
sunholo/vertex/init.py,sha256=1OQwcPBKZYBTDPdyU7IM4X4OmiXLdsNV30C-fee2scQ,2875
|
|
144
|
-
sunholo/vertex/memory_tools.py,sha256=
|
|
144
|
+
sunholo/vertex/memory_tools.py,sha256=ZirFbS7EKxQaoRmOrb4BnG6jPJ83wt43N8M4zTVbutU,7717
|
|
145
145
|
sunholo/vertex/safety.py,sha256=S9PgQT1O_BQAkcqauWncRJaydiP8Q_Jzmu9gxYfy1VA,2482
|
|
146
146
|
sunholo/vertex/type_dict_to_json.py,sha256=uTzL4o9tJRao4u-gJOFcACgWGkBOtqACmb6ihvCErL8,4694
|
|
147
|
-
sunholo-0.95.
|
|
148
|
-
sunholo-0.95.
|
|
149
|
-
sunholo-0.95.
|
|
150
|
-
sunholo-0.95.
|
|
151
|
-
sunholo-0.95.
|
|
152
|
-
sunholo-0.95.
|
|
147
|
+
sunholo-0.95.4.dist-info/LICENSE.txt,sha256=SdE3QjnD3GEmqqg9EX3TM9f7WmtOzqS1KJve8rhbYmU,11345
|
|
148
|
+
sunholo-0.95.4.dist-info/METADATA,sha256=0uNENTJHgisWBlLoAF-E2HpFxgxWiuAhxpJ9Tw9-LbE,7889
|
|
149
|
+
sunholo-0.95.4.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
|
|
150
|
+
sunholo-0.95.4.dist-info/entry_points.txt,sha256=bZuN5AIHingMPt4Ro1b_T-FnQvZ3teBes-3OyO0asl4,49
|
|
151
|
+
sunholo-0.95.4.dist-info/top_level.txt,sha256=wt5tadn5--5JrZsjJz2LceoUvcrIvxjHJe-RxuudxAk,8
|
|
152
|
+
sunholo-0.95.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|