sunholo 0.73.2__py3-none-any.whl → 0.73.3__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/cli/chat_vac.py +99 -7
- {sunholo-0.73.2.dist-info → sunholo-0.73.3.dist-info}/METADATA +2 -2
- {sunholo-0.73.2.dist-info → sunholo-0.73.3.dist-info}/RECORD +7 -7
- {sunholo-0.73.2.dist-info → sunholo-0.73.3.dist-info}/LICENSE.txt +0 -0
- {sunholo-0.73.2.dist-info → sunholo-0.73.3.dist-info}/WHEEL +0 -0
- {sunholo-0.73.2.dist-info → sunholo-0.73.3.dist-info}/entry_points.txt +0 -0
- {sunholo-0.73.2.dist-info → sunholo-0.73.3.dist-info}/top_level.txt +0 -0
sunholo/cli/chat_vac.py
CHANGED
|
@@ -8,6 +8,8 @@ from ..qna.parsers import parse_output
|
|
|
8
8
|
from ..gcs.add_file import add_file_to_gcs
|
|
9
9
|
from .run_proxy import clean_proxy_list, start_proxy, stop_proxy
|
|
10
10
|
from ..invoke import invoke_vac
|
|
11
|
+
from ..utils.big_context import has_text_extension, merge_text_files, load_gitignore_patterns, build_file_tree
|
|
12
|
+
import tempfile
|
|
11
13
|
|
|
12
14
|
import uuid
|
|
13
15
|
import os
|
|
@@ -24,6 +26,55 @@ from rich.panel import Panel
|
|
|
24
26
|
from rich.text import Text
|
|
25
27
|
from rich.table import Table
|
|
26
28
|
|
|
29
|
+
def read_and_add_to_user_input(user_input):
|
|
30
|
+
read_input = None
|
|
31
|
+
|
|
32
|
+
path = user_input.split(" ", 1)[1] if " " in user_input else None
|
|
33
|
+
if not path:
|
|
34
|
+
console.print("[bold red]Please provide a valid file or folder path.[/bold red]")
|
|
35
|
+
return None
|
|
36
|
+
|
|
37
|
+
if os.path.isfile(path):
|
|
38
|
+
if not has_text_extension(path):
|
|
39
|
+
console.print("[bold red]Unsupported file type. Please provide a text file or preprocess to text, or use !upload (e.g. images) or `sunholo embed`.[/bold red]")
|
|
40
|
+
return None
|
|
41
|
+
|
|
42
|
+
try:
|
|
43
|
+
with open(path, 'r', encoding='utf-8') as file:
|
|
44
|
+
file_content = file.read()
|
|
45
|
+
read_input = file_content
|
|
46
|
+
console.print(f"[bold yellow]File content from {path} read into user_input: [{len(read_input.split())}] words[/bold yellow]")
|
|
47
|
+
except FileNotFoundError:
|
|
48
|
+
console.print("[bold red]File not found. Please check the path and try again.[/bold red]")
|
|
49
|
+
return None
|
|
50
|
+
except IOError:
|
|
51
|
+
console.print("[bold red]File could not be read. Please ensure it is a readable text file.[/bold red]")
|
|
52
|
+
return None
|
|
53
|
+
elif os.path.isdir(path):
|
|
54
|
+
patterns = []
|
|
55
|
+
gitignore_path = os.path.join(path, '.gitignore')
|
|
56
|
+
|
|
57
|
+
if os.path.exists(gitignore_path):
|
|
58
|
+
patterns = load_gitignore_patterns(gitignore_path)
|
|
59
|
+
|
|
60
|
+
try:
|
|
61
|
+
with tempfile.NamedTemporaryFile(delete=False, mode='w+', encoding='utf-8') as temp_file:
|
|
62
|
+
temp_file_path = temp_file.name
|
|
63
|
+
file_tree = merge_text_files(path, temp_file_path, patterns)
|
|
64
|
+
console.print(f"[bold yellow]Contents of the folder '{path}' have been merged add added to input.[/bold yellow]")
|
|
65
|
+
console.print("\n".join(file_tree))
|
|
66
|
+
temp_file.seek(0)
|
|
67
|
+
read_input = temp_file.read()
|
|
68
|
+
console.print(f"[bold yellow]Total words: [{len(read_input.split())}] - watch out for high token costs! Use !clear_read to reset[/bold yellow]")
|
|
69
|
+
os.remove(temp_file_path) # Clean up the temporary file
|
|
70
|
+
except Exception as e:
|
|
71
|
+
console.print(f"[bold red]An error occurred while reading the folder: {str(e)}[/bold red]")
|
|
72
|
+
return None
|
|
73
|
+
else:
|
|
74
|
+
console.print("[bold red]The provided path is neither a file nor a folder. Please check the path and try again.[/bold red]")
|
|
75
|
+
return None
|
|
76
|
+
|
|
77
|
+
return read_input
|
|
27
78
|
|
|
28
79
|
def get_service_url(vac_name, project, region, no_config=False):
|
|
29
80
|
|
|
@@ -67,6 +118,8 @@ def stream_chat_session(service_url, service_name, stream=True):
|
|
|
67
118
|
chat_history = []
|
|
68
119
|
agent_name = ConfigManager(service_name).vacConfig("agent")
|
|
69
120
|
file_reply = None
|
|
121
|
+
read_file = None
|
|
122
|
+
read_file_count = None
|
|
70
123
|
while True:
|
|
71
124
|
session_id = str(uuid.uuid4())
|
|
72
125
|
user_input = Prompt.ask("[bold cyan]You[/bold cyan]")
|
|
@@ -81,9 +134,26 @@ def stream_chat_session(service_url, service_name, stream=True):
|
|
|
81
134
|
|
|
82
135
|
if special_reply:
|
|
83
136
|
console.print(f"[bold yellow]{service_name}:[/bold yellow] {special_reply}", end='\n')
|
|
84
|
-
continue
|
|
85
|
-
|
|
86
|
-
if user_input.lower().startswith("
|
|
137
|
+
continue
|
|
138
|
+
|
|
139
|
+
if user_input.lower().startswith("!read"):
|
|
140
|
+
read_file = read_and_add_to_user_input(user_input)
|
|
141
|
+
if read_file:
|
|
142
|
+
read_file_count = len(read_file.split())
|
|
143
|
+
continue
|
|
144
|
+
|
|
145
|
+
if user_input.lower().startswith("!ls"):
|
|
146
|
+
items = os.listdir(os.getcwd())
|
|
147
|
+
for item in items:
|
|
148
|
+
console.print(item)
|
|
149
|
+
continue
|
|
150
|
+
|
|
151
|
+
if user_input.lower().startswith("!tree"):
|
|
152
|
+
tree = build_file_tree(os.getcwd(), patterns=[])
|
|
153
|
+
console.print(tree)
|
|
154
|
+
continue
|
|
155
|
+
|
|
156
|
+
if user_input.lower().startswith("!upload"):
|
|
87
157
|
file_path = user_input.split(" ", 1)[1] if " " in user_input else None
|
|
88
158
|
if not file_path:
|
|
89
159
|
console.print("[bold red]Please provide a valid file path.[/bold red]")
|
|
@@ -95,7 +165,7 @@ def stream_chat_session(service_url, service_name, stream=True):
|
|
|
95
165
|
console.print("[bold red]Invalid file upload[/bold red]")
|
|
96
166
|
continue
|
|
97
167
|
|
|
98
|
-
console.print(f"[bold yellow]{service_name}:[/bold yellow] Uploaded {file_path} to {file_reply} - image will be sent each reply until you issue 'clear_upload' ", end='\n')
|
|
168
|
+
console.print(f"[bold yellow]{service_name}:[/bold yellow] Uploaded {file_path} to {file_reply} - image will be sent each reply until you issue '!clear_upload' ", end='\n')
|
|
99
169
|
|
|
100
170
|
except FileNotFoundError:
|
|
101
171
|
console.print("[bold red]File not found. Please check the path and try again.[/bold red]")
|
|
@@ -103,10 +173,25 @@ def stream_chat_session(service_url, service_name, stream=True):
|
|
|
103
173
|
# file_reply stays for each message from now on
|
|
104
174
|
continue
|
|
105
175
|
|
|
106
|
-
if user_input.lower().startswith("clear_upload"):
|
|
176
|
+
if user_input.lower().startswith("!clear_upload"):
|
|
107
177
|
console.print("[bold yellow]File upload path cleared.[/bold yellow]")
|
|
108
178
|
file_path = None
|
|
179
|
+
continue
|
|
180
|
+
|
|
181
|
+
if user_input.lower().startswith("!clear_read"):
|
|
182
|
+
console.print("[bold yellow]Read in file(s) cleared.[/bold yellow]")
|
|
183
|
+
read_file = None
|
|
184
|
+
read_file_count = None
|
|
185
|
+
continue
|
|
109
186
|
|
|
187
|
+
if read_file:
|
|
188
|
+
user_input = f"<user added file>{read_file}</user added file>\n{user_input}"
|
|
189
|
+
|
|
190
|
+
# guardrail
|
|
191
|
+
if len(user_input)> 1000000:
|
|
192
|
+
console.print("[bold red]Over 1 million characters in user_input, aborting as probably unintentional. Use API directly instead.[/bold red]")
|
|
193
|
+
continue
|
|
194
|
+
|
|
110
195
|
if not stream:
|
|
111
196
|
vac_response = send_to_qa(user_input,
|
|
112
197
|
vector_name=service_name,
|
|
@@ -166,8 +251,15 @@ def stream_chat_session(service_url, service_name, stream=True):
|
|
|
166
251
|
response_started = False
|
|
167
252
|
vac_response = ""
|
|
168
253
|
|
|
169
|
-
|
|
170
|
-
|
|
254
|
+
|
|
255
|
+
thinking = "[bold orange]Thinking...[/bold orange]"
|
|
256
|
+
if file_reply:
|
|
257
|
+
thinking = f"[bold orange]Thinking with upload {file_reply} - issue !clear_upload to remove...[/bold orange]"
|
|
258
|
+
|
|
259
|
+
if read_file:
|
|
260
|
+
thinking = f"{thinking} - [bold orange]additional [{read_file_count}] words added via !read_file contents - issue !clear_read to remove[/bold orange]"
|
|
261
|
+
|
|
262
|
+
with console.status(thinking, spinner="star") as status:
|
|
171
263
|
for token in stream_response():
|
|
172
264
|
if not response_started:
|
|
173
265
|
status.stop()
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: sunholo
|
|
3
|
-
Version: 0.73.
|
|
3
|
+
Version: 0.73.3
|
|
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.73.
|
|
6
|
+
Download-URL: https://github.com/sunholo-data/sunholo-py/archive/refs/tags/v0.73.3.tar.gz
|
|
7
7
|
Author: Holosun ApS
|
|
8
8
|
Author-email: multivac@sunholo.com
|
|
9
9
|
License: Apache License, Version 2.0
|
|
@@ -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=jtGfi_ZdhVdyFhfw0e4ynEpmwIyrxQtV63OituYWy6o,6729
|
|
35
35
|
sunholo/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
36
|
-
sunholo/cli/chat_vac.py,sha256=
|
|
36
|
+
sunholo/cli/chat_vac.py,sha256=9NNdIt0pWLZandxtav9Eu7ru9WOBHjh1TN1oP3pqMbM,22852
|
|
37
37
|
sunholo/cli/cli.py,sha256=u70fcSQzQx2iPvE23SVCVYRFabmZ-XtgEd6vHcrABi0,3725
|
|
38
38
|
sunholo/cli/cli_init.py,sha256=JMZ9AX2cPDZ-_mv3adiv2ToFVNyRPtjk9Biszl1kiR0,2358
|
|
39
39
|
sunholo/cli/configs.py,sha256=QUM9DvKOdZmEQRM5uI3Nh887T0YDiSMr7O240zTLqws,4546
|
|
@@ -117,9 +117,9 @@ sunholo/vertex/extensions_class.py,sha256=4PsUM9dSYrIPpq9bZ3K2rL9MRb_rlqAgnMsW0o
|
|
|
117
117
|
sunholo/vertex/init.py,sha256=-w7b9GKsyJnAJpYHYz6_zBUtmeJeLXlEkgOfwoe4DEI,2715
|
|
118
118
|
sunholo/vertex/memory_tools.py,sha256=pomHrDKqvY8MZxfUqoEwhdlpCvSGP6KmFJMVKOimXjs,6842
|
|
119
119
|
sunholo/vertex/safety.py,sha256=S9PgQT1O_BQAkcqauWncRJaydiP8Q_Jzmu9gxYfy1VA,2482
|
|
120
|
-
sunholo-0.73.
|
|
121
|
-
sunholo-0.73.
|
|
122
|
-
sunholo-0.73.
|
|
123
|
-
sunholo-0.73.
|
|
124
|
-
sunholo-0.73.
|
|
125
|
-
sunholo-0.73.
|
|
120
|
+
sunholo-0.73.3.dist-info/LICENSE.txt,sha256=SdE3QjnD3GEmqqg9EX3TM9f7WmtOzqS1KJve8rhbYmU,11345
|
|
121
|
+
sunholo-0.73.3.dist-info/METADATA,sha256=oZNyJJifnIAdT0EMyILv8u5vKUaR4lzyPUmNcXU9bvw,6909
|
|
122
|
+
sunholo-0.73.3.dist-info/WHEEL,sha256=y4mX-SOX4fYIkonsAGA5N0Oy-8_gI4FXw5HNI1xqvWg,91
|
|
123
|
+
sunholo-0.73.3.dist-info/entry_points.txt,sha256=bZuN5AIHingMPt4Ro1b_T-FnQvZ3teBes-3OyO0asl4,49
|
|
124
|
+
sunholo-0.73.3.dist-info/top_level.txt,sha256=wt5tadn5--5JrZsjJz2LceoUvcrIvxjHJe-RxuudxAk,8
|
|
125
|
+
sunholo-0.73.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|