sunholo 0.101.0__py3-none-any.whl → 0.101.2__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.
@@ -14,13 +14,16 @@ try:
14
14
  import proto
15
15
  from google.generativeai.types import RequestOptions
16
16
  from google.api_core import retry
17
+ from google.generativeai import ChatSession
17
18
  except ImportError:
18
19
  genai = None
20
+ ChatSession = None
19
21
 
20
22
  from .images import extract_gs_images_and_genai_upload
21
23
 
22
24
  if TYPE_CHECKING:
23
25
  from google.generativeai.protos import Part
26
+ from google.generativeai import ChatSession
24
27
 
25
28
 
26
29
 
@@ -369,8 +372,28 @@ class GenAIFunctionProcessor:
369
372
  log.info(f"Cleaning:\n{string}\n > to >\n{clean}")
370
373
 
371
374
  return clean
375
+
376
+ def convert_composite_to_native(self, value):
377
+ """
378
+ Recursively converts a proto MapComposite or RepeatedComposite object to native Python types.
379
+
380
+ Args:
381
+ value: The proto object, which could be a MapComposite, RepeatedComposite, or a primitive.
382
+
383
+ Returns:
384
+ The equivalent Python dictionary, list, or primitive type.
385
+ """
386
+ if isinstance(value, proto.marshal.collections.maps.MapComposite):
387
+ # Convert MapComposite to a dictionary, recursively processing its values
388
+ return {key: self.convert_composite_to_native(val) for key, val in value.items()}
389
+ elif isinstance(value, proto.marshal.collections.repeated.RepeatedComposite):
390
+ # Convert RepeatedComposite to a list, recursively processing its elements
391
+ return [self.convert_composite_to_native(item) for item in value]
392
+ else:
393
+ # If it's a primitive value, return it as is
394
+ return value
372
395
 
373
- def run_agent_loop(self, chat, content, callback=None, guardrail_max=10, loop_return=3):
396
+ def run_agent_loop(self, chat:ChatSession, content:list, callback=None, guardrail_max=10, loop_return=3):
374
397
  """
375
398
  Runs the agent loop, sending messages to the orchestrator, processing responses, and executing functions.
376
399
 
@@ -488,7 +511,9 @@ class GenAIFunctionProcessor:
488
511
  fn_result_json = None
489
512
  # Convert MapComposite to a standard Python dictionary
490
513
  if isinstance(fn_result, proto.marshal.collections.maps.MapComposite):
491
- fn_result_json = dict(fn_result)
514
+ fn_result_json = self.convert_composite_to_native(fn_result)
515
+ elif isinstance(fn_result, proto.marshal.collections.repeated.RepeatedComposite):
516
+ fn_result = self.convert_composite_to_native(fn_result)
492
517
  elif isinstance(fn_result, dict):
493
518
  fn_result_json = fn_result
494
519
  elif isinstance(fn_result, str):
@@ -6,17 +6,49 @@ def load_prompt_from_yaml(key, prefix="sunholo", load_from_file=False, f_string=
6
6
  """
7
7
  Returns a string you can use with prompts.
8
8
 
9
- Will first try to load from the Langfuse prompt library, if unavailable will look in promptConfig type file.
9
+ If load_from_file=False, by default it will try to load from Langfuse, if fails (which is laggy so not ideal) then load from file.
10
+
11
+ Prompts on Langfuse should be specified with a name with {prefix}-{key} e.g. "sunholo-hello"
12
+
13
+ Prompts in files will use yaml:
14
+
15
+ ```yaml
16
+ kind: promptConfig
17
+ apiVersion: v1
18
+ prompts:
19
+ sunholo:
20
+ hello: |
21
+ Say hello to {name}
22
+ ```
23
+
24
+ And load via utils.ConfigManager:
25
+
26
+ ```python
27
+ # equivalent to load_prompt_from_yaml("hello", load_from_file=True)
28
+ config = ConfigManager("sunholo")
29
+ config.promptConfig("hello")
30
+ ```
10
31
 
11
32
  If f_string is True will be in a Langchain style prompt e.g. { one brace }
12
- If f_string is False will be Langfuse style prompt e.g. {{ two braces }}
33
+ If f_string is False will be Langfuse style prompt e.g. {{ two braces }} - see https://langfuse.com/docs/prompts/get-started
13
34
 
14
35
  Example:
15
36
 
