pygpt-net 2.6.27__py3-none-any.whl → 2.6.28__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.
- pygpt_net/CHANGELOG.txt +6 -0
- pygpt_net/__init__.py +3 -3
- pygpt_net/app.py +5 -1
- pygpt_net/controller/kernel/kernel.py +2 -0
- pygpt_net/controller/notepad/notepad.py +10 -1
- pygpt_net/controller/theme/markdown.py +2 -0
- pygpt_net/controller/ui/tabs.py +5 -0
- pygpt_net/core/audio/backend/native.py +1 -3
- pygpt_net/core/command/command.py +2 -0
- pygpt_net/core/render/web/helpers.py +13 -3
- pygpt_net/core/render/web/renderer.py +3 -3
- pygpt_net/data/config/config.json +3 -3
- pygpt_net/data/config/models.json +3 -3
- pygpt_net/data/css/web-blocks.darkest.css +91 -0
- pygpt_net/data/css/web-chatgpt.css +7 -5
- pygpt_net/data/css/web-chatgpt.dark.css +5 -2
- pygpt_net/data/css/web-chatgpt.darkest.css +91 -0
- pygpt_net/data/css/web-chatgpt.light.css +8 -2
- pygpt_net/data/css/web-chatgpt_wide.css +7 -4
- pygpt_net/data/css/web-chatgpt_wide.dark.css +5 -2
- pygpt_net/data/css/web-chatgpt_wide.darkest.css +91 -0
- pygpt_net/data/css/web-chatgpt_wide.light.css +9 -6
- pygpt_net/data/themes/dark_darkest.css +31 -0
- pygpt_net/data/themes/dark_darkest.xml +10 -0
- pygpt_net/plugin/tuya/__init__.py +12 -0
- pygpt_net/plugin/tuya/config.py +256 -0
- pygpt_net/plugin/tuya/plugin.py +117 -0
- pygpt_net/plugin/tuya/worker.py +588 -0
- pygpt_net/plugin/wikipedia/__init__.py +12 -0
- pygpt_net/plugin/wikipedia/config.py +228 -0
- pygpt_net/plugin/wikipedia/plugin.py +114 -0
- pygpt_net/plugin/wikipedia/worker.py +430 -0
- pygpt_net/provider/core/config/patch.py +11 -0
- pygpt_net/ui/widget/tabs/output.py +2 -0
- pygpt_net/ui/widget/textarea/input.py +10 -7
- {pygpt_net-2.6.27.dist-info → pygpt_net-2.6.28.dist-info}/METADATA +40 -2
- {pygpt_net-2.6.27.dist-info → pygpt_net-2.6.28.dist-info}/RECORD +40 -27
- {pygpt_net-2.6.27.dist-info → pygpt_net-2.6.28.dist-info}/LICENSE +0 -0
- {pygpt_net-2.6.27.dist-info → pygpt_net-2.6.28.dist-info}/WHEEL +0 -0
- {pygpt_net-2.6.27.dist-info → pygpt_net-2.6.28.dist-info}/entry_points.txt +0 -0
|
@@ -0,0 +1,228 @@
|
|
|
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: 2025.08.27 20:18:26 #
|
|
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
|
+
# Settings
|
|
22
|
+
plugin.add_option(
|
|
23
|
+
"lang",
|
|
24
|
+
type="text",
|
|
25
|
+
value="en",
|
|
26
|
+
label="Language",
|
|
27
|
+
description="Default Wikipedia language (e.g., en, pl, de).",
|
|
28
|
+
)
|
|
29
|
+
plugin.add_option(
|
|
30
|
+
"auto_suggest",
|
|
31
|
+
type="bool",
|
|
32
|
+
value=True,
|
|
33
|
+
label="Auto suggest",
|
|
34
|
+
description="Use Wikipedia auto_suggest when resolving titles.",
|
|
35
|
+
)
|
|
36
|
+
plugin.add_option(
|
|
37
|
+
"redirect",
|
|
38
|
+
type="bool",
|
|
39
|
+
value=True,
|
|
40
|
+
label="Follow redirects",
|
|
41
|
+
description="Follow redirects when resolving pages.",
|
|
42
|
+
)
|
|
43
|
+
plugin.add_option(
|
|
44
|
+
"rate_limit",
|
|
45
|
+
type="bool",
|
|
46
|
+
value=True,
|
|
47
|
+
label="Rate limit",
|
|
48
|
+
description="Enable built-in wikipedia rate limiting.",
|
|
49
|
+
)
|
|
50
|
+
plugin.add_option(
|
|
51
|
+
"user_agent",
|
|
52
|
+
type="text",
|
|
53
|
+
value="pygpt-net-wikipedia-plugin/1.0 (+https://pygpt.net)",
|
|
54
|
+
label="User-Agent",
|
|
55
|
+
description="Custom User-Agent for requests.",
|
|
56
|
+
)
|
|
57
|
+
plugin.add_option(
|
|
58
|
+
"summary_sentences",
|
|
59
|
+
type="int",
|
|
60
|
+
value=3,
|
|
61
|
+
label="Summary sentences",
|
|
62
|
+
description="Default number of sentences returned by wp_summary.",
|
|
63
|
+
)
|
|
64
|
+
plugin.add_option(
|
|
65
|
+
"results_default",
|
|
66
|
+
type="int",
|
|
67
|
+
value=10,
|
|
68
|
+
label="Default results limit",
|
|
69
|
+
description="Default number of results for searches and geosearch.",
|
|
70
|
+
)
|
|
71
|
+
plugin.add_option(
|
|
72
|
+
"content_max_chars",
|
|
73
|
+
type="int",
|
|
74
|
+
value=5000,
|
|
75
|
+
label="Content max chars",
|
|
76
|
+
description="Max characters returned for page content when clipping.",
|
|
77
|
+
)
|
|
78
|
+
plugin.add_option(
|
|
79
|
+
"max_list_items",
|
|
80
|
+
type="int",
|
|
81
|
+
value=50,
|
|
82
|
+
label="Max list items",
|
|
83
|
+
description="Max items from lists like links, images, etc.",
|
|
84
|
+
)
|
|
85
|
+
plugin.add_option(
|
|
86
|
+
"content_full_default",
|
|
87
|
+
type="bool",
|
|
88
|
+
value=False,
|
|
89
|
+
label="Full content by default",
|
|
90
|
+
description="Return un-clipped article/section content unless overridden by command param.",
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
# ---------------- Commands ----------------
|
|
94
|
+
|
|
95
|
+
# Language
|
|
96
|
+
plugin.add_cmd(
|
|
97
|
+
"wp_set_lang",
|
|
98
|
+
instruction="Set Wikipedia language (MediaWiki code).",
|
|
99
|
+
params=[{"name": "lang", "type": "str", "required": True, "description": "e.g., en, pl, de"}],
|
|
100
|
+
enabled=True,
|
|
101
|
+
description="Lang: set",
|
|
102
|
+
tab="lang",
|
|
103
|
+
)
|
|
104
|
+
plugin.add_cmd(
|
|
105
|
+
"wp_get_lang",
|
|
106
|
+
instruction="Get current Wikipedia language.",
|
|
107
|
+
params=[],
|
|
108
|
+
enabled=True,
|
|
109
|
+
description="Lang: get",
|
|
110
|
+
tab="lang",
|
|
111
|
+
)
|
|
112
|
+
plugin.add_cmd(
|
|
113
|
+
"wp_languages",
|
|
114
|
+
instruction="Get list of supported languages.",
|
|
115
|
+
params=[{"name": "short", "type": "bool", "required": False, "description": "Return only codes"}],
|
|
116
|
+
enabled=True,
|
|
117
|
+
description="Lang: list",
|
|
118
|
+
tab="lang",
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
# Search / Suggest
|
|
122
|
+
plugin.add_cmd(
|
|
123
|
+
"wp_search",
|
|
124
|
+
instruction="Search Wikipedia by query.",
|
|
125
|
+
params=[
|
|
126
|
+
{"name": "q", "type": "str", "required": True, "description": "Query string"},
|
|
127
|
+
{"name": "results", "type": "int", "required": False, "description": "Results limit"},
|
|
128
|
+
{"name": "suggestion", "type": "bool", "required": False, "description": "Return suggestion as well"},
|
|
129
|
+
],
|
|
130
|
+
enabled=True,
|
|
131
|
+
description="Search: query",
|
|
132
|
+
tab="search",
|
|
133
|
+
)
|
|
134
|
+
plugin.add_cmd(
|
|
135
|
+
"wp_suggest",
|
|
136
|
+
instruction="Get suggestion for a query.",
|
|
137
|
+
params=[{"name": "q", "type": "str", "required": True, "description": "Query string"}],
|
|
138
|
+
enabled=True,
|
|
139
|
+
description="Search: suggest",
|
|
140
|
+
tab="search",
|
|
141
|
+
)
|
|
142
|
+
|
|
143
|
+
# Read
|
|
144
|
+
plugin.add_cmd(
|
|
145
|
+
"wp_summary",
|
|
146
|
+
instruction="Get article summary.",
|
|
147
|
+
params=[
|
|
148
|
+
{"name": "title", "type": "str", "required": False, "description": "Article title (or use 'q')"},
|
|
149
|
+
{"name": "q", "type": "str", "required": False, "description": "Alias of title"},
|
|
150
|
+
{"name": "sentences", "type": "int", "required": False, "description": "Number of sentences"},
|
|
151
|
+
{"name": "auto_suggest", "type": "bool", "required": False, "description": "Use auto suggest"},
|
|
152
|
+
{"name": "redirect", "type": "bool", "required": False, "description": "Follow redirects"},
|
|
153
|
+
],
|
|
154
|
+
enabled=True,
|
|
155
|
+
description="Read: summary",
|
|
156
|
+
tab="page",
|
|
157
|
+
)
|
|
158
|
+
plugin.add_cmd(
|
|
159
|
+
"wp_page",
|
|
160
|
+
instruction="Get page details (content and lists).",
|
|
161
|
+
params=[
|
|
162
|
+
{"name": "title", "type": "str", "required": True, "description": "Article title"},
|
|
163
|
+
{"name": "include", "type": "list", "required": False, "description": "Fields to include"},
|
|
164
|
+
{"name": "content_chars", "type": "int", "required": False, "description": "Limit content length (ignored if full=true)"},
|
|
165
|
+
{"name": "max_list_items", "type": "int", "required": False, "description": "Limit list items"},
|
|
166
|
+
{"name": "auto_suggest", "type": "bool", "required": False, "description": "Use auto suggest"},
|
|
167
|
+
{"name": "redirect", "type": "bool", "required": False, "description": "Follow redirects"},
|
|
168
|
+
{"name": "open", "type": "bool", "required": False, "description": "Open in browser"},
|
|
169
|
+
{"name": "full", "type": "bool", "required": False, "description": "Return full content (no clipping)"},
|
|
170
|
+
],
|
|
171
|
+
enabled=True,
|
|
172
|
+
description="Read: page",
|
|
173
|
+
tab="page",
|
|
174
|
+
)
|
|
175
|
+
plugin.add_cmd(
|
|
176
|
+
"wp_section",
|
|
177
|
+
instruction="Get content of a specific section.",
|
|
178
|
+
params=[
|
|
179
|
+
{"name": "title", "type": "str", "required": True, "description": "Article title"},
|
|
180
|
+
{"name": "section", "type": "str", "required": True, "description": "Section title"},
|
|
181
|
+
{"name": "content_chars", "type": "int", "required": False, "description": "Limit content length (ignored if full=true)"},
|
|
182
|
+
{"name": "auto_suggest", "type": "bool", "required": False, "description": "Use auto suggest"},
|
|
183
|
+
{"name": "redirect", "type": "bool", "required": False, "description": "Follow redirects"},
|
|
184
|
+
{"name": "full", "type": "bool", "required": False, "description": "Return full content (no clipping)"},
|
|
185
|
+
],
|
|
186
|
+
enabled=True,
|
|
187
|
+
description="Read: section",
|
|
188
|
+
tab="page",
|
|
189
|
+
)
|
|
190
|
+
|
|
191
|
+
# Discover
|
|
192
|
+
plugin.add_cmd(
|
|
193
|
+
"wp_random",
|
|
194
|
+
instruction="Get random article titles.",
|
|
195
|
+
params=[{"name": "results", "type": "int", "required": False, "description": "How many"}],
|
|
196
|
+
enabled=True,
|
|
197
|
+
description="Discover: random",
|
|
198
|
+
tab="discover",
|
|
199
|
+
)
|
|
200
|
+
plugin.add_cmd(
|
|
201
|
+
"wp_geosearch",
|
|
202
|
+
instruction="Find pages near coordinates.",
|
|
203
|
+
params=[
|
|
204
|
+
{"name": "lat", "type": "float", "required": True, "description": "Latitude"},
|
|
205
|
+
{"name": "lon", "type": "float", "required": True, "description": "Longitude"},
|
|
206
|
+
{"name": "radius", "type": "int", "required": False, "description": "Radius in meters"},
|
|
207
|
+
{"name": "results", "type": "int", "required": False, "description": "Results limit"},
|
|
208
|
+
{"name": "title", "type": "str", "required": False, "description": "Optional search bias title"},
|
|
209
|
+
],
|
|
210
|
+
enabled=True,
|
|
211
|
+
description="Discover: geosearch",
|
|
212
|
+
tab="discover",
|
|
213
|
+
)
|
|
214
|
+
|
|
215
|
+
# Utilities
|
|
216
|
+
plugin.add_cmd(
|
|
217
|
+
"wp_open",
|
|
218
|
+
instruction="Open article in browser by title or URL.",
|
|
219
|
+
params=[
|
|
220
|
+
{"name": "title", "type": "str", "required": False, "description": "Article title"},
|
|
221
|
+
{"name": "url", "type": "str", "required": False, "description": "Direct URL"},
|
|
222
|
+
{"name": "auto_suggest", "type": "bool", "required": False, "description": "Use auto suggest"},
|
|
223
|
+
{"name": "redirect", "type": "bool", "required": False, "description": "Follow redirects"},
|
|
224
|
+
],
|
|
225
|
+
enabled=True,
|
|
226
|
+
description="Utils: open in browser",
|
|
227
|
+
tab="utils",
|
|
228
|
+
)
|
|
@@ -0,0 +1,114 @@
|
|
|
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: 2025.08.27 20: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
|
+
|
|
18
|
+
|
|
19
|
+
class Plugin(BasePlugin):
|
|
20
|
+
def __init__(self, *args, **kwargs):
|
|
21
|
+
super(Plugin, self).__init__(*args, **kwargs)
|
|
22
|
+
self.id = "wikipedia"
|
|
23
|
+
self.name = "Wikipedia"
|
|
24
|
+
self.description = "Search Wikipedia for information."
|
|
25
|
+
self.prefix = "API"
|
|
26
|
+
self.order = 100
|
|
27
|
+
self.allowed_cmds = [
|
|
28
|
+
"wp_set_lang",
|
|
29
|
+
"wp_get_lang",
|
|
30
|
+
"wp_languages",
|
|
31
|
+
"wp_search",
|
|
32
|
+
"wp_suggest",
|
|
33
|
+
"wp_summary",
|
|
34
|
+
"wp_page",
|
|
35
|
+
"wp_section",
|
|
36
|
+
"wp_random",
|
|
37
|
+
"wp_geosearch",
|
|
38
|
+
"wp_open"
|
|
39
|
+
]
|
|
40
|
+
self.use_locale = False
|
|
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: event args
|
|
55
|
+
:param kwargs: event kwargs
|
|
56
|
+
"""
|
|
57
|
+
name = event.name
|
|
58
|
+
data = event.data
|
|
59
|
+
ctx = event.ctx
|
|
60
|
+
|
|
61
|
+
if name == Event.CMD_SYNTAX:
|
|
62
|
+
self.cmd_syntax(data)
|
|
63
|
+
|
|
64
|
+
elif name == Event.CMD_EXECUTE:
|
|
65
|
+
self.cmd(
|
|
66
|
+
ctx,
|
|
67
|
+
data['commands'],
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
def cmd_syntax(self, data: dict):
|
|
71
|
+
"""
|
|
72
|
+
Event: CMD_SYNTAX
|
|
73
|
+
|
|
74
|
+
:param data: event data dict
|
|
75
|
+
"""
|
|
76
|
+
for option in self.allowed_cmds:
|
|
77
|
+
if self.has_cmd(option):
|
|
78
|
+
data['cmd'].append(self.get_cmd(option)) # append command
|
|
79
|
+
|
|
80
|
+
def cmd(self, ctx: CtxItem, cmds: list):
|
|
81
|
+
"""
|
|
82
|
+
Event: CMD_EXECUTE
|
|
83
|
+
|
|
84
|
+
:param ctx: CtxItem
|
|
85
|
+
:param cmds: commands dict
|
|
86
|
+
"""
|
|
87
|
+
from .worker import Worker
|
|
88
|
+
|
|
89
|
+
is_cmd = False
|
|
90
|
+
my_commands = []
|
|
91
|
+
for item in cmds:
|
|
92
|
+
if item["cmd"] in self.allowed_cmds:
|
|
93
|
+
my_commands.append(item)
|
|
94
|
+
is_cmd = True
|
|
95
|
+
|
|
96
|
+
if not is_cmd:
|
|
97
|
+
return
|
|
98
|
+
|
|
99
|
+
# set state: busy
|
|
100
|
+
self.cmd_prepare(ctx, my_commands)
|
|
101
|
+
|
|
102
|
+
try:
|
|
103
|
+
worker = Worker()
|
|
104
|
+
worker.from_defaults(self)
|
|
105
|
+
worker.cmds = my_commands
|
|
106
|
+
worker.ctx = ctx
|
|
107
|
+
|
|
108
|
+
if not self.is_async(ctx):
|
|
109
|
+
worker.run()
|
|
110
|
+
return
|
|
111
|
+
worker.run_async()
|
|
112
|
+
|
|
113
|
+
except Exception as e:
|
|
114
|
+
self.error(e)
|