sunholo 0.62.17__tar.gz → 0.63.0__tar.gz
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-0.62.17/sunholo.egg-info → sunholo-0.63.0}/PKG-INFO +9 -42
- sunholo-0.63.0/README.md +37 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/setup.py +1 -1
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/auth/run.py +19 -22
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/cli/chat_vac.py +72 -37
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/cli/embedder.py +16 -7
- {sunholo-0.62.17 → sunholo-0.63.0/sunholo.egg-info}/PKG-INFO +9 -42
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo.egg-info/SOURCES.txt +1 -0
- sunholo-0.63.0/tests/test_chunker.py +23 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/tests/test_dispatch_to_qa.py +7 -1
- sunholo-0.62.17/README.md +0 -70
- {sunholo-0.62.17 → sunholo-0.63.0}/LICENSE.txt +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/MANIFEST.in +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/setup.cfg +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/__init__.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/agents/__init__.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/agents/chat_history.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/agents/dispatch_to_qa.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/agents/fastapi/__init__.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/agents/fastapi/base.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/agents/fastapi/qna_routes.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/agents/flask/__init__.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/agents/flask/base.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/agents/flask/qna_routes.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/agents/langserve.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/agents/pubsub.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/agents/route.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/agents/special_commands.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/archive/__init__.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/archive/archive.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/auth/__init__.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/bots/__init__.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/bots/discord.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/bots/github_webhook.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/bots/webapp.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/chunker/__init__.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/chunker/data_to_embed_pubsub.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/chunker/doc_handling.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/chunker/images.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/chunker/loaders.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/chunker/message_data.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/chunker/pdfs.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/chunker/publish.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/chunker/splitter.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/cli/__init__.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/cli/cli.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/cli/cli_init.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/cli/configs.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/cli/deploy.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/cli/merge_texts.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/cli/run_proxy.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/cli/sun_rich.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/components/__init__.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/components/llm.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/components/retriever.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/components/vectorstore.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/database/__init__.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/database/alloydb.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/database/database.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/database/lancedb.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/database/sql/sb/create_function.sql +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/database/sql/sb/create_function_time.sql +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/database/sql/sb/create_table.sql +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/database/sql/sb/delete_source_row.sql +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/database/sql/sb/return_sources.sql +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/database/sql/sb/setup.sql +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/database/static_dbs.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/database/uuid.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/embedder/__init__.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/embedder/embed_chunk.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/gcs/__init__.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/gcs/add_file.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/gcs/download_url.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/gcs/metadata.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/langfuse/__init__.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/langfuse/callback.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/langfuse/prompts.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/llamaindex/__init__.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/llamaindex/generate.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/llamaindex/get_files.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/llamaindex/import_files.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/logging.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/lookup/__init__.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/lookup/model_lookup.yaml +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/patches/__init__.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/patches/langchain/__init__.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/patches/langchain/lancedb.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/patches/langchain/vertexai.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/pubsub/__init__.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/pubsub/process_pubsub.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/pubsub/pubsub_manager.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/qna/__init__.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/qna/parsers.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/qna/retry.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/streaming/__init__.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/streaming/content_buffer.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/streaming/langserve.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/streaming/stream_lookup.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/streaming/streaming.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/summarise/__init__.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/summarise/summarise.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/utils/__init__.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/utils/big_context.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/utils/config.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/utils/config_schema.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/utils/gcp.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/utils/gcp_project.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/utils/parsers.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/utils/timedelta.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/utils/user_ids.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/vertex/__init__.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/vertex/init.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/vertex/memory_tools.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo/vertex/safety.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo.egg-info/dependency_links.txt +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo.egg-info/entry_points.txt +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo.egg-info/requires.txt +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/sunholo.egg-info/top_level.txt +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/tests/test_chat_history.py +0 -0
- {sunholo-0.62.17 → sunholo-0.63.0}/tests/test_config.py +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: sunholo
|
|
3
|
-
Version: 0.
|
|
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.
|
|
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
|
-
|
|
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
|
-
|
|
119
|
+
vhs record > cassette.tape
|
|
134
120
|
```
|
|
135
121
|
|
|
136
|
-
|
|
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
|
-
|
|
145
|
-
|
|
146
|
-
|
|
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]
|
sunholo-0.63.0/README.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
## Introduction
|
|
2
|
+
This is the Sunholo Python project, a comprehensive toolkit for working with language models and vector stores on Google Cloud Platform. It provides a wide range of functionalities and utilities to facilitate the development and deployment of language model applications.
|
|
3
|
+
|
|
4
|
+
Please refer to the website for full documentation at https://dev.sunholo.com/
|
|
5
|
+
|
|
6
|
+
## Demos
|
|
7
|
+
|
|
8
|
+
Using https://github.com/charmbracelet/vhs
|
|
9
|
+
|
|
10
|
+
```sh
|
|
11
|
+
vhs record > cassette.tape
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Then make gif:
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
vhs docs/tapes/config-list.tape
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
Copyright [2024] [Holosun ApS]
|
|
24
|
+
|
|
25
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
26
|
+
you may not use this file except in compliance with the License.
|
|
27
|
+
You may obtain a copy of the License at
|
|
28
|
+
|
|
29
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
30
|
+
|
|
31
|
+
Unless required by applicable law or agreed to in writing, software
|
|
32
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
33
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
34
|
+
See the License for the specific language governing permissions and
|
|
35
|
+
limitations under the License.
|
|
36
|
+
```
|
|
37
|
+
|
|
@@ -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
|
-
|
|
57
|
-
|
|
58
|
-
else
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
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
|
|
@@ -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
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
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
|
-
|
|
207
|
+
answer = ""
|
|
182
208
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
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
|
|
215
|
+
if answer:
|
|
190
216
|
chat_history.append({"name": "Human", "content": user_input})
|
|
191
|
-
chat_history.append({"name": "AI", "content":
|
|
217
|
+
chat_history.append({"name": "AI", "content": answer})
|
|
192
218
|
print() # For new line after streaming ends
|
|
193
219
|
|
|
194
220
|
return chat_history
|
|
@@ -273,6 +299,7 @@ def vac_command(args):
|
|
|
273
299
|
def invoke_vac(service_url, data, vector_name=None, metadata=None, is_file=False):
|
|
274
300
|
try:
|
|
275
301
|
if is_file:
|
|
302
|
+
console.print("Uploading file to chunker...")
|
|
276
303
|
# Handle file upload
|
|
277
304
|
if not isinstance(data, Path) or not data.is_file():
|
|
278
305
|
raise ValueError("For file uploads, 'data' must be a Path object pointing to a valid file.")
|
|
@@ -287,12 +314,20 @@ def invoke_vac(service_url, data, vector_name=None, metadata=None, is_file=False
|
|
|
287
314
|
|
|
288
315
|
response = requests.post(service_url, files=files, data=form_data)
|
|
289
316
|
else:
|
|
317
|
+
console.print("Uploading JSON to chunker...")
|
|
290
318
|
try:
|
|
291
|
-
|
|
319
|
+
if isinstance(data, dict):
|
|
320
|
+
json_data = data
|
|
321
|
+
else:
|
|
322
|
+
json_data = json.loads(data)
|
|
292
323
|
except json.JSONDecodeError as err:
|
|
293
324
|
console.print(f"[bold red]ERROR: invalid JSON: {str(err)} [/bold red]")
|
|
294
325
|
sys.exit(1)
|
|
326
|
+
except Exception as err:
|
|
327
|
+
console.print(f"[bold red]ERROR: could not parse JSON: {str(err)} [/bold red]")
|
|
328
|
+
sys.exit(1)
|
|
295
329
|
|
|
330
|
+
log.debug(f"Sending data: {data} or json_data: {json.dumps(json_data)}")
|
|
296
331
|
# Handle JSON data
|
|
297
332
|
headers = {"Content-Type": "application/json"}
|
|
298
333
|
response = requests.post(service_url, headers=headers, data=json.dumps(json_data))
|
|
@@ -18,12 +18,15 @@ def create_metadata(vac, metadata):
|
|
|
18
18
|
# Default metadata if none provided
|
|
19
19
|
default_metadata = {"vector_name": vac, "source": "sunholo-cli", "eventTime": formatted_time}
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
if
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
try:
|
|
22
|
+
# Merge default metadata with provided metadata
|
|
23
|
+
if metadata:
|
|
24
|
+
if not isinstance(metadata, dict):
|
|
25
|
+
metadata = json.loads(metadata)
|
|
26
|
+
else:
|
|
27
|
+
metadata = {}
|
|
28
|
+
except Exception as err:
|
|
29
|
+
console.print(f"[bold red]ERROR: metadata not parsed: {err} for {metadata}")
|
|
27
30
|
|
|
28
31
|
# Update metadata with default values if not present
|
|
29
32
|
metadata.update(default_metadata)
|
|
@@ -87,7 +90,7 @@ def embed_command(args):
|
|
|
87
90
|
chunk_args = Namespace(**chunk_args)
|
|
88
91
|
chunk_url = resolve_service_url(chunk_args, no_config=True)
|
|
89
92
|
|
|
90
|
-
with console.status(f"[bold orange]Sending {args.data} to chunk via {chunk_url}[/bold orange]", spinner="star"):
|
|
93
|
+
with console.status(f"[bold orange]Sending '{args.data}' to chunk via {chunk_url}[/bold orange]", spinner="star"):
|
|
91
94
|
if args.is_file:
|
|
92
95
|
|
|
93
96
|
metadata = create_metadata(args.vac_name, args.metadata)
|
|
@@ -102,6 +105,7 @@ def embed_command(args):
|
|
|
102
105
|
|
|
103
106
|
else:
|
|
104
107
|
json_data = encode_data(args.vac_name, args.data, args.metadata, args.local_chunks)
|
|
108
|
+
console.print(f"Chunk JSON data: {json_data}")
|
|
105
109
|
chunk_res = invoke_vac(f"{chunk_url}/pubsub_to_store", json_data)
|
|
106
110
|
|
|
107
111
|
stop_proxy("chunker")
|
|
@@ -113,6 +117,11 @@ def embed_command(args):
|
|
|
113
117
|
|
|
114
118
|
return
|
|
115
119
|
|
|
120
|
+
if not chunk_res:
|
|
121
|
+
console.rule(f"[bold orange]No chunks were found for processing of {args.data}[/bold orange]")
|
|
122
|
+
|
|
123
|
+
return
|
|
124
|
+
|
|
116
125
|
console.rule("Processing chunks locally")
|
|
117
126
|
|
|
118
127
|
if args.embed_override:
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: sunholo
|
|
3
|
-
Version: 0.
|
|
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.
|
|
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
|
-
|
|
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
|
-
|
|
119
|
+
vhs record > cassette.tape
|
|
134
120
|
```
|
|
135
121
|
|
|
136
|
-
|
|
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
|
-
|
|
145
|
-
|
|
146
|
-
|
|
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]
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
from unittest.mock import patch, MagicMock
|
|
3
|
+
from sunholo.chunker.data_to_embed_pubsub import data_to_embed_pubsub
|
|
4
|
+
|
|
5
|
+
# Mock external calls within the function
|
|
6
|
+
@patch('sunholo.chunker.data_to_embed_pubsub.process_pubsub_message', return_value=({}, {}, 'test_vector'))
|
|
7
|
+
@patch('sunholo.chunker.data_to_embed_pubsub.process_chunker_data', return_value='processed_data')
|
|
8
|
+
def test_data_to_embed_pubsub(mock_process_chunker_data, mock_process_pubsub_message):
|
|
9
|
+
# Test the function with various inputs including edge cases
|
|
10
|
+
assert data_to_embed_pubsub({}) == 'processed_data'
|
|
11
|
+
assert data_to_embed_pubsub({'key': 'value'}) == 'processed_data'
|
|
12
|
+
mock_process_pubsub_message.assert_called()
|
|
13
|
+
mock_process_chunker_data.assert_called()
|
|
14
|
+
|
|
15
|
+
# Ensure tests are self-contained and do not require external dependencies
|
|
16
|
+
mock_process_pubsub_message = MagicMock(return_value=({}, {}, 'test_vector'))
|
|
17
|
+
mock_process_chunker_data = MagicMock(return_value='processed_data')
|
|
18
|
+
assert data_to_embed_pubsub({'key': 'value'}) == 'processed_data'
|
|
19
|
+
|
|
20
|
+
# Validate the function's output against expected results
|
|
21
|
+
expected_output = 'processed_data'
|
|
22
|
+
actual_output = data_to_embed_pubsub({'key': 'value'})
|
|
23
|
+
assert actual_output == expected_output, f"Expected {expected_output}, got {actual_output}"
|
|
@@ -8,13 +8,19 @@ from sunholo.agents.dispatch_to_qa import prep_request_payload
|
|
|
8
8
|
# Additional test cases to cover all logic paths
|
|
9
9
|
("", [], "empty_input_vector", False, "http://example.com/invoke", {"user_input": "", "chat_history": [], "vector_name": "empty_input_vector"}),
|
|
10
10
|
("Valid input", ["Chat history present"], "history_vector", False, "http://example.com/invoke", {"user_input": "Valid input", "chat_history": ["Chat history present"], "vector_name": "history_vector"}),
|
|
11
|
-
("Stream request", [], "stream_vector", True, "http://example.com/stream", {"user_input": "Stream request", "chat_history": [], "vector_name": "stream_vector"})
|
|
11
|
+
("Stream request", [], "stream_vector", True, "http://example.com/stream", {"user_input": "Stream request", "chat_history": [], "vector_name": "stream_vector"}),
|
|
12
|
+
# New test cases for prep_request_payload function
|
|
13
|
+
("User input with override endpoint", [], "override_vector", False, "http://override.com/invoke", {"user_input": "User input with override endpoint", "chat_history": [], "vector_name": "override_vector"}),
|
|
14
|
+
("Stream with chat history and override endpoint", ["Chat history for override"], "override_stream_vector", True, "http://override.com/stream", {"user_input": "Stream with chat history and override endpoint", "chat_history": ["Chat history for override"], "vector_name": "override_stream_vector"})
|
|
12
15
|
])
|
|
13
16
|
@patch('sunholo.agents.dispatch_to_qa.load_config_key')
|
|
14
17
|
@patch('sunholo.agents.dispatch_to_qa.route_endpoint')
|
|
15
18
|
def test_prep_request_payload(mock_route_endpoint, mock_load_config_key, user_input, chat_history, vector_name, stream, expected_endpoint, expected_payload):
|
|
16
19
|
mock_route_endpoint.return_value = {"invoke": "http://example.com/invoke", "stream": "http://example.com/stream"}
|
|
17
20
|
mock_load_config_key.side_effect = lambda key, vector_name=None, kind=None: "my_vector" if key == "vector_name" else None
|
|
21
|
+
# Mocking for override endpoint scenario
|
|
22
|
+
if vector_name.startswith("override"):
|
|
23
|
+
mock_route_endpoint.return_value = {"invoke": "http://override.com/invoke", "stream": "http://override.com/stream"}
|
|
18
24
|
|
|
19
25
|
endpoint, payload = prep_request_payload(user_input, chat_history, vector_name, stream)
|
|
20
26
|
|
sunholo-0.62.17/README.md
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
## Introduction
|
|
2
|
-
This is the Sunholo Python project, a comprehensive toolkit for working with language models and vector stores on Google Cloud Platform. It provides a wide range of functionalities and utilities to facilitate the development and deployment of language model applications.
|
|
3
|
-
|
|
4
|
-
Please refer to the website for full documentation at https://dev.sunholo.com/
|
|
5
|
-
|
|
6
|
-
# sunholo-py
|
|
7
|
-
|
|
8
|
-
(draft release https://pypi.org/project/sunholo/ )
|
|
9
|
-
## Table of Contents
|
|
10
|
-
- [Agents](#agents)
|
|
11
|
-
- [Archive](#archive)
|
|
12
|
-
- [Bots](#bots)
|
|
13
|
-
- [Chunker](#chunker)
|
|
14
|
-
- [Components](#components)
|
|
15
|
-
- [Database](#database)
|
|
16
|
-
- [Embedder](#embedder)
|
|
17
|
-
- [PubSub](#pubsub)
|
|
18
|
-
- [QnA](#qna)
|
|
19
|
-
- [Streaming](#streaming)
|
|
20
|
-
- [Summarise](#summarise)
|
|
21
|
-
- [Utils](#utils)
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
```sh
|
|
25
|
-
pip install sunholo
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
A python library to enable LLMOps within cloud environments
|
|
29
|
-
|
|
30
|
-
`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.
|
|
31
|
-
|
|
32
|
-
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 )
|
|
33
|
-
|
|
34
|
-
The package includes:
|
|
35
|
-
|
|
36
|
-
* `agents/` - functions for working with agents, including easy flask apps, parsing chat history and dispatching requests to different agent endpoints
|
|
37
|
-
* `archive/` - functions to record all Q&A activity to BigQuery via PubSub
|
|
38
|
-
* `bots/` - functions for special cases regarding frontend bots such as GChat, Web Apps, Discord and Slack
|
|
39
|
-
* `chunker/` - functions to slice up documents for sending into vector stores
|
|
40
|
-
* `components/` - functions to help configure which LLM, prompt, vectorstore or document retriever you will use based on a yaml config file
|
|
41
|
-
* `database/` - database setup functions and SQL to run on those sources such as Supabase
|
|
42
|
-
* `embedder/` - functions to send chunks into embedding vector stores
|
|
43
|
-
* `pubsub/` - use of PubSub for a message queue between components
|
|
44
|
-
* `qna/` - utilities for running agents such as retry strats and parsing of output/input
|
|
45
|
-
* `streaming/` - creation of streaming responses from LLM bots
|
|
46
|
-
* `summarise/` - creation of summaries of large documents
|
|
47
|
-
* `utils/` - reading configuration files, Google Cloud Platform metadata
|
|
48
|
-
|
|
49
|
-
## Configuration
|
|
50
|
-
|
|
51
|
-
The library uses the config specifications that some examples are given in the `config/` folder.
|
|
52
|
-
|
|
53
|
-
When using the functions, make sure to have the `config/` folder in the root of where your application is running (usually `$HOME/config`)
|
|
54
|
-
|
|
55
|
-
```
|
|
56
|
-
Copyright [2024] [Holosun ApS]
|
|
57
|
-
|
|
58
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
59
|
-
you may not use this file except in compliance with the License.
|
|
60
|
-
You may obtain a copy of the License at
|
|
61
|
-
|
|
62
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
63
|
-
|
|
64
|
-
Unless required by applicable law or agreed to in writing, software
|
|
65
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
66
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
67
|
-
See the License for the specific language governing permissions and
|
|
68
|
-
limitations under the License.
|
|
69
|
-
```
|
|
70
|
-
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|