sunholo 0.62.12__py3-none-any.whl → 0.62.14__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/agents/flask/qna_routes.py +2 -0
- sunholo/cli/run_proxy.py +1 -1
- sunholo/vertex/__init__.py +2 -1
- sunholo/vertex/memory_tools.py +51 -1
- sunholo/vertex/safety.py +35 -0
- {sunholo-0.62.12.dist-info → sunholo-0.62.14.dist-info}/METADATA +2 -2
- {sunholo-0.62.12.dist-info → sunholo-0.62.14.dist-info}/RECORD +11 -10
- {sunholo-0.62.12.dist-info → sunholo-0.62.14.dist-info}/LICENSE.txt +0 -0
- {sunholo-0.62.12.dist-info → sunholo-0.62.14.dist-info}/WHEEL +0 -0
- {sunholo-0.62.12.dist-info → sunholo-0.62.14.dist-info}/entry_points.txt +0 -0
- {sunholo-0.62.12.dist-info → sunholo-0.62.14.dist-info}/top_level.txt +0 -0
|
@@ -206,6 +206,8 @@ def prep_vac(request, vector_name):
|
|
|
206
206
|
stream_wait_time = data.pop('stream_wait_time', 7)
|
|
207
207
|
stream_timeout = data.pop('stream_timeout', 120)
|
|
208
208
|
chat_history = data.pop('chat_history', None)
|
|
209
|
+
vector_name = data.pop('vector_name', vector_name)
|
|
210
|
+
|
|
209
211
|
paired_messages = extract_chat_history(chat_history)
|
|
210
212
|
|
|
211
213
|
all_input = {'user_input': user_input,
|
sunholo/cli/run_proxy.py
CHANGED
|
@@ -277,7 +277,7 @@ def setup_proxy_subparser(subparsers):
|
|
|
277
277
|
start_parser.add_argument('--port', type=int, help='Port to run the proxy on. Auto-assigns if not provided.')
|
|
278
278
|
start_parser.add_argument('--local', action='store_true', help='Run the service locally instead of proxying to Cloud Run.')
|
|
279
279
|
start_parser.add_argument('--app-type', choices=['flask', 'fastapi'], help='If local, type of the local app (flask or fastapi).')
|
|
280
|
-
start_parser.add_argument('--app-folder', help='If local, folder containing the local app.py')
|
|
280
|
+
start_parser.add_argument('--app-folder', default=".", help='If local, folder containing the local app.py')
|
|
281
281
|
start_parser.add_argument('--log-file', action='store_true', help='Whether to create a file containing proxy logs.')
|
|
282
282
|
start_parser.set_defaults(func=lambda args: start_proxy(args.service_name,
|
|
283
283
|
args.region,
|
sunholo/vertex/__init__.py
CHANGED
sunholo/vertex/memory_tools.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
try:
|
|
2
2
|
from vertexai.preview import rag
|
|
3
|
-
from vertexai.preview.generative_models import Tool, grounding
|
|
3
|
+
from vertexai.preview.generative_models import Tool, grounding, GenerationResponse
|
|
4
4
|
except ImportError:
|
|
5
5
|
rag = None
|
|
6
6
|
|
|
@@ -89,3 +89,53 @@ def get_vertex_memories(vector_name):
|
|
|
89
89
|
log.warning("No llamaindex Vertex corpus configurations could be found")
|
|
90
90
|
|
|
91
91
|
return tools
|
|
92
|
+
|
|
93
|
+
def print_grounding_response(response):
|
|
94
|
+
"""Prints Gemini response with grounding citations."""
|
|
95
|
+
grounding_metadata = response.candidates[0].grounding_metadata
|
|
96
|
+
|
|
97
|
+
# Citation indices are in byte units
|
|
98
|
+
ENCODING = "utf-8"
|
|
99
|
+
text_bytes = response.text.encode(ENCODING)
|
|
100
|
+
|
|
101
|
+
prev_index = 0
|
|
102
|
+
markdown_text = ""
|
|
103
|
+
|
|
104
|
+
sources: dict[str, str] = {}
|
|
105
|
+
footnote = 1
|
|
106
|
+
for attribution in grounding_metadata.grounding_attributions:
|
|
107
|
+
context = attribution.web or attribution.retrieved_context
|
|
108
|
+
if not context:
|
|
109
|
+
log.info(f"Skipping Grounding Attribution {attribution}")
|
|
110
|
+
continue
|
|
111
|
+
|
|
112
|
+
title = context.title
|
|
113
|
+
uri = context.uri
|
|
114
|
+
end_index = int(attribution.segment.end_index)
|
|
115
|
+
|
|
116
|
+
if uri not in sources:
|
|
117
|
+
sources[uri] = {"title": title, "footnote": footnote}
|
|
118
|
+
footnote += 1
|
|
119
|
+
|
|
120
|
+
text_segment = text_bytes[prev_index:end_index].decode(ENCODING)
|
|
121
|
+
markdown_text += f"{text_segment} [[{sources[uri]['footnote']}]]({uri})"
|
|
122
|
+
prev_index = end_index
|
|
123
|
+
|
|
124
|
+
if prev_index < len(text_bytes):
|
|
125
|
+
markdown_text += str(text_bytes[prev_index:], encoding=ENCODING)
|
|
126
|
+
|
|
127
|
+
markdown_text += "\n## Grounding Sources\n"
|
|
128
|
+
|
|
129
|
+
if grounding_metadata.web_search_queries:
|
|
130
|
+
markdown_text += (
|
|
131
|
+
f"\n**Web Search Queries:** {grounding_metadata.web_search_queries}\n"
|
|
132
|
+
)
|
|
133
|
+
elif grounding_metadata.retrieval_queries:
|
|
134
|
+
markdown_text += (
|
|
135
|
+
f"\n**Retrieval Queries:** {grounding_metadata.retrieval_queries}\n"
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
for uri, source in sources.items():
|
|
139
|
+
markdown_text += f"{source['footnote']}. [{source['title']}]({uri})\n"
|
|
140
|
+
|
|
141
|
+
log.info(markdown_text)
|
sunholo/vertex/safety.py
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
try:
|
|
2
|
+
from vertexai.generative_models import (
|
|
3
|
+
HarmCategory,
|
|
4
|
+
HarmBlockThreshold,
|
|
5
|
+
)
|
|
6
|
+
except ImportError:
|
|
7
|
+
pass
|
|
8
|
+
|
|
9
|
+
def vertex_safety(threshold: str = "BLOCK_ONLY_HIGH"):
|
|
10
|
+
"""
|
|
11
|
+
BLOCK_ONLY_HIGH - block when high probability of unsafe content is detected
|
|
12
|
+
BLOCK_MEDIUM_AND_ABOVE - block when medium or high probability of content is detected
|
|
13
|
+
BLOCK_LOW_AND_ABOVE - block when low, medium, or high probability of unsafe content is detected
|
|
14
|
+
BLOCK_NONE - no block, but need to be on an allow list to use
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
if threshold == 'BLOCK_ONLY_HIGH':
|
|
18
|
+
thresh = HarmBlockThreshold.BLOCK_ONLY_HIGH
|
|
19
|
+
elif threshold == 'BLOCK_MEDIUM_AND_ABOVE':
|
|
20
|
+
thresh = HarmBlockThreshold.BLOCK_MEDIUM_AND_ABOVE
|
|
21
|
+
elif threshold == 'BLOCK_LOW_AND_ABOVE':
|
|
22
|
+
thresh = HarmBlockThreshold.BLOCK_LOW_AND_ABOVE
|
|
23
|
+
elif threshold == 'BLOCK_NONE':
|
|
24
|
+
thresh = HarmBlockThreshold.BLOCK_NONE
|
|
25
|
+
else:
|
|
26
|
+
raise ValueError("Invalid threshold")
|
|
27
|
+
|
|
28
|
+
safety_settings = {
|
|
29
|
+
HarmCategory.HARM_CATEGORY_HARASSMENT: thresh,
|
|
30
|
+
HarmCategory.HARM_CATEGORY_HATE_SPEECH: thresh,
|
|
31
|
+
HarmCategory.HARM_CATEGORY_SEXUALLY_EXPLICIT: thresh,
|
|
32
|
+
HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT: thresh,
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return safety_settings
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: sunholo
|
|
3
|
-
Version: 0.62.
|
|
3
|
+
Version: 0.62.14
|
|
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.62.
|
|
6
|
+
Download-URL: https://github.com/sunholo-data/sunholo-py/archive/refs/tags/v0.62.14.tar.gz
|
|
7
7
|
Author: Holosun ApS
|
|
8
8
|
Author-email: multivac@sunholo.com
|
|
9
9
|
License: Apache License, Version 2.0
|
|
@@ -12,7 +12,7 @@ sunholo/agents/fastapi/base.py,sha256=clk76cHbUAvU0OYJrRfCWX_5f0ACbhDsIzYBhI3wyo
|
|
|
12
12
|
sunholo/agents/fastapi/qna_routes.py,sha256=DgK4Btu5XriOC1JaRQ4G_nWEjJfnQ0J5pyLanF6eF1g,3857
|
|
13
13
|
sunholo/agents/flask/__init__.py,sha256=uqfHNw2Ru3EJ4dJEcbp86h_lkquBQPMxZbjhV_xe3rs,72
|
|
14
14
|
sunholo/agents/flask/base.py,sha256=FgSaCODyoTtlstJtsqlLPScdgRUtv9_plxftdzHdVFo,809
|
|
15
|
-
sunholo/agents/flask/qna_routes.py,sha256=
|
|
15
|
+
sunholo/agents/flask/qna_routes.py,sha256=x9QMY-z-1_ThCLAAtHQPC-oTmVulch3sTy_9KwsKHtI,8617
|
|
16
16
|
sunholo/archive/__init__.py,sha256=qNHWm5rGPVOlxZBZCpA1wTYPbalizRT7f8X4rs2t290,31
|
|
17
17
|
sunholo/archive/archive.py,sha256=C-UhG5x-XtZ8VheQp92IYJqgD0V3NFQjniqlit94t18,1197
|
|
18
18
|
sunholo/auth/__init__.py,sha256=4owDjSaWYkbTlPK47UHTOC0gCWbZsqn4ZIEw5NWZTlg,28
|
|
@@ -38,7 +38,7 @@ sunholo/cli/configs.py,sha256=QUM9DvKOdZmEQRM5uI3Nh887T0YDiSMr7O240zTLqws,4546
|
|
|
38
38
|
sunholo/cli/deploy.py,sha256=zxdwUsRTRMC8U5vyRv0JiKBLFn84Ug_Tc88-_h9hJSs,1609
|
|
39
39
|
sunholo/cli/embedder.py,sha256=5m_FaAqF6bnLJQj93HGySC-OOCXo2NCUVG_ZBjE1oUM,6937
|
|
40
40
|
sunholo/cli/merge_texts.py,sha256=U9vdMwKmcPoc6iPOWX5MKSxn49dNGbNzVLw8ui5PhEU,1823
|
|
41
|
-
sunholo/cli/run_proxy.py,sha256=
|
|
41
|
+
sunholo/cli/run_proxy.py,sha256=5CihmxymaCSwu1U58ySux38T3CQhx_FZkGRJLs99ix4,11294
|
|
42
42
|
sunholo/cli/sun_rich.py,sha256=UpMqeJ0C8i0pkue1AHnnyyX0bFJ9zZeJ7HBR6yhuA8A,54
|
|
43
43
|
sunholo/components/__init__.py,sha256=IDoylb74zFKo6NIS3RQqUl0PDFBGVxM1dfUmO7OJ44U,176
|
|
44
44
|
sunholo/components/llm.py,sha256=T4we3tGmqUj4tPwxQr9M6AXv_BALqZV_dRSvINan-oU,10374
|
|
@@ -97,12 +97,13 @@ sunholo/utils/gcp_project.py,sha256=0ozs6tzI4qEvEeXb8MxLnCdEVoWKxlM6OH05htj7_tc,
|
|
|
97
97
|
sunholo/utils/parsers.py,sha256=OrHmASqIbI45atVOhiGodgLvnfrzkvVzyHnSvAXD89I,3841
|
|
98
98
|
sunholo/utils/timedelta.py,sha256=BbLabEx7_rbErj_YbNM0MBcaFN76DC4PTe4zD2ucezg,493
|
|
99
99
|
sunholo/utils/user_ids.py,sha256=SQd5_H7FE7vcTZp9AQuQDWBXd4FEEd7TeVMQe1H4Ny8,292
|
|
100
|
-
sunholo/vertex/__init__.py,sha256=
|
|
100
|
+
sunholo/vertex/__init__.py,sha256=JvHcGFuv6R_nAhY2AdoqqhMpJ5ugeWPZ_svGhWrObBk,136
|
|
101
101
|
sunholo/vertex/init.py,sha256=JDMUaBRdednzbKF-5p33qqLit2LMsvgvWW-NRz0AqO0,1801
|
|
102
|
-
sunholo/vertex/memory_tools.py,sha256=
|
|
103
|
-
sunholo
|
|
104
|
-
sunholo-0.62.
|
|
105
|
-
sunholo-0.62.
|
|
106
|
-
sunholo-0.62.
|
|
107
|
-
sunholo-0.62.
|
|
108
|
-
sunholo-0.62.
|
|
102
|
+
sunholo/vertex/memory_tools.py,sha256=PMMJa0ecb0GUavUX275lhJjhmelc7bEIoM81G_uH4ys,5306
|
|
103
|
+
sunholo/vertex/safety.py,sha256=3meAX0HyGZYrH7rXPUAHxtI_3w_zoy_RX7Shtkoa660,1275
|
|
104
|
+
sunholo-0.62.14.dist-info/LICENSE.txt,sha256=SdE3QjnD3GEmqqg9EX3TM9f7WmtOzqS1KJve8rhbYmU,11345
|
|
105
|
+
sunholo-0.62.14.dist-info/METADATA,sha256=fOpbqUK_ycWdrySd41SQ2xXuyLP79cnGzyyEefc3iHU,8059
|
|
106
|
+
sunholo-0.62.14.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
|
107
|
+
sunholo-0.62.14.dist-info/entry_points.txt,sha256=bZuN5AIHingMPt4Ro1b_T-FnQvZ3teBes-3OyO0asl4,49
|
|
108
|
+
sunholo-0.62.14.dist-info/top_level.txt,sha256=wt5tadn5--5JrZsjJz2LceoUvcrIvxjHJe-RxuudxAk,8
|
|
109
|
+
sunholo-0.62.14.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|