sunholo 0.69.16__py3-none-any.whl → 0.70.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.
@@ -60,10 +60,10 @@ def process_chunker_data(message_data, metadata, vector_name):
60
60
  metadata["vector_name"] = vector_name
61
61
 
62
62
  if message_data is None:
63
- log.error(f"No message_data was found in data: {message_data}")
63
+ log.warning(f"No message_data was found in data: {metadata=}")
64
64
  return
65
65
 
66
- log.debug(f"Found metadata in pubsub: {metadata}")
66
+ log.debug(f"Found metadata in pubsub: {metadata=}")
67
67
 
68
68
  # checks if only a llamaindex chunking/embedder, return early as no other processing needed
69
69
  llamacheck = llamaindex_chunker_check(message_data, metadata, vector_name)
sunholo/cli/chat_vac.py CHANGED
@@ -211,7 +211,11 @@ def headless_mode(service_url, service_name, user_input, chat_history=None, stre
211
211
  if isinstance(token, bytes):
212
212
  token = token.decode('utf-8')
213
213
  print(token, end='', flush=True)
214
- answer += token
214
+ if isinstance(token, dict):
215
+ # ?
216
+ pass
217
+ elif isinstance(token, str):
218
+ answer += token
215
219
 
216
220
  if answer:
217
221
  chat_history.append({"name": "Human", "content": user_input})
@@ -80,6 +80,13 @@ class DiscoveryEngineClient:
80
80
  predicate=if_exception_type(ResourceExhausted) # Retry if a ResourceExhausted error occurs
81
81
  )
82
82
 
83
+ def data_store_path(self, collection: str = "default_collection"):
84
+ return self.store_client.collection_path(
85
+ project=self.project_id,
86
+ location=self.location,
87
+ collection=collection,
88
+ )
89
+
83
90
  def create_data_store(
84
91
  self, chunk_size: int = 500,
85
92
  collection: str = "default_collection"
@@ -121,15 +128,9 @@ class DiscoveryEngineClient:
121
128
  document_processing_config=doc_config
122
129
  )
123
130
 
124
- parent = self.store_client.collection_path(
125
- project=self.project_id,
126
- location=self.location,
127
- collection=collection,
128
- )
129
-
130
131
  # https://cloud.google.com/python/docs/reference/discoveryengine/0.11.4/google.cloud.discoveryengine_v1alpha.types.CreateDataStoreRequest
