sunholo 0.104.5__py3-none-any.whl → 0.105.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.
@@ -618,7 +618,7 @@ if __name__ == "__main__":
618
618
  user_id = user_id,
619
619
  session_id = session_id,
620
620
  tags = tags,
621
- release = f"sunholo-v{package_version}"
621
+ release = package_version
622
622
  )
623
623
 
624
624
  def prep_vac(self, request, vector_name):
@@ -660,7 +660,12 @@ if __name__ == "__main__":
660
660
  raise ValueError(f"Unable to find vac_config for {vector_name} - {str(e)}")
661
661
 
662
662
  if trace:
663
- trace.update(input=data, metadata=vac_config.configs_by_kind)
663
+ this_vac_config = vac_config.configs_by_kind.get("vacConfig")
664
+ metadata_config=None
665
+ if this_vac_config:
666
+ metadata_config = this_vac_config.get(vector_name)
667
+
668
+ trace.update(input=data, metadata=metadata_config)
664
669
 
665
670
  user_input = data.pop('user_input').strip()
666
671
  stream_wait_time = data.pop('stream_wait_time', 7)
@@ -12,7 +12,7 @@ from collections import deque
12
12
  try:
13
13
  import google.generativeai as genai
14
14
  import proto
15
- from google.generativeai.types import RequestOptions
15
+ from google.generativeai.types import RequestOptions, GenerateContentResponse
16
16
  from google.api_core import retry
17
17
  from google.generativeai import ChatSession
18
18
  from google.api_core.exceptions import RetryError
@@ -441,11 +441,11 @@ class GenAIFunctionProcessor:
441
441
 
442
442
  log.info(f"== Start input content for loop [{guardrail}]\n ## Content: {content_parse}")
443
443
  this_text = "" # reset for this loop
444
- response = []
444
+ response = None
445
445
 
446
446
  try:
447
447
  token_queue.append("\n= Calling Agent =\n")