16
37
  ```python
17
38
  from sunholo.langfuse.prompts import load_prompt_from_yaml
18
- from langchain_core.prompts import PromptTemplate
19
-
39
+ # f_string
40
+ hello_template = load_prompt_from_yaml("hello")
41
+ hello_template.format(name="Bob")
42
+
43
+ #langfuse style
44
+ hello_template = load_prompt_from_yaml("hello", f_string=False)
45
+ hello_template.compile(name="Bob")
46
+
47
+ # if prompt not available on langfuse, will attempt to load from local promptConfig file
48
+ hello_template = load_prompt_from_yaml("hello", load_from_file=True)
49
+
50
+ ```
51
+
20
52
  """
21
53
  config = ConfigManager(prefix)
22
54
  if load_from_file:
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sunholo
3
- Version: 0.101.0
3
+ Version: 0.101.2
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.101.0.tar.gz
6
+ Download-URL: https://github.com/sunholo-data/sunholo-py/archive/refs/tags/v0.101.2.tar.gz
7
7
  Author: Holosun ApS
8
8
  Author-email: multivac@sunholo.com
9
9
  License: Apache License, Version 2.0
@@ -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=WaeO705mK0BOz1k7OwsGslw7qF1WiyE_zsueYt07vV8,1191
90
90
  sunholo/genai/init.py,sha256=yG8E67TduFCTQPELo83OJuWfjwTnGZsyACospahyEaY,687
91
- sunholo/genai/process_funcs_cls.py,sha256=VvbTjyGQ_dq0xiEUx-Zn0ZomKbKTZwuoWdiWeestRfM,27419
91
+ sunholo/genai/process_funcs_cls.py,sha256=krjhwruW-7OUR0gEOPC5Ew9KOoAoTWDMW5HfvpvuPNM,28755
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=Wkrv3exjN3aDQdI1Q4tv8I8xSloKgdz_LzGomayfLhw,7734
@@ -97,7 +97,7 @@ sunholo/invoke/invoke_vac_utils.py,sha256=sJc1edHTHMzMGXjji1N67c3iUaP7BmAL5nj82Q
97
97
  sunholo/langfuse/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
98
98
  sunholo/langfuse/callback.py,sha256=jl0SZsFS53uMW9DGeM9SOL_EsRZsba0wwFGLqKzu9_U,1684
99
99
  sunholo/langfuse/evals.py,sha256=fQBaC0dBTYfgCzyfv9QBRvUfc9f42lbwQAeZmynaHO8,3841
100
- sunholo/langfuse/prompts.py,sha256=3Zo-YX2YpZdKNAGKjlGePXb8t8FisA9BrraA6tO7RHM,1422
100
+ sunholo/langfuse/prompts.py,sha256=9TkmT2A-P4YRlk7sWz_EYk6yASxPKU8jhM7jAg9ND_Q,2330
101
101
  sunholo/llamaindex/__init__.py,sha256=DlY_cHWCsVEV1C5WBgDdHRgOMlJc8pDoCRukUJ8PT9w,88
102
102
  sunholo/llamaindex/get_files.py,sha256=6rhXCDqQ_lrIapISQ_OYQDjiSATXvS_9m3qq53-oIl0,781
103
103
  sunholo/llamaindex/import_files.py,sha256=Bnic5wz8c61af9Kwq8KSrNBbc4imYnzMtBCb2jzSImI,6224
@@ -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.101.0.dist-info/LICENSE.txt,sha256=SdE3QjnD3GEmqqg9EX3TM9f7WmtOzqS1KJve8rhbYmU,11345
151
- sunholo-0.101.0.dist-info/METADATA,sha256=f5ACnI-b0miaBTKmVuiOB6xgtIcwb9QXDq3s__-_3Aw,8312
152
- sunholo-0.101.0.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
153
- sunholo-0.101.0.dist-info/entry_points.txt,sha256=bZuN5AIHingMPt4Ro1b_T-FnQvZ3teBes-3OyO0asl4,49
154
- sunholo-0.101.0.dist-info/top_level.txt,sha256=wt5tadn5--5JrZsjJz2LceoUvcrIvxjHJe-RxuudxAk,8
155
- sunholo-0.101.0.dist-info/RECORD,,
150
+ sunholo-0.101.2.dist-info/LICENSE.txt,sha256=SdE3QjnD3GEmqqg9EX3TM9f7WmtOzqS1KJve8rhbYmU,11345
151
+ sunholo-0.101.2.dist-info/METADATA,sha256=Df6VGsfppMzyER5-llKTW2B9jBjY5SuIrivo2kZrcA4,8312
152
+ sunholo-0.101.2.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
153
+ sunholo-0.101.2.dist-info/entry_points.txt,sha256=bZuN5AIHingMPt4Ro1b_T-FnQvZ3teBes-3OyO0asl4,49
154
+ sunholo-0.101.2.dist-info/top_level.txt,sha256=wt5tadn5--5JrZsjJz2LceoUvcrIvxjHJe-RxuudxAk,8
155
+ sunholo-0.101.2.dist-info/RECORD,,