sunholo 0.69.6__py3-none-any.whl → 0.69.9__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/discovery_engine/chunker_handler.py +2 -7
- sunholo/discovery_engine/create_new.py +2 -3
- sunholo/discovery_engine/discovery_engine_client.py +22 -11
- {sunholo-0.69.6.dist-info → sunholo-0.69.9.dist-info}/METADATA +2 -2
- {sunholo-0.69.6.dist-info → sunholo-0.69.9.dist-info}/RECORD +9 -9
- {sunholo-0.69.6.dist-info → sunholo-0.69.9.dist-info}/LICENSE.txt +0 -0
- {sunholo-0.69.6.dist-info → sunholo-0.69.9.dist-info}/WHEEL +0 -0
- {sunholo-0.69.6.dist-info → sunholo-0.69.9.dist-info}/entry_points.txt +0 -0
- {sunholo-0.69.6.dist-info → sunholo-0.69.9.dist-info}/top_level.txt +0 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
from ..logging import log
|
|
2
2
|
from ..utils.config import load_config_key
|
|
3
|
+
from ..utils.gcp_project import get_gcp_project
|
|
3
4
|
from ..components import load_memories
|
|
4
5
|
|
|
5
6
|
from .discovery_engine_client import DiscoveryEngineClient
|
|
@@ -20,11 +21,6 @@ def do_discovery_engine(message_data, metadata, vector_name):
|
|
|
20
21
|
```
|
|
21
22
|
"""
|
|
22
23
|
|
|
23
|
-
global_gcp_config = load_config_key("gcp_config", vector_name="global", kind="vacConfig")
|
|
24
|
-
gcp_config = load_config_key("gcp_config", vector_name=vector_name, kind="vacConfig")
|
|
25
|
-
if not gcp_config and not global_gcp_config:
|
|
26
|
-
raise ValueError(f"Need config.{vector_name}.gcp_config to configure discovery engine")
|
|
27
|
-
|
|
28
24
|
memories = load_memories(vector_name)
|
|
29
25
|
tools = []
|
|
30
26
|
|
|
@@ -38,11 +34,10 @@ def do_discovery_engine(message_data, metadata, vector_name):
|
|
|
38
34
|
vectorstore = value.get('vectorstore')
|
|
39
35
|
if vectorstore == "discovery_engine" or vectorstore == "vertex_ai_search":
|
|
40
36
|
log.info(f"Found vectorstore {vectorstore}")
|
|
41
|
-
project_id = gcp_config.get('project_id') or global_gcp_config['project_id']
|
|
42
37
|
#location = gcp_config.get('location')
|
|
43
38
|
corpus = DiscoveryEngineClient(
|
|
44
39
|
data_store_id=vector_name,
|
|
45
|
-
project_id=
|
|
40
|
+
project_id=get_gcp_project(),
|
|
46
41
|
# location needs to be 'eu' or 'us' which doesn't work with other configurations
|
|
47
42
|
#location=location or global_location
|
|
48
43
|
)
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
from .discovery_engine_client import DiscoveryEngineClient
|
|
2
2
|
from ..utils.config import load_config_key
|
|
3
|
+
from ..utils.gcp_project import get_gcp_project
|
|
3
4
|
|
|
4
5
|
def create_new_discovery_engine(vector_name):
|
|
5
|
-
global_config = load_config_key("gcp_config", "global", kind="vacConfig")
|
|
6
|
-
gcp_config = load_config_key("gcp_config", vector_name=vector_name, kind="vacConfig")
|
|
7
6
|
|
|
8
7
|
chunker_config = load_config_key("chunker", vector_name=vector_name, kind="vacConfig")
|
|
9
8
|
|
|
@@ -12,7 +11,7 @@ def create_new_discovery_engine(vector_name):
|
|
|
12
11
|
if "chunk_size" in chunker_config:
|
|
13
12
|
chunk_size = chunker_config["chunk_size"]
|
|
14
13
|
|
|
15
|
-
project_id =
|
|
14
|
+
project_id = get_gcp_project()
|
|
16
15
|
if not project_id:
|
|
17
16
|
raise ValueError("Could not find project_id in gcp_config")
|
|
18
17
|
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
try:
|
|
2
2
|
from google.api_core.client_options import ClientOptions
|
|
3
3
|
from google.cloud import discoveryengine_v1alpha as discoveryengine
|
|
4
|
+
from google.api_core.retry import Retry, if_exception_type
|
|
5
|
+
from google.api_core.exceptions import ResourceExhausted
|
|
4
6
|
except ImportError:
|
|
5
7
|
ClientOptions = None
|
|
6
8
|
discoveryengine = None
|
|
@@ -65,6 +67,16 @@ class DiscoveryEngineClient:
|
|
|
65
67
|
self.doc_client = discoveryengine.DocumentServiceClient(client_options=client_options)
|
|
66
68
|
self.search_client = discoveryengine.SearchServiceClient(client_options=client_options)
|
|
67
69
|
|
|
70
|
+
@classmethod
|
|
71
|
+
def my_retry(cls):
|
|
72
|
+
return Retry(
|
|
73
|
+
initial=1.0, # Initial delay before retrying (in seconds)
|
|
74
|
+
maximum=60.0, # Maximum delay between retries (in seconds)
|
|
75
|
+
multiplier=2.0, # Multiplier for the delay between retries
|
|
76
|
+
timeout=300.0, # Maximum total time to wait before giving up (in seconds)
|
|
77
|
+
predicate=if_exception_type(ResourceExhausted) # Retry if a ResourceExhausted error occurs
|
|
78
|
+
)
|
|
79
|
+
|
|
68
80
|
def create_data_store(
|
|
69
81
|
self, chunk_size: int = 500,
|
|
70
82
|
collection: str = "default_collection"
|
|
@@ -237,17 +249,16 @@ class DiscoveryEngineClient:
|
|
|
237
249
|
)
|
|
238
250
|
|
|
239
251
|
# Make the request
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
log.info(f"{response=} {metadata=}")
|
|
252
|
+
@self.my_retry()
|
|
253
|
+
def import_documents_with_retry(doc_client, request):
|
|
254
|
+
return doc_client.import_documents(request=request)
|
|
255
|
+
|
|
256
|
+
try:
|
|
257
|
+
operation = import_documents_with_retry(self.doc_client, request)
|
|
258
|
+
except ResourceExhausted as e:
|
|
259
|
+
print(f"Operation failed after retries due to quota exceeded: {e}")
|
|
260
|
+
except Exception as e:
|
|
261
|
+
print(f"An unexpected error occurred: {e}")
|
|
251
262
|
|
|
252
263
|
return operation.operation.name
|
|
253
264
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: sunholo
|
|
3
|
-
Version: 0.69.
|
|
3
|
+
Version: 0.69.9
|
|
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.69.
|
|
6
|
+
Download-URL: https://github.com/sunholo-data/sunholo-py/archive/refs/tags/v0.69.9.tar.gz
|
|
7
7
|
Author: Holosun ApS
|
|
8
8
|
Author-email: multivac@sunholo.com
|
|
9
9
|
License: Apache License, Version 2.0
|
|
@@ -61,9 +61,9 @@ sunholo/database/sql/sb/delete_source_row.sql,sha256=r6fEuUKdbiLHCDGKSbKINDCpJjs
|
|
|
61
61
|
sunholo/database/sql/sb/return_sources.sql,sha256=89KAnxfK8n_qGK9jy1OQT8f9n4uYUtYL5cCxbC2mj_c,255
|
|
62
62
|
sunholo/database/sql/sb/setup.sql,sha256=CvoFvZQev2uWjmFa3aj3m3iuPFzAAJZ0S7Qi3L3-zZI,89
|
|
63
63
|
sunholo/discovery_engine/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
64
|
-
sunholo/discovery_engine/chunker_handler.py,sha256=
|
|
65
|
-
sunholo/discovery_engine/create_new.py,sha256=
|
|
66
|
-
sunholo/discovery_engine/discovery_engine_client.py,sha256=
|
|
64
|
+
sunholo/discovery_engine/chunker_handler.py,sha256=9zv72CxgKlKpOcSAt-XFtq0Ra-Z6tBTwMuXQhRPE5mY,4425
|
|
65
|
+
sunholo/discovery_engine/create_new.py,sha256=7oZG78T6lW0EspRzlo7-qRyXFSuFxDn2dfSAVEaqlqY,978
|
|
66
|
+
sunholo/discovery_engine/discovery_engine_client.py,sha256=UYMhXtGWXuyyg4fA1piVjqfrWXkSP_MFimh6NzaUlZ8,12413
|
|
67
67
|
sunholo/embedder/__init__.py,sha256=sI4N_CqgEVcrMDxXgxKp1FsfsB4FpjoXgPGkl4N_u4I,44
|
|
68
68
|
sunholo/embedder/embed_chunk.py,sha256=P744zUQJgqrjILunzaqtTerB9AwoXFU6tXBtz4rjWgQ,6673
|
|
69
69
|
sunholo/gcs/__init__.py,sha256=DtVw_AZwQn-IguR5BJuIi2XJeF_FQXizhJikzRNrXiE,50
|
|
@@ -111,9 +111,9 @@ sunholo/vertex/__init__.py,sha256=JvHcGFuv6R_nAhY2AdoqqhMpJ5ugeWPZ_svGhWrObBk,13
|
|
|
111
111
|
sunholo/vertex/init.py,sha256=JDMUaBRdednzbKF-5p33qqLit2LMsvgvWW-NRz0AqO0,1801
|
|
112
112
|
sunholo/vertex/memory_tools.py,sha256=8F1iTWnqEK9mX4W5RzCVKIjydIcNp6OFxjn_dtQ3GXo,5379
|
|
113
113
|
sunholo/vertex/safety.py,sha256=3meAX0HyGZYrH7rXPUAHxtI_3w_zoy_RX7Shtkoa660,1275
|
|
114
|
-
sunholo-0.69.
|
|
115
|
-
sunholo-0.69.
|
|
116
|
-
sunholo-0.69.
|
|
117
|
-
sunholo-0.69.
|
|
118
|
-
sunholo-0.69.
|
|
119
|
-
sunholo-0.69.
|
|
114
|
+
sunholo-0.69.9.dist-info/LICENSE.txt,sha256=SdE3QjnD3GEmqqg9EX3TM9f7WmtOzqS1KJve8rhbYmU,11345
|
|
115
|
+
sunholo-0.69.9.dist-info/METADATA,sha256=53jro7ekONplbxTNVWi4DTYXHawjUEnEuLNPi704EwI,6155
|
|
116
|
+
sunholo-0.69.9.dist-info/WHEEL,sha256=mguMlWGMX-VHnMpKOjjQidIo1ssRlCFu4a4mBpz1s2M,91
|
|
117
|
+
sunholo-0.69.9.dist-info/entry_points.txt,sha256=bZuN5AIHingMPt4Ro1b_T-FnQvZ3teBes-3OyO0asl4,49
|
|
118
|
+
sunholo-0.69.9.dist-info/top_level.txt,sha256=wt5tadn5--5JrZsjJz2LceoUvcrIvxjHJe-RxuudxAk,8
|
|
119
|
+
sunholo-0.69.9.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|