pygpt-net 2.4.41__py3-none-any.whl → 2.4.42__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.
- CHANGELOG.md +8 -0
- README.md +135 -70
- pygpt_net/CHANGELOG.txt +8 -0
- pygpt_net/__init__.py +3 -3
- pygpt_net/app.py +3 -1
- pygpt_net/controller/audio/__init__.py +2 -2
- pygpt_net/controller/camera.py +1 -10
- pygpt_net/controller/chat/audio.py +2 -2
- pygpt_net/controller/config/placeholder.py +15 -1
- pygpt_net/controller/ui/mode.py +16 -21
- pygpt_net/core/audio/__init__.py +4 -1
- pygpt_net/core/audio/whisper.py +37 -0
- pygpt_net/core/bridge/worker.py +2 -2
- pygpt_net/core/debug/events.py +22 -10
- pygpt_net/core/debug/tabs.py +6 -3
- pygpt_net/core/history.py +3 -2
- pygpt_net/core/idx/__init__.py +16 -4
- pygpt_net/core/idx/chat.py +15 -5
- pygpt_net/core/idx/indexing.py +24 -8
- pygpt_net/core/installer.py +2 -4
- pygpt_net/core/models.py +62 -17
- pygpt_net/core/modes.py +11 -13
- pygpt_net/core/notepad.py +4 -4
- pygpt_net/core/plugins.py +27 -16
- pygpt_net/core/presets.py +20 -9
- pygpt_net/core/profile.py +11 -3
- pygpt_net/core/render/web/parser.py +3 -1
- pygpt_net/core/settings.py +5 -5
- pygpt_net/core/tabs/tab.py +10 -2
- pygpt_net/core/tokens.py +8 -6
- pygpt_net/core/web/__init__.py +105 -0
- pygpt_net/core/{web.py → web/helpers.py} +93 -67
- pygpt_net/data/config/config.json +3 -3
- pygpt_net/data/config/models.json +3 -3
- pygpt_net/data/config/modes.json +3 -3
- pygpt_net/data/locale/locale.en.ini +1 -0
- pygpt_net/data/locale/plugin.cmd_web.en.ini +2 -0
- pygpt_net/data/locale/plugin.mailer.en.ini +21 -0
- pygpt_net/item/ctx.py +13 -2
- pygpt_net/plugin/agent/__init__.py +7 -2
- pygpt_net/plugin/audio_output/__init__.py +6 -1
- pygpt_net/plugin/base/plugin.py +58 -26
- pygpt_net/plugin/base/worker.py +20 -17
- pygpt_net/plugin/cmd_history/config.py +2 -2
- pygpt_net/plugin/cmd_web/__init__.py +3 -4
- pygpt_net/plugin/cmd_web/config.py +71 -3
- pygpt_net/plugin/cmd_web/websearch.py +20 -12
- pygpt_net/plugin/cmd_web/worker.py +67 -4
- pygpt_net/plugin/idx_llama_index/config.py +3 -3
- pygpt_net/plugin/mailer/__init__.py +123 -0
- pygpt_net/plugin/mailer/config.py +149 -0
- pygpt_net/plugin/mailer/runner.py +285 -0
- pygpt_net/plugin/mailer/worker.py +123 -0
- pygpt_net/provider/agents/base.py +5 -2
- pygpt_net/provider/agents/openai.py +4 -2
- pygpt_net/provider/agents/openai_assistant.py +4 -2
- pygpt_net/provider/agents/planner.py +4 -2
- pygpt_net/provider/agents/react.py +4 -2
- pygpt_net/provider/audio_output/openai_tts.py +5 -11
- pygpt_net/provider/core/assistant/base.py +5 -3
- pygpt_net/provider/core/assistant/json_file.py +8 -5
- pygpt_net/provider/core/assistant_file/base.py +4 -3
- pygpt_net/provider/core/assistant_file/db_sqlite/__init__.py +4 -3
- pygpt_net/provider/core/assistant_file/db_sqlite/storage.py +3 -2
- pygpt_net/provider/core/assistant_store/base.py +6 -4
- pygpt_net/provider/core/assistant_store/db_sqlite/__init__.py +5 -4
- pygpt_net/provider/core/assistant_store/db_sqlite/storage.py +5 -3
- pygpt_net/provider/core/attachment/base.py +5 -3
- pygpt_net/provider/core/attachment/json_file.py +4 -3
- pygpt_net/provider/core/calendar/base.py +5 -3
- pygpt_net/provider/core/calendar/db_sqlite/__init__.py +6 -5
- pygpt_net/provider/core/calendar/db_sqlite/storage.py +5 -4
- pygpt_net/provider/core/config/base.py +8 -6
- pygpt_net/provider/core/config/json_file.py +9 -7
- pygpt_net/provider/core/ctx/base.py +27 -25
- pygpt_net/provider/core/ctx/db_sqlite/__init__.py +51 -35
- pygpt_net/provider/core/ctx/db_sqlite/storage.py +42 -31
- pygpt_net/provider/core/ctx/db_sqlite/utils.py +11 -9
- pygpt_net/provider/core/index/base.py +129 -23
- pygpt_net/provider/core/index/db_sqlite/__init__.py +130 -23
- pygpt_net/provider/core/index/db_sqlite/storage.py +130 -23
- pygpt_net/provider/core/index/db_sqlite/utils.py +4 -2
- pygpt_net/provider/core/mode/base.py +5 -3
- pygpt_net/provider/core/mode/json_file.py +7 -6
- pygpt_net/provider/core/model/base.py +6 -4
- pygpt_net/provider/core/model/json_file.py +9 -7
- pygpt_net/provider/core/notepad/base.py +5 -3
- pygpt_net/provider/core/notepad/db_sqlite/__init__.py +5 -4
- pygpt_net/provider/core/notepad/db_sqlite/storage.py +4 -3
- pygpt_net/provider/core/plugin_preset/base.py +4 -2
- pygpt_net/provider/core/plugin_preset/json_file.py +5 -3
- pygpt_net/provider/core/preset/base.py +6 -4
- pygpt_net/provider/core/preset/json_file.py +9 -9
- pygpt_net/provider/core/prompt/base.py +6 -3
- pygpt_net/provider/core/prompt/json_file.py +11 -6
- pygpt_net/provider/gpt/assistants.py +15 -6
- pygpt_net/provider/gpt/audio.py +5 -5
- pygpt_net/provider/gpt/chat.py +7 -5
- pygpt_net/provider/gpt/completion.py +8 -4
- pygpt_net/provider/gpt/image.py +3 -3
- pygpt_net/provider/gpt/store.py +46 -12
- pygpt_net/provider/gpt/vision.py +16 -11
- pygpt_net/provider/llms/anthropic.py +7 -2
- pygpt_net/provider/llms/azure_openai.py +26 -5
- pygpt_net/provider/llms/base.py +47 -9
- pygpt_net/provider/llms/google.py +7 -2
- pygpt_net/provider/llms/hugging_face.py +13 -3
- pygpt_net/provider/llms/hugging_face_api.py +18 -4
- pygpt_net/provider/llms/local.py +7 -2
- pygpt_net/provider/llms/ollama.py +30 -6
- pygpt_net/provider/llms/openai.py +32 -6
- pygpt_net/provider/vector_stores/__init__.py +45 -14
- pygpt_net/provider/vector_stores/base.py +35 -8
- pygpt_net/provider/vector_stores/chroma.py +13 -3
- pygpt_net/provider/vector_stores/ctx_attachment.py +31 -12
- pygpt_net/provider/vector_stores/elasticsearch.py +12 -3
- pygpt_net/provider/vector_stores/pinecode.py +12 -3
- pygpt_net/provider/vector_stores/redis.py +12 -3
- pygpt_net/provider/vector_stores/simple.py +12 -3
- pygpt_net/provider/vector_stores/temp.py +16 -4
- pygpt_net/provider/web/base.py +10 -3
- pygpt_net/provider/web/google_custom_search.py +9 -3
- pygpt_net/provider/web/microsoft_bing.py +9 -3
- pygpt_net/tools/__init__.py +13 -5
- pygpt_net/tools/audio_transcriber/__init__.py +4 -3
- pygpt_net/tools/base.py +15 -8
- pygpt_net/tools/code_interpreter/__init__.py +4 -3
- pygpt_net/tools/html_canvas/__init__.py +4 -3
- pygpt_net/tools/image_viewer/__init__.py +10 -4
- pygpt_net/tools/indexer/__init__.py +8 -7
- pygpt_net/tools/media_player/__init__.py +4 -3
- pygpt_net/tools/text_editor/__init__.py +36 -10
- pygpt_net/ui/layout/chat/output.py +2 -2
- pygpt_net/ui/menu/audio.py +12 -1
- {pygpt_net-2.4.41.dist-info → pygpt_net-2.4.42.dist-info}/METADATA +136 -71
- {pygpt_net-2.4.41.dist-info → pygpt_net-2.4.42.dist-info}/RECORD +139 -132
- {pygpt_net-2.4.41.dist-info → pygpt_net-2.4.42.dist-info}/LICENSE +0 -0
- {pygpt_net-2.4.41.dist-info → pygpt_net-2.4.42.dist-info}/WHEEL +0 -0
- {pygpt_net-2.4.41.dist-info → pygpt_net-2.4.42.dist-info}/entry_points.txt +0 -0
@@ -6,7 +6,7 @@
|
|
6
6
|
# GitHub: https://github.com/szczyglis-dev/py-gpt #
|
7
7
|
# MIT License #
|
8
8
|
# Created By : Marcin Szczygliński #
|
9
|
-
# Updated Date: 2024.
|
9
|
+
# Updated Date: 2024.12.14 19:00:00 #
|
10
10
|
# ================================================== #
|
11
11
|
|
12
12
|
from pygpt_net.plugin.base.config import BaseConfig, BasePlugin
|
@@ -34,7 +34,7 @@ class Config(BaseConfig):
|
|
34
34
|
plugin.add_option(
|
35
35
|
"model_summarize",
|
36
36
|
type="combo",
|
37
|
-
value="gpt-
|
37
|
+
value="gpt-4o-mini",
|
38
38
|
label="Model",
|
39
39
|
description="Model used for summarize, default: gpt-3.5-turbo",
|
40
40
|
tooltip="Summarize model",
|
@@ -6,14 +6,12 @@
|
|
6
6
|
# GitHub: https://github.com/szczyglis-dev/py-gpt #
|
7
7
|
# MIT License #
|
8
8
|
# Created By : Marcin Szczygliński #
|
9
|
-
# Updated Date: 2024.12.
|
9
|
+
# Updated Date: 2024.12.15 01:00:00 #
|
10
10
|
# ================================================== #
|
11
11
|
|
12
12
|
import ssl
|
13
13
|
from urllib.request import Request, urlopen
|
14
14
|
|
15
|
-
from requests import HTTPError
|
16
|
-
|
17
15
|
from pygpt_net.plugin.base.plugin import BasePlugin
|
18
16
|
from pygpt_net.provider.web.base import BaseProvider
|
19
17
|
from pygpt_net.core.events import Event
|
@@ -38,6 +36,7 @@ class Plugin(BasePlugin):
|
|
38
36
|
"web_urls",
|
39
37
|
"web_url_open",
|
40
38
|
"web_url_raw",
|
39
|
+
"web_request",
|
41
40
|
"web_index",
|
42
41
|
"web_index_query",
|
43
42
|
"web_extract_links",
|
@@ -96,7 +95,7 @@ class Plugin(BasePlugin):
|
|
96
95
|
|
97
96
|
:return: providers dict
|
98
97
|
"""
|
99
|
-
return self.window.core.web.get_providers(
|
98
|
+
return self.window.core.web.get_providers(self.window.core.web.PROVIDER_SEARCH_ENGINE)
|
100
99
|
|
101
100
|
def get_provider_options(self) -> list:
|
102
101
|
"""Get provider options"""
|
@@ -6,7 +6,7 @@
|
|
6
6
|
# GitHub: https://github.com/szczyglis-dev/py-gpt #
|
7
7
|
# MIT License #
|
8
8
|
# Created By : Marcin Szczygliński #
|
9
|
-
# Updated Date: 2024.12.
|
9
|
+
# Updated Date: 2024.12.15 01:00:00 #
|
10
10
|
# ================================================== #
|
11
11
|
|
12
12
|
from pygpt_net.plugin.base.config import BaseConfig, BasePlugin
|
@@ -150,11 +150,12 @@ class Config(BaseConfig):
|
|
150
150
|
)
|
151
151
|
plugin.add_option(
|
152
152
|
"idx",
|
153
|
-
type="
|
153
|
+
type="combo",
|
154
154
|
value="base",
|
155
155
|
label="Index to use",
|
156
156
|
description="ID of index to use for web page indexing (persistent index)",
|
157
157
|
tooltip="Index name",
|
158
|
+
use="idx",
|
158
159
|
tab="indexing",
|
159
160
|
)
|
160
161
|
plugin.add_option(
|
@@ -162,7 +163,7 @@ class Config(BaseConfig):
|
|
162
163
|
type="combo",
|
163
164
|
value="gpt-4o-mini",
|
164
165
|
label="Model used for web page summarize",
|
165
|
-
description="Model used for web page summarize, default: gpt-
|
166
|
+
description="Model used for web page summarize, default: gpt-4o-mini",
|
166
167
|
use="models",
|
167
168
|
advanced=True,
|
168
169
|
)
|
@@ -246,6 +247,73 @@ class Config(BaseConfig):
|
|
246
247
|
enabled=True,
|
247
248
|
description="If enabled, model will be able to search the Web and get founded URLs list",
|
248
249
|
)
|
250
|
+
plugin.add_cmd(
|
251
|
+
"web_request",
|
252
|
+
instruction="send HTTP request to specified URL or API endpoint, using `requests` library. Tip: to "
|
253
|
+
"send raw data, use `data` parameter. To send data in `application/x-www-form-urlencoded` format, "
|
254
|
+
"use `data_form` parameter. To send data in `application/json` format, use `data_json` parameter. "
|
255
|
+
"Sending data in `data_form` and `data_json` parameters will automatically set `Content-Type`. To "
|
256
|
+
"upload files, use `files` parameter. To send cookies, use `cookies` parameter. To set custom headers, "
|
257
|
+
"use `headers` parameter. You can combine all parameters.",
|
258
|
+
params=[
|
259
|
+
{
|
260
|
+
"name": "url",
|
261
|
+
"type": "str",
|
262
|
+
"description": "URL to website or API endpoint",
|
263
|
+
"required": True,
|
264
|
+
},
|
265
|
+
{
|
266
|
+
"name": "method",
|
267
|
+
"type": "str",
|
268
|
+
"description": "HTTP method, default: GET",
|
269
|
+
"required": False,
|
270
|
+
},
|
271
|
+
{
|
272
|
+
"name": "headers",
|
273
|
+
"type": "dict",
|
274
|
+
"description": "HTTP headers",
|
275
|
+
"required": False,
|
276
|
+
},
|
277
|
+
{
|
278
|
+
"name": "params",
|
279
|
+
"type": "dict",
|
280
|
+
"description": "GET parameters",
|
281
|
+
"required": False,
|
282
|
+
},
|
283
|
+
{
|
284
|
+
"name": "data",
|
285
|
+
"type": "str",
|
286
|
+
"description": "raw data to send in POST requests",
|
287
|
+
"required": False,
|
288
|
+
},
|
289
|
+
{
|
290
|
+
"name": "data_form",
|
291
|
+
"type": "dict",
|
292
|
+
"description": "data to send in POST `application/x-www-form-urlencoded` requests",
|
293
|
+
"required": False,
|
294
|
+
},
|
295
|
+
{
|
296
|
+
"name": "data_json",
|
297
|
+
"type": "dict",
|
298
|
+
"description": "JSON data to send in POST `application/json` requests",
|
299
|
+
"required": False,
|
300
|
+
},
|
301
|
+
{
|
302
|
+
"name": "cookies",
|
303
|
+
"type": "dict",
|
304
|
+
"description": "Cookies",
|
305
|
+
"required": False,
|
306
|
+
},
|
307
|
+
{
|
308
|
+
"name": "files",
|
309
|
+
"type": "dict",
|
310
|
+
"description": "Files to upload, key is form field name, value is absolute path to file",
|
311
|
+
"required": False,
|
312
|
+
},
|
313
|
+
],
|
314
|
+
enabled=True,
|
315
|
+
description="If enabled, model will be able to send any HTTP request to specified URL or API endpoint",
|
316
|
+
)
|
249
317
|
plugin.add_cmd(
|
250
318
|
"web_extract_links",
|
251
319
|
instruction="open webpage and get list of all links from it",
|
@@ -6,10 +6,11 @@
|
|
6
6
|
# GitHub: https://github.com/szczyglis-dev/py-gpt #
|
7
7
|
# MIT License #
|
8
8
|
# Created By : Marcin Szczygliński #
|
9
|
-
# Updated Date: 2024.12.
|
9
|
+
# Updated Date: 2024.12.14 22:00:00 #
|
10
10
|
# ================================================== #
|
11
11
|
|
12
12
|
import re
|
13
|
+
from typing import Optional, Tuple, Any, List
|
13
14
|
|
14
15
|
from bs4 import BeautifulSoup
|
15
16
|
|
@@ -32,7 +33,7 @@ class WebSearch:
|
|
32
33
|
query: str,
|
33
34
|
num: int,
|
34
35
|
offset: int = 1
|
35
|
-
) ->
|
36
|
+
) -> List[str]:
|
36
37
|
"""
|
37
38
|
Execute search query and return list of urls
|
38
39
|
|
@@ -43,7 +44,7 @@ class WebSearch:
|
|
43
44
|
"""
|
44
45
|
return self.plugin.get_provider().search(query, num, offset)
|
45
46
|
|
46
|
-
def get_urls(self, query: str) ->
|
47
|
+
def get_urls(self, query: str) -> List[str]:
|
47
48
|
"""
|
48
49
|
Search the web and returns URLs
|
49
50
|
|
@@ -104,7 +105,7 @@ class WebSearch:
|
|
104
105
|
self,
|
105
106
|
text: str,
|
106
107
|
chunk_size: int
|
107
|
-
) ->
|
108
|
+
) -> List[str]:
|
108
109
|
"""
|
109
110
|
Split text into chunks
|
110
111
|
|
@@ -120,7 +121,7 @@ class WebSearch:
|
|
120
121
|
self,
|
121
122
|
chunks: list,
|
122
123
|
query: str,
|
123
|
-
summarize_prompt: str = None
|
124
|
+
summarize_prompt: Optional[str] = None
|
124
125
|
) -> str:
|
125
126
|
"""
|
126
127
|
Get summarized text from chunks
|
@@ -195,7 +196,7 @@ class WebSearch:
|
|
195
196
|
query: str,
|
196
197
|
page_no: int = 1,
|
197
198
|
summarize_prompt: str = ""
|
198
|
-
) ->
|
199
|
+
) -> Tuple[str, int, int, str, str]:
|
199
200
|
"""
|
200
201
|
Get result from search query
|
201
202
|
|
@@ -260,7 +261,7 @@ class WebSearch:
|
|
260
261
|
if result is not None and result != "":
|
261
262
|
# get thumbnail image
|
262
263
|
if self.plugin.get_option_value("img_thumbnail"):
|
263
|
-
img = self.plugin.window.core.web.get_main_image(url)
|
264
|
+
img = self.plugin.window.core.web.helpers.get_main_image(url)
|
264
265
|
self.log("Summary generated (chars: {})".format(len(result)))
|
265
266
|
# index webpage if auto-index is enabled
|
266
267
|
self.index_url(url)
|
@@ -289,7 +290,11 @@ class WebSearch:
|
|
289
290
|
url, \
|
290
291
|
img
|
291
292
|
|
292
|
-
def open_url(
|
293
|
+
def open_url(
|
294
|
+
self,
|
295
|
+
url: str,
|
296
|
+
summarize_prompt: str = ""
|
297
|
+
) -> Tuple[Optional[str], str, Optional[str]]:
|
293
298
|
"""
|
294
299
|
Get result from specified URL
|
295
300
|
|
@@ -337,7 +342,7 @@ class WebSearch:
|
|
337
342
|
|
338
343
|
# get thumbnail image
|
339
344
|
if self.plugin.get_option_value("img_thumbnail"):
|
340
|
-
img = self.plugin.window.core.web.get_main_image(url)
|
345
|
+
img = self.plugin.window.core.web.helpers.get_main_image(url)
|
341
346
|
|
342
347
|
if result is not None and result != "":
|
343
348
|
self.log("Summary generated (chars: {})".format(len(result)))
|
@@ -357,7 +362,10 @@ class WebSearch:
|
|
357
362
|
|
358
363
|
return result, url, img
|
359
364
|
|
360
|
-
def open_url_raw(
|
365
|
+
def open_url_raw(
|
366
|
+
self,
|
367
|
+
url: str
|
368
|
+
) -> Tuple[str, str, Optional[str]]:
|
361
369
|
"""
|
362
370
|
Get raw content from specified URL
|
363
371
|
|
@@ -377,7 +385,7 @@ class WebSearch:
|
|
377
385
|
# index webpage if auto-index is enabled
|
378
386
|
if result:
|
379
387
|
if self.plugin.get_option_value("img_thumbnail"):
|
380
|
-
img = self.plugin.window.core.web.get_main_image(url)
|
388
|
+
img = self.plugin.window.core.web.helpers.get_main_image(url)
|
381
389
|
self.index_url(url)
|
382
390
|
|
383
391
|
# strip if too long
|
@@ -414,7 +422,7 @@ class WebSearch:
|
|
414
422
|
except Exception as e:
|
415
423
|
self.error(e)
|
416
424
|
|
417
|
-
def error(self, err:
|
425
|
+
def error(self, err: Any):
|
418
426
|
"""
|
419
427
|
Log error message
|
420
428
|
|
@@ -6,7 +6,7 @@
|
|
6
6
|
# GitHub: https://github.com/szczyglis-dev/py-gpt #
|
7
7
|
# MIT License #
|
8
8
|
# Created By : Marcin Szczygliński #
|
9
|
-
# Updated Date: 2024.12.
|
9
|
+
# Updated Date: 2024.12.15 01:00:00 #
|
10
10
|
# ================================================== #
|
11
11
|
|
12
12
|
import json
|
@@ -64,6 +64,9 @@ class Worker(BaseWorker):
|
|
64
64
|
elif item["cmd"] == "web_extract_images":
|
65
65
|
response = self.cmd_web_extract_images(item)
|
66
66
|
|
67
|
+
elif item["cmd"] == "web_request":
|
68
|
+
response = self.cmd_web_request(item)
|
69
|
+
|
67
70
|
if response:
|
68
71
|
responses.append(response)
|
69
72
|
|
@@ -363,7 +366,7 @@ class Worker(BaseWorker):
|
|
363
366
|
url = self.get_param(item, "url")
|
364
367
|
if not url:
|
365
368
|
return self.make_response(item, "No URL provided")
|
366
|
-
links = self.plugin.window.core.web.get_links(url)
|
369
|
+
links = self.plugin.window.core.web.helpers.get_links(url)
|
367
370
|
result = {
|
368
371
|
'links': links,
|
369
372
|
}
|
@@ -385,17 +388,77 @@ class Worker(BaseWorker):
|
|
385
388
|
download = bool(self.get_param(item, "download"))
|
386
389
|
if not url:
|
387
390
|
return self.make_response(item, "No URL provided")
|
388
|
-
images = self.plugin.window.core.web.get_images(url)
|
391
|
+
images = self.plugin.window.core.web.helpers.get_images(url)
|
389
392
|
result = {
|
390
393
|
'images': images,
|
391
394
|
}
|
392
395
|
if images and download:
|
393
396
|
for img in images:
|
394
397
|
try:
|
395
|
-
path = self.plugin.window.core.web.download_image(img)
|
398
|
+
path = self.plugin.window.core.web.helpers.download_image(img)
|
396
399
|
if path:
|
397
400
|
self.ctx.images_before.append(path)
|
398
401
|
except Exception as e:
|
399
402
|
print(e)
|
400
403
|
self.ctx.urls_before.append(url)
|
401
404
|
return self.make_response(item, result)
|
405
|
+
|
406
|
+
def cmd_web_request(self, item: dict) -> dict:
|
407
|
+
"""
|
408
|
+
Web request command
|
409
|
+
|
410
|
+
:param item: command item
|
411
|
+
:return: response item
|
412
|
+
"""
|
413
|
+
url = ""
|
414
|
+
method = "GET"
|
415
|
+
data = None
|
416
|
+
raw = None
|
417
|
+
json = None
|
418
|
+
headers = None
|
419
|
+
params = None
|
420
|
+
cookies = None
|
421
|
+
files = None
|
422
|
+
|
423
|
+
if self.has_param(item, "url"):
|
424
|
+
url = self.get_param(item, "url")
|
425
|
+
if not url:
|
426
|
+
return self.make_response(item, "No URL provided")
|
427
|
+
if self.has_param(item, "method"):
|
428
|
+
method = self.get_param(item, "method")
|
429
|
+
if self.has_param(item, "data_form"):
|
430
|
+
data = self.get_param(item, "data_form")
|
431
|
+
if self.has_param(item, "data"):
|
432
|
+
raw = self.get_param(item, "data")
|
433
|
+
if self.has_param(item, "data_json"):
|
434
|
+
json = self.get_param(item, "data_json")
|
435
|
+
if self.has_param(item, "headers"):
|
436
|
+
headers = self.get_param(item, "headers")
|
437
|
+
if self.has_param(item, "params"):
|
438
|
+
params = self.get_param(item, "params")
|
439
|
+
if self.has_param(item, "cookies"):
|
440
|
+
cookies = self.get_param(item, "cookies")
|
441
|
+
if self.has_param(item, "files"):
|
442
|
+
files = self.get_param(item, "files")
|
443
|
+
|
444
|
+
code, response = self.window.core.web.helpers.request(
|
445
|
+
url=url,
|
446
|
+
method=method,
|
447
|
+
headers=headers,
|
448
|
+
params=params,
|
449
|
+
data=data if data else raw,
|
450
|
+
json=json,
|
451
|
+
cookies=cookies,
|
452
|
+
files=files,
|
453
|
+
timeout=self.plugin.get_option_value("timeout"),
|
454
|
+
disable_ssl_verify=self.plugin.get_option_value("disable_ssl"),
|
455
|
+
allow_redirects=True,
|
456
|
+
stream=False,
|
457
|
+
user_agent=self.plugin.get_option_value("user_agent"))
|
458
|
+
result = {
|
459
|
+
'url': url,
|
460
|
+
'code': code,
|
461
|
+
'response': response,
|
462
|
+
}
|
463
|
+
self.ctx.urls_before.append(url)
|
464
|
+
return self.make_response(item, result)
|
@@ -6,7 +6,7 @@
|
|
6
6
|
# GitHub: https://github.com/szczyglis-dev/py-gpt #
|
7
7
|
# MIT License #
|
8
8
|
# Created By : Marcin Szczygliński #
|
9
|
-
# Updated Date: 2024.
|
9
|
+
# Updated Date: 2024.12.14 19:00:00 #
|
10
10
|
# ================================================== #
|
11
11
|
|
12
12
|
from pygpt_net.plugin.base.config import BaseConfig, BasePlugin
|
@@ -71,7 +71,7 @@ class Config(BaseConfig):
|
|
71
71
|
"model_prepare_question",
|
72
72
|
type="combo",
|
73
73
|
use="models",
|
74
|
-
value="gpt-
|
74
|
+
value="gpt-4o-mini",
|
75
75
|
label="Model for question preparation",
|
76
76
|
description="Model used to prepare question before asking Llama-index, default: gpt-3.5-turbo",
|
77
77
|
tooltip="Model",
|
@@ -88,7 +88,7 @@ class Config(BaseConfig):
|
|
88
88
|
plugin.add_option(
|
89
89
|
"model_query",
|
90
90
|
type="combo",
|
91
|
-
value="gpt-
|
91
|
+
value="gpt-4o-mini",
|
92
92
|
label="Model",
|
93
93
|
description="Model used for querying Llama-index, default: gpt-3.5-turbo",
|
94
94
|
tooltip="Query model",
|
@@ -0,0 +1,123 @@
|
|
1
|
+
#!/usr/bin/env python3
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
# ================================================== #
|
4
|
+
# This file is a part of PYGPT package #
|
5
|
+
# Website: https://pygpt.net #
|
6
|
+
# GitHub: https://github.com/szczyglis-dev/py-gpt #
|
7
|
+
# MIT License #
|
8
|
+
# Created By : Marcin Szczygliński #
|
9
|
+
# Updated Date: 2024.12.15 04:00:00 #
|
10
|
+
# ================================================== #
|
11
|
+
|
12
|
+
from pygpt_net.plugin.base.plugin import BasePlugin
|
13
|
+
from pygpt_net.core.events import Event
|
14
|
+
from pygpt_net.item.ctx import CtxItem
|
15
|
+
|
16
|
+
from .config import Config
|
17
|
+
from .runner import Runner
|
18
|
+
from .worker import Worker
|
19
|
+
|
20
|
+
from pygpt_net.utils import trans
|
21
|
+
|
22
|
+
|
23
|
+
class Plugin(BasePlugin):
|
24
|
+
def __init__(self, *args, **kwargs):
|
25
|
+
super(Plugin, self).__init__(*args, **kwargs)
|
26
|
+
self.id = "mailer"
|
27
|
+
self.name = "Mailer"
|
28
|
+
self.description = "Provides email sending"
|
29
|
+
self.prefix = "Email"
|
30
|
+
self.type = [
|
31
|
+
'email',
|
32
|
+
]
|
33
|
+
self.order = 100
|
34
|
+
self.allowed_cmds = [
|
35
|
+
"send_mail",
|
36
|
+
"get_emails",
|
37
|
+
"get_email_body",
|
38
|
+
]
|
39
|
+
self.use_locale = True
|
40
|
+
self.runner = Runner(self)
|
41
|
+
self.worker = None
|
42
|
+
self.config = Config(self)
|
43
|
+
self.init_options()
|
44
|
+
|
45
|
+
def init_options(self):
|
46
|
+
"""Initialize options"""
|
47
|
+
self.config.from_defaults(self)
|
48
|
+
|
49
|
+
def handle(self, event: Event, *args, **kwargs):
|
50
|
+
"""
|
51
|
+
Handle dispatched event
|
52
|
+
|
53
|
+
:param event: event object
|
54
|
+
:param args: args
|
55
|
+
:param kwargs: kwargs
|
56
|
+
"""
|
57
|
+
name = event.name
|
58
|
+
data = event.data
|
59
|
+
ctx = event.ctx
|
60
|
+
silent = data.get("silent", False)
|
61
|
+
|
62
|
+
if name == Event.CMD_SYNTAX:
|
63
|
+
self.cmd_syntax(data)
|
64
|
+
|
65
|
+
elif name == Event.CMD_EXECUTE:
|
66
|
+
self.cmd(
|
67
|
+
ctx,
|
68
|
+
data['commands'],
|
69
|
+
silent,
|
70
|
+
)
|
71
|
+
|
72
|
+
def cmd_syntax(self, data: dict):
|
73
|
+
"""
|
74
|
+
Event: CMD_SYNTAX
|
75
|
+
|
76
|
+
:param data: event data dict
|
77
|
+
"""
|
78
|
+
for item in self.allowed_cmds:
|
79
|
+
if self.has_cmd(item):
|
80
|
+
cmd = self.get_cmd(item)
|
81
|
+
data['cmd'].append(cmd) # append command
|
82
|
+
|
83
|
+
def cmd(self, ctx: CtxItem, cmds: list, silent: bool = False):
|
84
|
+
"""
|
85
|
+
Event: CMD_EXECUTE
|
86
|
+
|
87
|
+
:param ctx: CtxItem
|
88
|
+
:param cmds: commands dict
|
89
|
+
:param silent: silent mode
|
90
|
+
"""
|
91
|
+
is_cmd = False
|
92
|
+
force = False
|
93
|
+
my_commands = []
|
94
|
+
for item in cmds:
|
95
|
+
if item["cmd"] in self.allowed_cmds:
|
96
|
+
my_commands.append(item)
|
97
|
+
is_cmd = True
|
98
|
+
if "force" in item and item["force"]:
|
99
|
+
force = True # call from tool
|
100
|
+
|
101
|
+
if not is_cmd:
|
102
|
+
return
|
103
|
+
|
104
|
+
# set state: busy
|
105
|
+
if not silent:
|
106
|
+
self.cmd_prepare(ctx, my_commands)
|
107
|
+
|
108
|
+
try:
|
109
|
+
worker = Worker()
|
110
|
+
worker.from_defaults(self)
|
111
|
+
worker.cmds = my_commands
|
112
|
+
worker.ctx = ctx
|
113
|
+
|
114
|
+
# connect signals
|
115
|
+
self.runner.attach_signals(worker.signals)
|
116
|
+
|
117
|
+
if not self.is_async(ctx) and not force:
|
118
|
+
worker.run()
|
119
|
+
return
|
120
|
+
worker.run_async()
|
121
|
+
|
122
|
+
except Exception as e:
|
123
|
+
self.error(e)
|
@@ -0,0 +1,149 @@
|
|
1
|
+
#!/usr/bin/env python3
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
# ================================================== #
|
4
|
+
# This file is a part of PYGPT package #
|
5
|
+
# Website: https://pygpt.net #
|
6
|
+
# GitHub: https://github.com/szczyglis-dev/py-gpt #
|
7
|
+
# MIT License #
|
8
|
+
# Created By : Marcin Szczygliński #
|
9
|
+
# Updated Date: 2024.12.15 04:00:00 #
|
10
|
+
# ================================================== #
|
11
|
+
|
12
|
+
from pygpt_net.plugin.base.config import BaseConfig, BasePlugin
|
13
|
+
|
14
|
+
|
15
|
+
class Config(BaseConfig):
|
16
|
+
def __init__(self, plugin: BasePlugin = None, *args, **kwargs):
|
17
|
+
super(Config, self).__init__(plugin)
|
18
|
+
self.plugin = plugin
|
19
|
+
|
20
|
+
def from_defaults(self, plugin: BasePlugin = None):
|
21
|
+
"""
|
22
|
+
Set default options for plugin
|
23
|
+
|
24
|
+
:param plugin: plugin instance
|
25
|
+
"""
|
26
|
+
plugin.add_option(
|
27
|
+
"smtp_host",
|
28
|
+
type="text",
|
29
|
+
value="",
|
30
|
+
label="SMTP Host",
|
31
|
+
persist=True,
|
32
|
+
tab="smtp",
|
33
|
+
)
|
34
|
+
plugin.add_option(
|
35
|
+
"smtp_port_inbox",
|
36
|
+
type="int",
|
37
|
+
value=995,
|
38
|
+
label="SMTP Port (Inbox)",
|
39
|
+
persist=True,
|
40
|
+
tab="smtp",
|
41
|
+
)
|
42
|
+
plugin.add_option(
|
43
|
+
"smtp_port_outbox",
|
44
|
+
type="int",
|
45
|
+
value=465,
|
46
|
+
label="SMTP Port (Outbox)",
|
47
|
+
persist=True,
|
48
|
+
tab="smtp",
|
49
|
+
)
|
50
|
+
plugin.add_option(
|
51
|
+
"smtp_user",
|
52
|
+
type="text",
|
53
|
+
value="",
|
54
|
+
label="SMTP User",
|
55
|
+
persist=True,
|
56
|
+
tab="smtp",
|
57
|
+
)
|
58
|
+
plugin.add_option(
|
59
|
+
"smtp_password",
|
60
|
+
type="text",
|
61
|
+
value="",
|
62
|
+
label="SMTP Password",
|
63
|
+
secret=True,
|
64
|
+
persist=True,
|
65
|
+
tab="smtp",
|
66
|
+
)
|
67
|
+
plugin.add_option(
|
68
|
+
"from_email",
|
69
|
+
type="text",
|
70
|
+
value="",
|
71
|
+
label="From (email)",
|
72
|
+
)
|
73
|
+
plugin.add_cmd(
|
74
|
+
"send_email",
|
75
|
+
instruction="Send email to specified address",
|
76
|
+
params=[
|
77
|
+
{
|
78
|
+
"name": "recipient",
|
79
|
+
"type": "str",
|
80
|
+
"description": "Recipient email address",
|
81
|
+
"required": True,
|
82
|
+
},
|
83
|
+
{
|
84
|
+
"name": "subject",
|
85
|
+
"type": "str",
|
86
|
+
"description": "Email subject",
|
87
|
+
"required": True,
|
88
|
+
},
|
89
|
+
{
|
90
|
+
"name": "message",
|
91
|
+
"type": "str",
|
92
|
+
"description": "Email message",
|
93
|
+
"required": True,
|
94
|
+
},
|
95
|
+
],
|
96
|
+
enabled=True,
|
97
|
+
description="Allows sending emails",
|
98
|
+
tab="general",
|
99
|
+
)
|
100
|
+
plugin.add_cmd(
|
101
|
+
"get_emails",
|
102
|
+
instruction="Retrieve emails from the inbox. Use this to access emails from the inbox when the user "
|
103
|
+
"requests fetching emails from their server.",
|
104
|
+
params=[
|
105
|
+
{
|
106
|
+
"name": "limit",
|
107
|
+
"type": "int",
|
108
|
+
"description": "Limit of emails to receive, default: 10",
|
109
|
+
"required": True,
|
110
|
+
},
|
111
|
+
{
|
112
|
+
"name": "offset",
|
113
|
+
"type": "int",
|
114
|
+
"description": "Offset of emails to receive, default: 0",
|
115
|
+
"required": False,
|
116
|
+
},
|
117
|
+
{
|
118
|
+
"name": "order",
|
119
|
+
"type": "text",
|
120
|
+
"description": "Sort order, default: desc, options: asc, desc",
|
121
|
+
"required": False,
|
122
|
+
},
|
123
|
+
],
|
124
|
+
enabled=True,
|
125
|
+
description="Allows receiving emails",
|
126
|
+
tab="general",
|
127
|
+
)
|
128
|
+
plugin.add_cmd(
|
129
|
+
"get_email_body",
|
130
|
+
instruction="Retrieve the complete email content from the inbox. Use this to access the message body. "
|
131
|
+
"To obtain email IDs, use the 'get_emails' function first.",
|
132
|
+
params=[
|
133
|
+
{
|
134
|
+
"name": "id",
|
135
|
+
"type": "int",
|
136
|
+
"description": "Email ID (index)",
|
137
|
+
"required": True,
|
138
|
+
},
|
139
|
+
{
|
140
|
+
"name": "format",
|
141
|
+
"type": "text",
|
142
|
+
"description": "Display format, default: text, options: text, html",
|
143
|
+
"required": False,
|
144
|
+
},
|
145
|
+
],
|
146
|
+
enabled=True,
|
147
|
+
description="Allows receiving email body",
|
148
|
+
tab="general",
|
149
|
+
)
|