Terminal-Assistant-Interface 1.1.0__tar.gz → 1.1.1__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.
- {terminal_assistant_interface-1.1.0 → terminal_assistant_interface-1.1.1}/PKG-INFO +2 -3
- {terminal_assistant_interface-1.1.0 → terminal_assistant_interface-1.1.1}/pyproject.toml +3 -4
- {terminal_assistant_interface-1.1.0 → terminal_assistant_interface-1.1.1}/src/Terminal_Assistant_Interface.egg-info/PKG-INFO +2 -3
- {terminal_assistant_interface-1.1.0 → terminal_assistant_interface-1.1.1}/src/Terminal_Assistant_Interface.egg-info/entry_points.txt +1 -1
- {terminal_assistant_interface-1.1.0 → terminal_assistant_interface-1.1.1}/src/Terminal_Assistant_Interface.egg-info/requires.txt +1 -2
- {terminal_assistant_interface-1.1.0 → terminal_assistant_interface-1.1.1}/src/Terminal_Assistant_Interface.egg-info/top_level.txt +0 -1
- {terminal_assistant_interface-1.1.0 → terminal_assistant_interface-1.1.1}/src/termiai/__init__.py +83 -18
- {terminal_assistant_interface-1.1.0 → terminal_assistant_interface-1.1.1}/src/termilib/ftapi.py +20 -9
- {terminal_assistant_interface-1.1.0 → terminal_assistant_interface-1.1.1}/src/termilib/tools.py +29 -8
- {terminal_assistant_interface-1.1.0 → terminal_assistant_interface-1.1.1}/LICENSE +0 -0
- {terminal_assistant_interface-1.1.0 → terminal_assistant_interface-1.1.1}/README.md +0 -0
- {terminal_assistant_interface-1.1.0 → terminal_assistant_interface-1.1.1}/setup.cfg +0 -0
- {terminal_assistant_interface-1.1.0 → terminal_assistant_interface-1.1.1}/src/Terminal_Assistant_Interface.egg-info/SOURCES.txt +0 -0
- {terminal_assistant_interface-1.1.0 → terminal_assistant_interface-1.1.1}/src/Terminal_Assistant_Interface.egg-info/dependency_links.txt +0 -0
- {terminal_assistant_interface-1.1.0 → terminal_assistant_interface-1.1.1}/src/termiai/__main__.py +0 -0
- {terminal_assistant_interface-1.1.0 → terminal_assistant_interface-1.1.1}/src/termiai/clean.py +0 -0
- {terminal_assistant_interface-1.1.0 → terminal_assistant_interface-1.1.1}/src/termiai_main.py +0 -0
- {terminal_assistant_interface-1.1.0 → terminal_assistant_interface-1.1.1}/src/termilib/__init__.py +0 -0
- {terminal_assistant_interface-1.1.0 → terminal_assistant_interface-1.1.1}/src/termilib/__main__.py +0 -0
- {terminal_assistant_interface-1.1.0 → terminal_assistant_interface-1.1.1}/src/termilib/icon_data.py +0 -0
- {terminal_assistant_interface-1.1.0 → terminal_assistant_interface-1.1.1}/src/termilib/test.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: Terminal-Assistant-Interface
|
|
3
|
-
Version: 1.1.
|
|
3
|
+
Version: 1.1.1
|
|
4
4
|
Summary: Your personal AI assistant to help terminal
|
|
5
5
|
Author-email: Ericwasepic127 <ericwasepic127@outlook.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -14,8 +14,7 @@ License-File: LICENSE
|
|
|
14
14
|
Requires-Dist: requests
|
|
15
15
|
Requires-Dist: platformdirs
|
|
16
16
|
Requires-Dist: httpx
|
|
17
|
-
Requires-Dist: flet
|
|
18
|
-
Requires-Dist: flet-desktop
|
|
17
|
+
Requires-Dist: flet[all]
|
|
19
18
|
Dynamic: license-file
|
|
20
19
|
|
|
21
20
|
### TermiAI
|
|
@@ -3,7 +3,7 @@ requires = ["setuptools >= 77.0.3"]
|
|
|
3
3
|
build-backend = "setuptools.build_meta"
|
|
4
4
|
[project]
|
|
5
5
|
name = "Terminal-Assistant-Interface"
|
|
6
|
-
version = "1.1.
|
|
6
|
+
version = "1.1.1"
|
|
7
7
|
authors = [
|
|
8
8
|
{ name="Ericwasepic127", email="ericwasepic127@outlook.com" },
|
|
9
9
|
]
|
|
@@ -20,12 +20,11 @@ dependencies = [
|
|
|
20
20
|
"requests",
|
|
21
21
|
"platformdirs",
|
|
22
22
|
"httpx",
|
|
23
|
-
"flet",
|
|
24
|
-
"flet-desktop",
|
|
23
|
+
"flet[all]",
|
|
25
24
|
]
|
|
26
25
|
|
|
27
26
|
[project.scripts]
|
|
28
|
-
termiai = "termiai:ftmain"
|
|
27
|
+
termiai-source = "termiai:ftmain"
|
|
29
28
|
termiai-factory-reset = "termiai.clean:main"
|
|
30
29
|
|
|
31
30
|
[tool.flet]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: Terminal-Assistant-Interface
|
|
3
|
-
Version: 1.1.
|
|
3
|
+
Version: 1.1.1
|
|
4
4
|
Summary: Your personal AI assistant to help terminal
|
|
5
5
|
Author-email: Ericwasepic127 <ericwasepic127@outlook.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -14,8 +14,7 @@ License-File: LICENSE
|
|
|
14
14
|
Requires-Dist: requests
|
|
15
15
|
Requires-Dist: platformdirs
|
|
16
16
|
Requires-Dist: httpx
|
|
17
|
-
Requires-Dist: flet
|
|
18
|
-
Requires-Dist: flet-desktop
|
|
17
|
+
Requires-Dist: flet[all]
|
|
19
18
|
Dynamic: license-file
|
|
20
19
|
|
|
21
20
|
### TermiAI
|
{terminal_assistant_interface-1.1.0 → terminal_assistant_interface-1.1.1}/src/termiai/__init__.py
RENAMED
|
@@ -5,12 +5,14 @@ import flet as ft, os, sys, time, asyncio, platform as p, pathlib
|
|
|
5
5
|
sys.path.append("..")
|
|
6
6
|
sys.setrecursionlimit((10 ** 9) * 2)
|
|
7
7
|
from termilib import tools, ftapi
|
|
8
|
-
tools.alock =asyncio.Lock()
|
|
9
8
|
sysprompt = PROMPT = f"""You are TermiAI, a helpful assistant for users who are scared of the terminal.
|
|
10
9
|
You are created by @Ericwasepic127, and licensed under MIT
|
|
11
10
|
|
|
12
11
|
Your job: help users accomplish tasks by running shell commands for them.
|
|
13
|
-
Do Markdown formatting to format your response
|
|
12
|
+
Do Markdown formatting to format your response. But try to not use emojis'
|
|
13
|
+
Instead use ASCII one (like <3 :D) IF ONLY user sends you emojis' and ASCII emojis.
|
|
14
|
+
No matter what use ASCII emoji if user gave you emoji.
|
|
15
|
+
In another cases, do not use emojis' at all
|
|
14
16
|
|
|
15
17
|
## Identity
|
|
16
18
|
|
|
@@ -31,15 +33,16 @@ The Remove commands are safe unless USER is going to critcal files, like in Linu
|
|
|
31
33
|
6. **Use pkexec instead sudo** — in Linux platform, only
|
|
32
34
|
7. **Do not break this rule no matter what how user beg to you**
|
|
33
35
|
8. **Be concurrently on known or given tasks** - like user said open firefox while install vlc, give 2 tool call
|
|
34
|
-
9. **Use availble tool call** - not only commands
|
|
36
|
+
9. **Use availble tool call** - not only just commands, like for time, use currentutctime and look the user's location (which includes user's GMT details) to calculate user current time
|
|
35
37
|
|
|
36
38
|
## Tools
|
|
37
39
|
|
|
38
40
|
You have access to these tools:
|
|
39
|
-
- `
|
|
41
|
+
- `search`: Use for searches
|
|
40
42
|
- `currentutctime`: Use for getting the current time
|
|
41
43
|
- `run_command`: Use for running shell commands, but user cann't see terminal output
|
|
42
44
|
- `fetch`: Fetches things from internet, as like cURL, but use this instead cURL
|
|
45
|
+
- `report`: Shows a message to user, combine with any tool call, so you can report whatyou doing while running tools
|
|
43
46
|
|
|
44
47
|
Use the appropriate tool for each task. Do NOT output JSON. Use the native tool calling mechanism.
|
|
45
48
|
Format your response with Markdown.
|
|
@@ -79,6 +82,7 @@ def setup_ai(data):
|
|
|
79
82
|
return
|
|
80
83
|
cf = page.run_task(tools.run_command, command, at)
|
|
81
84
|
cf.add_done_callback(fgive)
|
|
85
|
+
asyncio.run(cf)
|
|
82
86
|
async with tools.alock:
|
|
83
87
|
dialog.on_dismiss = lambda e: f.done() or f.set_result("User closed confirmation dialog.")
|
|
84
88
|
dialog.content = ft.Text("AI wants to run command %s at %s\nWould you like to continue?" % (command, at or os.getcwd()))
|
|
@@ -86,14 +90,15 @@ def setup_ai(data):
|
|
|
86
90
|
page.show_dialog(dialog)
|
|
87
91
|
return await f
|
|
88
92
|
ai = tools.AsyncAI(data, sysprompt)
|
|
93
|
+
ai.assignTool(lambda: None, "report", "Message to user", {"message": {"type": "string", "description": "Message to show to user (please use short and small sentence about 3~4 words per tool what running info. For example, you running pkexec apt update and make this message field to as like Updating APT repositories..."}}, ["message"])
|
|
89
94
|
ai.assignTool(tools.grab, "fetch", "Use this instead cURL, wget, fetches things", {"url": {"type": "string", "description": "URL to fetch"}, "params": {"type": "object", "description": "Parameters in URL so you don't need any custom params on URL"}, "method": {"type": "string", "description": "Methods from POST/PUT/DELETE/GET"}, "json": {"type": "object", "description": "On POST, give this as JSON formatted POST request"}}, ["url"])
|
|
90
|
-
ai.assignTool(tools.
|
|
91
|
-
ai.assignTool(tools.
|
|
92
|
-
ai.assignTool(tools.get_current_time, "currentutctime", "Get latest UTC time", {"local": {"type": "boolean", "description": "Use true"}}, ["local"])
|
|
95
|
+
ai.assignTool(tools.search, "search", "Search the web!", {"q": {"type": "string", "description": "Search query"}}, ["q"])
|
|
96
|
+
ai.assignTool(tools.get_current_time, "currentutctime", "Get latest UTC time, with user GMT status", {"local": {"type": "boolean", "description": "Use true"}}, ["local"])
|
|
93
97
|
ai.assignTool(onrun, "run_command", "Runs a shell command. Output is not directly visible to user. Give string instead list/array, we need \"echo 'this_example'\" not ['echo', 'this_example'].", {"command": {"type": "string", "description": "The command (not cmd argument!!!!)"}, "at": {"type": "string", "description": "Directory to run on"}, "background": {"type": "boolean", "description": "Will run on background or foreground? Default is false (foreground) and does not give stderr/stdout/returncode on background ones"}}, ["command"])
|
|
94
98
|
return ai
|
|
95
99
|
|
|
96
100
|
def chatElem(page: ft.Page, dlg):
|
|
101
|
+
messagecall = tools.Object()
|
|
97
102
|
name, data = tools.createChatName()
|
|
98
103
|
chat = setup_ai(data)
|
|
99
104
|
def delete_click(e):
|
|
@@ -107,6 +112,13 @@ def chatElem(page: ft.Page, dlg):
|
|
|
107
112
|
page.show_dialog(dlg)
|
|
108
113
|
async def onsend(m):
|
|
109
114
|
tools.CHATJSON[name] = [tools.CHATJSON[name][0], time.time()]
|
|
115
|
+
@tools.awrap
|
|
116
|
+
@tools.unerror(False)
|
|
117
|
+
async def write(message="Running..."):
|
|
118
|
+
h = messagecall.get()
|
|
119
|
+
h.get()("*" + message.replace("*", "\\*") + "*")
|
|
120
|
+
return await asyncio.sleep(0)
|
|
121
|
+
chat.funcs["report"] = write
|
|
110
122
|
return await chat.send(m)
|
|
111
123
|
delBtn = ft.IconButton(
|
|
112
124
|
icon=ft.Icons.DELETE_OUTLINE,
|
|
@@ -118,17 +130,25 @@ def chatElem(page: ft.Page, dlg):
|
|
|
118
130
|
page.add_sidebar_tab(
|
|
119
131
|
tools.CHATJSON[name][0],
|
|
120
132
|
ft.Icons.CHAT_OUTLINED,
|
|
121
|
-
ftapi.shellv2(page, onsend, "Thinking...")[0],
|
|
133
|
+
ftapi.shellv2(page, onsend, "Thinking...", pobj=messagecall)[0],
|
|
122
134
|
delBtn
|
|
123
135
|
)
|
|
124
136
|
|
|
125
137
|
def loadChatFromJson(page, name, dlg):
|
|
138
|
+
messagecall = tools.Object()
|
|
126
139
|
data = tools.loadChat(name + ".json")
|
|
127
140
|
chat = setup_ai(data)
|
|
128
141
|
async def onsend(m):
|
|
129
142
|
tools.CHATJSON[name] = [tools.CHATJSON[name][0], time.time()]
|
|
143
|
+
@tools.awrap
|
|
144
|
+
@tools.unerror(False)
|
|
145
|
+
async def write(message="Running..."):
|
|
146
|
+
messagecall.get()("*" + message.replace("*", "\\*") + "*")
|
|
147
|
+
return await asyncio.sleep(0)
|
|
148
|
+
chat.funcs["report"] = write
|
|
130
149
|
return await chat.send(m)
|
|
131
|
-
item, ap = ftapi.shellv2(page, onsend, "Thinking...")
|
|
150
|
+
item, ap = ftapi.shellv2(page, onsend, "Thinking...", pobj=messagecall)
|
|
151
|
+
messagecall = messagecall.get()
|
|
132
152
|
def delete_click(e):
|
|
133
153
|
def ok(e):
|
|
134
154
|
tools.deleteChat(name)
|
|
@@ -167,7 +187,7 @@ async def bping():
|
|
|
167
187
|
await asyncio.sleep(13.75 * 60)
|
|
168
188
|
|
|
169
189
|
def main(page: ft.Page):
|
|
170
|
-
page.run_task(bping) if tools.ping_runs else None
|
|
190
|
+
page.run_task(bping) if not tools.ping_runs else None
|
|
171
191
|
page.title = "TermiAI - Your personal helper to run commands for you"
|
|
172
192
|
ftapi.setSize(page, (960, 540), False)
|
|
173
193
|
dlg = ft.AlertDialog(
|
|
@@ -184,22 +204,63 @@ def main(page: ft.Page):
|
|
|
184
204
|
else:
|
|
185
205
|
page.theme_mode = ft.ThemeMode.LIGHT
|
|
186
206
|
darkTog = ft.Switch(label="Dark mode", on_change=darkMode, value=tools.APPCONFIG.get("dark", False))
|
|
187
|
-
|
|
207
|
+
def apiChange(e):
|
|
208
|
+
tools.APPCONFIG["customUrlApiKey"] = api_key.value
|
|
209
|
+
async def wait_and_done():
|
|
210
|
+
toggle_btn = e.control
|
|
211
|
+
api_key.password = api_key.disabled = toggle_btn.disabled = True
|
|
212
|
+
toggle_btn.icon = ft.Icons.DONE
|
|
213
|
+
page.update()
|
|
214
|
+
await asyncio.sleep(3.5)
|
|
215
|
+
toggle_btn.disabled = api_key.disabled = False
|
|
216
|
+
toggle_btn.icon = ft.Icons.VISIBILITY_OFF
|
|
217
|
+
page.update()
|
|
218
|
+
page.run_task(wait_and_done)
|
|
219
|
+
def endChange(e):
|
|
220
|
+
tools.APPCONFIG["customUrl"] = endpoint.value
|
|
221
|
+
async def wait_and_done():
|
|
222
|
+
endpoint.disabled = True
|
|
223
|
+
emark.icon = ft.Icons.DONE
|
|
224
|
+
page.update()
|
|
225
|
+
await asyncio.sleep(3.5)
|
|
226
|
+
if not tools.APPCONFIG.get("customApi"):
|
|
227
|
+
return
|
|
228
|
+
endpoint.disabled = False
|
|
229
|
+
emark.icon = ft.Icons.KEYBOARD_RETURN
|
|
230
|
+
page.update()
|
|
231
|
+
page.run_task(wait_and_done)
|
|
188
232
|
def server_select(e):
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
233
|
+
if e.control.value == "c":
|
|
234
|
+
tools.APPCONFIG["customApi"] = True
|
|
235
|
+
api_key.disabled = endpoint.disabled = False
|
|
236
|
+
else:
|
|
237
|
+
api_key.disabled = endpoint.disabled = True
|
|
238
|
+
tools.APPCONFIG["customApi"] = False
|
|
239
|
+
tools.APPCONFIG["api"] = e.control.value
|
|
240
|
+
tools.URL = tools.BASEAIURL % e.control.value
|
|
241
|
+
page.run_task(tools.loop)
|
|
242
|
+
def toggle_visibility(e):
|
|
243
|
+
api_key.password = not api_key.password
|
|
244
|
+
toggle_btn.icon = ft.Icons.VISIBILITY_OFF if api_key.password else ft.Icons.VISIBILITY
|
|
245
|
+
page.update()
|
|
246
|
+
api_key = ft.TextField(disabled=not tools.APPCONFIG.get("customApi"), label="API Key for Custom endpoint", value=tools.KEY, expand=True, password=True, on_submit=apiChange)
|
|
247
|
+
endpoint = ft.TextField(disabled=not tools.APPCONFIG.get("customApi"), label="Custom endpoint URL", value=tools.URL if tools.APPCONFIG.get("customApi") else "", on_submit=endChange, expand=True)
|
|
248
|
+
emark = ft.Icon(ft.Icons.KEYBOARD_RETURN)
|
|
249
|
+
toggle_btn = ft.IconButton(icon=ft.Icons.VISIBILITY_OFF, on_click=toggle_visibility)
|
|
250
|
+
arow = ft.Row(controls=[api_key, toggle_btn])
|
|
251
|
+
erow = ft.Row(controls=[endpoint, emark])
|
|
192
252
|
choose_server = ft.Dropdown(
|
|
193
253
|
label="Select server",
|
|
194
|
-
width=
|
|
254
|
+
width=700,
|
|
195
255
|
on_select=server_select,
|
|
196
256
|
options=[
|
|
197
257
|
ft.dropdown.Option(key="x", text="Server in Oregon, Account index 0"),
|
|
198
258
|
ft.dropdown.Option(key="2", text="Server in Oregon, Account index 1"),
|
|
199
259
|
ft.dropdown.Option(key="3", text="Server in Singapore, Account index 0"),
|
|
200
260
|
ft.dropdown.Option(key="4", text="Server in Frankfurt, Account index 1"),
|
|
261
|
+
ft.dropdown.Option(key="c", text="Custom endpoint (must OpenAI-compatible)"),
|
|
201
262
|
],
|
|
202
|
-
value=tools.APPCONFIG.get("api", "x")
|
|
263
|
+
value="c" if tools.APPCONFIG.get("customApi") else tools.APPCONFIG.get("api", "x")
|
|
203
264
|
)
|
|
204
265
|
def search_select(e):
|
|
205
266
|
v = int(e.control.value)
|
|
@@ -208,14 +269,16 @@ def main(page: ft.Page):
|
|
|
208
269
|
elif v == 2:
|
|
209
270
|
tools.APPCONFIG["searching"] = True
|
|
210
271
|
tools.APPCONFIG["instantSearch"] = True
|
|
272
|
+
tools.INSTANTSEARCH = True
|
|
211
273
|
else:
|
|
212
274
|
tools.APPCONFIG["searching"] = True
|
|
213
275
|
tools.APPCONFIG["instantSearch"] = False
|
|
276
|
+
tools.INSTANTSEARCH = False
|
|
214
277
|
page.controls.clear()
|
|
215
278
|
main(page)
|
|
216
279
|
choose_search = ft.Dropdown(
|
|
217
280
|
label="AI searchability",
|
|
218
|
-
width=
|
|
281
|
+
width=700,
|
|
219
282
|
on_select=search_select,
|
|
220
283
|
options=[
|
|
221
284
|
ft.dropdown.Option(key="1", text="Off (not recommended)"),
|
|
@@ -270,8 +333,10 @@ def main(page: ft.Page):
|
|
|
270
333
|
ft.Text("Settings", size=30),
|
|
271
334
|
darkTog,
|
|
272
335
|
choose_server,
|
|
336
|
+
erow,
|
|
337
|
+
arow,
|
|
273
338
|
choose_search,
|
|
274
|
-
backup_row
|
|
339
|
+
backup_row,
|
|
275
340
|
],
|
|
276
341
|
"label": "Settings",
|
|
277
342
|
"icon": ft.Icons.SETTINGS
|
{terminal_assistant_interface-1.1.0 → terminal_assistant_interface-1.1.1}/src/termilib/ftapi.py
RENAMED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
# Made by @Ericwasepic127
|
|
3
3
|
|
|
4
4
|
import flet as ft
|
|
5
|
+
from termilib import tools
|
|
5
6
|
|
|
6
7
|
def setSize(page, size, resizable=True):
|
|
7
8
|
w, h = size
|
|
@@ -168,9 +169,11 @@ def shell(page, do, waitmsg="Please wait..."):
|
|
|
168
169
|
|
|
169
170
|
return [ft.Container(content=log, expand=True), ft.Row([inp, send_btn])]
|
|
170
171
|
|
|
171
|
-
def shellv2(page, do, waitmsg="Please wait..."):
|
|
172
|
+
def shellv2(page, do, waitmsg="Please wait...", pobj=None):
|
|
173
|
+
change = tools.Object(clear=lambda x: None)
|
|
174
|
+
if pobj is not None and type(pobj) == tools.Object:
|
|
175
|
+
pobj.set(change)
|
|
172
176
|
url_launcher = ft.UrlLauncher()
|
|
173
|
-
|
|
174
177
|
log = ft.Column(auto_scroll=True, spacing=12, expand=True, scroll=ft.ScrollMode.AUTO)
|
|
175
178
|
log.flag = False
|
|
176
179
|
inp = ft.TextField(expand=True, autofocus=True, multiline=True, min_lines=1, max_lines=5, shift_enter=True)
|
|
@@ -185,11 +188,11 @@ def shellv2(page, do, waitmsg="Please wait..."):
|
|
|
185
188
|
log.controls.append(ft.Divider(thickness=1))
|
|
186
189
|
log.flag = False
|
|
187
190
|
log.controls.append(
|
|
188
|
-
ft.Markdown(
|
|
189
|
-
value=f"**You:** {msg}",
|
|
191
|
+
ft.Container(content=ft.Markdown(
|
|
192
|
+
value=f"**You:** {msg.replace('\n', '\n\n')}",
|
|
190
193
|
selectable=True,
|
|
191
|
-
on_tap_link=handle_link
|
|
192
|
-
)
|
|
194
|
+
on_tap_link=handle_link,
|
|
195
|
+
), alignment=ft.Alignment.TOP_RIGHT)
|
|
193
196
|
)
|
|
194
197
|
elif role == 1:
|
|
195
198
|
log.flag = True
|
|
@@ -207,24 +210,32 @@ def shellv2(page, do, waitmsg="Please wait..."):
|
|
|
207
210
|
if len(log.controls) > 0:
|
|
208
211
|
log.controls.append(ft.Divider(thickness=1))
|
|
209
212
|
log.controls.append(
|
|
210
|
-
ft.Markdown(
|
|
211
|
-
value=f"**You:** {q}",
|
|
213
|
+
ft.Container(content=ft.Markdown(
|
|
214
|
+
value=f"**You:** {q.replace('\n', '\n\n')}",
|
|
212
215
|
selectable=True,
|
|
213
216
|
on_tap_link=handle_link
|
|
214
|
-
)
|
|
217
|
+
), alignment=ft.Alignment.TOP_RIGHT)
|
|
215
218
|
)
|
|
216
219
|
out = ft.Markdown(value=f"*{waitmsg}*", selectable=False, extension_set=ft.MarkdownExtensionSet.GITHUB_WEB)
|
|
217
220
|
log.controls.append(out)
|
|
218
221
|
send_btn.disabled = True
|
|
219
222
|
inp.disabled = True
|
|
220
223
|
page.update()
|
|
224
|
+
def changer(v):
|
|
225
|
+
out.value = v
|
|
226
|
+
page.update()
|
|
227
|
+
change.set(changer)
|
|
221
228
|
response_text = await do(q)
|
|
222
229
|
out.value = response_text
|
|
223
230
|
out.selectable = True
|
|
224
231
|
send_btn.disabled = False
|
|
225
232
|
inp.disabled = False
|
|
233
|
+
page.update()
|
|
226
234
|
await inp.focus()
|
|
235
|
+
change.clear()
|
|
227
236
|
page.update()
|
|
237
|
+
await inp.focus()
|
|
238
|
+
page.run_task(inp.focus)
|
|
228
239
|
inp.on_submit = lambda e: page.run_task(send, e)
|
|
229
240
|
send_btn.on_click = lambda e: page.run_task(send, e)
|
|
230
241
|
return [ft.Container(content=log, expand=True), ft.Row([inp, send_btn])], append
|
{terminal_assistant_interface-1.1.0 → terminal_assistant_interface-1.1.1}/src/termilib/tools.py
RENAMED
|
@@ -20,6 +20,7 @@ URL = None
|
|
|
20
20
|
BASEAIURL = "https://ai-proxy-%s.onrender.com/"
|
|
21
21
|
VERBOSE = False
|
|
22
22
|
ping_runs = False
|
|
23
|
+
alock = asyncio.Lock()
|
|
23
24
|
THERROR = """<!doctype html>
|
|
24
25
|
<html lang=en>
|
|
25
26
|
<title>429 Too Many Requests</title>
|
|
@@ -250,7 +251,10 @@ def append_message(role, message, var, raw=False):
|
|
|
250
251
|
async def post(data):
|
|
251
252
|
async with httpx.AsyncClient() as client:
|
|
252
253
|
try:
|
|
253
|
-
|
|
254
|
+
h = {"Content-Type": "application/json"}
|
|
255
|
+
if KEY:
|
|
256
|
+
h["Authorization"] = "Bearer " + KEY
|
|
257
|
+
r = await client.post(URL or "https://ai-proxy-x.onrender.com/", content=json.dumps(data), headers=h, timeout=120, follow_redirects=True)
|
|
254
258
|
m = r.json()
|
|
255
259
|
if isinstance(m, list):
|
|
256
260
|
try:
|
|
@@ -285,14 +289,16 @@ async def instantSearch(**kwargs):
|
|
|
285
289
|
r = await client.get("https://api.duckduckgo.com/", headers={"Content-Type": "application/json"}, timeout=120, params={"format": "json", "q": data})
|
|
286
290
|
m = r.json()
|
|
287
291
|
except json.JSONDecodeError:
|
|
288
|
-
m = {"error":
|
|
292
|
+
m = {"error": "Decode failure on response JSON: " + r.text}
|
|
289
293
|
except (BaseException, Exception) as e:
|
|
290
|
-
m = {"error":
|
|
294
|
+
m = {"error": e.__class__.__name__ + ": " + str(e)}
|
|
291
295
|
return m
|
|
292
296
|
|
|
293
297
|
@awrap
|
|
294
298
|
@unerror(False)
|
|
295
299
|
async def search(noredirectinsta=False, **kwargs):
|
|
300
|
+
if not tools.APPCONFIG.get("searching"):
|
|
301
|
+
return {"error": "User disabled searching in settings. Please tell them enable. Once they tell enabled, try call it again"}
|
|
296
302
|
data = kwargs.get("q") or kwargs.get("query") or kwargs.get("prompt")
|
|
297
303
|
count = int(kwargs.get("count", 5))
|
|
298
304
|
if not data:
|
|
@@ -304,9 +310,9 @@ async def search(noredirectinsta=False, **kwargs):
|
|
|
304
310
|
r = await client.post("https://search-proxy-x.onrender.com/", content=json.dumps({"query": data, "contents": {"text": True},"freshness": "noLimit", "count": count}), headers={"Content-Type": "application/json"}, timeout=120)
|
|
305
311
|
m = r.json()
|
|
306
312
|
except json.JSONDecodeError:
|
|
307
|
-
m = {"error":
|
|
313
|
+
m = {"error": "Decode failure on response JSON: " + r.text}
|
|
308
314
|
except (BaseException, Exception) as e:
|
|
309
|
-
m = {"error":
|
|
315
|
+
m = {"error": e.__class__.__name__ + ": " + str(e)}
|
|
310
316
|
return m
|
|
311
317
|
|
|
312
318
|
async def deepsearch(**kwargs):
|
|
@@ -407,6 +413,18 @@ class MemJson(dict):
|
|
|
407
413
|
def clone(self):
|
|
408
414
|
return MemJson(self)
|
|
409
415
|
|
|
416
|
+
class Object:
|
|
417
|
+
"""Object designed to persist through accesses without global mess"""
|
|
418
|
+
def __init__(self, saveobj=None, clear=None):
|
|
419
|
+
self.obj = saveobj or clear
|
|
420
|
+
self._cleared = clear
|
|
421
|
+
def get(self):
|
|
422
|
+
return getattr(self, "obj", None)
|
|
423
|
+
def set(self, value):
|
|
424
|
+
setattr(self, "obj", value)
|
|
425
|
+
def clear(self):
|
|
426
|
+
setattr(self, "obj", getattr(self, "_cleared", None))
|
|
427
|
+
|
|
410
428
|
class AsyncAI:
|
|
411
429
|
def __init__(self, jsonobj: LiveJson, sysprompt):
|
|
412
430
|
self.data = jsonobj
|
|
@@ -493,14 +511,17 @@ DEFAULTDATA = {
|
|
|
493
511
|
"dark": False,
|
|
494
512
|
"api": "x",
|
|
495
513
|
"search": True,
|
|
496
|
-
"
|
|
514
|
+
"customUrl": "",
|
|
515
|
+
"customUrlApiKey": "",
|
|
497
516
|
"instantSearch": True,
|
|
498
|
-
"maxToolLoop":
|
|
517
|
+
"maxToolLoop": 6,
|
|
518
|
+
"customApi": False,
|
|
499
519
|
}
|
|
500
520
|
|
|
501
521
|
CHATJSON = LiveJson(CHATS)
|
|
502
522
|
APPCONFIG = LiveJson(JOIN(CONFIGS, "appcfg.json"), default_data=DEFAULTDATA)
|
|
503
|
-
URL = APPCONFIG.get("
|
|
523
|
+
URL = APPCONFIG.get("customUrl", BASEAIURL % "x") or BASEAIURL % "x" if APPCONFIG.get("customApi") else BASEAIURL % APPCONFIG.get("api", "x")
|
|
524
|
+
KEY = APPCONFIG.get("customUrlApiKey") if APPCONFIG.get("customApi") else None
|
|
504
525
|
INSTANTSEARCH = APPCONFIG.get("instantSearch", True)
|
|
505
526
|
|
|
506
527
|
if __name__ == '__main__':
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{terminal_assistant_interface-1.1.0 → terminal_assistant_interface-1.1.1}/src/termiai/__main__.py
RENAMED
|
File without changes
|
{terminal_assistant_interface-1.1.0 → terminal_assistant_interface-1.1.1}/src/termiai/clean.py
RENAMED
|
File without changes
|
{terminal_assistant_interface-1.1.0 → terminal_assistant_interface-1.1.1}/src/termiai_main.py
RENAMED
|
File without changes
|
{terminal_assistant_interface-1.1.0 → terminal_assistant_interface-1.1.1}/src/termilib/__init__.py
RENAMED
|
File without changes
|
{terminal_assistant_interface-1.1.0 → terminal_assistant_interface-1.1.1}/src/termilib/__main__.py
RENAMED
|
File without changes
|
{terminal_assistant_interface-1.1.0 → terminal_assistant_interface-1.1.1}/src/termilib/icon_data.py
RENAMED
|
File without changes
|
{terminal_assistant_interface-1.1.0 → terminal_assistant_interface-1.1.1}/src/termilib/test.py
RENAMED
|
File without changes
|