sunholo 0.110.2__py3-none-any.whl → 0.110.4__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 +18 -6
- sunholo/langfuse/prompts.py +29 -21
- {sunholo-0.110.2.dist-info → sunholo-0.110.4.dist-info}/METADATA +2 -2
- {sunholo-0.110.2.dist-info → sunholo-0.110.4.dist-info}/RECORD +8 -8
- {sunholo-0.110.2.dist-info → sunholo-0.110.4.dist-info}/LICENSE.txt +0 -0
- {sunholo-0.110.2.dist-info → sunholo-0.110.4.dist-info}/WHEEL +0 -0
- {sunholo-0.110.2.dist-info → sunholo-0.110.4.dist-info}/entry_points.txt +0 -0
- {sunholo-0.110.2.dist-info → sunholo-0.110.4.dist-info}/top_level.txt +0 -0
sunholo/genai/file_handling.py
CHANGED
|
@@ -121,20 +121,27 @@ async def construct_file_content(gs_list, bucket:str):
|
|
|
121
121
|
display_url = file_info.get('url')
|
|
122
122
|
mime_type = file_info['contentType']
|
|
123
123
|
name = sanitize_file(file_info['name'])
|
|
124
|
-
|
|
124
|
+
display_name = file_info['name']
|
|
125
|
+
log.info(f"Processing {name=} {display_name=}")
|
|
125
126
|
try:
|
|
126
127
|
myfile = genai.get_file(name)
|
|
127
128
|
content.append(
|
|
128
129
|
{"role": "user", "parts": [
|
|
129
130
|
{"file_data": myfile},
|
|
130
|
-
{"text": f"You have been given the ability to work with file {
|
|
131
|
+
{"text": f"You have been given the ability to work with file {display_name=} with {mime_type=} {display_url=}"}
|
|
131
132
|
]
|
|
132
133
|
})
|
|
133
134
|
log.info(f"Found existing genai.get_file {name=}")
|
|
134
135
|
|
|
135
136
|
except Exception as e:
|
|
136
137
|
log.info(f"Not found checking genai.get_file: '{name}' {str(e)}")
|
|
137
|
-
tasks.append(
|
|
138
|
+
tasks.append(
|
|
139
|
+
download_gcs_upload_genai(img_url,
|
|
140
|
+
mime_type=mime_type,
|
|
141
|
+
name=name,
|
|
142
|
+
display_url=display_url,
|
|
143
|
+
display_name=display_name)
|
|
144
|
+
)
|
|
138
145
|
|
|
139
146
|
# Run all tasks in parallel
|
|
140
147
|
if tasks:
|
|
@@ -152,7 +159,12 @@ async def download_file_with_error_handling(img_url, mime_type, name):
|
|
|
152
159
|
log.error(msg)
|
|
153
160
|
return {"role": "user", "parts": [{"text": msg}]}
|
|
154
161
|
|
|
155
|
-
async def download_gcs_upload_genai(img_url,
|
|
162
|
+
async def download_gcs_upload_genai(img_url,
|
|
163
|
+
mime_type,
|
|
164
|
+
name=None,
|
|
165
|
+
display_url=None,
|
|
166
|
+
display_name=None,
|
|
167
|
+
retries=3, delay=2):
|
|
156
168
|
import aiofiles
|
|
157
169
|
from google.generativeai.types import file_types
|
|
158
170
|
"""
|
|
@@ -202,11 +214,11 @@ async def download_gcs_upload_genai(img_url, mime_type, name=None, display_url=N
|
|
|
202
214
|
# Upload the file and get its content reference
|
|
203
215
|
try:
|
|
204
216
|
downloaded_content: file_types.File = await asyncio.to_thread(
|
|
205
|
-
partial(genai.upload_file, name=name, mime_type=mime_type),
|
|
217
|
+
partial(genai.upload_file, name=name, mime_type=mime_type, display_name=display_name),
|
|
206
218
|
sanitized_file
|
|
207
219
|
)
|
|
208
220
|
return {"role": "user", "parts": [{"file_data": downloaded_content},
|
|
209
|
-
{"text": f"You have been given the ability to read and work with filename '{
|
|
221
|
+
{"text": f"You have been given the ability to read and work with filename '{display_name=}' with {mime_type=} {display_url=}"}
|
|
210
222
|
]}
|
|
211
223
|
except Exception as err:
|
|
212
224
|
msg = f"Could not upload {sanitized_file} to genai.upload_file: {str(err)} {traceback.format_exc()} {display_url=}"
|
sunholo/langfuse/prompts.py
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
from ..custom_logging import log
|
|
2
2
|
from ..utils import ConfigManager
|
|
3
|
+
import threading
|
|
4
|
+
try:
|
|
5
|
+
from langfuse import Langfuse
|
|
6
|
+
langfuse = Langfuse()
|
|
7
|
+
except ImportError:
|
|
8
|
+
langfuse = None
|
|
3
9
|
|
|
4
10
|
# Load the YAML file
|
|
5
11
|
def load_prompt_from_yaml(key, prefix="sunholo", load_from_file=False, f_string=True):
|
|
@@ -50,31 +56,33 @@ def load_prompt_from_yaml(key, prefix="sunholo", load_from_file=False, f_string=
|
|
|
50
56
|
```
|
|
51
57
|
|
|
52
58
|
"""
|
|
53
|
-
|
|
59
|
+
# Initialize Langfuse client
|
|
54
60
|
if load_from_file:
|
|
61
|
+
config = ConfigManager(prefix)
|
|
55
62
|
|
|
56
63
|
return config.promptConfig(key)
|
|
57
64
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
langfuse = Langfuse()
|
|
63
|
-
|
|
64
|
-
try:
|
|
65
|
-
if prefix is None:
|
|
66
|
-
langfuse_template = key
|
|
67
|
-
else:
|
|
68
|
-
langfuse_template = f"{prefix}-{key}"
|
|
69
|
-
|
|
70
|
-
langfuse_prompt = langfuse.get_prompt(langfuse_template, cache_ttl_seconds=300)
|
|
71
|
-
|
|
72
|
-
if f_string:
|
|
73
|
-
return langfuse_prompt.get_langchain_prompt()
|
|
65
|
+
if langfuse is None:
|
|
66
|
+
log.warning("No Langfuse import available - install via sunholo[http]")
|
|
67
|
+
else:
|
|
68
|
+
langfuse_result = [None]
|
|
74
69
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
70
|
+
def langfuse_load():
|
|
71
|
+
try:
|
|
72
|
+
template = f"{prefix}-{key}" if prefix else key
|
|
73
|
+
prompt = langfuse.get_prompt(template, cache_ttl_seconds=300)
|
|
74
|
+
langfuse_result[0] = prompt.get_langchain_prompt() if f_string else prompt
|
|
75
|
+
except Exception as err:
|
|
76
|
+
log.warning(f"Langfuse error: {template} - {str(err)}")
|
|
77
|
+
config = ConfigManager(prefix)
|
|
78
|
+
langfuse_result[0] = config.promptConfig(key)
|
|
79
|
+
|
|
80
|
+
thread = threading.Thread(target=langfuse_load)
|
|
81
|
+
thread.start()
|
|
82
|
+
thread.join(timeout=1)
|
|
83
|
+
|
|
84
|
+
if langfuse_result[0]:
|
|
85
|
+
return langfuse_result[0]
|
|
79
86
|
|
|
87
|
+
config = ConfigManager(prefix)
|
|
80
88
|
return config.promptConfig(key)
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: sunholo
|
|
3
|
-
Version: 0.110.
|
|
3
|
+
Version: 0.110.4
|
|
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.110.
|
|
6
|
+
Download-URL: https://github.com/sunholo-data/sunholo-py/archive/refs/tags/v0.110.4.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=Z3E7TR1DnP9WnneeEGC8LcT6k-9GFxwXDPaVZWw8HLE,8366
|
|
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
|
|
@@ -98,7 +98,7 @@ sunholo/invoke/invoke_vac_utils.py,sha256=sJc1edHTHMzMGXjji1N67c3iUaP7BmAL5nj82Q
|
|
|
98
98
|
sunholo/langfuse/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
99
99
|
sunholo/langfuse/callback.py,sha256=jl0SZsFS53uMW9DGeM9SOL_EsRZsba0wwFGLqKzu9_U,1684
|
|
100
100
|
sunholo/langfuse/evals.py,sha256=fQBaC0dBTYfgCzyfv9QBRvUfc9f42lbwQAeZmynaHO8,3841
|
|
101
|
-
sunholo/langfuse/prompts.py,sha256=
|
|
101
|
+
sunholo/langfuse/prompts.py,sha256=E3ZBd51k8NWkeO7K-uYkUPJhbqJWXee8X0N79pVCaIA,2744
|
|
102
102
|
sunholo/llamaindex/__init__.py,sha256=DlY_cHWCsVEV1C5WBgDdHRgOMlJc8pDoCRukUJ8PT9w,88
|
|
103
103
|
sunholo/llamaindex/get_files.py,sha256=6rhXCDqQ_lrIapISQ_OYQDjiSATXvS_9m3qq53-oIl0,781
|
|
104
104
|
sunholo/llamaindex/import_files.py,sha256=Bnic5wz8c61af9Kwq8KSrNBbc4imYnzMtBCb2jzSImI,6224
|
|
@@ -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.110.
|
|
154
|
-
sunholo-0.110.
|
|
155
|
-
sunholo-0.110.
|
|
156
|
-
sunholo-0.110.
|
|
157
|
-
sunholo-0.110.
|
|
158
|
-
sunholo-0.110.
|
|
153
|
+
sunholo-0.110.4.dist-info/LICENSE.txt,sha256=SdE3QjnD3GEmqqg9EX3TM9f7WmtOzqS1KJve8rhbYmU,11345
|
|
154
|
+
sunholo-0.110.4.dist-info/METADATA,sha256=4EZvfegaiERNSi6qN-RUVWy1CojNXbCjGg4sZ89g2cI,8705
|
|
155
|
+
sunholo-0.110.4.dist-info/WHEEL,sha256=R06PA3UVYHThwHvxuRWMqaGcr-PuniXahwjmQRFMEkY,91
|
|
156
|
+
sunholo-0.110.4.dist-info/entry_points.txt,sha256=bZuN5AIHingMPt4Ro1b_T-FnQvZ3teBes-3OyO0asl4,49
|
|
157
|
+
sunholo-0.110.4.dist-info/top_level.txt,sha256=wt5tadn5--5JrZsjJz2LceoUvcrIvxjHJe-RxuudxAk,8
|
|
158
|
+
sunholo-0.110.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|