sunholo 0.64.5__py3-none-any.whl → 0.64.6__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.
@@ -26,7 +26,7 @@ from ...logging import log
26
26
  from ...utils.config import load_config
27
27
  from ...utils.version import sunholo_version
28
28
  import os
29
- from ...gcs.add_file import add_file_to_gcs
29
+ from ...gcs.add_file import add_file_to_gcs, handle_base64_image
30
30
 
31
31
 
32
32
  try:
@@ -178,9 +178,29 @@ def register_qna_routes(app, stream_interpreter, vac_interpreter):
178
178
  if not messages:
179
179
  return jsonify({"error": "No messages provided"}), 400
180
180
 
181
- user_message = next((msg['content'] for msg in reversed(messages) if msg['role'] == 'user'), None)
181
+ user_message = None
182
+ image_uri = None
183
+ mime_type = None
184
+
185
+ for msg in reversed(messages):
186
+ if msg['role'] == 'user':
187
+ if isinstance(msg['content'], list):
188
+ for content_item in msg['content']:
189
+ if content_item['type'] == 'text':
190
+ user_message = content_item['text']
191
+ elif content_item['type'] == 'image_url':
192
+ base64_data = content_item['image_url']['url']
193
+ image_uri, mime_type = handle_base64_image(base64_data, vector_name)
194
+ else:
195
+ user_message = msg['content']
196
+ break
197
+
182
198
  if not user_message:
183
199
  return jsonify({"error": "No user message provided"}), 400
200
+
201
+ if image_uri:
202
+ data["image_uri"] = image_uri
203
+ data["mime"] = mime_type
184
204
 
