sunholo 0.66.22__py3-none-any.whl → 0.67.2__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/swagger.py CHANGED
@@ -198,24 +198,20 @@ See more at https://dev.sunholo.com/
198
198
  }
199
199
  }
200
200
  }
201
-
202
201
  vac_services = vac_config['vac']
203
202
 
204
- for vector_name, config in vac_services.items():
203
+ def configure_agent(vector_name, config, agent_config_paths):
205
204
  agent_type = config['agent']
206
- agent_config_paths = agent_config['agents'].get(agent_type, {})
207
205
  log.info(f'Configuring swagger for agent_type: {agent_type} for vector_name: {vector_name}')
208
206
  try:
209
207
  stem = route_vac(vector_name).strip()
210
208
  except ValueError:
211
209
  log.warning(f"Failed to find URL stem for {vector_name}/{agent_type} - skipping")
212
- continue
213
-
210
+ return
211
+
214
212
  for method, endpoints in agent_config_paths.items():
215
- # controls if get requests are protected or not
216
213
  do_auth = True
217
214
 
218
- # default get: noauth, post: auth
219
215
  if method not in ['get', 'post', 'get-auth', 'post-noauth']:
220
216
  continue
221
217
 
@@ -228,7 +224,7 @@ See more at https://dev.sunholo.com/
228
224
  elif method == 'get':
229
225
  do_auth = False
230
226
  elif method == 'post':
231
- do_auth = True # not needed but to be clear whats happening
227
+ do_auth = True
232
228
 
233
229
  for endpoint_key, endpoint_template in endpoints.items():
234
230
  endpoint_template = endpoint_template.strip()
@@ -262,79 +258,26 @@ See more at https://dev.sunholo.com/
262
258
  }
263
259
  }))
264
260
  }
265
- # Handle default agent configuration for agent types without specific entries
261
+
262
+ for vector_name, config in vac_services.items():
263
+ agent_type = config['agent']
264
+ agent_config_paths = agent_config['agents'].get(agent_type, {})
265
+ configure_agent(vector_name, config, agent_config_paths)
266
+
266
267
  default_agent_config = agent_config['agents'].get('default', {})
267
-
268
+
268
269
  for vector_name, config in vac_services.items():
269
270
  agent_type = config['agent']
270
271
  if agent_type in agent_config['agents']:
271
272
  continue
272
273
  log.info(f'Applying default configuration for agent_type: {agent_type} for vector_name: {vector_name}')
273
- try:
274
- stem = route_vac(vector_name).strip()
275
- except ValueError:
276
- log.warning(f"Failed to find URL stem for {vector_name}/{agent_type} - skipping")
277
- continue
278
-
279
- for method, endpoints in default_agent_config.items():
280
- # controls if get requests are protected or not
281
- do_auth = True
282
-
283
- # default get: noauth, post: auth
284
- if method not in ['get', 'post', 'get-auth', 'post-noauth']:
285
- continue
286
-
287
- if method == 'get-auth':
288
- do_auth = True
289
- method = 'get'
290
- elif method == 'post-noauth':
291
- do_auth = False
292
- method = 'post'
293
- elif method == 'get':
294
- do_auth = False
295
- elif method == 'post':
296
- do_auth = True # not needed but to be clear whats happening
297
-
298
- for endpoint_key, endpoint_template in endpoints.items():
299
- endpoint_template = endpoint_template.strip()
300
- endpoint_address = endpoint_template.replace("{stem}", stem).replace("{vector_name}", vector_name).strip()
301
- endpoint_path = endpoint_template.replace("{stem}", f"/{agent_type}").replace("{vector_name}", vector_name).strip()
302
- log.debug(f"default Endpoint_template: {endpoint_template}")
303
- log.debug(f"default endpoint address: {endpoint_address}")
304
- log.debug(f"default endpoint_path: {endpoint_path}")
305
- if endpoint_path not in swagger_template['paths']:
306
- swagger_template['paths'][endpoint_path] = {}
307
-
308
- operation_id = f"{method}_{agent_type}_{endpoint_key}_{vector_name}"
309
-
310
- security = [{'ApiKeyAuth': []}] if do_auth else [{'None': []}]
311
-
312
- swagger_template['paths'][endpoint_path][method] = {
313
- 'summary': f"{method.capitalize()} {agent_type}",
314
- 'operationId': operation_id,
315
- 'x-google-backend': {
316
- 'address': endpoint_address,
317
- 'protocol': 'h2',
318
- 'deadline': 180000 # Timeout of 3 minutes (1,800,00 milliseconds)
319
- },
320
- 'security': security,
321
- 'responses': copy.deepcopy(default_agent_config.get('response', {}).get(endpoint_key, {
322
- '200': {
323
- 'description': 'Default - A successful response',
324
- 'schema': {
325
- 'type': 'string'
326
- }
327
- }
328
- }))
329
- }
274
+ configure_agent(vector_name, config, default_agent_config)
330
275
 
