sunholo 0.109.4__py3-none-any.whl → 0.109.5__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/file_handling.py +7 -7
- {sunholo-0.109.4.dist-info → sunholo-0.109.5.dist-info}/METADATA +2 -2
- {sunholo-0.109.4.dist-info → sunholo-0.109.5.dist-info}/RECORD +7 -7
- {sunholo-0.109.4.dist-info → sunholo-0.109.5.dist-info}/LICENSE.txt +0 -0
- {sunholo-0.109.4.dist-info → sunholo-0.109.5.dist-info}/WHEEL +0 -0
- {sunholo-0.109.4.dist-info → sunholo-0.109.5.dist-info}/entry_points.txt +0 -0
- {sunholo-0.109.4.dist-info → sunholo-0.109.5.dist-info}/top_level.txt +0 -0
sunholo/genai/file_handling.py
CHANGED
|
@@ -82,7 +82,7 @@ def sanitize_file(filename):
|
|
|
82
82
|
sanitized_name = re.sub(r'^-+|-+$', '', sanitized_name) # Remove leading or trailing dashes
|
|
83
83
|
|
|
84
84
|
# Reattach the original extension
|
|
85
|
-
return
|
|
85
|
+
return sanitized_name[:40]
|
|
86
86
|
|
|
87
87
|
async def construct_file_content(gs_list, bucket:str):
|
|
88
88
|
"""
|
|
@@ -131,7 +131,7 @@ async def construct_file_content(gs_list, bucket:str):
|
|
|
131
131
|
|
|
132
132
|
except Exception as e:
|
|
133
133
|
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))
|
|
134
|
+
tasks.append(download_gcs_upload_genai(img_url, mime_type=mime_type, name=name, display_url=display_url))
|
|
135
135
|
|
|
136
136
|
# Run all tasks in parallel
|
|
137
137
|
if tasks:
|
|
@@ -149,7 +149,7 @@ async def download_file_with_error_handling(img_url, mime_type, name):
|
|
|
149
149
|
log.error(msg)
|
|
150
150
|
return {"role": "user", "parts": [{"text": msg}]}
|
|
151
151
|
|
|
152
|
-
async def download_gcs_upload_genai(img_url, mime_type, name=None, retries=3, delay=2):
|
|
152
|
+
async def download_gcs_upload_genai(img_url, mime_type, name=None, display_url=None, retries=3, delay=2):
|
|
153
153
|
import aiofiles
|
|
154
154
|
from google.generativeai.types import file_types
|
|
155
155
|
"""
|
|
@@ -181,7 +181,7 @@ async def download_gcs_upload_genai(img_url, mime_type, name=None, retries=3, de
|
|
|
181
181
|
|
|
182
182
|
if file_size > 19434343:
|
|
183
183
|
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
|
|
184
|
+
msg = f"The file for {img_url} is too large ({file_size} bytes) to be used directly. Use RAG instead or {display_url=}"
|
|
185
185
|
return {"role": "user", "parts": [{"text": msg}]}
|
|
186
186
|
|
|
187
187
|
extension = mimetypes.guess_extension(mime_type)
|
|
@@ -203,15 +203,15 @@ async def download_gcs_upload_genai(img_url, mime_type, name=None, retries=3, de
|
|
|
203
203
|
sanitized_file
|
|
204
204
|
)
|
|
205
205
|
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=}
|
|
206
|
+
{"text": f"You have been given the ability to read and work with filename '{name=}' with {mime_type=} {display_url=}"}
|
|
207
207
|
]}
|
|
208
208
|
except Exception as err:
|
|
209
|
-
msg = f"Could not upload {sanitized_file} to genai.upload_file: {str(err)} {traceback.format_exc()}"
|
|
209
|
+
msg = f"Could not upload {sanitized_file} to genai.upload_file: {str(err)} {traceback.format_exc()} {display_url=}"
|
|
210
210
|
log.error(msg)
|
|
211
211
|
return {"role": "user", "parts": [{"text": msg}]}
|
|
212
212
|
|
|
213
213
|
except Exception as err:
|
|
214
|
-
log.error(f"Error processing file {img_url} on attempt {attempt + 1}/{retries}: {str(err)}")
|
|
214
|
+
log.error(f"Error processing file {img_url} {mime_type=} on attempt {attempt + 1}/{retries}: {str(err)}")
|
|
215
215
|
|
|
216
216
|
if attempt < retries - 1:
|
|
217
217
|
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.
|
|
3
|
+
Version: 0.109.5
|
|
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.
|
|
6
|
+
Download-URL: https://github.com/sunholo-data/sunholo-py/archive/refs/tags/v0.109.5.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=
|
|
89
|
+
sunholo/genai/file_handling.py,sha256=vWkekjcKEpvavuO46Ogrqi8Ng1LPu-7iGgaWwDV4dsk,7665
|
|
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.
|
|
154
|
-
sunholo-0.109.
|
|
155
|
-
sunholo-0.109.
|
|
156
|
-
sunholo-0.109.
|
|
157
|
-
sunholo-0.109.
|
|
158
|
-
sunholo-0.109.
|
|
153
|
+
sunholo-0.109.5.dist-info/LICENSE.txt,sha256=SdE3QjnD3GEmqqg9EX3TM9f7WmtOzqS1KJve8rhbYmU,11345
|
|
154
|
+
sunholo-0.109.5.dist-info/METADATA,sha256=Otmc-ulFD1PWOgeoOh0pbNnsEI_4z_Ve3Ir2wX8BTpE,8705
|
|
155
|
+
sunholo-0.109.5.dist-info/WHEEL,sha256=a7TGlA-5DaHMRrarXjVbQagU3Man_dCnGIWMJr5kRWo,91
|
|
156
|
+
sunholo-0.109.5.dist-info/entry_points.txt,sha256=bZuN5AIHingMPt4Ro1b_T-FnQvZ3teBes-3OyO0asl4,49
|
|
157
|
+
sunholo-0.109.5.dist-info/top_level.txt,sha256=wt5tadn5--5JrZsjJz2LceoUvcrIvxjHJe-RxuudxAk,8
|
|
158
|
+
sunholo-0.109.5.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|