sunholo 0.85.3__py3-none-any.whl → 0.86.1__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 +1 -0
- sunholo/genai/init.py +18 -0
- sunholo/genai/process_funcs_cls.py +11 -2
- {sunholo-0.85.3.dist-info → sunholo-0.86.1.dist-info}/METADATA +2 -2
- {sunholo-0.85.3.dist-info → sunholo-0.86.1.dist-info}/RECORD +9 -8
- {sunholo-0.85.3.dist-info → sunholo-0.86.1.dist-info}/LICENSE.txt +0 -0
- {sunholo-0.85.3.dist-info → sunholo-0.86.1.dist-info}/WHEEL +0 -0
- {sunholo-0.85.3.dist-info → sunholo-0.86.1.dist-info}/entry_points.txt +0 -0
- {sunholo-0.85.3.dist-info → sunholo-0.86.1.dist-info}/top_level.txt +0 -0
sunholo/genai/__init__.py
CHANGED
sunholo/genai/init.py
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import os
|
|
2
|
+
|
|
3
|
+
def init_genai():
|
|
4
|
+
"""
|
|
5
|
+
There are some features that come to the google.generativeai first,
|
|
6
|
+
which needs to be authenticated via a GOOGLE_API_KEY environment variable,
|
|
7
|
+
created via the Google AI Console at https://aistudio.google.com/app/apikey
|
|
8
|
+
"""
|
|
9
|
+
try:
|
|
10
|
+
import google.generativeai as genai
|
|
11
|
+
except ImportError:
|
|
12
|
+
raise ImportError("google.generativeai not installed, please install via 'pip install sunholo'[gcp]'")
|
|
13
|
+
|
|
14
|
+
GOOGLE_API_KEY=os.getenv('GOOGLE_API_KEY')
|
|
15
|
+
if not GOOGLE_API_KEY:
|
|
16
|
+
raise ValueError("google.generativeai needs GOOGLE_API_KEY set in environment variable")
|
|
17
|
+
|
|
18
|
+
genai.configure(api_key=GOOGLE_API_KEY)
|
|
@@ -6,6 +6,8 @@ from .safety import genai_safety
|
|
|
6
6
|
|
|
7
7
|
from typing import TYPE_CHECKING, Union
|
|
8
8
|
|
|
9
|
+
import json
|
|
10
|
+
|
|
9
11
|
try:
|
|
10
12
|
import google.generativeai as genai
|
|
11
13
|
except ImportError:
|
|
@@ -58,7 +60,7 @@ class GenAIFunctionProcessor:
|
|
|
58
60
|
|
|
59
61
|
self.config = config
|
|
60
62
|
self.funcs = self.construct_tools()
|
|
61
|
-
self.model_name = config.vacConfig("model")
|
|
63
|
+
self.model_name = config.vacConfig("model") if config.vacConfig("llm") == "vertex" else "gemini-1.5-flash"
|
|
62
64
|
self.last_api_requests_and_responses = []
|
|
63
65
|
self._validate_functions()
|
|
64
66
|
|
|
@@ -111,7 +113,7 @@ class GenAIFunctionProcessor:
|
|
|
111
113
|
Part(
|
|
112
114
|
function_response=genai.protos.FunctionResponse(
|
|
113
115
|
name=part[0],
|
|
114
|
-
response={"result": part[2]}
|
|
116
|
+
response={"result": part[2], "args": json.dumps(part[1])}
|
|
115
117
|
)
|
|
116
118
|
)
|
|
117
119
|
)
|
|
@@ -146,6 +148,13 @@ class GenAIFunctionProcessor:
|
|
|
146
148
|
if isinstance(result, list) and target_value in result:
|
|
147
149
|
log.info(f"Target value '{target_value}' found in the result of function '{function_name}'.")
|
|
148
150
|
return True
|
|
151
|
+
elif isinstance(result, dict) and isinstance(target_value, dict):
|
|
152
|
+
for key, expected_value in target_value.items():
|
|
153
|
+
if key in result:
|
|
154
|
+
if result[key] == expected_value:
|
|
155
|
+
log.info(f"The key '{key}' has the same value in both dictionaries.")
|
|
156
|
+
return True
|
|
157
|
+
return False
|
|
149
158
|
elif result == target_value:
|
|
150
159
|
log.info(f"Target value '{target_value}' found in the result of function '{function_name}'.")
|
|
151
160
|
return True
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: sunholo
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.86.1
|
|
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.
|
|
6
|
+
Download-URL: https://github.com/sunholo-data/sunholo-py/archive/refs/tags/v0.86.1.tar.gz
|
|
7
7
|
Author: Holosun ApS
|
|
8
8
|
Author-email: multivac@sunholo.com
|
|
9
9
|
License: Apache License, Version 2.0
|
|
@@ -84,8 +84,9 @@ sunholo/gcs/add_file.py,sha256=TRbdEd3j-lFnyC7kqs5IWEPMPlDMFLR68fdTWga06Wo,8096
|
|
|
84
84
|
sunholo/gcs/download_folder.py,sha256=ijJTnS595JqZhBH8iHFErQilMbkuKgL-bnTCMLGuvlA,1614
|
|
85
85
|
sunholo/gcs/download_url.py,sha256=q1NiJSvEhdNrmU5ZJ-sBCMC_J5CxzrajY8LRgdPOV_M,6130
|
|
86
86
|
sunholo/gcs/metadata.py,sha256=oQLcXi4brsZ74aegWyC1JZmhlaEV270HS5_UWtAYYWE,898
|
|
87
|
-
sunholo/genai/__init__.py,sha256=
|
|
88
|
-
sunholo/genai/
|
|
87
|
+
sunholo/genai/__init__.py,sha256=dBl6IA3-Fx6-Vx81r0XqxHlUq6WeW1iDX188dpChu8s,115
|
|
88
|
+
sunholo/genai/init.py,sha256=yG8E67TduFCTQPELo83OJuWfjwTnGZsyACospahyEaY,687
|
|
89
|
+
sunholo/genai/process_funcs_cls.py,sha256=8aEsa4PYSMFM-nfBJEB6bmunfOdGRcrPyGofzCXrcPc,12315
|
|
89
90
|
sunholo/genai/safety.py,sha256=mkFDO_BeEgiKjQd9o2I4UxB6XI7a9U-oOFjZ8LGRUC4,1238
|
|
90
91
|
sunholo/invoke/__init__.py,sha256=bELcqIjzKvaupcIN5OQmDgGx_8jARtH9T6PCe8UgcvE,99
|
|
91
92
|
sunholo/invoke/async_class.py,sha256=vmLT6DqE1YaPd4W88_QzPQvSzsjwLUAwt23vGZm-BEs,5767
|
|
@@ -140,9 +141,9 @@ sunholo/vertex/init.py,sha256=1OQwcPBKZYBTDPdyU7IM4X4OmiXLdsNV30C-fee2scQ,2875
|
|
|
140
141
|
sunholo/vertex/memory_tools.py,sha256=q_phxgGX2TG2j2MXNULF2xGzQnQPENwjPN9nZ_A9Gh0,7526
|
|
141
142
|
sunholo/vertex/safety.py,sha256=S9PgQT1O_BQAkcqauWncRJaydiP8Q_Jzmu9gxYfy1VA,2482
|
|
142
143
|
sunholo/vertex/type_dict_to_json.py,sha256=uTzL4o9tJRao4u-gJOFcACgWGkBOtqACmb6ihvCErL8,4694
|
|
143
|
-
sunholo-0.
|
|
144
|
-
sunholo-0.
|
|
145
|
-
sunholo-0.
|
|
146
|
-
sunholo-0.
|
|
147
|
-
sunholo-0.
|
|
148
|
-
sunholo-0.
|
|
144
|
+
sunholo-0.86.1.dist-info/LICENSE.txt,sha256=SdE3QjnD3GEmqqg9EX3TM9f7WmtOzqS1KJve8rhbYmU,11345
|
|
145
|
+
sunholo-0.86.1.dist-info/METADATA,sha256=33nerpBWHKZTB-opKzrasdhI3cosYq0D-imCPCNeCuc,7598
|
|
146
|
+
sunholo-0.86.1.dist-info/WHEEL,sha256=HiCZjzuy6Dw0hdX5R3LCFPDmFS4BWl8H-8W39XfmgX4,91
|
|
147
|
+
sunholo-0.86.1.dist-info/entry_points.txt,sha256=bZuN5AIHingMPt4Ro1b_T-FnQvZ3teBes-3OyO0asl4,49
|
|
148
|
+
sunholo-0.86.1.dist-info/top_level.txt,sha256=wt5tadn5--5JrZsjJz2LceoUvcrIvxjHJe-RxuudxAk,8
|
|
149
|
+
sunholo-0.86.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|