331
276
  yaml = YAML()
332
- yaml.width = 4096 # to avoid breaking urls
277
+ yaml.width = 4096
333
278
 
334
- # Capture YAML output in a string buffer
335
279
  string_stream = StringIO()
336
280
  yaml.dump(swagger_template, string_stream)
337
281
  yaml_string = string_stream.getvalue()
338
282
 
339
- return yaml_string
340
-
283
+ return yaml_string
@@ -27,9 +27,14 @@ def publish_chunks(chunks: list[Document], vector_name: str):
27
27
 
28
28
  log.info("Publishing chunks to embed_chunk")
29
29
 
30
- pubsub_manager = PubSubManager(vector_name,
31
- pubsub_topic="chunk-to-pubsub-embed",
32
- project_id=project)
30
+ try:
31
+ pubsub_manager = PubSubManager(vector_name,
32
+ pubsub_topic="chunk-to-pubsub-embed",
33
+ project_id=project)
34
+ except Exception as err:
35
+ log.error(f"PubSubManager init error: Could not publish chunks to {project} {vector_name} pubsub_topic chunk-to-pubsub-embed - {str(err)}")
36
+
37
+ return None
33
38
 
34
39
  for chunk in chunks:
35
40
  # Convert chunk to string, as Pub/Sub messages must be strings or bytes
sunholo/cli/chat_vac.py CHANGED
@@ -12,7 +12,6 @@ import sys
12
12
  import subprocess
13
13
  import json
14
14
  import requests
15
- import os
16
15
  from pathlib import Path
17
16
 
18
17
  from rich import print
@@ -320,7 +319,7 @@ def vac_command(args):
320
319
  def invoke_vac(service_url, data, vector_name=None, metadata=None, is_file=False):
321
320
  try:
322
321
  if is_file:
323
- console.print("Uploading file to chunker...")
322
+ console.print("Uploading file...")
324
323
  # Handle file upload
325
324
  if not isinstance(data, Path) or not data.is_file():
326
325
  raise ValueError("For file uploads, 'data' must be a Path object pointing to a valid file.")