448
- response = chat.send_message(content, stream=True, request_options=RequestOptions(
448
+ response:GenerateContentResponse = chat.send_message(content, stream=True, request_options=RequestOptions(
449
449
  retry=retry.Retry(
450
450
  initial=10,
451
451
  multiplier=2,
@@ -465,19 +465,20 @@ class GenAIFunctionProcessor:
465
465
  token_queue.append(msg)
466
466
  break
467
467
 
468
- loop_metadata = response.usage_metadata
469
- if loop_metadata:
470
- usage_metadata = {
471
- "prompt_token_count": usage_metadata["prompt_token_count"] + (loop_metadata.prompt_token_count or 0),
472
- "candidates_token_count": usage_metadata["candidates_token_count"] + (loop_metadata.candidates_token_count or 0),
473
- "total_token_count": usage_metadata["total_token_count"] + (loop_metadata.total_token_count or 0),
474
- }
475
- token_queue.append((
476
- "\n-- Agent response -- "
477
- f"Loop tokens: [{loop_metadata.prompt_token_count}]/[{usage_metadata['prompt_token_count']}] "
478
- f"Session tokens: [{loop_metadata.total_token_count}]/[{usage_metadata['total_token_count']}] \n"
479
- ))
480
- loop_metadata = None
468
+ if response:
469
+ loop_metadata = response.usage_metadata
470
+ if loop_metadata:
471
+ usage_metadata = {
472
+ "prompt_token_count": usage_metadata["prompt_token_count"] + (loop_metadata.prompt_token_count or 0),
473
+ "candidates_token_count": usage_metadata["candidates_token_count"] + (loop_metadata.candidates_token_count or 0),
474
+ "total_token_count": usage_metadata["total_token_count"] + (loop_metadata.total_token_count or 0),
475
+ }
476
+ token_queue.append((
477
+ "\n-- Agent response -- "
478
+ f"Loop tokens: [{loop_metadata.prompt_token_count}]/[{usage_metadata['prompt_token_count']}] "
479
+ f"Session tokens: [{loop_metadata.total_token_count}]/[{usage_metadata['total_token_count']}] \n"
480
+ ))
481
+ loop_metadata = None
481
482
 
482
483
  for chunk in response:
483
484
  if not chunk:
@@ -87,25 +87,31 @@ def start_streaming_chat(question,
87
87
  break
88
88
  else:
89
89
  log.info(f"Stream has ended after {round(time.time() - first_start, 2)} seconds")
90
- log.info("Sending final full message plus sources...")
90
+
91
91
 
92
92
 
93
93
  # if you need it to stop it elsewhere use
94
94
  # stop_event.set()
95
95
  content_to_send = content_buffer.read()
96
96
  if content_to_send:
97
- log.info(f"==\n{content_to_send}")
97
+ log.info(f"==Flush==\n{content_to_send}")
98
98
  yield content_to_send
99
99
  content_buffer.clear()
100
100
 
101
101
  # Stop the stream thread
102
102
  chat_thread.join()
103
103
 
104
- # the json object with full response in 'answer' and the 'sources' array
105
- final_result = result_queue.get()
104
+ if kwargs.get("stream_only"):
105
+ log.info("stream_only so finishing now")
106
+ final_yield = ""
107
+ else:
108
+ log.info("Sending final full message plus sources...")
109
+ # the json object with full response in 'answer' and the 'sources' array
110
+ final_result = result_queue.get()
111
+ final_yield = parse_output(final_result)
106
112
 
107
113
  # parses out source_documents if not present etc.
108
- yield parse_output(final_result)
114
+ yield final_yield
109
115
 
110
116
  async def start_streaming_chat_async(question, vector_name, qna_func_async, chat_history=[], wait_time=2, timeout=120, **kwargs):
111
117
  """
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sunholo
3
- Version: 0.104.5
3
+ Version: 0.105.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.104.5.tar.gz
6
+ Download-URL: https://github.com/sunholo-data/sunholo-py/archive/refs/tags/v0.105.0.tar.gz
7
7
  Author: Holosun ApS
8
8
  Author-email: multivac@sunholo.com
9
9
  License: Apache License, Version 2.0
@@ -14,7 +14,7 @@ sunholo/agents/fastapi/qna_routes.py,sha256=lKHkXPmwltu9EH3RMwmD153-J6pE7kWQ4BhB
14
14
  sunholo/agents/flask/__init__.py,sha256=poJDKMr2qj8qMb99JqCvCPSiEt1tj2tLQ3hKW3f2aVw,107
15
15
  sunholo/agents/flask/base.py,sha256=HLz3Z5efWaewTwSFEM6JH48NA9otoJBoVFJlARGk9L8,788
16
16
  sunholo/agents/flask/qna_routes.py,sha256=uwUD1yrzOPH27m2AXpiQrPk_2VfJOQOM6dAynOWQtoQ,22532
17
- sunholo/agents/flask/vac_routes.py,sha256=z-9gqrYiyqt4rRKa6c5rGgwdfK9Z3fNfSjMwMS63xOw,28541
17
+ sunholo/agents/flask/vac_routes.py,sha256=mS_e2Kel-wCis4GAmxmn-trO76Q2jVzIx98p0H0P4sg,28723
18
18
  sunholo/archive/__init__.py,sha256=qNHWm5rGPVOlxZBZCpA1wTYPbalizRT7f8X4rs2t290,31
19
19
  sunholo/archive/archive.py,sha256=PxVfDtO2_2ZEEbnhXSCbXLdeoHoQVImo4y3Jr2XkCFY,1204
20
20
  sunholo/auth/__init__.py,sha256=TeP-OY0XGxYV_8AQcVGoh35bvyWhNUcMRfhuD5l44Sk,91
@@ -88,7 +88,7 @@ sunholo/gcs/metadata.py,sha256=oQLcXi4brsZ74aegWyC1JZmhlaEV270HS5_UWtAYYWE,898
88
88
  sunholo/genai/__init__.py,sha256=dBl6IA3-Fx6-Vx81r0XqxHlUq6WeW1iDX188dpChu8s,115
89
89
  sunholo/genai/images.py,sha256=EyjsDqt6XQw99pZUQamomCpMOoIah9bp3XY94WPU7Ms,1678
90
90
  sunholo/genai/init.py,sha256=yG8E67TduFCTQPELo83OJuWfjwTnGZsyACospahyEaY,687
91
- sunholo/genai/process_funcs_cls.py,sha256=6NZiYd9VWEzRN_-25PvOpBnQcfuJfWMuqi2hgAYm9ls,29530
91
+ sunholo/genai/process_funcs_cls.py,sha256=aO23nFLYCJEQ1ZR1rWefSNaqpUg4KXJGIua_ouDVR8E,29658
92
92
  sunholo/genai/safety.py,sha256=mkFDO_BeEgiKjQd9o2I4UxB6XI7a9U-oOFjZ8LGRUC4,1238
93
93
  sunholo/invoke/__init__.py,sha256=o1RhwBGOtVK0MIdD55fAIMCkJsxTksi8GD5uoqVKI-8,184
94
94
  sunholo/invoke/async_class.py,sha256=G8vD2H94fpBc37mSJSQODEKJ67P2mPQEHabtDaLOvxE,8033
@@ -119,7 +119,7 @@ sunholo/streaming/__init__.py,sha256=MpbydI2UYo_adttPQFkxNM33b-QRyNEbrKJx0C2AGPc
119
119
  sunholo/streaming/content_buffer.py,sha256=0LHMwH4ctq5kjhIgMFNH0bA1RL0jMISlLVzzLcFrvv4,12766
120
120
  sunholo/streaming/langserve.py,sha256=hi7q8WY8DPKrALl9m_dOMxWOdE-iEuk7YW05SVDFIX8,6514
121
121
  sunholo/streaming/stream_lookup.py,sha256=hYg1DbdSE_QNJ8ZB-ynXJlWgvFjrGvwoUsGJu_E0pRQ,360
122
- sunholo/streaming/streaming.py,sha256=S4GzVNol3J_8tkzXodvkcR-THiTGnIKYj40NtrBhtL4,16459
122
+ sunholo/streaming/streaming.py,sha256=gSxLuwK-5-t5D1AjcHf838BY-L4jvdkdn_xePl-DK3o,16635
123
123
  sunholo/summarise/__init__.py,sha256=MZk3dblUMODcPb1crq4v-Z508NrFIpkSWNf9FIO8BcU,38
124
124
  sunholo/summarise/summarise.py,sha256=95A-6PXFGanjona8DvZPnnIHLbzZ2ip5hO0wOAJQhfw,3791
125
125
  sunholo/terraform/__init__.py,sha256=yixxEltc3n9UpZaVi05GlgS-YRq_DVGjUc37I9ajeP4,76
@@ -147,9 +147,9 @@ sunholo/vertex/init.py,sha256=1OQwcPBKZYBTDPdyU7IM4X4OmiXLdsNV30C-fee2scQ,2875
147
147
  sunholo/vertex/memory_tools.py,sha256=tBZxqVZ4InTmdBvLlOYwoSEWu4-kGquc-gxDwZCC4FA,7667
148
148
  sunholo/vertex/safety.py,sha256=S9PgQT1O_BQAkcqauWncRJaydiP8Q_Jzmu9gxYfy1VA,2482
149
149
  sunholo/vertex/type_dict_to_json.py,sha256=uTzL4o9tJRao4u-gJOFcACgWGkBOtqACmb6ihvCErL8,4694
150
- sunholo-0.104.5.dist-info/LICENSE.txt,sha256=SdE3QjnD3GEmqqg9EX3TM9f7WmtOzqS1KJve8rhbYmU,11345
151
- sunholo-0.104.5.dist-info/METADATA,sha256=V3lxW5D4BUNeU7gySWFPnxVHG1HHdXtqAR-1MLbEN_M,8312
152
- sunholo-0.104.5.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
153
- sunholo-0.104.5.dist-info/entry_points.txt,sha256=bZuN5AIHingMPt4Ro1b_T-FnQvZ3teBes-3OyO0asl4,49
154
- sunholo-0.104.5.dist-info/top_level.txt,sha256=wt5tadn5--5JrZsjJz2LceoUvcrIvxjHJe-RxuudxAk,8
155
- sunholo-0.104.5.dist-info/RECORD,,
150
+ sunholo-0.105.0.dist-info/LICENSE.txt,sha256=SdE3QjnD3GEmqqg9EX3TM9f7WmtOzqS1KJve8rhbYmU,11345
151
+ sunholo-0.105.0.dist-info/METADATA,sha256=VJ8EeXPxQ19YS2iUjsBY5W5V-4vBdxtHwowutoeMMiE,8312
152
+ sunholo-0.105.0.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
153
+ sunholo-0.105.0.dist-info/entry_points.txt,sha256=bZuN5AIHingMPt4Ro1b_T-FnQvZ3teBes-3OyO0asl4,49
154
+ sunholo-0.105.0.dist-info/top_level.txt,sha256=wt5tadn5--5JrZsjJz2LceoUvcrIvxjHJe-RxuudxAk,8
155
+ sunholo-0.105.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.1.0)
2
+ Generator: setuptools (75.2.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5