sunholo 0.109.4__py3-none-any.whl → 0.109.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.
@@ -51,6 +51,7 @@ VIDEO_MIMES = [
51
51
  AUDIO_MIMES = [
52
52
  'audio/wav',
53
53
  'audio/mp3',
54
+ 'audio/mpeg', #added
54
55
  'audio/aiff',
55
56
  'audio/aac',
56
57
  'audio/ogg',
@@ -82,7 +83,7 @@ def sanitize_file(filename):
82
83
  sanitized_name = re.sub(r'^-+|-+$', '', sanitized_name) # Remove leading or trailing dashes
83
84
 
84
85
  # Reattach the original extension
85
- return f"{sanitized_name}"
86
+ return sanitized_name[:40]
86
87
 
87
88
  async def construct_file_content(gs_list, bucket:str):
88
89
  """
@@ -105,6 +106,8 @@ async def construct_file_content(gs_list, bucket:str):
105
106
  continue
106
107
  if the_mime_type in ALLOWED_MIME_TYPES:
107
108
  file_list.append(element)
109
+ else:
110
+ log.warning(f'{the_mime_type} is not in allowed MIME types for {element.get("name")}')
108
111
 
109
112
  if not file_list:
110
113
  return {"role": "user", "parts": [{"text": "No eligible contentTypes were found"}]}
@@ -131,7 +134,7 @@ async def construct_file_content(gs_list, bucket:str):
131
134
 
132
135
  except Exception as e:
133
136
  log.info(f"Not found checking genai.get_file: '{name}' {str(e)}")
134
- tasks.append(download_gcs_upload_genai(img_url, mime_type, name=name))
137
+ tasks.append(download_gcs_upload_genai(img_url, mime_type=mime_type, name=name, display_url=display_url))
135
138
 
136
139
  # Run all tasks in parallel
137
140
  if tasks:
@@ -149,7 +152,7 @@ async def download_file_with_error_handling(img_url, mime_type, name):
149
152
  log.error(msg)
150
153
  return {"role": "user", "parts": [{"text": msg}]}
151
154
 
152
- async def download_gcs_upload_genai(img_url, mime_type, name=None, retries=3, delay=2):
155
+ async def download_gcs_upload_genai(img_url, mime_type, name=None, display_url=None, retries=3, delay=2):
153
156
  import aiofiles
154
157
  from google.generativeai.types import file_types
155
158
  """
@@ -181,7 +184,7 @@ async def download_gcs_upload_genai(img_url, mime_type, name=None, retries=3, de
181
184
 
182
185
  if file_size > 19434343:
183
186
  log.warning(f"File size for {img_url}: {file_size} is too big.")
184
- msg = f"The file for {img_url} is too large ({file_size} bytes) to be used directly. Use RAG instead."
187
+ msg = f"The file for {img_url} is too large ({file_size} bytes) to be used directly. Use RAG instead or {display_url=}"
185
188
  return {"role": "user", "parts": [{"text": msg}]}
186
189
 
187
190
  extension = mimetypes.guess_extension(mime_type)
@@ -203,15 +206,15 @@ async def download_gcs_upload_genai(img_url, mime_type, name=None, retries=3, de
203
206
  sanitized_file
204
207
  )
205
208
  return {"role": "user", "parts": [{"file_data": downloaded_content},
206
- {"text": f"You have been given the ability to read and work with filename '{name}' with {mime_type=}."}
209
+ {"text": f"You have been given the ability to read and work with filename '{name=}' with {mime_type=} {display_url=}"}
207
210
  ]}
208
211
  except Exception as err:
209
- msg = f"Could not upload {sanitized_file} to genai.upload_file: {str(err)} {traceback.format_exc()}"
212
+ msg = f"Could not upload {sanitized_file} to genai.upload_file: {str(err)} {traceback.format_exc()} {display_url=}"
210
213
  log.error(msg)
211
214
  return {"role": "user", "parts": [{"text": msg}]}
212
215
 
213
216
  except Exception as err:
214
- log.error(f"Error processing file {img_url} on attempt {attempt + 1}/{retries}: {str(err)}")
217
+ log.error(f"Error processing file {img_url} {mime_type=} on attempt {attempt + 1}/{retries}: {str(err)}")
215
218
 
216
219
  if attempt < retries - 1:
217
220
  log.info(f"Retrying in {delay} seconds...")
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sunholo
3
- Version: 0.109.4
3
+ Version: 0.109.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.109.4.tar.gz
6
+ Download-URL: https://github.com/sunholo-data/sunholo-py/archive/refs/tags/v0.109.6.tar.gz
7
7
  Author: Holosun ApS
8
8
  Author-email: multivac@sunholo.com
9
9
  License: Apache License, Version 2.0
@@ -86,7 +86,7 @@ sunholo/gcs/download_url.py,sha256=Ul81n1rklr8WogPsuxWWD1Nr8RHU451LzHPMJNhAKzw,6
86
86
  sunholo/gcs/extract_and_sign.py,sha256=paRrTCvCN5vkQwCB7OSkxWi-pfOgOtZ0bwdXE08c3Ps,1546
87
87
  sunholo/gcs/metadata.py,sha256=oQLcXi4brsZ74aegWyC1JZmhlaEV270HS5_UWtAYYWE,898
88
88
  sunholo/genai/__init__.py,sha256=6SWK7uV5F625J-P3xQoD6WKL59a9RSaidj-Guslyt8Q,192
89
- sunholo/genai/file_handling.py,sha256=cGQeDvB93-3XgHRA020E7344yG7_EgX0KAsJLitQJBg,7552
89
+ sunholo/genai/file_handling.py,sha256=N2AOqBaPJ9xGMQ1T_W45-rENyaMK7RRSBUZOOVrCDIg,7803
90
90
  sunholo/genai/images.py,sha256=EyjsDqt6XQw99pZUQamomCpMOoIah9bp3XY94WPU7Ms,1678
91
91
  sunholo/genai/init.py,sha256=yG8E67TduFCTQPELo83OJuWfjwTnGZsyACospahyEaY,687
92
92
  sunholo/genai/process_funcs_cls.py,sha256=7_RQMqIAZ3nPP-GFgCHBvS39fwuWuGtvSyuJaJN_G3E,31590
@@ -150,9 +150,9 @@ sunholo/vertex/init.py,sha256=1OQwcPBKZYBTDPdyU7IM4X4OmiXLdsNV30C-fee2scQ,2875
150
150
  sunholo/vertex/memory_tools.py,sha256=tBZxqVZ4InTmdBvLlOYwoSEWu4-kGquc-gxDwZCC4FA,7667
151
151
  sunholo/vertex/safety.py,sha256=S9PgQT1O_BQAkcqauWncRJaydiP8Q_Jzmu9gxYfy1VA,2482
152
152
  sunholo/vertex/type_dict_to_json.py,sha256=uTzL4o9tJRao4u-gJOFcACgWGkBOtqACmb6ihvCErL8,4694
153
- sunholo-0.109.4.dist-info/LICENSE.txt,sha256=SdE3QjnD3GEmqqg9EX3TM9f7WmtOzqS1KJve8rhbYmU,11345
154
- sunholo-0.109.4.dist-info/METADATA,sha256=_nE3mKEViVRioU2NglcZCIXJ0PMqdsM7lYi__xkj8ao,8705
155
- sunholo-0.109.4.dist-info/WHEEL,sha256=a7TGlA-5DaHMRrarXjVbQagU3Man_dCnGIWMJr5kRWo,91
156
- sunholo-0.109.4.dist-info/entry_points.txt,sha256=bZuN5AIHingMPt4Ro1b_T-FnQvZ3teBes-3OyO0asl4,49
157
- sunholo-0.109.4.dist-info/top_level.txt,sha256=wt5tadn5--5JrZsjJz2LceoUvcrIvxjHJe-RxuudxAk,8
158
- sunholo-0.109.4.dist-info/RECORD,,
153
+ sunholo-0.109.6.dist-info/LICENSE.txt,sha256=SdE3QjnD3GEmqqg9EX3TM9f7WmtOzqS1KJve8rhbYmU,11345
154
+ sunholo-0.109.6.dist-info/METADATA,sha256=Yidth4UGDIHn3VpR57h_UBzQqlAVkCh7QXEKPFGMx0E,8705
155
+ sunholo-0.109.6.dist-info/WHEEL,sha256=a7TGlA-5DaHMRrarXjVbQagU3Man_dCnGIWMJr5kRWo,91
156
+ sunholo-0.109.6.dist-info/entry_points.txt,sha256=bZuN5AIHingMPt4Ro1b_T-FnQvZ3teBes-3OyO0asl4,49
157
+ sunholo-0.109.6.dist-info/top_level.txt,sha256=wt5tadn5--5JrZsjJz2LceoUvcrIvxjHJe-RxuudxAk,8
158
+ sunholo-0.109.6.dist-info/RECORD,,