sunholo 0.86.0__py3-none-any.whl → 0.87.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.
@@ -53,10 +53,11 @@ if __name__ == "__main__":
53
53
  ```
54
54
 
55
55
  """
56
- def __init__(self, app, stream_interpreter, vac_interpreter):
56
+ def __init__(self, app, stream_interpreter, vac_interpreter, additional_routes=None):
57
57
  self.app = app
58
58
  self.stream_interpreter = stream_interpreter
59
59
  self.vac_interpreter = vac_interpreter
60
+ self.additional_routes = additional_routes if additional_routes is not None else []
60
61
  self.register_routes()
61
62
 
62
63
  def register_routes(self):
@@ -82,6 +83,47 @@ if __name__ == "__main__":
82
83
  # OpenAI compatible endpoint
83
84
  self.app.route('/openai/v1/chat/completions', methods=['POST'])(self.handle_openai_compatible_endpoint)
84
85
  self.app.route('/openai/v1/chat/completions/<vector_name>', methods=['POST'])(self.handle_openai_compatible_endpoint)
86
+ # Register additional routes
87
+ self.register_additional_routes()
88
+
89
+ def register_additional_routes(self):
90
+ """
91
+ Registers additional custom routes provided during initialization.
92
+
93
+ Example:
94
+ ```python
95
+ from flask import Flask, jsonify
96
+ from agents.flask import VACRoutes
97
+
98
+ app = Flask(__name__)
99
+
100
+ def stream_interpreter(question, vector_name, chat_history, **kwargs):
101
+ # Implement your streaming logic
102
+ ...
103
+
104
+ def vac_interpreter(question, vector_name, chat_history, **kwargs):
105
+ # Implement your static VAC logic
106
+ ...
107
+
108
+ def custom_handler():
109
+ return jsonify({"message": "Custom route!"})
110
+
111
+ custom_routes = [
112
+ {
113
+ "rule": "/custom",
114
+ "methods": ["GET"],
115
+ "handler": custom_handler
116
+ }
117
+ ]
118
+
119
+ vac_routes = VACRoutes(app, stream_interpreter, vac_interpreter, additional_routes=custom_routes)
120
+
121
+ if __name__ == "__main__":
122
+ app.run(debug=True)
123
+ ```
124
+ """
125
+ for route in self.additional_routes:
126
+ self.app.route(route["rule"], methods=route["methods"])(route["handler"])
85
127
 
86
128
  def home(self):
87
129
  return jsonify("OK")
@@ -121,7 +163,7 @@ if __name__ == "__main__":
121
163
  def handle_stream_vac(self, vector_name):
122
164
  observed_stream_interpreter = observe()(self.stream_interpreter)
123
165
  prep = self.prep_vac(request, vector_name)
124
- log.debug(f"Processing prep: {prep}")
166
+ log.info(f"Processing prep: {prep}")
125
167
  trace = prep["trace"]
126
168
  span = prep["span"]
127
169
  command_response = prep["command_response"]
@@ -438,8 +480,10 @@ if __name__ == "__main__":
438
480
  data["image_uri"] = image_uri
439
481
  data["mime"] = mime_type
440
482
  except Exception as e:
483
+ log.error(traceback.format_exc())
441
484
  return jsonify({'error': str(e), 'traceback': traceback.format_exc()}), 500
442
485
  else:
486
+ log.error("No file selected")
443
487
  return jsonify({"error": "No file selected"}), 400
444
488
  else:
445
489
  return jsonify({"error": "Unsupported content type"}), 400
sunholo/gcs/add_file.py CHANGED
@@ -70,6 +70,8 @@ def handle_base64_image(base64_data: str, vector_name: str, extension: str):
70
70
 
71
71
 
72
72
  def resolve_bucket(vector_name):
73
+ bucket_name = None
74
+
73
75
  if os.getenv('EXTENSIONS_BUCKET'):
74
76
  log.warning('Resolving to EXTENSIONS_BUCKET environment variable')
75
77
  return os.getenv('EXTENSIONS_BUCKET')
@@ -144,6 +146,7 @@ def add_file_to_gcs(filename: str,
144
146
  hour_prev = (now - datetime.timedelta(hours=1)).strftime("%H")
145
147
 
146
148
  if os.getenv('EXTENSIONS_BUCKET'):
149
+ log.warning(f"setting {bucket_filepath=} to {os.path.basename(filename)} basename due to EXTENSIONS_BUCKET setting")
147
150
  bucket_filepath = os.path.basename(filename)
148
151
 
149
152
  if not vector_name:
@@ -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:
@@ -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
@@ -193,6 +202,10 @@ class GenAIFunctionProcessor:
193
202
  """
194
203
  api_requests_and_responses = []
195
204
 
205
+ if not full_response:
206
+ log.info("No response was found to process")
207
+ return api_requests_and_responses
208
+
196
209
  # Loop through each part in the response to handle multiple function calls
197
210
  #TODO: async
198
211
  for part in full_response.candidates[0].content.parts:
@@ -275,7 +288,7 @@ class GenAIFunctionProcessor:
275
288
  if generation_config is None:
276
289
  generation_config = {
277
290
  "temperature": 0.1,
278
- "max_output_tokens": 4000,
291
+ "max_output_tokens": 8000,
279
292
  }
280
293
 
281
294
  # Extract the functions from the dictionary to pass into the model
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sunholo
3
- Version: 0.86.0
3
+ Version: 0.87.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.86.0.tar.gz
6
+ Download-URL: https://github.com/sunholo-data/sunholo-py/archive/refs/tags/v0.87.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=FgSaCODyoTtlstJtsqlLPScdgRUtv9_plxftdzHdVFo,809
16
16
  sunholo/agents/flask/qna_routes.py,sha256=uwUD1yrzOPH27m2AXpiQrPk_2VfJOQOM6dAynOWQtoQ,22532
17
- sunholo/agents/flask/vac_routes.py,sha256=aHVaWCfdOTMdtlbCdRbxn0cPQ1YZkUF0lG0xfNbbZUw,19575
17
+ sunholo/agents/flask/vac_routes.py,sha256=aZ69r4V5s5EHzJ8Tht0KTuEiHrSPHFiwF8XYPOA_7Q0,21034
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
@@ -80,13 +80,13 @@ sunholo/embedder/embed_chunk.py,sha256=MCbTePWjUbIRVDFFhHJ94BvOZvIom62-mTr0PmfQy
80
80
  sunholo/excel/__init__.py,sha256=AqTMN9K4qJYi4maEgoORc5oxDVGO_eqmwzDaVP37JgY,56
81
81
  sunholo/excel/plugin.py,sha256=rl3FoECZ6Ts8KKExPrbPwr3u3CegZfsevmcjgUXAlhE,4033
82
82
  sunholo/gcs/__init__.py,sha256=SZvbsMFDko40sIRHTHppA37IijvJTae54vrhooEF5-4,90
83
- sunholo/gcs/add_file.py,sha256=TRbdEd3j-lFnyC7kqs5IWEPMPlDMFLR68fdTWga06Wo,8096
83
+ sunholo/gcs/add_file.py,sha256=oSUCrTS_bdKJ-WcK8SAUCGEkS2noVbBhUBLwJRNxtpQ,8245
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
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=8wLO45x6FTNbbTbNtgK8Xa_bm1mLyn5vOqoE9RPvE78,11839
89
+ sunholo/genai/process_funcs_cls.py,sha256=lvbbUveb3h7h58hNyOK_-cchd7iobqhIRVD199isGHI,12449
90
90
  sunholo/genai/safety.py,sha256=mkFDO_BeEgiKjQd9o2I4UxB6XI7a9U-oOFjZ8LGRUC4,1238
91
91
  sunholo/invoke/__init__.py,sha256=bELcqIjzKvaupcIN5OQmDgGx_8jARtH9T6PCe8UgcvE,99
92
92
  sunholo/invoke/async_class.py,sha256=vmLT6DqE1YaPd4W88_QzPQvSzsjwLUAwt23vGZm-BEs,5767
@@ -141,9 +141,9 @@ sunholo/vertex/init.py,sha256=1OQwcPBKZYBTDPdyU7IM4X4OmiXLdsNV30C-fee2scQ,2875
141
141
  sunholo/vertex/memory_tools.py,sha256=q_phxgGX2TG2j2MXNULF2xGzQnQPENwjPN9nZ_A9Gh0,7526
142
142
  sunholo/vertex/safety.py,sha256=S9PgQT1O_BQAkcqauWncRJaydiP8Q_Jzmu9gxYfy1VA,2482
143
143
  sunholo/vertex/type_dict_to_json.py,sha256=uTzL4o9tJRao4u-gJOFcACgWGkBOtqACmb6ihvCErL8,4694
144
- sunholo-0.86.0.dist-info/LICENSE.txt,sha256=SdE3QjnD3GEmqqg9EX3TM9f7WmtOzqS1KJve8rhbYmU,11345
145
- sunholo-0.86.0.dist-info/METADATA,sha256=65x3Mmm4bllUh35pA4bDP7XDlfgVmZ1L_OdXX29fhIs,7598
146
- sunholo-0.86.0.dist-info/WHEEL,sha256=HiCZjzuy6Dw0hdX5R3LCFPDmFS4BWl8H-8W39XfmgX4,91
147
- sunholo-0.86.0.dist-info/entry_points.txt,sha256=bZuN5AIHingMPt4Ro1b_T-FnQvZ3teBes-3OyO0asl4,49
148
- sunholo-0.86.0.dist-info/top_level.txt,sha256=wt5tadn5--5JrZsjJz2LceoUvcrIvxjHJe-RxuudxAk,8
149
- sunholo-0.86.0.dist-info/RECORD,,
144
+ sunholo-0.87.0.dist-info/LICENSE.txt,sha256=SdE3QjnD3GEmqqg9EX3TM9f7WmtOzqS1KJve8rhbYmU,11345
145
+ sunholo-0.87.0.dist-info/METADATA,sha256=Sy38TeVoPDo6SPuonnZiDu9__xGrBb-rVPaHpUvToVc,7598
146
+ sunholo-0.87.0.dist-info/WHEEL,sha256=Mdi9PDNwEZptOjTlUcAth7XJDFtKrHYaQMPulZeBCiQ,91
147
+ sunholo-0.87.0.dist-info/entry_points.txt,sha256=bZuN5AIHingMPt4Ro1b_T-FnQvZ3teBes-3OyO0asl4,49
148
+ sunholo-0.87.0.dist-info/top_level.txt,sha256=wt5tadn5--5JrZsjJz2LceoUvcrIvxjHJe-RxuudxAk,8
149
+ sunholo-0.87.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (72.2.0)
2
+ Generator: setuptools (73.0.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5