sunholo 0.126.3__py3-none-any.whl → 0.127.0__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/dispatch_to_qa.py +5 -6
- sunholo/discovery_engine/chunker_handler.py +9 -1
- sunholo/discovery_engine/discovery_engine_client.py +8 -2
- sunholo/embedder/embed_metadata.py +1 -1
- sunholo/utils/config_class.py +19 -12
- {sunholo-0.126.3.dist-info → sunholo-0.127.0.dist-info}/METADATA +3 -1
- {sunholo-0.126.3.dist-info → sunholo-0.127.0.dist-info}/RECORD +11 -11
- {sunholo-0.126.3.dist-info → sunholo-0.127.0.dist-info}/WHEEL +0 -0
- {sunholo-0.126.3.dist-info → sunholo-0.127.0.dist-info}/entry_points.txt +0 -0
- {sunholo-0.126.3.dist-info → sunholo-0.127.0.dist-info}/licenses/LICENSE.txt +0 -0
- {sunholo-0.126.3.dist-info → sunholo-0.127.0.dist-info}/top_level.txt +0 -0
sunholo/agents/dispatch_to_qa.py
CHANGED
@@ -21,11 +21,6 @@ import traceback
|
|
21
21
|
from .route import route_endpoint
|
22
22
|
import os
|
23
23
|
|
24
|
-
try:
|
25
|
-
from langfuse import Langfuse
|
26
|
-
langfuse = Langfuse()
|
27
|
-
except ImportError:
|
28
|
-
langfuse = None
|
29
24
|
|
30
25
|
def prep_request_payload(user_input, chat_history, vector_name, stream, **kwargs):
|
31
26
|
"""
|
@@ -93,7 +88,11 @@ def prep_request_payload(user_input, chat_history, vector_name, stream, **kwargs
|
|
93
88
|
return qna_endpoint, qna_data
|
94
89
|
|
95
90
|
def add_langfuse_trace(qna_endpoint):
|
96
|
-
|
91
|
+
try:
|
92
|
+
from langfuse import Langfuse
|
93
|
+
langfuse = Langfuse()
|
94
|
+
except Exception as err:
|
95
|
+
log.error(err)
|
97
96
|
return None
|
98
97
|
|
99
98
|
trace = langfuse.trace(name = f'dispatch/{os.path.basename(qna_endpoint)}')
|
@@ -36,6 +36,7 @@ def do_discovery_engine(message_data:str, metadata:dict, config:ConfigManager=No
|
|
36
36
|
if vectorstore == "discovery_engine" or vectorstore == "vertex_ai_search":
|
37
37
|
log.info(f"Found vectorstore {vectorstore}")
|
38
38
|
if value.get('read_only'):
|
39
|
+
log.info(f"{vectorstore} is read only, skipping")
|
39
40
|
continue
|
40
41
|
|
41
42
|
project_id = value.get("project_id")
|
@@ -50,6 +51,7 @@ def do_discovery_engine(message_data:str, metadata:dict, config:ConfigManager=No
|
|
50
51
|
if not project_id:
|
51
52
|
raise ValueError("Couldn't retrieve project_id for vertex_ai_search")
|
52
53
|
|
54
|
+
log.info(f"Using {project_id} and {location} for DiscoveryEngineClient")
|
53
55
|
corpus = DiscoveryEngineClient(
|
54
56
|
data_store_id=config.vector_name,
|
55
57
|
project_id=project_id,
|
@@ -67,10 +69,13 @@ def do_discovery_engine(message_data:str, metadata:dict, config:ConfigManager=No
|
|
67
69
|
if message_data.startswith("gs://"):
|
68
70
|
log.info(f"DiscoveryEngineClient.import_files for {message_data}")
|
69
71
|
if "/pdf_parts/" in message_data:
|
72
|
+
log.info(f"Not processing files with /pdf_parts/ - {message_data}")
|
70
73
|
return None
|
71
74
|
for corp in corpuses:
|
72
75
|
try:
|
76
|
+
|
73
77
|
metadata = audit_metadata(metadata, chunk_length=500)
|
78
|
+
log.info(f"Importing {message_data} {metadata=} to {corp}")
|
74
79
|
response = corp.import_document_with_metadata(
|
75
80
|
gcs_uri=message_data,
|
76
81
|
metadata=metadata
|
@@ -160,7 +165,10 @@ def discovery_engine_chunker_check(message_data,
|
|
160
165
|
try:
|
161
166
|
log.info(f"Process discovery engine for {metadata}")
|
162
167
|
disc_meta = do_discovery_engine(message_data, metadata, config=config)
|
163
|
-
|
168
|
+
if disc_meta is None:
|
169
|
+
log.error(f"No disc_meta found for {metadata}")
|
170
|
+
else:
|
171
|
+
log.info(f"Processed discovery engine: {disc_meta}")
|
164
172
|
except Exception as err:
|
165
173
|
log.error(f"Error processing discovery engine: {str(err)} {traceback.format_exc()}")
|
166
174
|
disc_meta = None
|
@@ -16,6 +16,7 @@ import asyncio
|
|
16
16
|
import json
|
17
17
|
import uuid
|
18
18
|
from ..utils.mime import guess_mime_type
|
19
|
+
import traceback
|
19
20
|
|
20
21
|
class DiscoveryEngineClient:
|
21
22
|
"""
|
@@ -80,8 +81,10 @@ class DiscoveryEngineClient:
|
|
80
81
|
self.async_search_client = discoveryengine.SearchServiceAsyncClient(client_options=client_options)
|
81
82
|
except RuntimeError:
|
82
83
|
# No event loop in non-async environment, set async client to None
|
83
|
-
log.info("No event loop detected; skipping async client initialization")
|
84
|
+
log.info("No event loop detected; skipping Discoveryengine async client initialization")
|
84
85
|
self.async_search_client = None
|
86
|
+
|
87
|
+
log.info(f"Discovery Engine client initialized with {self.project_id=}, {self.data_store_id=}, {self.location=}")
|
85
88
|
|
86
89
|
@classmethod
|
87
90
|
def my_retry(cls):
|
@@ -490,6 +493,7 @@ class DiscoveryEngineClient:
|
|
490
493
|
return doc_client.import_documents(request=request)
|
491
494
|
|
492
495
|
try:
|
496
|
+
log.debug(f"Requesting import of documents: {request=}")
|
493
497
|
operation = import_documents_with_retry(self.doc_client, request)
|
494
498
|
except ResourceExhausted as e:
|
495
499
|
log.error(f"DiscoveryEngine Operation failed after retries due to quota exceeded: {e}")
|
@@ -610,6 +614,7 @@ class DiscoveryEngineClient:
|
|
610
614
|
reconciliation_mode=discoveryengine.ImportDocumentsRequest.ReconciliationMode.INCREMENTAL,
|
611
615
|
)
|
612
616
|
|
617
|
+
log.debug(f"Making import_document_request: {request}")
|
613
618
|
return self._import_document_request(request)
|
614
619
|
|
615
620
|
def _create_unique_gsuri_docid(self, gcs_uri:str):
|
@@ -632,6 +637,7 @@ class DiscoveryEngineClient:
|
|
632
637
|
str: The operation name.
|
633
638
|
"""
|
634
639
|
try:
|
640
|
+
log.info(f"Importing doc with metadata: {gcs_uri=}, {metadata=}")
|
635
641
|
# 1. Generate a unique document ID
|
636
642
|
document_id = self._create_unique_gsuri_docid(gcs_uri)
|
637
643
|
|
@@ -662,7 +668,7 @@ class DiscoveryEngineClient:
|
|
662
668
|
return self._import_document_request(request)
|
663
669
|
|
664
670
|
except Exception as e:
|
665
|
-
log.error(f"Error importing document with metadata: {e}")
|
671
|
+
log.error(f"Error importing document with metadata: {e} {traceback.format_exc()}")
|
666
672
|
raise e
|
667
673
|
|
668
674
|
def get_mime_type(self, uri:str):
|
@@ -6,7 +6,7 @@ from ..utils.mime import guess_mime_type
|
|
6
6
|
|
7
7
|
from ..custom_logging import log
|
8
8
|
|
9
|
-
def audit_metadata(metadata, chunk_length=None):
|
9
|
+
def audit_metadata(metadata:dict, chunk_length:int=None) -> dict:
|
10
10
|
|
11
11
|
if 'eventTime' not in metadata:
|
12
12
|
metadata['eventTime'] = datetime.datetime.now().isoformat(timespec='microseconds') + "Z"
|
sunholo/utils/config_class.py
CHANGED
@@ -112,18 +112,6 @@ class ConfigManager:
|
|
112
112
|
"""
|
113
113
|
Helper function to load a config file and update the cache.
|
114
114
|
|
115
|
-
Args:
|
116
|
-
config_file (str): The path to the configuration file.
|
117
|
-
filename (str): The name of the configuration file.
|
118
|
-
is_local (bool): Indicates if the config file is from the local folder.
|
119
|
-
|
120
|
-
Returns:
|
121
|
-
dict: The loaded configuration.
|
122
|
-
"""
|
123
|
-
def _reload_config_file(self, config_file, filename, is_local=False):
|
124
|
-
"""
|
125
|
-
Helper function to load a config file and update the cache.
|
126
|
-
|
127
115
|
Args:
|
128
116
|
config_file (str): The path to the configuration file.
|
129
117
|
filename (str): The name of the configuration file.
|
@@ -244,4 +232,23 @@ class ConfigManager:
|
|
244
232
|
return agents[key]
|
245
233
|
else:
|
246
234
|
return agents.get("default")
|
235
|
+
|
236
|
+
def permissionConfig(self, key: str):
|
237
|
+
"""
|
238
|
+
Fetch a key from 'permissionConfig' kind configuration.
|
247
239
|
|
240
|
+
Args:
|
241
|
+
key (str): The key to fetch from the configuration.
|
242
|
+
|
243
|
+
Returns:
|
244
|
+
str: The value associated with the specified key.
|
245
|
+
"""
|
246
|
+
self._check_and_reload_configs()
|
247
|
+
config = self.configs_by_kind.get('permissionConfig')
|
248
|
+
if not config:
|
249
|
+
return None
|
250
|
+
agents = config.get('permissions')
|
251
|
+
if key in agents:
|
252
|
+
return agents[key]
|
253
|
+
else:
|
254
|
+
return None
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: sunholo
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.127.0
|
4
4
|
Summary: Large Language Model DevOps - a package to help deploy LLMs to the Cloud.
|
5
5
|
Author-email: Holosun ApS <multivac@sunholo.com>
|
6
6
|
License: Apache License, Version 2.0
|
@@ -142,6 +142,7 @@ Requires-Dist: google-cloud-discoveryengine>=0.13.4; extra == "gcp"
|
|
142
142
|
Requires-Dist: google-cloud-texttospeech; extra == "gcp"
|
143
143
|
Requires-Dist: google-genai>=0.2.2; extra == "gcp"
|
144
144
|
Requires-Dist: google-generativeai>=0.8.3; extra == "gcp"
|
145
|
+
Requires-Dist: langchain; extra == "gcp"
|
145
146
|
Requires-Dist: langchain-google-genai>=2.0.0; extra == "gcp"
|
146
147
|
Requires-Dist: langchain_google_alloydb_pg>=0.2.2; extra == "gcp"
|
147
148
|
Requires-Dist: langchain-google-vertexai; extra == "gcp"
|
@@ -164,6 +165,7 @@ Requires-Dist: flask; extra == "http"
|
|
164
165
|
Requires-Dist: gunicorn; extra == "http"
|
165
166
|
Requires-Dist: httpcore; extra == "http"
|
166
167
|
Requires-Dist: httpx; extra == "http"
|
168
|
+
Requires-Dist: langchain; extra == "http"
|
167
169
|
Requires-Dist: langfuse; extra == "http"
|
168
170
|
Requires-Dist: python-socketio; extra == "http"
|
169
171
|
Requires-Dist: requests; extra == "http"
|
@@ -3,7 +3,7 @@ sunholo/custom_logging.py,sha256=YfIN1oP3dOEkkYkyRBU8BGS3uJFGwUDsFCl8mIVbwvE,122
|
|
3
3
|
sunholo/langchain_types.py,sha256=uZ4zvgej_f7pLqjtu4YP7qMC_eZD5ym_5x4pyvA1Ih4,1834
|
4
4
|
sunholo/agents/__init__.py,sha256=X2I3pPkGeKWjc3d0QgSpkTyqD8J8JtrEWqwrumf1MMc,391
|
5
5
|
sunholo/agents/chat_history.py,sha256=Gph_CdlP2otYnNdR1q1Umyyyvcad2F6K3LxU5yBQ9l0,5387
|
6
|
-
sunholo/agents/dispatch_to_qa.py,sha256=
|
6
|
+
sunholo/agents/dispatch_to_qa.py,sha256=NHihwAoCJ5_Lk11e_jZnucVUGQyZHCB-YpkfMHBCpQk,8882
|
7
7
|
sunholo/agents/langserve.py,sha256=C46ph2mnygr6bdHijYWYyfQDI9ylAF0_9Kx2PfcCJpU,4414
|
8
8
|
sunholo/agents/pubsub.py,sha256=TscZN_6am6DfaQkC-Yl18ZIBOoLE-0nDSiil6GpQEh4,1344
|
9
9
|
sunholo/agents/route.py,sha256=mV8tGABbSqcg3PQL02MgQOs41gKEHLMyIJJJcTuFdbE,2988
|
@@ -72,14 +72,14 @@ sunholo/database/sql/sb/delete_source_row.sql,sha256=r6fEuUKdbiLHCDGKSbKINDCpJjs
|
|
72
72
|
sunholo/database/sql/sb/return_sources.sql,sha256=89KAnxfK8n_qGK9jy1OQT8f9n4uYUtYL5cCxbC2mj_c,255
|
73
73
|
sunholo/database/sql/sb/setup.sql,sha256=CvoFvZQev2uWjmFa3aj3m3iuPFzAAJZ0S7Qi3L3-zZI,89
|
74
74
|
sunholo/discovery_engine/__init__.py,sha256=hLgqRDJ22Aov9o2QjAEfsVgnL3kMdM-g5p8RJ9OyKdQ,130
|
75
|
-
sunholo/discovery_engine/chunker_handler.py,sha256=
|
75
|
+
sunholo/discovery_engine/chunker_handler.py,sha256=44qlTpdtz2GKzrhoQrxVMk-RPVFp7vQDPJoe9KmCcsw,7517
|
76
76
|
sunholo/discovery_engine/cli.py,sha256=KGVle5rkLL49oF9TQhrGI--8017IvvLOEoYur545Qb0,12790
|
77
77
|
sunholo/discovery_engine/create_new.py,sha256=WUi4_xh_dFaGX3xA9jkNKZhaR6LCELjMPeRb0hyj4FU,1226
|
78
|
-
sunholo/discovery_engine/discovery_engine_client.py,sha256=
|
78
|
+
sunholo/discovery_engine/discovery_engine_client.py,sha256=0KhKRFKCvqvtkUOIrCXNk5353t9duuEtUQDhQnN2B24,37335
|
79
79
|
sunholo/discovery_engine/get_ai_search_chunks.py,sha256=I6Dt1CznqEvE7XIZ2PkLqopmjpO96iVEWJJqL5cJjOU,5554
|
80
80
|
sunholo/embedder/__init__.py,sha256=sI4N_CqgEVcrMDxXgxKp1FsfsB4FpjoXgPGkl4N_u4I,44
|
81
81
|
sunholo/embedder/embed_chunk.py,sha256=did2pKkWM2o0KkRcb0H9l2x_WjCq6OyuHDxGbITFKPM,6530
|
82
|
-
sunholo/embedder/embed_metadata.py,sha256=
|
82
|
+
sunholo/embedder/embed_metadata.py,sha256=qjv6oELuJRYKvR5SU5YHt-JAc_QfNOTNHbYeEXlQd1o,6617
|
83
83
|
sunholo/excel/__init__.py,sha256=AqTMN9K4qJYi4maEgoORc5oxDVGO_eqmwzDaVP37JgY,56
|
84
84
|
sunholo/excel/plugin.py,sha256=TJJdcKWyqEIce1agCJImvqvNp2CvLhzi4wUmLYHcLc8,4032
|
85
85
|
sunholo/gcs/__init__.py,sha256=SZvbsMFDko40sIRHTHppA37IijvJTae54vrhooEF5-4,90
|
@@ -151,7 +151,7 @@ sunholo/utils/__init__.py,sha256=Hv02T5L2zYWvCso5hzzwm8FQogwBq0OgtUbN_7Quzqc,89
|
|
151
151
|
sunholo/utils/api_key.py,sha256=Ct4bIAQZxzPEw14hP586LpVxBAVi_W9Serpy0BK-7KI,244
|
152
152
|
sunholo/utils/big_context.py,sha256=HuP9_r_Nx1jvZHxjMEihgoZAXmnCh80zzsj1fq3mIOg,6021
|
153
153
|
sunholo/utils/config.py,sha256=bz0ODJyqnoHQIsk4pmNpVxxq5WvwS0SfOq4cnCjQPJk,9105
|
154
|
-
sunholo/utils/config_class.py,sha256=
|
154
|
+
sunholo/utils/config_class.py,sha256=zhp71gNZb-t1cbkN2N3zwCAEiX0FSvKaKlpBxosgI4U,9750
|
155
155
|
sunholo/utils/config_schema.py,sha256=Wv-ncitzljOhgbDaq9qnFqH5LCuxNv59dTGDWgd1qdk,4189
|
156
156
|
sunholo/utils/gcp.py,sha256=lus1HH8YhFInw6QRKwfvKZq-Lz-2KQg4ips9v1I_3zE,4783
|
157
157
|
sunholo/utils/gcp_project.py,sha256=Fa0IhCX12bZ1ctF_PKN8PNYd7hihEUfb90kilBfUDjg,1411
|
@@ -168,9 +168,9 @@ sunholo/vertex/init.py,sha256=1OQwcPBKZYBTDPdyU7IM4X4OmiXLdsNV30C-fee2scQ,2875
|
|
168
168
|
sunholo/vertex/memory_tools.py,sha256=tBZxqVZ4InTmdBvLlOYwoSEWu4-kGquc-gxDwZCC4FA,7667
|
169
169
|
sunholo/vertex/safety.py,sha256=S9PgQT1O_BQAkcqauWncRJaydiP8Q_Jzmu9gxYfy1VA,2482
|
170
170
|
sunholo/vertex/type_dict_to_json.py,sha256=uTzL4o9tJRao4u-gJOFcACgWGkBOtqACmb6ihvCErL8,4694
|
171
|
-
sunholo-0.
|
172
|
-
sunholo-0.
|
173
|
-
sunholo-0.
|
174
|
-
sunholo-0.
|
175
|
-
sunholo-0.
|
176
|
-
sunholo-0.
|
171
|
+
sunholo-0.127.0.dist-info/licenses/LICENSE.txt,sha256=SdE3QjnD3GEmqqg9EX3TM9f7WmtOzqS1KJve8rhbYmU,11345
|
172
|
+
sunholo-0.127.0.dist-info/METADATA,sha256=hvXLBki1RQ_ZLhcm3Ej-qQq1-9XADsZg-F6N7oxzP1A,10084
|
173
|
+
sunholo-0.127.0.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
174
|
+
sunholo-0.127.0.dist-info/entry_points.txt,sha256=bZuN5AIHingMPt4Ro1b_T-FnQvZ3teBes-3OyO0asl4,49
|
175
|
+
sunholo-0.127.0.dist-info/top_level.txt,sha256=wt5tadn5--5JrZsjJz2LceoUvcrIvxjHJe-RxuudxAk,8
|
176
|
+
sunholo-0.127.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|