@@ -335,7 +334,7 @@ def invoke_vac(service_url, data, vector_name=None, metadata=None, is_file=False
335
334
 
336
335
  response = requests.post(service_url, files=files, data=form_data)
337
336
  else:
338
- console.print("Uploading JSON to chunker...")
337
+ console.print("Uploading JSON...")
339
338
  try:
340
339
  if isinstance(data, dict):
341
340
  json_data = data
@@ -8,6 +8,7 @@ try:
8
8
  from langchain_google_alloydb_pg import AlloyDBEngine, Column, AlloyDBLoader, AlloyDBDocumentSaver
9
9
  from google.cloud.alloydb.connector import IPTypes
10
10
  except ImportError:
11
+ AlloyDBEngine = None
11
12
  pass
12
13
 
13
14
  from .database import get_vector_size
@@ -16,6 +17,10 @@ from ..utils.config import load_config_key
16
17
 
17
18
  def create_alloydb_engine(vector_name):
18
19
 
20
+ if not AlloyDBEngine:
21
+ log.error("Can't create AlloyDBEngine - install via `pip install sunholo[gcp,database]`")
22
+ raise ValueError("Can't import AlloyDBEngine")
23
+
19
24
  alloydb_config = load_config_key(
20
25
  'alloydb_config',
21
26
  vector_name=vector_name,
@@ -124,6 +124,23 @@ def embed_pubsub_chunk(data: dict):
124
124
  if vector_name_other:
125
125
  log.warning(f"Using different vector_name for vectorstore: {vector_name_other} overriding {vector_name}")
126
126
  vector_name = vector_name_other
127
+
128
+ # dynamic vectorstore names (for per user_id stores)
129
+ if value.get('from_metadata_id'):
130
+ the_id = value.get('from_metadata_id')
131
+ log.info(f"Lookup vectorstore vector_name from id: {the_id}")
132
+
133
+ if the_id not in metadata:
134
+ log.warning("Could not find vectorstore from_metadata_id {the_id} in metadata - skipping")
135
+ continue
136
+ else:
137
+ match_id = metadata.get(the_id)
138
+ if match_id:
139
+ vector_name = match_id
140
+ else:
141
+ log.warning("Could not find any value for vectorstore from_metadata_id: {the_id} - skipping")
142
+ continue
143
+
127
144
  vectorstore_obj = pick_vectorstore(vectorstore, vector_name=vector_name, embeddings=embeddings)
128
145
  vs_retriever = vectorstore_obj.as_retriever(search_kwargs=dict(k=3))
129
146
  vectorstore_list.append(vs_retriever)
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sunholo
3
- Version: 0.66.22
3
+ Version: 0.67.2
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.66.22.tar.gz
6
+ Download-URL: https://github.com/sunholo-data/sunholo-py/archive/refs/tags/v0.67.2.tar.gz
7
7
  Author: Holosun ApS
8
8
  Author-email: multivac@sunholo.com
9
9
  License: Apache License, Version 2.0
@@ -21,7 +21,7 @@ License-File: LICENSE.txt
21
21
  Requires-Dist: google-auth
22
22
  Requires-Dist: ruamel.yaml
23
23
  Requires-Dist: langchain >=0.2.5
24
- Requires-Dist: langchain-experimental
24
+ Requires-Dist: langchain-experimental >0.0.60
25
25
  Requires-Dist: langchain-community
26
26
  Provides-Extra: all
27
27
  Requires-Dist: asyncpg ; extra == 'all'
@@ -52,7 +52,7 @@ Requires-Dist: langchain-community ; extra == 'all'
52
52
  Requires-Dist: langchain-openai ; extra == 'all'
53
53
  Requires-Dist: langchain-google-genai ; extra == 'all'
54
54
  Requires-Dist: langchain-google-alloydb-pg ; extra == 'all'
55
- Requires-Dist: langchain-anthropic ; extra == 'all'
55
+ Requires-Dist: langchain-anthropic >=0.1.13 ; extra == 'all'
56
56
  Requires-Dist: langfuse ; extra == 'all'
57
57
  Requires-Dist: pg8000 ; extra == 'all'
58
58
  Requires-Dist: pgvector ; extra == 'all'
@@ -63,9 +63,9 @@ Requires-Dist: rich ; extra == 'all'
63
63
  Requires-Dist: supabase ; extra == 'all'
64
64
  Requires-Dist: tiktoken ; extra == 'all'
65
65
  Provides-Extra: anthropic
66
- Requires-Dist: langchain-anthropic ; extra == 'anthropic'
66
+ Requires-Dist: langchain-anthropic >=0.1.13 ; extra == 'anthropic'
67
67
  Provides-Extra: cli
68
- Requires-Dist: jsonschema ; extra == 'cli'
68
+ Requires-Dist: jsonschema >=4.21.1 ; extra == 'cli'
69
69
  Requires-Dist: rich ; extra == 'cli'
70
70
  Provides-Extra: database
71
71
  Requires-Dist: asyncpg ; extra == 'database'
@@ -86,9 +86,9 @@ Requires-Dist: google-cloud-storage ; extra == 'gcp'
86
86
  Requires-Dist: google-cloud-logging ; extra == 'gcp'
87
87
  Requires-Dist: google-cloud-pubsub ; extra == 'gcp'
88
88
  Requires-Dist: google-cloud-discoveryengine ; extra == 'gcp'
89
- Requires-Dist: google-generativeai ; extra == 'gcp'
90
- Requires-Dist: langchain-google-genai ; extra == 'gcp'
91
- Requires-Dist: langchain-google-alloydb-pg ; extra == 'gcp'
89
+ Requires-Dist: google-generativeai >=0.4.1 ; extra == 'gcp'
90
+ Requires-Dist: langchain-google-genai >=1.0.5 ; extra == 'gcp'
91
+ Requires-Dist: langchain-google-alloydb-pg >=0.2.2 ; extra == 'gcp'
92
92
  Requires-Dist: google-api-python-client ; extra == 'gcp'
93
93
  Requires-Dist: google-cloud-alloydb-connector[pg8000] ; extra == 'gcp'
94
94
  Provides-Extra: http
@@ -7,7 +7,7 @@ sunholo/agents/langserve.py,sha256=FdhQjorAY2bMn2rpuabNT6bU3uqSKWrl8DjpH3L_V7k,4
7
7
  sunholo/agents/pubsub.py,sha256=5hbbhbBGyVWRpt2sAGC5FEheYH1mCCwVUhZEB1S7vGg,1337
8
8
  sunholo/agents/route.py,sha256=V1HKXTvaNuYgjmT5_QgIQum4O7O0Mw497m6YiMpEzX0,2383
9
9
  sunholo/agents/special_commands.py,sha256=ecD5jrBVXo170sdgPILi0m_m_4nRFEv6qKn5zYEvEK8,6494
10
- sunholo/agents/swagger.py,sha256=npZT7jRJA65xMXNjTcYsC3-RMd8qYP71vy_fSCCcKGg,13572
10
+ sunholo/agents/swagger.py,sha256=wK90aGOgUojZjfMcjqhhJ_ksJ6ZCsVT1Iy02oU6Q5XM,10786
11
11
  sunholo/agents/fastapi/__init__.py,sha256=S_pj4_bTUmDGoq_exaREHlOKThi0zTuGT0VZY0YfODQ,88
12
12
  sunholo/agents/fastapi/base.py,sha256=clk76cHbUAvU0OYJrRfCWX_5f0ACbhDsIzYBhI3wyoE,2514
13
13
  sunholo/agents/fastapi/qna_routes.py,sha256=DgK4Btu5XriOC1JaRQ4G_nWEjJfnQ0J5pyLanF6eF1g,3857
@@ -29,10 +29,10 @@ sunholo/chunker/images.py,sha256=Xmh1vwHrVhoXm5iH2dhCc52O8YgdzE8KrDSdL-pGnp8,186
29
29
  sunholo/chunker/loaders.py,sha256=xiToUVgPz2ZzcqpUAq7aNP3PTenb_rBUAFzu0JPycIg,10268
30
30
  sunholo/chunker/message_data.py,sha256=X6aA4yX5aGN_mEvsDPWvdYRqqn5GO1BU9QhT9w5A0ec,6789
31
31
  sunholo/chunker/pdfs.py,sha256=daCZ1xjn1YvxlifIyxskWNpLJLe-Q9D_Jq12MWx3tZo,2473
32
- sunholo/chunker/publish.py,sha256=GNXV6IPdKM2GZUcjGXIERu49D0ITYtizsLIktKVtMjM,2768
32
+ sunholo/chunker/publish.py,sha256=Rh6cfcDjjkMVQeweOaPxc9U1w7u1wiXlIDML20rrxhE,2989
33
33
  sunholo/chunker/splitter.py,sha256=FLkDhkePkg_zGQpFBK13Cznw575D-Rf9pcaCpc1HUxY,6726
34
34
  sunholo/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
35
- sunholo/cli/chat_vac.py,sha256=_M0M1t03QJUdkJEe4Ro74FWRa1LohiztLivbjvK0ECA,18691
35
+ sunholo/cli/chat_vac.py,sha256=CceXT-nNVhXIGtVUg07FT8Azd0LBZN18kvCGIkJq7zM,18659
36
36
  sunholo/cli/cli.py,sha256=8e00HBN6eYIUJ8cnvKteBJNn7aZPRMk4b82jwcGg9D4,3741
37
37
  sunholo/cli/cli_init.py,sha256=JMZ9AX2cPDZ-_mv3adiv2ToFVNyRPtjk9Biszl1kiR0,2358
38
38
  sunholo/cli/configs.py,sha256=QUM9DvKOdZmEQRM5uI3Nh887T0YDiSMr7O240zTLqws,4546
@@ -47,7 +47,7 @@ sunholo/components/llm.py,sha256=T4we3tGmqUj4tPwxQr9M6AXv_BALqZV_dRSvINan-oU,103
47
47
  sunholo/components/retriever.py,sha256=jAgcmEM_D2Qfb3hYqHVZMZMLUEUqUbqmhD6G5czmEas,3820
48
48
  sunholo/components/vectorstore.py,sha256=lB8vx_N6eBA44orNeVo1WRn0Q8GCIjvPPT9AfiPWBWE,5620
49
49
  sunholo/database/__init__.py,sha256=Zz0Shcq-CtStf9rJGIYB_Ybzb8rY_Q9mfSj-nviM490,241
50
- sunholo/database/alloydb.py,sha256=Myk1l97c7cMgZIk3eiJiJzjQW0GLNTlGqbJJwxFIDdQ,17122
50
+ sunholo/database/alloydb.py,sha256=UeWbk_DAqivquMGibX_tz8v1Jza9qnf4SWThNBG2Dh4,17327
51
51
  sunholo/database/database.py,sha256=UDHkceiEvJmS3esQX2LYEjEMrHcogN_JHuJXoVWCH3M,7354
52
52
  sunholo/database/lancedb.py,sha256=2rAbJVusMrm5TPtVTsUtmwn0z1iZ_wvbKhc6eyT6ClE,708
53
53
  sunholo/database/static_dbs.py,sha256=aOyU3AJ-Dzz3qSNjbuN2293cfYw5PhkcQuQxdwPMJ4w,435
@@ -59,7 +59,7 @@ sunholo/database/sql/sb/delete_source_row.sql,sha256=r6fEuUKdbiLHCDGKSbKINDCpJjs
59
59
  sunholo/database/sql/sb/return_sources.sql,sha256=89KAnxfK8n_qGK9jy1OQT8f9n4uYUtYL5cCxbC2mj_c,255
60
60
  sunholo/database/sql/sb/setup.sql,sha256=CvoFvZQev2uWjmFa3aj3m3iuPFzAAJZ0S7Qi3L3-zZI,89
61
61
  sunholo/embedder/__init__.py,sha256=sI4N_CqgEVcrMDxXgxKp1FsfsB4FpjoXgPGkl4N_u4I,44
62
- sunholo/embedder/embed_chunk.py,sha256=E6fHn2SFeQu9jsBO1wg5hSJUPTKbZ95Yc5QOltSn7jo,5840
62
+ sunholo/embedder/embed_chunk.py,sha256=P744zUQJgqrjILunzaqtTerB9AwoXFU6tXBtz4rjWgQ,6673
63
63
  sunholo/gcs/__init__.py,sha256=DtVw_AZwQn-IguR5BJuIi2XJeF_FQXizhJikzRNrXiE,50
64
64
  sunholo/gcs/add_file.py,sha256=ILU3Nq-rYjL0Ini9op6jBYtXCDl3iTO61ZA1q2zykJQ,5537
65
65
  sunholo/gcs/download_url.py,sha256=8XSEf8byfubqs5CMQeF_tn9wxqwUTq3n9mo5mLNIUTA,4801
@@ -105,9 +105,9 @@ sunholo/vertex/__init__.py,sha256=JvHcGFuv6R_nAhY2AdoqqhMpJ5ugeWPZ_svGhWrObBk,13
105
105
  sunholo/vertex/init.py,sha256=JDMUaBRdednzbKF-5p33qqLit2LMsvgvWW-NRz0AqO0,1801
106
106
  sunholo/vertex/memory_tools.py,sha256=8F1iTWnqEK9mX4W5RzCVKIjydIcNp6OFxjn_dtQ3GXo,5379
107
107
  sunholo/vertex/safety.py,sha256=3meAX0HyGZYrH7rXPUAHxtI_3w_zoy_RX7Shtkoa660,1275
108
- sunholo-0.66.22.dist-info/LICENSE.txt,sha256=SdE3QjnD3GEmqqg9EX3TM9f7WmtOzqS1KJve8rhbYmU,11345
109
- sunholo-0.66.22.dist-info/METADATA,sha256=IlI07pylXN-AMnC-00izt6cVpgCDJhbHpVzIom3CMwE,6098
110
- sunholo-0.66.22.dist-info/WHEEL,sha256=cpQTJ5IWu9CdaPViMhC9YzF8gZuS5-vlfoFihTBC86A,91
111
- sunholo-0.66.22.dist-info/entry_points.txt,sha256=bZuN5AIHingMPt4Ro1b_T-FnQvZ3teBes-3OyO0asl4,49
112
- sunholo-0.66.22.dist-info/top_level.txt,sha256=wt5tadn5--5JrZsjJz2LceoUvcrIvxjHJe-RxuudxAk,8
113
- sunholo-0.66.22.dist-info/RECORD,,
108
+ sunholo-0.67.2.dist-info/LICENSE.txt,sha256=SdE3QjnD3GEmqqg9EX3TM9f7WmtOzqS1KJve8rhbYmU,11345
109
+ sunholo-0.67.2.dist-info/METADATA,sha256=G-TlF50LwSi1KvftHrX-teBH5e0RIAk8xFQtS0JGCDg,6155
110
+ sunholo-0.67.2.dist-info/WHEEL,sha256=cpQTJ5IWu9CdaPViMhC9YzF8gZuS5-vlfoFihTBC86A,91
111
+ sunholo-0.67.2.dist-info/entry_points.txt,sha256=bZuN5AIHingMPt4Ro1b_T-FnQvZ3teBes-3OyO0asl4,49
112
+ sunholo-0.67.2.dist-info/top_level.txt,sha256=wt5tadn5--5JrZsjJz2LceoUvcrIvxjHJe-RxuudxAk,8
113
+ sunholo-0.67.2.dist-info/RECORD,,