185
205
  all_input = {
186
206
  "user_input": user_message,
sunholo/gcs/add_file.py CHANGED
@@ -13,6 +13,8 @@
13
13
  # limitations under the License.
14
14
  import datetime
15
15
  import os
16
+ import base64
17
+ import uuid
16
18
 
17
19
  try:
18
20
  from google.cloud import storage
@@ -22,6 +24,22 @@ except ImportError:
22
24
  from ..logging import log
23
25
  from ..utils.config import load_config_key
24
26
 
27
+
28
+ def handle_base64_image(base64_data, vector_name):
29
+ try:
30
+ header, encoded = base64_data.split(",", 1)
31
+ data = base64.b64decode(encoded)
32
+
33
+ filename = f"{uuid.uuid4()}.jpg"
34
+ with open(filename, "wb") as f:
35
+ f.write(data)
36
+
37
+ image_uri = add_file_to_gcs(filename, vector_name)
38
+ os.remove(filename) # Clean up the saved file
39
+ return image_uri, "image/jpeg"
40
+ except Exception as e:
41
+ raise Exception(f'Base64 image upload failed: {str(e)}')
42
+
25
43
  def add_file_to_gcs(filename: str, vector_name:str, bucket_name: str=None, metadata:dict=None, bucket_filepath:str=None):
26
44
 
27
45
  if not storage:
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sunholo
3
- Version: 0.64.5
3
+ Version: 0.64.6
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.64.5.tar.gz
6
+ Download-URL: https://github.com/sunholo-data/sunholo-py/archive/refs/tags/v0.64.6.tar.gz
7
7
  Author: Holosun ApS
8
8
  Author-email: multivac@sunholo.com
9
9
  License: Apache License, Version 2.0
@@ -12,7 +12,7 @@ sunholo/agents/fastapi/base.py,sha256=clk76cHbUAvU0OYJrRfCWX_5f0ACbhDsIzYBhI3wyo
12
12
  sunholo/agents/fastapi/qna_routes.py,sha256=DgK4Btu5XriOC1JaRQ4G_nWEjJfnQ0J5pyLanF6eF1g,3857
13
13
  sunholo/agents/flask/__init__.py,sha256=uqfHNw2Ru3EJ4dJEcbp86h_lkquBQPMxZbjhV_xe3rs,72
14
14
  sunholo/agents/flask/base.py,sha256=FgSaCODyoTtlstJtsqlLPScdgRUtv9_plxftdzHdVFo,809
15
- sunholo/agents/flask/qna_routes.py,sha256=4tUpwTKGqvHorRuVjomvkfLit3ERjjzYaVAtqn-6EJo,14673
15
+ sunholo/agents/flask/qna_routes.py,sha256=DWKpOl515MfewIvvVAwT-EbWLnjhg_bcBVFJVDeVW_8,15418
16
16
  sunholo/archive/__init__.py,sha256=qNHWm5rGPVOlxZBZCpA1wTYPbalizRT7f8X4rs2t290,31
17
17
  sunholo/archive/archive.py,sha256=C-UhG5x-XtZ8VheQp92IYJqgD0V3NFQjniqlit94t18,1197
18
18
  sunholo/auth/__init__.py,sha256=4owDjSaWYkbTlPK47UHTOC0gCWbZsqn4ZIEw5NWZTlg,28
@@ -59,7 +59,7 @@ sunholo/database/sql/sb/setup.sql,sha256=CvoFvZQev2uWjmFa3aj3m3iuPFzAAJZ0S7Qi3L3
59
59
  sunholo/embedder/__init__.py,sha256=sI4N_CqgEVcrMDxXgxKp1FsfsB4FpjoXgPGkl4N_u4I,44
60
60
  sunholo/embedder/embed_chunk.py,sha256=E6fHn2SFeQu9jsBO1wg5hSJUPTKbZ95Yc5QOltSn7jo,5840
61
61
  sunholo/gcs/__init__.py,sha256=DtVw_AZwQn-IguR5BJuIi2XJeF_FQXizhJikzRNrXiE,50
62
- sunholo/gcs/add_file.py,sha256=QBzPnl5HVZ2Z-rWmBua7gJHBnLAizgXkObjC3dTbccs,4958
62
+ sunholo/gcs/add_file.py,sha256=z5iWEqQpoqmuyhxoQlQcGXIuQ2lr8EKJnfes-NbiKrA,5493
63
63
  sunholo/gcs/download_url.py,sha256=8XSEf8byfubqs5CMQeF_tn9wxqwUTq3n9mo5mLNIUTA,4801
64
64
  sunholo/gcs/metadata.py,sha256=C9sMPsHsq1ETetdQCqB3EBs3Kws8b8QHS9L7ei_v5aw,891
65
65
  sunholo/langfuse/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -102,9 +102,9 @@ sunholo/vertex/__init__.py,sha256=JvHcGFuv6R_nAhY2AdoqqhMpJ5ugeWPZ_svGhWrObBk,13
102
102
  sunholo/vertex/init.py,sha256=JDMUaBRdednzbKF-5p33qqLit2LMsvgvWW-NRz0AqO0,1801
103
103
  sunholo/vertex/memory_tools.py,sha256=8F1iTWnqEK9mX4W5RzCVKIjydIcNp6OFxjn_dtQ3GXo,5379
104
104
  sunholo/vertex/safety.py,sha256=3meAX0HyGZYrH7rXPUAHxtI_3w_zoy_RX7Shtkoa660,1275
105
- sunholo-0.64.5.dist-info/LICENSE.txt,sha256=SdE3QjnD3GEmqqg9EX3TM9f7WmtOzqS1KJve8rhbYmU,11345
106
- sunholo-0.64.5.dist-info/METADATA,sha256=e_JboqgTpZEFQJx2UpjF5pCrqlOfdw0p46hAVhCX190,5971
107
- sunholo-0.64.5.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
108
- sunholo-0.64.5.dist-info/entry_points.txt,sha256=bZuN5AIHingMPt4Ro1b_T-FnQvZ3teBes-3OyO0asl4,49
109
- sunholo-0.64.5.dist-info/top_level.txt,sha256=wt5tadn5--5JrZsjJz2LceoUvcrIvxjHJe-RxuudxAk,8
110
- sunholo-0.64.5.dist-info/RECORD,,
105
+ sunholo-0.64.6.dist-info/LICENSE.txt,sha256=SdE3QjnD3GEmqqg9EX3TM9f7WmtOzqS1KJve8rhbYmU,11345
106
+ sunholo-0.64.6.dist-info/METADATA,sha256=ShQPolb2mmJyt1EJIc6GccsHjb_aPwbHInoS6H08Nl8,5971
107
+ sunholo-0.64.6.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
108
+ sunholo-0.64.6.dist-info/entry_points.txt,sha256=bZuN5AIHingMPt4Ro1b_T-FnQvZ3teBes-3OyO0asl4,49
109
+ sunholo-0.64.6.dist-info/top_level.txt,sha256=wt5tadn5--5JrZsjJz2LceoUvcrIvxjHJe-RxuudxAk,8
110
+ sunholo-0.64.6.dist-info/RECORD,,