sunholo 0.109.3__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 +9 -8
- {sunholo-0.109.3.dist-info → sunholo-0.109.5.dist-info}/METADATA +2 -2
- {sunholo-0.109.3.dist-info → sunholo-0.109.5.dist-info}/RECORD +7 -7
- {sunholo-0.109.3.dist-info → sunholo-0.109.5.dist-info}/WHEEL +1 -1
- {sunholo-0.109.3.dist-info → sunholo-0.109.5.dist-info}/LICENSE.txt +0 -0
- {sunholo-0.109.3.dist-info → sunholo-0.109.5.dist-info}/entry_points.txt +0 -0
- {sunholo-0.109.3.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
|
"""
|
|
@@ -115,6 +115,7 @@ async def construct_file_content(gs_list, bucket:str):
|
|
|
115
115
|
tasks = []
|
|
116
116
|
for file_info in file_list:
|
|
117
117
|
img_url = f"gs://{bucket}/{file_info['storagePath']}"
|
|
118
|
+
display_url = file_info.get('url')
|
|
118
119
|
mime_type = file_info['contentType']
|
|
119
120
|
name = sanitize_file(file_info['name'])
|
|
120
121
|
log.info(f"Processing {name=}")
|
|
@@ -123,14 +124,14 @@ async def construct_file_content(gs_list, bucket:str):
|
|
|
123
124
|
content.append(
|
|
124
125
|
{"role": "user", "parts": [
|
|
125
126
|
{"file_data": myfile},
|
|
126
|
-
{"text": f"You have been given the ability to work with file
|
|
127
|
+
{"text": f"You have been given the ability to work with file {name=} with {mime_type=} {display_url=}"}
|
|
127
128
|
]
|
|
128
129
|
})
|
|
129
130
|
log.info(f"Found existing genai.get_file {name=}")
|
|
130
131
|
|
|
131
132
|
except Exception as e:
|
|
132
133
|
log.info(f"Not found checking genai.get_file: '{name}' {str(e)}")
|
|
133
|
-
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))
|
|
134
135
|
|
|
135
136
|
# Run all tasks in parallel
|
|
136
137
|
if tasks:
|
|
@@ -148,7 +149,7 @@ async def download_file_with_error_handling(img_url, mime_type, name):
|
|
|
148
149
|
log.error(msg)
|
|
149
150
|
return {"role": "user", "parts": [{"text": msg}]}
|
|
150
151
|
|
|
151
|
-
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):
|
|
152
153
|
import aiofiles
|
|
153
154
|
from google.generativeai.types import file_types
|
|
154
155
|
"""
|
|
@@ -180,7 +181,7 @@ async def download_gcs_upload_genai(img_url, mime_type, name=None, retries=3, de
|
|
|
180
181
|
|
|
181
182
|
if file_size > 19434343:
|
|
182
183
|
log.warning(f"File size for {img_url}: {file_size} is too big.")
|
|
183
|
-
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=}"
|
|
184
185
|
return {"role": "user", "parts": [{"text": msg}]}
|
|
185
186
|
|
|
186
187
|
extension = mimetypes.guess_extension(mime_type)
|
|
@@ -202,15 +203,15 @@ async def download_gcs_upload_genai(img_url, mime_type, name=None, retries=3, de
|
|
|
202
203
|
sanitized_file
|
|
203
204
|
)
|
|
204
205
|
return {"role": "user", "parts": [{"file_data": downloaded_content},
|
|
205
|
-
{"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=}"}
|
|
206
207
|
]}
|
|
207
208
|
except Exception as err:
|
|
208
|
-
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=}"
|
|
209
210
|
log.error(msg)
|
|
210
211
|
return {"role": "user", "parts": [{"text": msg}]}
|
|
211
212
|
|
|
212
213
|
except Exception as err:
|
|
213
|
-
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)}")
|
|
214
215
|
|
|
215
216
|
if attempt < retries - 1:
|
|
216
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
|