131
132
  request = discoveryengine.CreateDataStoreRequest(
132
- parent=parent,
133
+ parent=self.data_store_path(collection),
133
134
  data_store_id=self.data_store_id,
134
135
  data_store=data_store,
135
136
  # Optional: For Advanced Site Search Only
sunholo/vertex/init.py CHANGED
@@ -1,6 +1,7 @@
1
1
  from ..logging import log
2
+ from ..utils.gcp_project import get_gcp_project
2
3
 
3
- def init_vertex(gcp_config):
4
+ def init_vertex(gcp_config=None, location="eu"):
4
5
  """
5
6
  Initializes the Vertex AI environment using the provided Google Cloud Platform configuration.
6
7
 
@@ -12,6 +13,7 @@ def init_vertex(gcp_config):
12
13
  gcp_config (dict): A dictionary containing the Google Cloud Platform configuration with keys:
13
14
  - 'project_id': The Google Cloud project ID to configure for Vertex AI.
14
15
  - 'location': The Google Cloud region to configure for Vertex AI.
16
+ If default None it will derive it from the environment
15
17
 
16
18
  Raises:
17
19
  KeyError: If the necessary keys ('project_id' or 'location') are missing in the gcp_config dictionary.
@@ -37,7 +39,11 @@ def init_vertex(gcp_config):
37
39
 
38
40
  return None
39
41
 
40
- # Initialize Vertex AI API once per session
41
- project_id = gcp_config.get('project_id')
42
- location = gcp_config.get('location')
42
+ if gcp_config:
43
+ # Initialize Vertex AI API once per session
44
+ project_id = gcp_config.get('project_id')
45
+ location = gcp_config.get('location') or location
46
+ else:
47
+ project_id = get_gcp_project()
48
+
43
49
  vertexai.init(project=project_id, location=location)
@@ -8,6 +8,8 @@ from ..logging import log
8
8
  from ..utils.config import load_config_key
9
9
  from ..components import load_memories
10
10
  from ..llamaindex.get_files import fetch_corpus
11
+ from ..discovery_engine.discovery_engine_client import DiscoveryEngineClient
12
+ from ..utils.gcp_project import get_gcp_project
11
13
 
12
14
  def get_vertex_memories(vector_name):
13
15
  """
@@ -42,10 +44,7 @@ def get_vertex_memories(vector_name):
42
44
  if not rag:
43
45
  raise ValueError("Need to install vertexai module via `pip install sunholo[gcp]`")
44
46
 
45
- global_project_id = gcp_config.get('project_id')
46
47
  global_location = gcp_config.get('location')
47
- global_rag_id = gcp_config.get('rag_id')
48
- global_data_store_id = gcp_config.get('data_store_id')
49
48
 
50
49
  memories = load_memories(vector_name)
51
50
  tools = []
@@ -60,12 +59,16 @@ def get_vertex_memories(vector_name):
60
59
  if vectorstore == "llamaindex":
61
60
  log.info(f"Found vectorstore {vectorstore}")
62
61
  rag_id = value.get('rag_id')
62
+ if rag_id is None:
63
+ raise ValueError("Must specify rag_id if using vectorstore: llamaindex")
64
+
63
65
  project_id = gcp_config.get('project_id')
64
66
  location = gcp_config.get('location')
67
+
65
68
  corpus = fetch_corpus(
66
- project_id=project_id or global_project_id,
69
+ project_id=project_id or get_gcp_project(),
67
70
  location=location or global_location,
68
- rag_id=rag_id or global_rag_id
71
+ rag_id=rag_id
69
72
  )
70
73
  corpus_tool = Tool.from_retrieval(
71
74
  retrieval=rag.Retrieval(
@@ -76,13 +79,12 @@ def get_vertex_memories(vector_name):
76
79
  )
77
80
  )
78
81
  tools.append(corpus_tool)
79
- elif vectorstore == "vertexai_agent_builder":
82
+ elif vectorstore == "discovery_engine" or vectorstore == "vertex_ai_search":
83
+
84
+ de = DiscoveryEngineClient(vector_name, project_id=get_gcp_project())
80
85
  log.info(f"Found vectorstore {vectorstore}")
81
- data_store_id = value.get('data_store_id') or global_data_store_id
82
- project_id = gcp_config.get('project_id') or global_project_id
83
- location = gcp_config.get('location') or global_location
84
- data_store_path=f"projects/{project_id}/locations/{location}/collections/default_collection/dataStores/{data_store_id}"
85
86
 
87
+ data_store_path = de.data_store_path()
86
88
  corpus_tool = Tool.from_retrieval(
87
89
  grounding.Retrieval(grounding.VertexAISearch(datastore=data_store_path))
88
90
  )
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sunholo
3
- Version: 0.69.16
3
+ Version: 0.70.0
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.16.tar.gz
6
+ Download-URL: https://github.com/sunholo-data/sunholo-py/archive/refs/tags/v0.70.0.tar.gz
7
7
  Author: Holosun ApS
8
8
  Author-email: multivac@sunholo.com
9
9
  License: Apache License, Version 2.0
@@ -24,7 +24,7 @@ sunholo/bots/discord.py,sha256=cCFae5K1BCa6JVkWGLh_iZ9qFO1JpXb6K4eJrlDfEro,2442
24
24
  sunholo/bots/github_webhook.py,sha256=5pQPRLM_wxxcILVaIzUDV8Kt7Arcm2dL1r1kMMHA524,9629
25
25
  sunholo/bots/webapp.py,sha256=EIMxdAJ_xtufwJmvnn7N_Fb_1hZ9DjhJ0Kf_hp02vEU,1926
26
26
  sunholo/chunker/__init__.py,sha256=yWYwpejyYxDpZv1joTrFMsh2SWAkd0z7a1VKtmOfMhA,77
27
- sunholo/chunker/data_to_embed_pubsub.py,sha256=tL9J7s-F4szmpbZYU4dpvLr5R-LgiuZLpRvhQnrTD1E,4203
27
+ sunholo/chunker/data_to_embed_pubsub.py,sha256=-bXtm3Tn6YczUWL9kSAc6OWdD6dDY2rKhgpD-90H6ms,4203
28
28
  sunholo/chunker/doc_handling.py,sha256=rIyknpzDyj5A0u_DqSQVD_CXLRNZPOU6TCL4bhCdjOI,8563
29
29
  sunholo/chunker/images.py,sha256=Xmh1vwHrVhoXm5iH2dhCc52O8YgdzE8KrDSdL-pGnp8,1861
30
30
  sunholo/chunker/loaders.py,sha256=xiToUVgPz2ZzcqpUAq7aNP3PTenb_rBUAFzu0JPycIg,10268
@@ -33,7 +33,7 @@ sunholo/chunker/pdfs.py,sha256=daCZ1xjn1YvxlifIyxskWNpLJLe-Q9D_Jq12MWx3tZo,2473
33
33
  sunholo/chunker/publish.py,sha256=tiO615A2uo_ZjzdFDzNH1PL_1kJeLMUQwLJ4w67rNIc,2932
34
34
  sunholo/chunker/splitter.py,sha256=FLkDhkePkg_zGQpFBK13Cznw575D-Rf9pcaCpc1HUxY,6726
35
35
  sunholo/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
36
- sunholo/cli/chat_vac.py,sha256=CceXT-nNVhXIGtVUg07FT8Azd0LBZN18kvCGIkJq7zM,18659
36
+ sunholo/cli/chat_vac.py,sha256=NcXQcz0HHE0epfUPmDat5Fk8XaDrTFGs3MINQlBu1vo,18785
37
37
  sunholo/cli/cli.py,sha256=8e00HBN6eYIUJ8cnvKteBJNn7aZPRMk4b82jwcGg9D4,3741
38
38
  sunholo/cli/cli_init.py,sha256=JMZ9AX2cPDZ-_mv3adiv2ToFVNyRPtjk9Biszl1kiR0,2358
39
39
  sunholo/cli/configs.py,sha256=QUM9DvKOdZmEQRM5uI3Nh887T0YDiSMr7O240zTLqws,4546
@@ -63,7 +63,7 @@ sunholo/database/sql/sb/setup.sql,sha256=CvoFvZQev2uWjmFa3aj3m3iuPFzAAJZ0S7Qi3L3
63
63
  sunholo/discovery_engine/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
64
64
  sunholo/discovery_engine/chunker_handler.py,sha256=puNnV6vKnjNqk28FLnsIPMNsC-1Y6s20PK7ioi8qwzc,4491
65
65
  sunholo/discovery_engine/create_new.py,sha256=7oZG78T6lW0EspRzlo7-qRyXFSuFxDn2dfSAVEaqlqY,978
66
- sunholo/discovery_engine/discovery_engine_client.py,sha256=aiEfn0511pIaS4lj6GwVA6LOiBn_PPphmMZGfjLfj5o,14486
66
+ sunholo/discovery_engine/discovery_engine_client.py,sha256=n4euIZjc3pWUYfoFhpvReIzHXnIYO8J9nKC8euKSTgY,14581
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
@@ -108,12 +108,12 @@ sunholo/utils/timedelta.py,sha256=BbLabEx7_rbErj_YbNM0MBcaFN76DC4PTe4zD2ucezg,49
108
108
  sunholo/utils/user_ids.py,sha256=SQd5_H7FE7vcTZp9AQuQDWBXd4FEEd7TeVMQe1H4Ny8,292
109
109
  sunholo/utils/version.py,sha256=jjU_4anXBikJxPg0Wur0X-B7-ec1tC7jToykAnAG9Dg,108
110
110
  sunholo/vertex/__init__.py,sha256=JvHcGFuv6R_nAhY2AdoqqhMpJ5ugeWPZ_svGhWrObBk,136
111
- sunholo/vertex/init.py,sha256=JDMUaBRdednzbKF-5p33qqLit2LMsvgvWW-NRz0AqO0,1801
112
- sunholo/vertex/memory_tools.py,sha256=8F1iTWnqEK9mX4W5RzCVKIjydIcNp6OFxjn_dtQ3GXo,5379
111
+ sunholo/vertex/init.py,sha256=RLjQppTUwubWgwf2PoAke-EtcwlVkFPaPMYvUsMw1KQ,2029
112
+ sunholo/vertex/memory_tools.py,sha256=Qo6-uV0_SlwBsCEYsPnrr1l_2UH_zLT_xPxiC9XxGQg,5278
113
113
  sunholo/vertex/safety.py,sha256=3meAX0HyGZYrH7rXPUAHxtI_3w_zoy_RX7Shtkoa660,1275
114
- sunholo-0.69.16.dist-info/LICENSE.txt,sha256=SdE3QjnD3GEmqqg9EX3TM9f7WmtOzqS1KJve8rhbYmU,11345
115
- sunholo-0.69.16.dist-info/METADATA,sha256=VHUSz1m6mWug70lj_pLHCxZFeMK72-xyE3xZqbtkxSQ,6242
116
- sunholo-0.69.16.dist-info/WHEEL,sha256=mguMlWGMX-VHnMpKOjjQidIo1ssRlCFu4a4mBpz1s2M,91
117
- sunholo-0.69.16.dist-info/entry_points.txt,sha256=bZuN5AIHingMPt4Ro1b_T-FnQvZ3teBes-3OyO0asl4,49
118
- sunholo-0.69.16.dist-info/top_level.txt,sha256=wt5tadn5--5JrZsjJz2LceoUvcrIvxjHJe-RxuudxAk,8
119
- sunholo-0.69.16.dist-info/RECORD,,
114
+ sunholo-0.70.0.dist-info/LICENSE.txt,sha256=SdE3QjnD3GEmqqg9EX3TM9f7WmtOzqS1KJve8rhbYmU,11345
115
+ sunholo-0.70.0.dist-info/METADATA,sha256=Jc55TzM3gNp1oMX2mF6sW-55-BjYesOKO_mVa9U15y4,6240
116
+ sunholo-0.70.0.dist-info/WHEEL,sha256=mguMlWGMX-VHnMpKOjjQidIo1ssRlCFu4a4mBpz1s2M,91
117
+ sunholo-0.70.0.dist-info/entry_points.txt,sha256=bZuN5AIHingMPt4Ro1b_T-FnQvZ3teBes-3OyO0asl4,49
118
+ sunholo-0.70.0.dist-info/top_level.txt,sha256=wt5tadn5--5JrZsjJz2LceoUvcrIvxjHJe-RxuudxAk,8
119
+ sunholo-0.70.0.dist-info/RECORD,,