sunholo 0.101.7__py3-none-any.whl → 0.101.8__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/images.py +22 -12
- {sunholo-0.101.7.dist-info → sunholo-0.101.8.dist-info}/METADATA +2 -2
- {sunholo-0.101.7.dist-info → sunholo-0.101.8.dist-info}/RECORD +7 -7
- {sunholo-0.101.7.dist-info → sunholo-0.101.8.dist-info}/LICENSE.txt +0 -0
- {sunholo-0.101.7.dist-info → sunholo-0.101.8.dist-info}/WHEEL +0 -0
- {sunholo-0.101.7.dist-info → sunholo-0.101.8.dist-info}/entry_points.txt +0 -0
- {sunholo-0.101.7.dist-info → sunholo-0.101.8.dist-info}/top_level.txt +0 -0
sunholo/genai/images.py
CHANGED
|
@@ -2,20 +2,21 @@ import re
|
|
|
2
2
|
from ..utils.mime import guess_mime_type
|
|
3
3
|
from ..gcs import get_bytes_from_gcs
|
|
4
4
|
from ..custom_logging import log
|
|
5
|
-
import io
|
|
6
5
|
import os
|
|
6
|
+
import tempfile
|
|
7
7
|
try:
|
|
8
8
|
import google.generativeai as genai
|
|
9
9
|
except ImportError:
|
|
10
10
|
genai = None
|
|
11
11
|
|
|
12
|
-
def extract_gs_images_and_genai_upload(content:str):
|
|
12
|
+
def extract_gs_images_and_genai_upload(content: str):
|
|
13
13
|
# Regular expression to find gs:// URLs
|
|
14
14
|
pattern = r'gs://[^ ]+\.(?:png|jpg|jpeg|pdf)'
|
|
15
15
|
|
|
16
16
|
gs_matches = re.findall(pattern, content)
|
|
17
17
|
unique_gs_matches = set(gs_matches)
|
|
18
18
|
output_gs_images = []
|
|
19
|
+
|
|
19
20
|
for gs_uri in unique_gs_matches:
|
|
20
21
|
mime_type = guess_mime_type(gs_uri)
|
|
21
22
|
if mime_type is None:
|
|
@@ -25,14 +26,23 @@ def extract_gs_images_and_genai_upload(content:str):
|
|
|
25
26
|
image_bytes = get_bytes_from_gcs(gs_uri)
|
|
26
27
|
if image_bytes is None:
|
|
27
28
|
continue
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
29
|
+
|
|
30
|
+
# Get the basename from the gs_uri to use as the file name
|
|
31
|
+
file_name = os.path.basename(gs_uri)
|
|
32
|
+
|
|
33
|
+
# Create a temporary directory and write the file with the basename
|
|
34
|
+
with tempfile.TemporaryDirectory() as temp_dir:
|
|
35
|
+
temp_file_path = os.path.join(temp_dir, file_name)
|
|
36
|
+
|
|
37
|
+
# Write the BytesIO object to the file
|
|
38
|
+
with open(temp_file_path, 'wb') as temp_file:
|
|
39
|
+
temp_file.write(image_bytes)
|
|
40
|
+
|
|
41
|
+
# Pass the temporary file's path to the upload function
|
|
42
|
+
try:
|
|
43
|
+
uploaded_file = genai.upload_file(temp_file_path)
|
|
44
|
+
output_gs_images.append(uploaded_file)
|
|
45
|
+
except Exception as e:
|
|
46
|
+
log.error(f"Error adding {gs_uri} to base64: {str(e)}")
|
|
37
47
|
|
|
38
|
-
return output_gs_images
|
|
48
|
+
return output_gs_images
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: sunholo
|
|
3
|
-
Version: 0.101.
|
|
3
|
+
Version: 0.101.8
|
|
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.101.
|
|
6
|
+
Download-URL: https://github.com/sunholo-data/sunholo-py/archive/refs/tags/v0.101.8.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=dBl6IA3-Fx6-Vx81r0XqxHlUq6WeW1iDX188dpChu8s,115
|
|
89
|
-
sunholo/genai/images.py,sha256=
|
|
89
|
+
sunholo/genai/images.py,sha256=eW5V2h2JdNqLkaw_u-pJSzu7edHzvrCWPLirolQXX5s,1617
|
|
90
90
|
sunholo/genai/init.py,sha256=yG8E67TduFCTQPELo83OJuWfjwTnGZsyACospahyEaY,687
|
|
91
91
|
sunholo/genai/process_funcs_cls.py,sha256=r8WF0kF5nYhC3qBb9p8X5101taq3lvfhEqs3EPg5QJY,28799
|
|
92
92
|
sunholo/genai/safety.py,sha256=mkFDO_BeEgiKjQd9o2I4UxB6XI7a9U-oOFjZ8LGRUC4,1238
|
|
@@ -147,9 +147,9 @@ sunholo/vertex/init.py,sha256=1OQwcPBKZYBTDPdyU7IM4X4OmiXLdsNV30C-fee2scQ,2875
|
|
|
147
147
|
sunholo/vertex/memory_tools.py,sha256=tBZxqVZ4InTmdBvLlOYwoSEWu4-kGquc-gxDwZCC4FA,7667
|
|
148
148
|
sunholo/vertex/safety.py,sha256=S9PgQT1O_BQAkcqauWncRJaydiP8Q_Jzmu9gxYfy1VA,2482
|
|
149
149
|
sunholo/vertex/type_dict_to_json.py,sha256=uTzL4o9tJRao4u-gJOFcACgWGkBOtqACmb6ihvCErL8,4694
|
|
150
|
-
sunholo-0.101.
|
|
151
|
-
sunholo-0.101.
|
|
152
|
-
sunholo-0.101.
|
|
153
|
-
sunholo-0.101.
|
|
154
|
-
sunholo-0.101.
|
|
155
|
-
sunholo-0.101.
|
|
150
|
+
sunholo-0.101.8.dist-info/LICENSE.txt,sha256=SdE3QjnD3GEmqqg9EX3TM9f7WmtOzqS1KJve8rhbYmU,11345
|
|
151
|
+
sunholo-0.101.8.dist-info/METADATA,sha256=ebKNiCxn5C0tp2_i76J48-qN7Uf7R83EvJDY6aLJOPI,8312
|
|
152
|
+
sunholo-0.101.8.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
|
|
153
|
+
sunholo-0.101.8.dist-info/entry_points.txt,sha256=bZuN5AIHingMPt4Ro1b_T-FnQvZ3teBes-3OyO0asl4,49
|
|
154
|
+
sunholo-0.101.8.dist-info/top_level.txt,sha256=wt5tadn5--5JrZsjJz2LceoUvcrIvxjHJe-RxuudxAk,8
|
|
155
|
+
sunholo-0.101.8.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|