sunholo 0.84.5__py3-none-any.whl → 0.84.7__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/genai/__init__.py CHANGED
@@ -0,0 +1,2 @@
1
+ from .process_funcs_cls import GenAIFunctionProcessor
2
+ from .safety import genai_safety
@@ -28,24 +28,21 @@ class GenAIFunctionProcessor:
28
28
  funcs (dict): A dictionary of function names mapped to their implementations.
29
29
 
30
30
  Example usage:
31
- # Subclassing GenAIFunctionProcessor for a specific application (e.g., AlloyDB)
32
- class AlloyDBFunctionProcessor(GenAIFunctionProcessor):
33
- def construct_tools(self) -> dict:
34
- # Implement function mapping specific to AlloyDB
35
- ...
31
+ ```python
32
+ class AlloyDBFunctionProcessor(GenAIFunctionProcessor):
33
+ def construct_tools(self) -> dict:
34
+ ...
36
35
 
37
- # Creating an instance of the subclass and using it
38
- config = ConfigManager()
39
- alloydb_processor = AlloyDBFunctionProcessor(config)
36
+ config = ConfigManager()
37
+ alloydb_processor = AlloyDBFunctionProcessor(config)
40
38
 
41
- # Processing functions based on a generative AI response
42
- results = alloydb_processor.process_funcs(full_response)
39
+ results = alloydb_processor.process_funcs(full_response)
43
40
 
44
- # Getting the configured model
45
- alloydb_model = alloydb_processor.get_model(
46
- model_name="gemini-1.5-pro",
47
- system_instruction="You are a helpful AlloyDB agent that helps users search and extract documents from the database."
48
- )
41
+ alloydb_model = alloydb_processor.get_model(
42
+ model_name="gemini-1.5-pro",
43
+ system_instruction="You are a helpful AlloyDB agent that helps users search and extract documents from the database."
44
+ )
45
+ ```
49
46
  """
50
47
 
51
48
  def __init__(self, config: ConfigManager):
@@ -60,6 +57,7 @@ class GenAIFunctionProcessor:
60
57
 
61
58
  self.config = config
62
59
  self.funcs = self.construct_tools()
60
+ self.model_name = config.vacConfig("model") or "gemini-1.5-flash"
63
61
  self._validate_functions()
64
62
 
65
63
  def construct_tools(self) -> dict:
@@ -93,7 +91,7 @@ class GenAIFunctionProcessor:
93
91
  log.error(f"Function {func_name} is missing a docstring.")
94
92
  raise ValueError(f"Function {func_name} must have a docstring to be used as a genai tool.")
95
93
 
96
- def process_funcs(self, full_response, output_parts=True) -> list[Part] | str:
94
+ def process_funcs(self, full_response, output_parts=True) -> list['Part'] | str:
97
95
  """
98
96
  Processes the functions based on the full_response from the generative model.
99
97
 
@@ -109,7 +107,9 @@ class GenAIFunctionProcessor:
109
107
  list[Part] | str: A list of Part objects or a formatted string with the results.
110
108
 
111
109
  Example usage:
112
- results = alloydb_processor.process_funcs(full_response)
110
+ ```python
111
+ results = alloydb_processor.process_funcs(full_response)
112
+ ```
113
113
  """
114
114
  api_requests_and_responses = []
115
115
 
@@ -164,7 +164,7 @@ class GenAIFunctionProcessor:
164
164
 
165
165
  return strings
166
166
 
167
- def get_model(self, model_name: str, system_instruction: str, generation_config=None):
167
+ def get_model(self, system_instruction: str, generation_config=None, model_name: str=None):
168
168
  """
169
169
  Constructs and returns the generative AI model configured with the tools.
170
170
 
@@ -180,10 +180,12 @@ class GenAIFunctionProcessor:
180
180
  GenerativeModel: An instance of the GenerativeModel configured with the provided tools.
181
181
 
182
182
  Example usage:
