sunholo 0.61.0__py3-none-any.whl → 0.61.5__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.
@@ -74,7 +74,7 @@ def embeds_to_json(message: dict):
74
74
  # Output: '[{"type": "image", "url": "https://example.com/image.png"}]'
75
75
  ```
76
76
  """
77
- if len(message['embeds'] > 0):
77
+ if 'embeds' in message and len(message['embeds']) > 0:
78
78
  return json.dumps(message.get("embeds"))
79
79
  else:
80
80
  return ""
sunholo/cli/chat_vac.py CHANGED
@@ -9,6 +9,7 @@ import uuid
9
9
  import sys
10
10
  import subprocess
11
11
  import json
12
+ import requests
12
13
 
13
14
  from rich import print
14
15
  from .sun_rich import console
@@ -143,27 +144,46 @@ def headless_mode(service_url, service_name, user_input, chat_history=None):
143
144
 
144
145
  return chat_history
145
146
 
147
+ def resolve_service_url(args):
148
+
149
+ if args.url_override:
150
+
151
+ return args.url_override
152
+
153
+ if not args.no_proxy:
154
+ try:
155
+ service_url = get_service_url(args.vac_name, args.project, args.region)
156
+ except ValueError as e:
157
+ console.print(f"[bold red]ERROR: Could not start {args.vac_name} proxy URL: {str(e)}[/bold red]")
158
+ sys.exit(1)
159
+ else:
160
+ console.print(f"Not using a proxy, connecting directly to {service_url}")
161
+
162
+ agent_url = load_config_key("agent_url", args.vac_name, "vacConfig")
163
+ if agent_url:
164
+ console.print("Found agent_url within vacConfig: {agent_url}")
165
+
166
+ service_url = agent_url or get_cloud_run_service_url(args.project, args.region, args.vac_name)
167
+
168
+ return service_url
146
169
 
147
170
  def vac_command(args):
171
+
172
+ service_url = resolve_service_url(args)
173
+
148
174
  if args.action == 'list':
175
+
149
176
  list_cloud_run_services(args.project, args.region)
177
+
150
178
  return
179
+
151
180
  elif args.action == 'get-url':
152
- service_url = get_cloud_run_service_url(args.project, args.region, args.vac_name)
153
- if service_url:
154
- console.print(service_url)
155
- return
156
- elif args.action == 'chat':
157
181
 
158
- if not args.no_proxy:
159
- try:
160
- service_url = get_service_url(args.vac_name, args.project, args.region)
161
- except ValueError as e:
162
- console.print(f"[bold red]ERROR: Could not start {args.vac_name} proxy URL: {str(e)}[/bold red]")
163
- sys.exit(1)
164
- else:
165
- service_url = get_cloud_run_service_url(args.project, args.region, args.vac_name)
166
- console.print(f"Not using a proxy, connecting directly to {service_url}")
182
+ console.print(service_url)
183
+
184
+ return
185
+
186
+ elif args.action == 'chat':
167
187
 
168
188
  agent_name = load_config_key("agent", args.vac_name, kind="vacConfig")
169
189
 
@@ -188,6 +208,24 @@ def vac_command(args):
188
208
 
189
209
  stop_proxy(agent_name, stop_local=False)
190
210
 
211
+ elif args.action == 'invoke':
212
+ try:
213
+ json_data = json.loads(args.data)
214
+ except json.JSONDecodeError as err:
215
+ console.print(f"[bold red]ERROR: invalid JSON: {str(err)} [/bold red]")
216
+ sys.exit(1)
217
+
218
+ invoke_vac(service_url, json_data)
219
+
220
+ def invoke_vac(service_url, data):
221
+ try:
222
+ headers = {"Content-Type": "application/json"}
223
+ response = requests.post(service_url, headers=headers, data=json.dumps(data))
224
+ response.raise_for_status()
225
+ print(response.json())
226
+ except requests.exceptions.RequestException as e:
227
+ console.print(f"[bold red]ERROR: Failed to invoke VAC: {e}[/bold red]")
228
+
191
229
 
192
230
  def list_cloud_run_services(project, region):
193
231
  """
@@ -281,6 +319,8 @@ def setup_vac_subparser(subparsers):
281
319
  subparsers: The subparsers object from argparse.ArgumentParser().
282
320
  """
283
321
  vac_parser = subparsers.add_parser('vac', help='Interact with deployed VAC services.')
322
+ vac_parser.add_argument('--url_override', help='Override the VAC service URL.')
323
+ vac_parser.add_argument('--no-proxy', action='store_true', help='Do not use the proxy and connect directly to the VAC service.')
284
324
  vac_subparsers = vac_parser.add_subparsers(dest='action', help='VAC subcommands')
285
325
 
286
326
  # Subcommand for listing VAC services
@@ -296,6 +336,10 @@ def setup_vac_subparser(subparsers):
296
336
  chat_parser.add_argument('user_input', help='User input for the VAC service when in headless mode.', nargs='?', default=None)
297
337
  chat_parser.add_argument('--headless', action='store_true', help='Run in headless mode.')
298
338
  chat_parser.add_argument('--chat_history', help='Chat history for headless mode (as JSON string).', default=None)
299
- chat_parser.add_argument('--no-proxy', action='store_true', help='Do not use the proxy and connect directly to the VAC service.')
339
+
340
+ # Subcommand for invoking a VAC service directly
341
+ invoke_parser = vac_subparsers.add_parser('invoke', help='Invoke a VAC service directly with custom data.')
342
+ invoke_parser.add_argument('vac_name', help='Name of the VAC service.')
343
+ invoke_parser.add_argument('data', help='Data to send to the VAC service (as JSON string).')
300
344
 
301
345
  vac_parser.set_defaults(func=vac_command)
@@ -45,7 +45,7 @@ def pick_vectorstore(vs_str, vector_name, embeddings, read_only=None):
45
45
  return vectorstore
46
46
 
47
47
  elif vs_str == 'cloudsql' or vs_str == 'postgres':
48
- from langchain.vectorstores.pgvector import PGVector
48
+ from langchain_community.vectorstores import PGVector
49
49
 
50
50
  log.debug("Inititaing CloudSQL/Postgres pgvector")
51
51
  #setup_cloudsql(vector_name)
sunholo/utils/config.py CHANGED
@@ -75,7 +75,7 @@ def load_all_configs():
75
75
  if filename in config_cache:
76
76
  cached_config, cache_time = config_cache[filename]
77
77
  if (current_time - cache_time) < timedelta(minutes=5):
78
- log.info(f"Returning cached config for {filename}")
78
+ log.debug(f"Returning cached config for {filename}")
79
79
  config = cached_config
80
80
  else:
81
81
  config = reload_config_file(config_file, filename)
@@ -167,7 +167,7 @@ def load_config(filename: str=None) -> tuple[dict, str]:
167
167
 
168
168
  return config, filename
169
169
 
170
- def load_config_key(key: str, vector_name: str, kind: str=None):
170
+ def load_config_key(key: str, vector_name: str, kind: str):
171
171
  """
172
172
  Load a specific key from a configuration file.
173
173
 
@@ -192,27 +192,16 @@ def load_config_key(key: str, vector_name: str, kind: str=None):
192
192
 
193
193
  configs_by_kind = load_all_configs()
194
194
 
195
- if kind:
196
- log.debug(f"Got kind: {kind} - applying to configs")
195
+ log.debug(f"Got kind: {kind} - applying to configs")
197
196
 
198
197
  if not configs_by_kind:
199
198
  log.warning("Did not load configs via folder")
200
199
 
201
- if kind and configs_by_kind.get(kind):
202
- config = configs_by_kind[kind]
203
- filename = kind
204
- else:
205
- config, filename = load_config(filename)
200
+ config = configs_by_kind[kind]
206
201
 
207
- log.debug(f"Fetching '{key}' for '{vector_name}'")
208
202
  apiVersion = config.get('apiVersion')
209
- kind = config.get('kind')
210
- vac = config.get('vac')
211
203
 
212
- if not apiVersion or not kind:
213
- raise ValueError("Deprecated config file, move to config with `apiVersion` and `kind` set")
214
-
215
- log.debug(f"Loaded config file {kind}/{apiVersion}")
204
+ log.debug(f"Fetching '{key}' for '{vector_name}' from '{kind}/{apiVersion}'")
216
205
 
217
206
  if kind == 'vacConfig':
218
207
  if vector_name == 'global':
@@ -226,7 +215,7 @@ def load_config_key(key: str, vector_name: str, kind: str=None):
226
215
  raise ValueError("Deprecated config file, move to config with `vac:` at top level for `vector_name`")
227
216
  vac_config = vac.get(vector_name)
228
217
  if not vac_config:
229
- raise ValueError(f"No config array was found for {vector_name} in {filename}")
218
+ raise ValueError(f"No config array was found for {vector_name} in {kind}")
230
219
 
231
220
  log.debug(f'vac_config: {vac_config} for {vector_name} - fetching "{key}"')
232
221
  key_value = vac_config.get(key)
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sunholo
3
- Version: 0.61.0
3
+ Version: 0.61.5
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.61.0.tar.gz
6
+ Download-URL: https://github.com/sunholo-data/sunholo-py/archive/refs/tags/v0.61.5.tar.gz
7
7
  Author: Holosun ApS
8
8
  Author-email: multivac@sunholo.com
9
9
  License: Apache License, Version 2.0
@@ -1,7 +1,7 @@
1
1
  sunholo/__init__.py,sha256=0CdpufyRKWyZe7J7UKigL6j_qOorM-p0OjHIAuf9M38,864
2
2
  sunholo/logging.py,sha256=1jzfy4q9h5DNG4MjwtbTiM8keZxymlrZ0gDQEtGLMHY,11400
3
3
  sunholo/agents/__init__.py,sha256=CnlbVohPt-Doth9PyROSlN3P8xMV9j9yS19YE-wCS90,341
4
- sunholo/agents/chat_history.py,sha256=PbwYmw1TwzI8H-cwQIGgHZ6UIr2Qb-JWow0RG3ayLM8,5195
4
+ sunholo/agents/chat_history.py,sha256=bkII7PNEbGCaobu2Rnr2rM9dim3BCK0kM-tiWhoI1tw,5219
5
5
  sunholo/agents/dispatch_to_qa.py,sha256=h5qbcPqJ5JGa21T8Z5is7jbn4eG3P4xULLj_X25q3WM,8208
6
6
  sunholo/agents/langserve.py,sha256=FdhQjorAY2bMn2rpuabNT6bU3uqSKWrl8DjpH3L_V7k,4375
7
7
  sunholo/agents/pubsub.py,sha256=5hbbhbBGyVWRpt2sAGC5FEheYH1mCCwVUhZEB1S7vGg,1337
@@ -31,7 +31,7 @@ sunholo/chunker/pdfs.py,sha256=daCZ1xjn1YvxlifIyxskWNpLJLe-Q9D_Jq12MWx3tZo,2473
31
31
  sunholo/chunker/publish.py,sha256=PoT8q3XJeFCg10WrLkYhuaaXIrGVkvUD3-R9IfoWoH4,2703
32
32
  sunholo/chunker/splitter.py,sha256=FLkDhkePkg_zGQpFBK13Cznw575D-Rf9pcaCpc1HUxY,6726
33
33
  sunholo/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
34
- sunholo/cli/chat_vac.py,sha256=_NUjwATKvzwfnBJRedP2GqPFNeaCF5F8OvdygXRH1LY,11379
34
+ sunholo/cli/chat_vac.py,sha256=hroQtcf12nYaHaYObE4EeNlHmcB4BZl6LBs_yhSnwYI,12713
35
35
  sunholo/cli/cli.py,sha256=cogY1F5rcIGFYpZVFtbDNlAIElpfyPSCvSLC1ZIpHXg,2666
36
36
  sunholo/cli/cli_init.py,sha256=JMZ9AX2cPDZ-_mv3adiv2ToFVNyRPtjk9Biszl1kiR0,2358
37
37
  sunholo/cli/configs.py,sha256=QUM9DvKOdZmEQRM5uI3Nh887T0YDiSMr7O240zTLqws,4546
@@ -43,7 +43,7 @@ sunholo/components/__init__.py,sha256=RJGNEihwvRIiDScKis04RHJv4yZGI1UpXlOmuCptNZ
43
43
  sunholo/components/llm.py,sha256=T4we3tGmqUj4tPwxQr9M6AXv_BALqZV_dRSvINan-oU,10374
44
44
  sunholo/components/prompt.py,sha256=eZSghXkIlRzXiSrzgkG7e5ytUYq6R6LV-qjHU8jStig,6353
45
45
  sunholo/components/retriever.py,sha256=_Lyt9RIgb2PD-rhV6oKAadiUs3ukT5uAYGW197tEskw,3755
46
- sunholo/components/vectorstore.py,sha256=dzspqOBtuxSjCFxem5_50sqwUUjbZ4oBYERtCwxZR6E,5619
46
+ sunholo/components/vectorstore.py,sha256=lB8vx_N6eBA44orNeVo1WRn0Q8GCIjvPPT9AfiPWBWE,5620
47
47
  sunholo/database/__init__.py,sha256=Zz0Shcq-CtStf9rJGIYB_Ybzb8rY_Q9mfSj-nviM490,241
48
48
  sunholo/database/alloydb.py,sha256=0zRLyeC9nACzj3v36ET9NqLeuzdwBJ2bE09CzgVTTFM,17098
49
49
  sunholo/database/database.py,sha256=doY05kG8BZBLL-arh4hq5ef1ouWOtGHqdsDc6M2YHgk,7345
@@ -88,16 +88,16 @@ sunholo/summarise/__init__.py,sha256=MZk3dblUMODcPb1crq4v-Z508NrFIpkSWNf9FIO8BcU
88
88
  sunholo/summarise/summarise.py,sha256=C3HhjepTjUhUC8FLk4jMQIBvq1BcORniwuTFHjPVhVo,3784
89
89
  sunholo/utils/__init__.py,sha256=G11nN_6ATjxpuMfG_BvcUr9UU8onPIgkpTK6CjOcbr8,48
90
90
  sunholo/utils/big_context.py,sha256=gJIP7_ZL-YSLhOMq8jmFTMqH1wq8eB1NK7oKPeZAq2s,5578
91
- sunholo/utils/config.py,sha256=3GSDFGbHugB3qlkHadKi3Z1CEr6EZhCOQ3TiNt03nNU,8594
91
+ sunholo/utils/config.py,sha256=M755G2VGVsfRvGBv2hM18KzFiSf5lJ6wj3ncDBCvWtg,8215
92
92
  sunholo/utils/config_schema.py,sha256=Wv-ncitzljOhgbDaq9qnFqH5LCuxNv59dTGDWgd1qdk,4189
93
93
  sunholo/utils/gcp.py,sha256=B2G1YKjeD7X9dqO86Jrp2vPuFwZ223Xl5Tg09Ndw-oc,5760
94
94
  sunholo/utils/parsers.py,sha256=OrHmASqIbI45atVOhiGodgLvnfrzkvVzyHnSvAXD89I,3841
95
95
  sunholo/utils/user_ids.py,sha256=SQd5_H7FE7vcTZp9AQuQDWBXd4FEEd7TeVMQe1H4Ny8,292
96
96
  sunholo/vertex/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
97
97
  sunholo/vertex/init_vertex.py,sha256=JDMUaBRdednzbKF-5p33qqLit2LMsvgvWW-NRz0AqO0,1801
98
- sunholo-0.61.0.dist-info/LICENSE.txt,sha256=SdE3QjnD3GEmqqg9EX3TM9f7WmtOzqS1KJve8rhbYmU,11345
99
- sunholo-0.61.0.dist-info/METADATA,sha256=bgegQWs1_EJTqy_Xqwebux6L8ACVcJn-wtuVPxpw_yw,8057
100
- sunholo-0.61.0.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
101
- sunholo-0.61.0.dist-info/entry_points.txt,sha256=bZuN5AIHingMPt4Ro1b_T-FnQvZ3teBes-3OyO0asl4,49
102
- sunholo-0.61.0.dist-info/top_level.txt,sha256=wt5tadn5--5JrZsjJz2LceoUvcrIvxjHJe-RxuudxAk,8
103
- sunholo-0.61.0.dist-info/RECORD,,
98
+ sunholo-0.61.5.dist-info/LICENSE.txt,sha256=SdE3QjnD3GEmqqg9EX3TM9f7WmtOzqS1KJve8rhbYmU,11345
99
+ sunholo-0.61.5.dist-info/METADATA,sha256=tJ2thVA-C3VH57sGLxsCI1dIVZ-H9gmxX-x8bzvaeQY,8057
100
+ sunholo-0.61.5.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
101
+ sunholo-0.61.5.dist-info/entry_points.txt,sha256=bZuN5AIHingMPt4Ro1b_T-FnQvZ3teBes-3OyO0asl4,49
102
+ sunholo-0.61.5.dist-info/top_level.txt,sha256=wt5tadn5--5JrZsjJz2LceoUvcrIvxjHJe-RxuudxAk,8
103
+ sunholo-0.61.5.dist-info/RECORD,,