sunholo 0.62.18__py3-none-any.whl → 0.63.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/auth/run.py CHANGED
@@ -53,26 +53,23 @@ def get_header(vector_name) -> Optional[dict]:
53
53
  else:
54
54
  run_url = "http://127.0.0.1:8080"
55
55
 
56
- if "http://" in run_url:
57
- return None
58
- else:
59
- # Append ID Token to make authenticated requests to Cloud Run services
60
- frame = inspect.currentframe()
61
- caller_frame = frame.f_back if frame is not None else None # One level up in the stack
56
+ # Append ID Token to make authenticated requests to Cloud Run services
57
+ frame = inspect.currentframe()
58
+ caller_frame = frame.f_back if frame is not None else None # One level up in the stack
59
+ deets = {
60
+ 'message': 'Authenticating for run_url',
61
+ 'run_url': run_url
62
+ }
63
+ if caller_frame:
62
64
  deets = {
63
- 'message': 'Authenticating for run_url',
64
- 'run_url': run_url
65
- }
66
- if caller_frame:
67
- deets = {
68
- 'message': 'Authenticating for run_url',
69
- 'file': caller_frame.f_code.co_filename,
70
- 'line': str(caller_frame.f_lineno),
71
- 'function': caller_frame.f_code.co_name,
72
- 'run_url': run_url
73
- }
74
- log.info(f"Authenticating for run_url {run_url} from {caller_frame.f_code.co_name}")
75
- id_token = get_id_token(run_url)
76
- headers = {"Authorization": f"Bearer {id_token}"}
77
- #log.info(f"id_token {id_token}")
78
- return headers
65
+ 'message': 'Authenticating for run_url',
66
+ 'file': caller_frame.f_code.co_filename,
67
+ 'line': str(caller_frame.f_lineno),
68
+ 'function': caller_frame.f_code.co_name,
69
+ 'run_url': run_url
70
+ }
71
+ log.info(f"Authenticating for run_url {run_url} from {caller_frame.f_code.co_name}")
72
+ id_token = get_id_token(run_url)
73
+ headers = {"Authorization": f"Bearer {id_token}"}
74
+ #log.info(f"id_token {id_token}")
75
+ return headers
sunholo/cli/chat_vac.py CHANGED
@@ -149,46 +149,72 @@ def headless_mode(service_url, service_name, user_input, chat_history=None, stre
149
149
  user_id = generate_user_id()
150
150
  session_id = str(uuid.uuid4())
151
151
 
152
- def stream_response():
153
- generate = generate_proxy_stream(
154
- send_to_qa,
155
- user_input,
156
- vector_name=service_name,
157
- chat_history=chat_history,
158
- generate_f_output=lambda x: x, # Replace with actual processing function
159
- stream_wait_time=0.5,
160
- stream_timeout=120,
161
- message_author=user_id,
162
- #TODO: populate these
163
- image_url=None,
164
- source_filters=None,
165
- search_kwargs=None,
166
- private_docs=None,
167
- whole_document=False,
168
- source_filters_and_or=False,
169
- # system kwargs
170
- configurable={
171
- "vector_name": service_name,
172
- },
173
- user_id=user_id,
174
- session_id=session_id,
175
- message_source="cli",
176
- override_endpoint=service_url
177
- )
178
- for part in generate():
179
- yield part
152
+ if not stream:
153
+ vac_response = send_to_qa(user_input,
154
+ vector_name=service_name,
155
+ chat_history=chat_history,
156
+ message_author=user_id,
157
+ #TODO: populate these
158
+ image_url=None,
159
+ source_filters=None,
160
+ search_kwargs=None,
161
+ private_docs=None,
162
+ whole_document=False,
163
+ source_filters_and_or=False,
164
+ # system kwargs
165
+ configurable={
166
+ "vector_name": service_name,
167
+ },
168
+ user_id=user_id,
169
+ session_id=session_id,
170
+ message_source="cli",
171
+ override_endpoint=service_url)
172
+
173
+ # ensures {'answer': answer}
174
+ answer = parse_output(vac_response)
175
+
176
+ console.print(answer.get('answer'))
177
+ else:
178
+ def stream_response():
179
+ generate = generate_proxy_stream(
180
+ send_to_qa,
181
+ user_input,
182
+ vector_name=service_name,
183
+ chat_history=chat_history,
184
+ generate_f_output=lambda x: x, # Replace with actual processing function
185
+ stream_wait_time=0.5,
186
+ stream_timeout=120,
187
+ message_author=user_id,
188
+ #TODO: populate these
189
+ image_url=None,
190
+ source_filters=None,
191
+ search_kwargs=None,
192
+ private_docs=None,
193
+ whole_document=False,
194
+ source_filters_and_or=False,
195
+ # system kwargs
196
+ configurable={
197
+ "vector_name": service_name,
198
+ },
199
+ user_id=user_id,
200
+ session_id=session_id,
201
+ message_source="cli",
202
+ override_endpoint=service_url
203
+ )
204
+ for part in generate():
205
+ yield part
180
206
 
181
- vac_response = ""
207
+ answer = ""
182
208
 
183
- for token in stream_response():
184
- if isinstance(token, bytes):
185
- token = token.decode('utf-8')
186
- print(token, end='', flush=True)
187
- vac_response += token
209
+ for token in stream_response():
210
+ if isinstance(token, bytes):
211
+ token = token.decode('utf-8')
212
+ print(token, end='', flush=True)
213
+ answer += token
188
214
 
189
- if vac_response:
215
+ if answer:
190
216
  chat_history.append({"name": "Human", "content": user_input})
191
- chat_history.append({"name": "AI", "content": vac_response})
217
+ chat_history.append({"name": "AI", "content": answer})
192
218
  print() # For new line after streaming ends
193
219
 
194
220
  return chat_history
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sunholo
3
- Version: 0.62.18
3
+ Version: 0.63.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.62.18.tar.gz
6
+ Download-URL: https://github.com/sunholo-data/sunholo-py/archive/refs/tags/v0.63.0.tar.gz
7
7
  Author: Holosun ApS
8
8
  Author-email: multivac@sunholo.com
9
9
  License: Apache License, Version 2.0
@@ -111,54 +111,21 @@ This is the Sunholo Python project, a comprehensive toolkit for working with lan
111
111
 
112
112
  Please refer to the website for full documentation at https://dev.sunholo.com/
113
113
 
114
- # sunholo-py
115
-
116
- (draft release https://pypi.org/project/sunholo/ )
117
- ## Table of Contents
118
- - [Agents](#agents)
119
- - [Archive](#archive)
120
- - [Bots](#bots)
121
- - [Chunker](#chunker)
122
- - [Components](#components)
123
- - [Database](#database)
124
- - [Embedder](#embedder)
125
- - [PubSub](#pubsub)
126
- - [QnA](#qna)
127
- - [Streaming](#streaming)
128
- - [Summarise](#summarise)
129
- - [Utils](#utils)
114
+ ## Demos
130
115
 
116
+ Using https://github.com/charmbracelet/vhs
131
117
 
132
118
  ```sh
133
- pip install sunholo
119
+ vhs record > cassette.tape
134
120
  ```
135
121
 
136
- A python library to enable LLMOps within cloud environments
137
-
138
- `sunholo` provides utilities to help manage LLM operations on Google Cloud Platform at first, but it is hoped that making it open source will help it support other clouds in the future. A lot of the functionality is not Google Cloud Platform specific, so still may be helpful.
139
-
140
- It is derived from the Edmonbrain project, the original blog post you can read here: https://code.markedmondson.me/running-llms-on-gcp/ and owes a lot to Langchain ( https://github.com/langchain-ai/langchain )
141
-
142
- The package includes:
122
+ Then make gif:
143
123
 
144
- * `agents/` - functions for working with agents, including easy flask apps, parsing chat history and dispatching requests to different agent endpoints
145
- * `archive/` - functions to record all Q&A activity to BigQuery via PubSub
146
- * `bots/` - functions for special cases regarding frontend bots such as GChat, Web Apps, Discord and Slack
147
- * `chunker/` - functions to slice up documents for sending into vector stores
148
- * `components/` - functions to help configure which LLM, prompt, vectorstore or document retriever you will use based on a yaml config file
149
- * `database/` - database setup functions and SQL to run on those sources such as Supabase
150
- * `embedder/` - functions to send chunks into embedding vector stores
151
- * `pubsub/` - use of PubSub for a message queue between components
152
- * `qna/` - utilities for running agents such as retry strats and parsing of output/input
153
- * `streaming/` - creation of streaming responses from LLM bots
154
- * `summarise/` - creation of summaries of large documents
155
- * `utils/` - reading configuration files, Google Cloud Platform metadata
156
-
157
- ## Configuration
124
+ ```sh
125
+ vhs docs/tapes/config-list.tape
126
+ ```
158
127
 
159
- The library uses the config specifications that some examples are given in the `config/` folder.
160
128
 
161
- When using the functions, make sure to have the `config/` folder in the root of where your application is running (usually `$HOME/config`)
162
129
 
163
130
  ```
164
131
  Copyright [2024] [Holosun ApS]
@@ -16,7 +16,7 @@ sunholo/agents/flask/qna_routes.py,sha256=Twx6bitUAQ8Urtuwu9PtdoxYv-3aBDbF4cOUl9
16
16
  sunholo/archive/__init__.py,sha256=qNHWm5rGPVOlxZBZCpA1wTYPbalizRT7f8X4rs2t290,31
17
17
  sunholo/archive/archive.py,sha256=C-UhG5x-XtZ8VheQp92IYJqgD0V3NFQjniqlit94t18,1197
18
18
  sunholo/auth/__init__.py,sha256=4owDjSaWYkbTlPK47UHTOC0gCWbZsqn4ZIEw5NWZTlg,28
19
- sunholo/auth/run.py,sha256=oJ8JcimcDcdIogf7fvXLAi9EFIYhTR2_mjpR2-b97HE,2829
19
+ sunholo/auth/run.py,sha256=SoXkyRSSO3ln4Uq71Zj2J2P9_TRp0Pg_wU1D9kI24Io,2690
20
20
  sunholo/bots/__init__.py,sha256=EMFd7e2z68l6pzYOnkzHbLd2xJRvxTKFRNCTuhZ8hIw,130
21
21
  sunholo/bots/discord.py,sha256=cCFae5K1BCa6JVkWGLh_iZ9qFO1JpXb6K4eJrlDfEro,2442
22
22
  sunholo/bots/github_webhook.py,sha256=5pQPRLM_wxxcILVaIzUDV8Kt7Arcm2dL1r1kMMHA524,9629
@@ -31,7 +31,7 @@ sunholo/chunker/pdfs.py,sha256=daCZ1xjn1YvxlifIyxskWNpLJLe-Q9D_Jq12MWx3tZo,2473
31
31
  sunholo/chunker/publish.py,sha256=GNXV6IPdKM2GZUcjGXIERu49D0ITYtizsLIktKVtMjM,2768
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=2ulmXgTG1AGe6tiJBUm0Ofyo5wHWck3L962aMOqehaw,16887
34
+ sunholo/cli/chat_vac.py,sha256=RbhKICZtWZEPwL9wFmTNzhCWKHHRmNSqQHIfA-wi04U,17820
35
35
  sunholo/cli/cli.py,sha256=1-grjOE5sB5k0wrccsqCWSXB1vfrYNgdHBFH5F94pa0,3632
36
36
  sunholo/cli/cli_init.py,sha256=JMZ9AX2cPDZ-_mv3adiv2ToFVNyRPtjk9Biszl1kiR0,2358
37
37
  sunholo/cli/configs.py,sha256=QUM9DvKOdZmEQRM5uI3Nh887T0YDiSMr7O240zTLqws,4546
@@ -101,9 +101,9 @@ sunholo/vertex/__init__.py,sha256=JvHcGFuv6R_nAhY2AdoqqhMpJ5ugeWPZ_svGhWrObBk,13
101
101
  sunholo/vertex/init.py,sha256=JDMUaBRdednzbKF-5p33qqLit2LMsvgvWW-NRz0AqO0,1801
102
102
  sunholo/vertex/memory_tools.py,sha256=8F1iTWnqEK9mX4W5RzCVKIjydIcNp6OFxjn_dtQ3GXo,5379
103
103
  sunholo/vertex/safety.py,sha256=3meAX0HyGZYrH7rXPUAHxtI_3w_zoy_RX7Shtkoa660,1275
104
- sunholo-0.62.18.dist-info/LICENSE.txt,sha256=SdE3QjnD3GEmqqg9EX3TM9f7WmtOzqS1KJve8rhbYmU,11345
105
- sunholo-0.62.18.dist-info/METADATA,sha256=c-va2QI7reKhO5mAWY7h-XGKwxhwr_9MRocPTq1-jEE,8059
106
- sunholo-0.62.18.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
107
- sunholo-0.62.18.dist-info/entry_points.txt,sha256=bZuN5AIHingMPt4Ro1b_T-FnQvZ3teBes-3OyO0asl4,49
108
- sunholo-0.62.18.dist-info/top_level.txt,sha256=wt5tadn5--5JrZsjJz2LceoUvcrIvxjHJe-RxuudxAk,8
109
- sunholo-0.62.18.dist-info/RECORD,,
104
+ sunholo-0.63.0.dist-info/LICENSE.txt,sha256=SdE3QjnD3GEmqqg9EX3TM9f7WmtOzqS1KJve8rhbYmU,11345
105
+ sunholo-0.63.0.dist-info/METADATA,sha256=0jHRQDDREVfY0MVPf6CZe6wZ_kiSePMGUg5li128Yf8,5939
106
+ sunholo-0.63.0.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
107
+ sunholo-0.63.0.dist-info/entry_points.txt,sha256=bZuN5AIHingMPt4Ro1b_T-FnQvZ3teBes-3OyO0asl4,49
108
+ sunholo-0.63.0.dist-info/top_level.txt,sha256=wt5tadn5--5JrZsjJz2LceoUvcrIvxjHJe-RxuudxAk,8
109
+ sunholo-0.63.0.dist-info/RECORD,,