183
- alloydb_model = alloydb_processor.get_model(
184
- model_name="gemini-1.5-pro",
185
- system_instruction="You are a helpful AlloyDB agent that helps users search and extract documents from the database."
186
- )
183
+ ```python
184
+ alloydb_model = alloydb_processor.get_model(
185
+ model_name="gemini-1.5-pro",
186
+ system_instruction="You are a helpful AlloyDB agent that helps users search and extract documents from the database."
187
+ )
188
+ ```
187
189
  """
188
190
  if generation_config is None:
189
191
  generation_config = {
@@ -196,7 +198,7 @@ class GenAIFunctionProcessor:
196
198
 
197
199
  try:
198
200
  model = genai.GenerativeModel(
199
- model_name=model_name,
201
+ model_name=model_name or self.model_name,
200
202
  tools=tools,
201
203
  generation_config=generation_config,
202
204
  safety_settings=genai_safety(),
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sunholo
3
- Version: 0.84.5
3
+ Version: 0.84.7
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.84.5.tar.gz
6
+ Download-URL: https://github.com/sunholo-data/sunholo-py/archive/refs/tags/v0.84.7.tar.gz
7
7
  Author: Holosun ApS
8
8
  Author-email: multivac@sunholo.com
9
9
  License: Apache License, Version 2.0
@@ -82,8 +82,8 @@ sunholo/gcs/add_file.py,sha256=TRbdEd3j-lFnyC7kqs5IWEPMPlDMFLR68fdTWga06Wo,8096
82
82
  sunholo/gcs/download_folder.py,sha256=ijJTnS595JqZhBH8iHFErQilMbkuKgL-bnTCMLGuvlA,1614
83
83
  sunholo/gcs/download_url.py,sha256=q1NiJSvEhdNrmU5ZJ-sBCMC_J5CxzrajY8LRgdPOV_M,6130
84
84
  sunholo/gcs/metadata.py,sha256=oQLcXi4brsZ74aegWyC1JZmhlaEV270HS5_UWtAYYWE,898
85
- sunholo/genai/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
86
- sunholo/genai/process_funcs_cls.py,sha256=mmbBlUjGbxvx8paf0sLa98fbboCoLwaSEjQV5R44DA8,8345
85
+ sunholo/genai/__init__.py,sha256=o2c17UbgzIDxNKKF8deCLoctNpatAYgm9Cf9XDfpqvg,87
86
+ sunholo/genai/process_funcs_cls.py,sha256=h0W767nXrwPesrc9iDEJ1bzesvXeze7YV8U7cASkKdc,8150
87
87
  sunholo/genai/safety.py,sha256=mkFDO_BeEgiKjQd9o2I4UxB6XI7a9U-oOFjZ8LGRUC4,1238
88
88
  sunholo/invoke/__init__.py,sha256=bELcqIjzKvaupcIN5OQmDgGx_8jARtH9T6PCe8UgcvE,99
89
89
  sunholo/invoke/async_class.py,sha256=J-qMgarhdi6nPQyOIFM5k0wF7nqr8aJGaz99-Ye6XGQ,3507
@@ -138,9 +138,9 @@ sunholo/vertex/init.py,sha256=1OQwcPBKZYBTDPdyU7IM4X4OmiXLdsNV30C-fee2scQ,2875
138
138
  sunholo/vertex/memory_tools.py,sha256=q_phxgGX2TG2j2MXNULF2xGzQnQPENwjPN9nZ_A9Gh0,7526
139
139
  sunholo/vertex/safety.py,sha256=S9PgQT1O_BQAkcqauWncRJaydiP8Q_Jzmu9gxYfy1VA,2482
140
140
  sunholo/vertex/type_dict_to_json.py,sha256=uTzL4o9tJRao4u-gJOFcACgWGkBOtqACmb6ihvCErL8,4694
141
- sunholo-0.84.5.dist-info/LICENSE.txt,sha256=SdE3QjnD3GEmqqg9EX3TM9f7WmtOzqS1KJve8rhbYmU,11345
142
- sunholo-0.84.5.dist-info/METADATA,sha256=xXnKIJEmFg5fMhGrdA5Sc3cbyaUdJkLG8cxCDAVdH0A,7412
143
- sunholo-0.84.5.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
144
- sunholo-0.84.5.dist-info/entry_points.txt,sha256=bZuN5AIHingMPt4Ro1b_T-FnQvZ3teBes-3OyO0asl4,49
145
- sunholo-0.84.5.dist-info/top_level.txt,sha256=wt5tadn5--5JrZsjJz2LceoUvcrIvxjHJe-RxuudxAk,8
146
- sunholo-0.84.5.dist-info/RECORD,,
141
+ sunholo-0.84.7.dist-info/LICENSE.txt,sha256=SdE3QjnD3GEmqqg9EX3TM9f7WmtOzqS1KJve8rhbYmU,11345
142
+ sunholo-0.84.7.dist-info/METADATA,sha256=7k9YTlJrqeB25j52O1Qr3kCfTAmu2hy5W_Tn62IepEE,7412
143
+ sunholo-0.84.7.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
144
+ sunholo-0.84.7.dist-info/entry_points.txt,sha256=bZuN5AIHingMPt4Ro1b_T-FnQvZ3teBes-3OyO0asl4,49
145
+ sunholo-0.84.7.dist-info/top_level.txt,sha256=wt5tadn5--5JrZsjJz2LceoUvcrIvxjHJe-RxuudxAk,8
146
+ sunholo-0.84.7.dist-info/RECORD,,