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.
Files changed (139) hide show
  1. CHANGELOG.md +8 -0
  2. README.md +135 -70
  3. pygpt_net/CHANGELOG.txt +8 -0
  4. pygpt_net/__init__.py +3 -3
  5. pygpt_net/app.py +3 -1
  6. pygpt_net/controller/audio/__init__.py +2 -2
  7. pygpt_net/controller/camera.py +1 -10
  8. pygpt_net/controller/chat/audio.py +2 -2
  9. pygpt_net/controller/config/placeholder.py +15 -1
  10. pygpt_net/controller/ui/mode.py +16 -21
  11. pygpt_net/core/audio/__init__.py +4 -1
  12. pygpt_net/core/audio/whisper.py +37 -0
  13. pygpt_net/core/bridge/worker.py +2 -2
  14. pygpt_net/core/debug/events.py +22 -10
  15. pygpt_net/core/debug/tabs.py +6 -3
  16. pygpt_net/core/history.py +3 -2
  17. pygpt_net/core/idx/__init__.py +16 -4
  18. pygpt_net/core/idx/chat.py +15 -5
  19. pygpt_net/core/idx/indexing.py +24 -8
  20. pygpt_net/core/installer.py +2 -4
  21. pygpt_net/core/models.py +62 -17
  22. pygpt_net/core/modes.py +11 -13
  23. pygpt_net/core/notepad.py +4 -4
  24. pygpt_net/core/plugins.py +27 -16
  25. pygpt_net/core/presets.py +20 -9
  26. pygpt_net/core/profile.py +11 -3
  27. pygpt_net/core/render/web/parser.py +3 -1
  28. pygpt_net/core/settings.py +5 -5
  29. pygpt_net/core/tabs/tab.py +10 -2
  30. pygpt_net/core/tokens.py +8 -6
  31. pygpt_net/core/web/__init__.py +105 -0
  32. pygpt_net/core/{web.py → web/helpers.py} +93 -67
  33. pygpt_net/data/config/config.json +3 -3
  34. pygpt_net/data/config/models.json +3 -3
  35. pygpt_net/data/config/modes.json +3 -3
  36. pygpt_net/data/locale/locale.en.ini +1 -0
  37. pygpt_net/data/locale/plugin.cmd_web.en.ini +2 -0
  38. pygpt_net/data/locale/plugin.mailer.en.ini +21 -0
  39. pygpt_net/item/ctx.py +13 -2
  40. pygpt_net/plugin/agent/__init__.py +7 -2
  41. pygpt_net/plugin/audio_output/__init__.py +6 -1
  42. pygpt_net/plugin/base/plugin.py +58 -26
  43. pygpt_net/plugin/base/worker.py +20 -17
  44. pygpt_net/plugin/cmd_history/config.py +2 -2
  45. pygpt_net/plugin/cmd_web/__init__.py +3 -4
  46. pygpt_net/plugin/cmd_web/config.py +71 -3
  47. pygpt_net/plugin/cmd_web/websearch.py +20 -12
  48. pygpt_net/plugin/cmd_web/worker.py +67 -4
  49. pygpt_net/plugin/idx_llama_index/config.py +3 -3
  50. pygpt_net/plugin/mailer/__init__.py +123 -0
  51. pygpt_net/plugin/mailer/config.py +149 -0
  52. pygpt_net/plugin/mailer/runner.py +285 -0
  53. pygpt_net/plugin/mailer/worker.py +123 -0
  54. pygpt_net/provider/agents/base.py +5 -2
  55. pygpt_net/provider/agents/openai.py +4 -2
  56. pygpt_net/provider/agents/openai_assistant.py +4 -2
  57. pygpt_net/provider/agents/planner.py +4 -2
  58. pygpt_net/provider/agents/react.py +4 -2
  59. pygpt_net/provider/audio_output/openai_tts.py +5 -11
  60. pygpt_net/provider/core/assistant/base.py +5 -3
  61. pygpt_net/provider/core/assistant/json_file.py +8 -5
  62. pygpt_net/provider/core/assistant_file/base.py +4 -3
  63. pygpt_net/provider/core/assistant_file/db_sqlite/__init__.py +4 -3
  64. pygpt_net/provider/core/assistant_file/db_sqlite/storage.py +3 -2
  65. pygpt_net/provider/core/assistant_store/base.py +6 -4
  66. pygpt_net/provider/core/assistant_store/db_sqlite/__init__.py +5 -4
  67. pygpt_net/provider/core/assistant_store/db_sqlite/storage.py +5 -3
  68. pygpt_net/provider/core/attachment/base.py +5 -3
  69. pygpt_net/provider/core/attachment/json_file.py +4 -3
  70. pygpt_net/provider/core/calendar/base.py +5 -3
  71. pygpt_net/provider/core/calendar/db_sqlite/__init__.py +6 -5
  72. pygpt_net/provider/core/calendar/db_sqlite/storage.py +5 -4
  73. pygpt_net/provider/core/config/base.py +8 -6
  74. pygpt_net/provider/core/config/json_file.py +9 -7
  75. pygpt_net/provider/core/ctx/base.py +27 -25
  76. pygpt_net/provider/core/ctx/db_sqlite/__init__.py +51 -35
  77. pygpt_net/provider/core/ctx/db_sqlite/storage.py +42 -31
  78. pygpt_net/provider/core/ctx/db_sqlite/utils.py +11 -9
  79. pygpt_net/provider/core/index/base.py +129 -23
  80. pygpt_net/provider/core/index/db_sqlite/__init__.py +130 -23
  81. pygpt_net/provider/core/index/db_sqlite/storage.py +130 -23
  82. pygpt_net/provider/core/index/db_sqlite/utils.py +4 -2
  83. pygpt_net/provider/core/mode/base.py +5 -3
  84. pygpt_net/provider/core/mode/json_file.py +7 -6
  85. pygpt_net/provider/core/model/base.py +6 -4
  86. pygpt_net/provider/core/model/json_file.py +9 -7
  87. pygpt_net/provider/core/notepad/base.py +5 -3
  88. pygpt_net/provider/core/notepad/db_sqlite/__init__.py +5 -4
  89. pygpt_net/provider/core/notepad/db_sqlite/storage.py +4 -3
  90. pygpt_net/provider/core/plugin_preset/base.py +4 -2
  91. pygpt_net/provider/core/plugin_preset/json_file.py +5 -3
  92. pygpt_net/provider/core/preset/base.py +6 -4
  93. pygpt_net/provider/core/preset/json_file.py +9 -9
  94. pygpt_net/provider/core/prompt/base.py +6 -3
  95. pygpt_net/provider/core/prompt/json_file.py +11 -6
  96. pygpt_net/provider/gpt/assistants.py +15 -6
  97. pygpt_net/provider/gpt/audio.py +5 -5
  98. pygpt_net/provider/gpt/chat.py +7 -5
  99. pygpt_net/provider/gpt/completion.py +8 -4
  100. pygpt_net/provider/gpt/image.py +3 -3
  101. pygpt_net/provider/gpt/store.py +46 -12
  102. pygpt_net/provider/gpt/vision.py +16 -11
  103. pygpt_net/provider/llms/anthropic.py +7 -2
  104. pygpt_net/provider/llms/azure_openai.py +26 -5
  105. pygpt_net/provider/llms/base.py +47 -9
  106. pygpt_net/provider/llms/google.py +7 -2
  107. pygpt_net/provider/llms/hugging_face.py +13 -3
  108. pygpt_net/provider/llms/hugging_face_api.py +18 -4
  109. pygpt_net/provider/llms/local.py +7 -2
  110. pygpt_net/provider/llms/ollama.py +30 -6
  111. pygpt_net/provider/llms/openai.py +32 -6
  112. pygpt_net/provider/vector_stores/__init__.py +45 -14
  113. pygpt_net/provider/vector_stores/base.py +35 -8
  114. pygpt_net/provider/vector_stores/chroma.py +13 -3
  115. pygpt_net/provider/vector_stores/ctx_attachment.py +31 -12
  116. pygpt_net/provider/vector_stores/elasticsearch.py +12 -3
  117. pygpt_net/provider/vector_stores/pinecode.py +12 -3
  118. pygpt_net/provider/vector_stores/redis.py +12 -3
  119. pygpt_net/provider/vector_stores/simple.py +12 -3
  120. pygpt_net/provider/vector_stores/temp.py +16 -4
  121. pygpt_net/provider/web/base.py +10 -3
  122. pygpt_net/provider/web/google_custom_search.py +9 -3
  123. pygpt_net/provider/web/microsoft_bing.py +9 -3
  124. pygpt_net/tools/__init__.py +13 -5
  125. pygpt_net/tools/audio_transcriber/__init__.py +4 -3
  126. pygpt_net/tools/base.py +15 -8
  127. pygpt_net/tools/code_interpreter/__init__.py +4 -3
  128. pygpt_net/tools/html_canvas/__init__.py +4 -3
  129. pygpt_net/tools/image_viewer/__init__.py +10 -4
  130. pygpt_net/tools/indexer/__init__.py +8 -7
  131. pygpt_net/tools/media_player/__init__.py +4 -3
  132. pygpt_net/tools/text_editor/__init__.py +36 -10
  133. pygpt_net/ui/layout/chat/output.py +2 -2
  134. pygpt_net/ui/menu/audio.py +12 -1
  135. {pygpt_net-2.4.41.dist-info → pygpt_net-2.4.42.dist-info}/METADATA +136 -71
  136. {pygpt_net-2.4.41.dist-info → pygpt_net-2.4.42.dist-info}/RECORD +139 -132
  137. {pygpt_net-2.4.41.dist-info → pygpt_net-2.4.42.dist-info}/LICENSE +0 -0
  138. {pygpt_net-2.4.41.dist-info → pygpt_net-2.4.42.dist-info}/WHEEL +0 -0
  139. {pygpt_net-2.4.41.dist-info → pygpt_net-2.4.42.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,285 @@
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
+ import datetime
13
+ import smtplib
14
+ import poplib
15
+
16
+ from email.parser import BytesParser
17
+ from typing import Any
18
+ from bs4 import BeautifulSoup
19
+
20
+ from pygpt_net.item.ctx import CtxItem
21
+
22
+
23
+ class Runner:
24
+ def __init__(self, plugin=None):
25
+ """
26
+ Cmd Runner
27
+
28
+ :param plugin: plugin
29
+ """
30
+ self.plugin = plugin
31
+ self.signals = None
32
+
33
+ def attach_signals(self, signals):
34
+ """
35
+ Attach signals
36
+
37
+ :param signals: signals
38
+ """
39
+ self.signals = signals
40
+
41
+ def parse_email(self, msg, as_text: bool = True) -> str:
42
+ """
43
+ Parse email message
44
+
45
+ :param msg: email message
46
+ :param as_text: return as text
47
+ :return: parsed email
48
+ """
49
+ body = ""
50
+ is_html = False
51
+ if msg.is_multipart():
52
+ for part in msg.walk():
53
+ content_type = part.get_content_type()
54
+ content_disposition = str(part.get('Content-Disposition'))
55
+ if content_type == 'text/plain' and 'attachment' not in content_disposition:
56
+ body = part.get_payload(decode=True).decode(part.get_content_charset('utf-8'))
57
+ elif content_type == 'text/html' and 'attachment' not in content_disposition:
58
+ body = part.get_payload(decode=True).decode(part.get_content_charset('utf-8'))
59
+ is_html = True
60
+ else:
61
+ body = msg.get_payload(decode=True).decode(msg.get_content_charset('utf-8'))
62
+ if is_html and as_text:
63
+ body = BeautifulSoup(body, 'html.parser').get_text()
64
+ return body
65
+
66
+ def smtp_get_email_body(self, ctx: CtxItem, item: dict, request: dict) -> dict:
67
+ """
68
+ Receive emails from mailbox
69
+
70
+ :param ctx: CtxItem
71
+ :param item: command item
72
+ :param request: request item
73
+ :return: response dict
74
+ """
75
+ server = self.plugin.get_option_value("smtp_host")
76
+ port = self.plugin.get_option_value("smtp_port_inbox")
77
+ id = item["params"].get("id", "")
78
+ username = self.plugin.get_option_value("smtp_user")
79
+ password = self.plugin.get_option_value("smtp_password")
80
+ msg = "Receiving email from: {}".format(server)
81
+ format = "text"
82
+ as_text = True
83
+ if "format" in item["params"]:
84
+ format = item["params"]["format"].lower()
85
+ if format == "html":
86
+ as_text = False
87
+ self.log(msg)
88
+ try:
89
+ if port in [995]:
90
+ pop3 = poplib.POP3_SSL(server, port)
91
+ else:
92
+ pop3 = poplib.POP3(server, port)
93
+
94
+ msg = pop3.getwelcome().decode('utf-8')
95
+ self.log(msg)
96
+ pop3.user(username)
97
+ pop3.pass_(password)
98
+ response, lines, octets = pop3.retr(id)
99
+ msg_content = b'\r\n'.join(lines)
100
+ msg = BytesParser().parsebytes(msg_content)
101
+ result = {
102
+ "ID": id,
103
+ "From": msg["From"],
104
+ "Subject": msg["Subject"],
105
+ "Date": msg["Date"],
106
+ "Message": self.parse_email(msg, as_text)
107
+ }
108
+ pop3.quit()
109
+ except Exception as e:
110
+ self.error(e)
111
+ result = "Error: {}".format(str(e))
112
+ return {
113
+ "request": request,
114
+ "result": str(result)
115
+ }
116
+
117
+ def smtp_receive_emails(self, ctx: CtxItem, item: dict, request: dict) -> dict:
118
+ """
119
+ Receive emails from mailbox
120
+
121
+ :param ctx: CtxItem
122
+ :param item: command item
123
+ :param request: request item
124
+ :return: response dict
125
+ """
126
+ server = self.plugin.get_option_value("smtp_host")
127
+ port = self.plugin.get_option_value("smtp_port_inbox")
128
+ limit = item["params"].get("limit", 10)
129
+ offset = item["params"].get("offset", 0)
130
+ username = self.plugin.get_option_value("smtp_user")
131
+ password = self.plugin.get_option_value("smtp_password")
132
+ msg = "Receiving emails from: {}".format(server)
133
+ order = "desc"
134
+ if "order" in item["params"]:
135
+ tmp_order = item["params"]["order"].lower()
136
+ if tmp_order in ["asc", "desc"]:
137
+ order = tmp_order
138
+ self.log(msg)
139
+
140
+ messages = []
141
+ try:
142
+ if port in [995]:
143
+ pop3 = poplib.POP3_SSL(server, port)
144
+ else:
145
+ pop3 = poplib.POP3(server, port)
146
+
147
+ msg = pop3.getwelcome().decode('utf-8')
148
+ self.log(msg)
149
+ pop3.user(username)
150
+ pop3.pass_(password)
151
+
152
+ message_count, mailbox_size = pop3.stat()
153
+ total = message_count
154
+ print(f'Num of messages: {message_count}, Inbox size: {mailbox_size} bytes')
155
+
156
+ if order == "desc":
157
+ if offset > 0:
158
+ message_count -= offset
159
+ if message_count < limit:
160
+ limit = message_count
161
+ range_max = message_count - limit
162
+ if limit == 0:
163
+ range_max = 0
164
+ for i in range(message_count, range_max, -1):
165
+ response, lines, octets = pop3.top(i, 0)
166
+ msg_content = b'\r\n'.join(lines)
167
+ msg = BytesParser().parsebytes(msg_content)
168
+ msg_body = {
169
+ "ID": i,
170
+ "From": msg["From"],
171
+ "Subject": msg["Subject"],
172
+ "Date": msg["Date"],
173
+ }
174
+ messages.append(msg_body)
175
+ else:
176
+ if limit == 0:
177
+ limit = message_count
178
+ else:
179
+ limit += offset
180
+ if limit > message_count:
181
+ limit = message_count
182
+ for i in range(offset + 1, limit + 1):
183
+ response, lines, octets = pop3.top(i, 0)
184
+ msg_content = b'\r\n'.join(lines)
185
+ msg = BytesParser().parsebytes(msg_content)
186
+ msg_body = {
187
+ "ID": i,
188
+ "From": msg["From"],
189
+ "Subject": msg["Subject"],
190
+ "Date": msg["Date"],
191
+ }
192
+ messages.append(msg_body)
193
+
194
+ pop3.quit()
195
+ result = {
196
+ "total": total,
197
+ "messages": messages,
198
+ }
199
+ except Exception as e:
200
+ self.error(e)
201
+ result = "Error: {}".format(str(e))
202
+ return {
203
+ "request": request,
204
+ "result": str(result)
205
+ }
206
+
207
+ def smtp_send_email(self, ctx: CtxItem, item: dict, request: dict) -> dict:
208
+ """
209
+ Execute system command on host
210
+
211
+ :param ctx: CtxItem
212
+ :param item: command item
213
+ :param request: request item
214
+ :return: response dict
215
+ """
216
+ msg = "Sending email to: {}".format(item["params"]['recipient'])
217
+ self.log(msg)
218
+ try:
219
+ email_to = item["params"]['recipient']
220
+ message = item["params"]['message']
221
+ subject = item["params"]['subject']
222
+ from_addr = self.plugin.get_option_value("from_email")
223
+ host = self.plugin.get_option_value("smtp_host")
224
+ port = self.plugin.get_option_value("smtp_port_outbox")
225
+ user = self.plugin.get_option_value("smtp_user")
226
+ password = self.plugin.get_option_value("smtp_password")
227
+ date = datetime.datetime.now().strftime("%d/%m/%Y %H:%M")
228
+ body = """From: {sender}\nTo: {to}\nDate: {date}\nSubject: {subject}\n\n{msg}
229
+ """.format(sender=from_addr, to=email_to, date=date, subject=subject, msg=message)
230
+ if port in [465]:
231
+ server = smtplib.SMTP_SSL(host, port)
232
+ else:
233
+ server = smtplib.SMTP(host, port)
234
+ server.ehlo()
235
+ if port in [587]:
236
+ server.starttls()
237
+ server.login(user, password)
238
+ server.sendmail(from_addr, email_to, body)
239
+ server.close()
240
+ result = "OK"
241
+ except Exception as e:
242
+ self.error(e)
243
+ result = "Error: {}".format(str(e))
244
+ return {
245
+ "request": request,
246
+ "result": str(result)
247
+ }
248
+
249
+ def error(self, err: Any):
250
+ """
251
+ Log error message
252
+
253
+ :param err: exception or error message
254
+ """
255
+ if self.signals is not None:
256
+ self.signals.error.emit(err)
257
+
258
+ def status(self, msg: str):
259
+ """
260
+ Send status message
261
+
262
+ :param msg: status message
263
+ """
264
+ if self.signals is not None:
265
+ self.signals.status.emit(msg)
266
+
267
+ def debug(self, msg: Any):
268
+ """
269
+ Log debug message
270
+
271
+ :param msg: message to log
272
+ """
273
+ if self.signals is not None:
274
+ self.signals.debug.emit(msg)
275
+
276
+ def log(self, msg, sandbox: bool = False):
277
+ """
278
+ Log message to console
279
+
280
+ :param msg: message to log
281
+ :param sandbox: is sandbox mode
282
+ """
283
+ full_msg = '[SMTP]' + ' ' + str(msg)
284
+ if self.signals is not None:
285
+ self.signals.log.emit(full_msg)
@@ -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 PySide6.QtCore import Slot, Signal
13
+
14
+ from pygpt_net.plugin.base.worker import BaseWorker, BaseSignals
15
+
16
+
17
+ class WorkerSignals(BaseSignals):
18
+ output = Signal(object, str)
19
+ html_output = Signal(object)
20
+ ipython_output = Signal(object)
21
+ build_finished = Signal()
22
+ clear = Signal()
23
+
24
+
25
+ class Worker(BaseWorker):
26
+ def __init__(self, *args, **kwargs):
27
+ super(Worker, self).__init__()
28
+ self.signals = WorkerSignals()
29
+ self.args = args
30
+ self.kwargs = kwargs
31
+ self.plugin = None
32
+ self.cmds = None
33
+ self.ctx = None
34
+
35
+ @Slot()
36
+ def run(self):
37
+ responses = []
38
+ for item in self.cmds:
39
+ if self.is_stopped():
40
+ break
41
+ try:
42
+ response = None
43
+ if (item["cmd"] in self.plugin.allowed_cmds
44
+ and (self.plugin.has_cmd(item["cmd"]) or 'force' in item)):
45
+
46
+ if item["cmd"] == "send_email":
47
+ response = self.cmd_send_mail(item)
48
+
49
+ elif item["cmd"] == "get_emails":
50
+ response = self.cmd_receive_emails(item)
51
+
52
+ elif item["cmd"] == "get_email_body":
53
+ response = self.cmd_get_email_body(item)
54
+
55
+ if response:
56
+ responses.append(response)
57
+
58
+ except Exception as e:
59
+ responses.append(
60
+ self.make_response(
61
+ item,
62
+ self.throw_error(e)
63
+ )
64
+ )
65
+
66
+ # send response
67
+ if len(responses) > 0:
68
+ self.reply_more(responses)
69
+
70
+ def cmd_send_mail(self, item: dict) -> dict:
71
+ """
72
+ Send email command
73
+
74
+ :param item: command item
75
+ :return: response item
76
+ """
77
+ request = self.from_request(item)
78
+ try:
79
+ result = self.plugin.runner.smtp_send_email(
80
+ ctx=self.ctx,
81
+ item=item,
82
+ request=request,
83
+ )
84
+ except Exception as e:
85
+ result = self.throw_error(e)
86
+ return self.make_response(item, result)
87
+
88
+ def cmd_receive_emails(self, item: dict) -> dict:
89
+ """
90
+ Receive emails command
91
+
92
+ :param item: command item
93
+ :return: response item
94
+ """
95
+ request = self.from_request(item)
96
+ try:
97
+ result = self.plugin.runner.smtp_receive_emails(
98
+ ctx=self.ctx,
99
+ item=item,
100
+ request=request,
101
+ )
102
+ except Exception as e:
103
+ result = self.throw_error(e)
104
+ return self.make_response(item, result)
105
+
106
+ def cmd_get_email_body(self, item: dict) -> dict:
107
+ """
108
+ Get email body command
109
+
110
+ :param item: command item
111
+ :return: response item
112
+ """
113
+ request = self.from_request(item)
114
+ try:
115
+ result = self.plugin.runner.smtp_get_email_body(
116
+ ctx=self.ctx,
117
+ item=item,
118
+ request=request,
119
+ )
120
+ except Exception as e:
121
+ result = self.throw_error(e)
122
+ return self.make_response(item, result)
123
+
@@ -6,9 +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.11.15 00:00:00 #
9
+ # Updated Date: 2024.12.14 22:00:00 #
10
10
  # ================================================== #
11
11
 
12
+ from typing import Dict, Any
13
+
14
+
12
15
  class BaseAgent:
13
16
  def __init__(self, *args, **kwargs):
14
17
  self.id = ""
@@ -22,7 +25,7 @@ class BaseAgent:
22
25
  """
23
26
  return self.mode
24
27
 
25
- def get_agent(self, window, kwargs: dict):
28
+ def get_agent(self, window, kwargs: Dict[str, Any]):
26
29
  """
27
30
  Return Agent provider instance
28
31
 
@@ -6,9 +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.11.15 00:00:00 #
9
+ # Updated Date: 2024.12.14 22:00:00 #
10
10
  # ================================================== #
11
11
 
12
+ from typing import Dict, Any
13
+
12
14
  from llama_index.agent.openai import OpenAIAgent as Agent
13
15
 
14
16
  from .base import BaseAgent
@@ -19,7 +21,7 @@ class OpenAIAgent(BaseAgent):
19
21
  self.id = "openai"
20
22
  self.mode = "step" # step|plan
21
23
 
22
- def get_agent(self, window, kwargs: dict):
24
+ def get_agent(self, window, kwargs: Dict[str, Any]):
23
25
  """
24
26
  Return Agent provider instance
25
27
 
@@ -6,9 +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.11.15 00:00:00 #
9
+ # Updated Date: 2024.12.14 22:00:00 #
10
10
  # ================================================== #
11
11
 
12
+ from typing import Dict, Any
13
+
12
14
  from llama_index.agent.openai import OpenAIAssistantAgent as Agent
13
15
 
14
16
  from pygpt_net.core.bridge.context import BridgeContext
@@ -21,7 +23,7 @@ class OpenAIAssistantAgent(BaseAgent):
21
23
  self.id = "openai_assistant"
22
24
  self.mode = "assistant" # step|plan|...
23
25
 
24
- def get_agent(self, window, kwargs: dict):
26
+ def get_agent(self, window, kwargs: Dict[str, Any]):
25
27
  """
26
28
  Return Agent provider instance
27
29
 
@@ -6,9 +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.11.15 00:00:00 #
9
+ # Updated Date: 2024.12.14 22:00:00 #
10
10
  # ================================================== #
11
11
 
12
+ from typing import Dict, Any
13
+
12
14
  from llama_index.core.agent import (
13
15
  StructuredPlannerAgent,
14
16
  FunctionCallingAgentWorker,
@@ -23,7 +25,7 @@ class PlannerAgent(BaseAgent):
23
25
  self.id = "planner"
24
26
  self.mode = "plan" # step|plan
25
27
 
26
- def get_agent(self, window, kwargs: dict):
28
+ def get_agent(self, window, kwargs: Dict[str, Any]):
27
29
  """
28
30
  Return Agent provider instance
29
31
 
@@ -6,9 +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.11.21 20:00:00 #
9
+ # Updated Date: 2024.12.14 22:00:00 #
10
10
  # ================================================== #
11
11
 
12
+ from typing import Dict, Any
13
+
12
14
  from llama_index.core.agent import ReActAgent as Agent
13
15
  from llama_index.core.agent.react_multimodal.step import (
14
16
  MultimodalReActAgentWorker,
@@ -26,7 +28,7 @@ class ReactAgent(BaseAgent):
26
28
  self.id = "react"
27
29
  self.mode = "step" # step|plan
28
30
 
29
- def get_agent(self, window, kwargs: dict):
31
+ def get_agent(self, window, kwargs: Dict[str, Any]):
30
32
  """
31
33
  Return Agent provider instance
32
34
 
@@ -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.02.23 19:00:00 #
9
+ # Updated Date: 2024.12.14 18:00:00 #
10
10
  # ================================================== #
11
11
 
12
12
  import os
@@ -26,14 +26,6 @@ class OpenAITextToSpeech(BaseProvider):
26
26
  self.plugin = kwargs.get("plugin")
27
27
  self.id = "openai_tts"
28
28
  self.name = "OpenAI TTS"
29
- self.allowed_voices = [
30
- 'alloy',
31
- 'echo',
32
- 'fable',
33
- 'onyx',
34
- 'nova',
35
- 'shimmer',
36
- ]
37
29
  self.allowed_models = [
38
30
  'tts-1',
39
31
  'tts-1-hd',
@@ -52,10 +44,11 @@ class OpenAITextToSpeech(BaseProvider):
52
44
  )
53
45
  self.plugin.add_option(
54
46
  "openai_voice",
55
- type="text",
47
+ type="combo",
56
48
  value="alloy",
57
49
  label="Voice",
58
50
  tab="openai_tts",
51
+ use="audio_tts_whisper_voices",
59
52
  description="Specify voice, available voices: "
60
53
  "alloy, echo, fable, onyx, nova, shimmer",
61
54
  )
@@ -71,9 +64,10 @@ class OpenAITextToSpeech(BaseProvider):
71
64
  output_file = self.plugin.output_file
72
65
  voice = self.plugin.get_option_value('openai_voice')
73
66
  model = self.plugin.get_option_value('openai_model')
67
+ allowed_voices = self.plugin.window.core.audio.whisper.get_voices()
74
68
  if model not in self.allowed_models:
75
69
  model = 'tts-1'
76
- if voice not in self.allowed_voices:
70
+ if voice not in allowed_voices:
77
71
  voice = 'alloy'
78
72
  path = os.path.join(
79
73
  self.plugin.window.core.config.path,
@@ -6,9 +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: 2023.12.31 04:00:00 #
9
+ # Updated Date: 2024.12.14 22:00:00 #
10
10
  # ================================================== #
11
11
 
12
+ from typing import Dict
13
+
12
14
  from packaging.version import Version
13
15
 
14
16
  from pygpt_net.item.assistant import AssistantItem
@@ -32,10 +34,10 @@ class BaseProvider:
32
34
  def create(self, assistant: AssistantItem) -> str:
33
35
  pass
34
36
 
35
- def load(self) -> dict:
37
+ def load(self) -> Dict[str, AssistantItem]:
36
38
  pass
37
39
 
38
- def save(self, items: dict):
40
+ def save(self, items: Dict[str, AssistantItem]):
39
41
  pass
40
42
 
41
43
  def remove(self, id: str):
@@ -6,12 +6,13 @@
6
6
  # GitHub: https://github.com/szczyglis-dev/py-gpt #
7
7
  # MIT License #
8
8
  # Created By : Marcin Szczygliński #
9
- # Updated Date: 2023.12.31 04:00:00 #
9
+ # Updated Date: 2024.12.14 22:00:00 #
10
10
  # ================================================== #
11
11
 
12
12
  import json
13
13
  import os
14
14
  import uuid
15
+ from typing import Dict, Any
15
16
 
16
17
  from packaging.version import Version
17
18
 
@@ -48,7 +49,7 @@ class JsonFileProvider(BaseProvider):
48
49
  assistant.id = self.create_id()
49
50
  return assistant.id
50
51
 
51
- def load(self) -> dict:
52
+ def load(self) -> Dict[str, AssistantItem]:
52
53
  """
53
54
  Load assistants from file
54
55
 
@@ -75,9 +76,11 @@ class JsonFileProvider(BaseProvider):
75
76
 
76
77
  return items
77
78
 
78
- def save(self, items: dict):
79
+ def save(self, items: Dict[str, AssistantItem]):
79
80
  """
80
81
  Save assistants to file
82
+
83
+ :param items: dict of assistants
81
84
  """
82
85
  try:
83
86
  # update assistants
@@ -122,7 +125,7 @@ class JsonFileProvider(BaseProvider):
122
125
  return False
123
126
 
124
127
  @staticmethod
125
- def serialize(item: AssistantItem) -> dict:
128
+ def serialize(item: AssistantItem) -> Dict[str, Any]:
126
129
  """
127
130
  Serialize item to dict
128
131
 
@@ -149,7 +152,7 @@ class JsonFileProvider(BaseProvider):
149
152
  }
150
153
 
151
154
  @staticmethod
152
- def deserialize(data: dict, item: AssistantItem):
155
+ def deserialize(data: Dict[str, Any], item: AssistantItem):
153
156
  """
154
157
  Deserialize item from dict
155
158
 
@@ -6,9 +6,10 @@
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.04.26 23:00:00 #
9
+ # Updated Date: 2024.12.14 22:00:00 #
10
10
  # ================================================== #
11
11
 
12
+ from typing import Dict
12
13
  from packaging.version import Version
13
14
 
14
15
  from pygpt_net.item.assistant import AssistantFileItem
@@ -35,13 +36,13 @@ class BaseProvider:
35
36
  def load(self, id) -> AssistantFileItem:
36
37
  pass
37
38
 
38
- def load_all(self) -> dict:
39
+ def load_all(self) -> Dict[str, AssistantFileItem]:
39
40
  pass
40
41
 
41
42
  def save(self, file: AssistantFileItem):
42
43
  pass
43
44
 
44
- def save_all(self, items: dict):
45
+ def save_all(self, items: Dict[str, AssistantFileItem]):
45
46
  pass
46
47
 
47
48
  def remove(self, id):