-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathllm.py
More file actions
2041 lines (1782 loc) · 109 KB
/
llm.py
File metadata and controls
2041 lines (1782 loc) · 109 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env python3 - строка Шебанга, позволяет ОС быстрее понять, какой интерпретатор использовать
import os
import sys
import pytesseract
import re
import requests
import webbrowser
import datetime
import tkinter.font as tkFont
import customtkinter as ctk
import tkinter as tk
import pystray
import cv2
import traceback
import speech_recognition as sr
import threading
import uvicorn
import socket
import pyttsx3
import platform
import pandas as pd
import odf.text
import odf.opendocument
import subprocess # nosec B404: Subprocess module is used safely with proper input validation
from webscout import KOBOLDAI, Toolbaz, GptOss, Scira, ExaChat, FreeAIChat, Venice, HeckAI, AllenAI, WiseCat, PerplexityLabs, Felo, TurboSeek, Netwrck, Marcus, LLMChat
from webscout.Provider.OPENAI import BLACKBOXAI, MonoChat, Refact
from datetime import datetime
from PIL import Image
from tkinter import messagebox, filedialog, PhotoImage
from packaging import version
# FastAPI импорты перенесены в api_server.py
from docx import Document
from dotenv import load_dotenv
from pyzbar.pyzbar import decode
# Загружаем переменные из .env файла в окружение
load_dotenv()
FONT_SIZE_KEY = "FONT_SIZE"
HOST_KEY = "HOST"
PORT_KEY = "PORT"
MODEL_KEY = "MODEL"
IS_TRANSLATE_KEY = "IS_TRANSLATE"
IMG_FOLDER_KEY = "IMG_FOLDER"
MODE_KEY = "MODE"
DEFAULT_COLOR_THEM_KEY = "DEFAULT_COLOR_THEM"
WRITE_HISTORY_KEY = "WRITE_HISTORY"
SYSTEM_PROMPT = "SYSTEM_PROMPT"
FREEAICHAT_API_KEY = "FREEAICHAT_API_KEY"
# Инициализируем переменные значениями по умолчанию (_val добавлено к имени переменной)
font_size_val = None
host_val = None
port_val = None
model_val = None
is_translate_val = None
img_folder_val = None
mode_val = None
def_color_them_val = None
write_history_val = None
system_prompt_val = None
freeaichat_api_key_val = None
# Проверяем, существует ли файл .env и считываем значения переменных
if os.path.exists(".env"):
font_size_val = os.getenv(FONT_SIZE_KEY)
host_val = os.getenv(HOST_KEY)
port_val = os.getenv(PORT_KEY)
model_val = os.getenv(MODEL_KEY)
is_translate_val = os.getenv(IS_TRANSLATE_KEY)
img_folder_val = os.getenv(IMG_FOLDER_KEY)
mode_val = os.getenv(MODE_KEY)
def_color_them_val = os.getenv(DEFAULT_COLOR_THEM_KEY)
write_history_val = os.getenv(WRITE_HISTORY_KEY)
system_prompt_val = os.getenv(SYSTEM_PROMPT)
freeaichat_api_key_val = os.getenv(FREEAICHAT_API_KEY)
# Скрываем сообщения от Pygame
os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = "hide"
CURRENT_VERSION = "1.65"
if system_prompt_val != None:
prompt = system_prompt_val
else:
prompt = """Работай по этим правилам. Без исключений.
ОБЩИЕ ПРИНЦИПЫ
– Никакой фантазии. Не придумывай данные, события, источники или чужие мнения без запроса.
– Если чего-то не знаешь — прямо пиши «не знаю».
– Приоритет — точность и логика, а не красивая подача.
– Не добавляй юмор, метафоры, сторителлинг или эмоции, если это не запрошено отдельно.
ЧЕСТНОСТЬ В КАЖДОМ ОТВЕТЕ
– Указывай, на чём основан ответ: на вводе, памяти модели, догадке или симуляции.
– Не скрывай ограничений. Если задача невозможна — так и скажи.
– Не предлагай обходные пути, если я прямо не просил.
НЕ ГОВОРИ И НЕ ПИШИ ТАКОЕ:
– «Работаю в фоне» — ты не можешь.
– «Пингую позже» или «напомню» — ты не можешь.
– «Готово» — только если действительно всё завершено в этом чате.
– Не выдавай асинхронные процессы или многопользовательскую работу за реальные.
ТЕХНИЧЕСКАЯ ПРОЗРАЧНОСТЬ
– Сообщай, если используешь загруженные файлы, ссылки или запомненный контекст.
– Уточняй, если информация неточная, устаревшая или неполная.
– Отдельно пиши, если делаешь предположение или используешь аналогию.
КАКИЕ ОТВЕТЫ ЖДУ:
– Чёткие, точные, без «воды»
– Поэтапные, если запрос сложный
– С вариантами — если возможны разные подходы
– С пояснением, если ответ может быть неоднозначным
""" # Добавление навыков ИИ и другие тонкие настройки
if img_folder_val is not None:
img_folder = img_folder_val
else:
img_folder = 'img'
# Функция для удаления эмодзи (Unicode > 0xFFFF)
def remove_emojis(text):
return re.sub(r'[\U00010000-\U0010ffff]', '', text)
def remove_sponsor_block(text):
return re.sub(r'---\*\*Sponsor.*?', '', text, flags=re.DOTALL).strip()
# Функция для получения корректного пути к ресурсам
def resource_path(relative_path):
""" Get absolute path to resource, works for dev and for PyInstaller """
try:
# PyInstaller creates a temp folder and stores path in _MEIPASS
base_path = sys._MEIPASS
except Exception:
base_path = os.path.abspath(".")
# print(os.path.join(base_path, relative_path))
return os.path.join(base_path, relative_path)
def update_app(update_url):
webbrowser.open(update_url)
def check_for_updates():
try:
# Получение информации о последнем релизе на GitHub
response = requests.get("https://api.github.com/repos/Processori7/llm/releases/latest", timeout=10)
response.raise_for_status()
latest_release = response.json()
# Получение ссылки на файл llm.exe последней версии
download_url = None
assets = latest_release["assets"]
for asset in assets:
if asset["name"] == "llm.exe": # Ищем только llm.exe
download_url = asset["browser_download_url"]
break
if download_url is None:
messagebox.showerror("Ошибка обновления", "Не удалось найти файл llm.exe для последней версии.")
return
# Сравнение текущей версии с последней версией
latest_version_str = latest_release["tag_name"]
match = re.search(r'\d+\.\d+', latest_version_str)
if match:
latest_version = match.group()
else:
latest_version = latest_version_str
if version.parse(latest_version) > version.parse(CURRENT_VERSION):
if platform.system() == "Windows":
# Предложение пользователю обновление
if messagebox.showwarning("Доступно обновление",
f"Доступна новая версия {latest_version}. Хотите обновить?", icon='warning',
type='yesno') == 'yes':
update_app(download_url)
else:
if messagebox.showwarning("Доступно обновление",
f"Доступна новая версия {latest_version}. Хотите обновить?", icon='warning',
type='yesno') == 'yes':
try:
# nosec B603, B607: Safe use of git command with fixed arguments
subprocess.run(["git", "pull"], check=True, timeout=30, capture_output=True, text=True) # nosec
except subprocess.CalledProcessError as e:
messagebox.showerror("Ошибка обновления", f"Не удалось выполнить git pull: {e}")
except FileNotFoundError:
messagebox.showerror("Ошибка обновления", "Git не найден в системе")
except subprocess.TimeoutExpired:
messagebox.showerror("Ошибка обновления", "Превышено время ожидания для git pull")
except requests.exceptions.RequestException as e:
messagebox.showerror("Error", str(e))
def test_all_models_and_log(output_file="test_results.txt"):
"""
Тестирует все модели из словаря model_functions и записывает результаты в файл.
:param output_file: Путь к файлу для записи результатов.
"""
# Открываем файл для записи результатов
with open(output_file, "w", encoding="utf-8") as file:
# Записываем заголовок
header = "-" * 80 + "\n"
header += f"{'Model':<50} {'Status':<10} {'Response'}\n"
header += "-" * 80 + "\n"
file.write(header)
print(header, end="") # Также выводим заголовок в консоль
# Проходим по каждой модели в словаре model_functions
for model_name, model_function in model_functions.items():
try:
# Вызываем функцию модели с тестовым запросом
response = model_function("Say 'Hello' in one word")
# Обрабатываем ответ
if response and isinstance(response, str) and len(response.strip()) > 0:
status = "✓"
display_text = (
response.strip()[:50] + "..."
if len(response.strip()) > 50
else response.strip()
)
else:
status = "✗"
display_text = "Empty or invalid response"
# Формируем строку с результатами
result_line = f"{model_name:<50} {status:<10} {display_text}\n"
file.write(result_line)
print(result_line, end="") # Выводим результат в консоль
except Exception as e:
# Обрабатываем ошибки и записываем их в файл
error_message = f"{model_name:<50} {'✗':<10} {str(e)}\n"
file.write(error_message)
print(error_message, end="") # Выводим ошибку в консоль
# Добавляем разделитель в конце
footer = "-" * 80 + "\n"
file.write(footer)
print(footer, end="")
def get_Polinations_img_models():
new_models = {}
try:
url = "https://image.pollinations.ai/models"
resp = requests.get(url, timeout=10)
if resp.ok:
models = resp.json() # Получаем список строк
for name in models: # Проходим по каждой строке
# Формируем ключ для словаря
key = f"(Polination) {name}_img"
# Добавляем в словарь с соответствующей лямбда-функцией
new_models[key] = lambda user_input, model_name=name: gen_img(user_input, model_name)
# Обновляем глобальный словарь
model_functions.update(new_models)
return new_models
else:
return f"Ошибка получения моделей изображений: {resp.status_code}"
except Exception as e:
return f"Ошибка получения моделей изображений: {str(e)}"
def get_Polinations_img_models_for_bot():
"""Получение моделей для генерации изображений для бота"""
new_models = {}
try:
url = "https://image.pollinations.ai/models"
resp = requests.get(url, timeout=10)
if resp.ok:
models = resp.json() # Получаем список строк
for name in models: # Проходим по каждой строке
# Формируем ключ для словаря
key = f"{name}_img (Polination)"
# Добавляем в словарь с соответствующей лямбда-функцией для бота
new_models[key] = lambda user_input, model_name=name: gen_img_for_bot(user_input, model_name)
return new_models
else:
return f"Ошибка получения моделей изображений: {resp.status_code}"
except Exception as e:
return f"Ошибка получения моделей изображений: {str(e)}"
#Получаю все текстовые модели Polinations
def get_Polinations_chat_models():
try:
new_models = {} # Инициализация словаря
url = "https://text.pollinations.ai/models"
resp = requests.get(url, timeout=10)
if resp.ok:
models = resp.json()
for model in models:
# Проверяем наличие ключа "description"
if "description" not in model:
continue # Пропускаем модели без описания
model_description = model["description"]
model_name = model["name"]
key = f"{model_description} (Polinations)"
# Фиксируем текущее значение model в замыкании
new_models[key] = lambda user_input, model_name=model_name: communicate_with_Pollinations_chat(
user_input, model_name)
# Обновляем глобальный словарь
model_functions.update(new_models)
return new_models
else:
return f"Ошибка получения текстовых моделей: {resp.status_code}"
except Exception as e:
return f"Ошибка получения текстовых моделей: {str(e)}"
def communicate_with_Refact(user_input, model):
try:
client = Refact()
response = client.chat.completions.create(
model=model,
messages=[{"role": "user", "content": user_input}],
stream=True
)
response_text = []
for chunk in response:
if chunk.choices[0].delta.content:
response_text.append(chunk.choices[0].delta.content)
# Объединяем все части в одну строку
final_response = ''.join(response_text)
return final_response
except Exception as e:
return f"{get_error_message(main_app.is_translate)}: {str(e)}"
def communicate_with_GptOss(user_input, model):
try:
ai = GptOss(model=model, timeout=40)
ai.model = model
ai.system_prompt = prompt
response = ai.chat(user_input)
return response
except Exception as e:
return f"{get_error_message(main_app.is_translate)}: {str(e)}"
def communicate_with_Toolbaz(user_input, model):
try:
ai = Toolbaz(model=model, timeout=40)
ai.model = model
ai.system_prompt = prompt
response = ai.chat(user_input)
return response
except Exception as e:
return f"{get_error_message(main_app.is_translate)}: {str(e)}"
def communicate_with_Scira(user_input, model):
try:
ai = Scira()
ai.model = model
ai.system_prompt = prompt
response = ai.search(user_input)
return response
except Exception as e:
return f"{get_error_message(main_app.is_translate)}: {str(e)}"
def communicate_with_ExaChat(user_input, model):
try:
ai = ExaChat()
ai.model = model
ai.system_prompt = prompt
response = ai.chat(user_input)
return response
except Exception as e:
return f"{get_error_message(main_app.is_translate)}: {str(e)}"
def communicate_with_PerplexityLabs(user_input, model):
try:
ai = PerplexityLabs()
ai.model = model
ai.system_prompt = prompt
response = ai.chat(user_input, stream=False)
return response
except Exception as e:
return f"{get_error_message(main_app.is_translate)}: {str(e)}"
def communicate_with_WiseCat(user_input, model):
try:
ai = WiseCat()
ai.model = model
ai.system_prompt = prompt
response = ai.chat(user_input, stream=False)
return response
except Exception as e:
return f"{get_error_message(main_app.is_translate)}: {str(e)}"
def communicate_with_AllenAI(user_input, model):
try:
ai = AllenAI()
ai.model = model
ai.system_prompt = prompt
response = ai.chat(user_input, stream=False)
return response
except Exception as e:
return f"{get_error_message(main_app.is_translate)}: {str(e)}"
def communicate_with_HeckAI(user_input, model):
try:
ai = HeckAI()
ai.model = model
ai.system_prompt = prompt
response = ai.chat(user_input, stream=False)
response = ai.fix_encoding(response)
return response
except Exception as e:
return f"{get_error_message(main_app.is_translate)}: {str(e)}"
def communicate_with_Venice(user_input, model):
try:
ai = Venice()
ai.model = model
ai.system_prompt = prompt
response = ai.chat(user_input, stream=False)
return response
except Exception as e:
return f"{get_error_message(main_app.is_translate)}: {str(e)}"
def communicate_with_Pollinations_chat(user_input, model):
try:
url = f"https://text.pollinations.ai/'{user_input}'?model={model}&private=True"
resp = requests.get(url, timeout=30)
if resp.ok:
try:
data = resp.json() # Может быть JSON
# Если это JSON и есть 'reasoning_content', возвращаем его без эмодзи
return remove_emojis(data.get('reasoning_content', str(data))) # fallback: выводим JSON как строку
except requests.exceptions.JSONDecodeError:
# Если не JSON, возвращаем обычный текст
text = remove_sponsor_block(resp.text)
return remove_emojis(text)
else:
return f"Ошибка сервера: {resp.status_code}"
except Exception as e:
return str(e)
def communicate_with_FreeAIChat(user_input, model):
try:
ai = FreeAIChat(model=model, api_key=freeaichat_api_key_val)
ai.system_prompt = prompt
response = ai.chat(user_input, stream=False)
response = ai.fix_encoding(response)
return response
except Exception as e:
return f"{get_error_message(main_app.is_translate)}: {str(e)}"
def communicate_with_LLMChat(user_input, model):
try:
ai = LLMChat()
ai.model = model
response = ai.chat(user_input, stream=True)
response_text = ""
for chunk in response:
response_text += chunk
return response_text
except Exception as e:
return f"{get_error_message(main_app.is_translate)}: {str(e)}"
def communicate_with_Netwrck(user_input, model):
try:
ai = Netwrck(model=model)
response = ai.chat(user_input, stream=True)
full_response = ""
for chunk in response:
full_response += chunk
return full_response
except Exception as e:
return f"{get_error_message(main_app.is_translate)}: {str(e)}"
def communicate_with_TurboSeek(user_input):
try:
ai = TurboSeek()
response = ai.chat(user_input, stream=True)
full_response = ""
for chunk in response:
full_response += chunk
return full_response
except Exception as e:
return f"{get_error_message(main_app.is_translate)}: {str(e)}"
def communicate_with_Marcus(user_input):
try:
ai = Marcus()
response = ai.chat(user_input)
return response
except Exception as e:
return f"{get_error_message(main_app.is_translate)}: {str(e)}"
def communicate_with_Felo(user_input):
try:
ai = Felo()
response = ai.search(user_input, stream=False)
return response
except Exception as e:
return f"{get_error_message(main_app.is_translate)}: {str(e)}"
def communicate_with_BlackboxAI(user_input, model):
try:
client = BLACKBOXAI()
response = client.chat.completions.create(
model=model,
messages=[{"role": "user", "content": user_input}]
)
return response.choices[0].message.content
except Exception as e:
return f"{get_error_message(main_app.is_translate)}: {str(e)}"
def communicate_with_Monochat(user_input, model):
try:
text = ""
client = MonoChat()
response = client.chat.completions.create(
model=model,
messages=[{"role": "user", "content": user_input}],
stream=True
)
for chunk in response:
if chunk.choices and hasattr(chunk.choices[0], "delta") and getattr(chunk.choices[0].delta, "content", None):
text = text + chunk.choices[0].delta.content
return text
except Exception as e:
return f"{get_error_message(main_app.is_translate)}: {str(e)}"
def communicate_with_KoboldAI(user_input):
try:
koboldai = KOBOLDAI()
response = koboldai.chat(user_input)
return response
except Exception as e:
return f"{get_error_message(main_app.is_translate)}: {str(e)}"
model_functions = {
# "gpt-4.5-preview (MonoChat)": lambda user_input: communicate_with_Monochat(user_input, "gpt-4.5-preview"),
# "deepseek-v3 (MonoChat)": lambda user_input: communicate_with_Monochat(user_input, "deepseek-v3"),
# "uncensored-r1-32b (MonoChat)": lambda user_input: communicate_with_Monochat(user_input, "uncensored-r1-32b"),
# "o4-mini (MonoChat)": lambda user_input: communicate_with_Monochat(user_input, "o4-mini"),
# "o3 (MonoChat)": lambda user_input: communicate_with_Monochat(user_input, "o3"),
# "gpt-4.1 (MonoChat)": lambda user_input: communicate_with_Monochat(user_input, "gpt-4.1"),
# "gpt-4.1-mini (MonoChat)": lambda user_input: communicate_with_Monochat(user_input, "gpt-4.1-mini"),
# "gpt-4o (MonoChat)": lambda user_input: communicate_with_Monochat(user_input, "gpt-4o"),
# "gpt-4o-mini (MonoChat)": lambda user_input: communicate_with_Monochat(user_input, "gpt-4o-mini"),
# "gpt-4o-search-preview (MonoChat)": lambda user_input: communicate_with_Monochat(user_input, "gpt-4o-search-preview"),
# "gpt-4o-mini-search-preview (MonoChat)": lambda user_input: communicate_with_Monochat(user_input, "gpt-4o-mini-search-preview"),
# "gpt-4-turbo (MonoChat)": lambda user_input: communicate_with_Monochat(user_input, "gpt-4-turbo"),
# "GPT-4.1 (BlackboxAI)": lambda user_input: communicate_with_BlackboxAI(user_input, "GPT-4.1"),
# "o3-mini (BlackboxAI)": lambda user_input: communicate_with_BlackboxAI(user_input, "o3-mini"),
# "gpt-4.1-nano (BlackboxAI)": lambda user_input: communicate_with_BlackboxAI(user_input, "gpt-4.1-nano"),
# "Claude-sonnet-3.7 (BlackboxAI)": lambda user_input: communicate_with_BlackboxAI(user_input, "Claude-sonnet-3.7"),
# "Claude-sonnet-3.5 (BlackboxAI)": lambda user_input: communicate_with_BlackboxAI(user_input, "Claude-sonnet-3.5"),
# "DeepSeek-R1 (BlackboxAI)": lambda user_input: communicate_with_BlackboxAI(user_input, "DeepSeek-R1"),
# "Mistral-Small-24B-Instruct-2501 (BlackboxAI)": lambda user_input: communicate_with_BlackboxAI(user_input, "Mistral-Small-24B-Instruct-2501"),
# "Deepcoder 14B Preview (BlackboxAI)": lambda user_input: communicate_with_BlackboxAI(user_input, "Deepcoder 14B Preview"),
# "DeepHermes 3 Llama 3 8B Preview (BlackboxAI)": lambda user_input: communicate_with_BlackboxAI(user_input, "DeepHermes 3 Llama 3 8B Preview"),
# "DeepSeek R1 Zero (BlackboxAI)": lambda user_input: communicate_with_BlackboxAI(user_input, "DeepSeek R1 Zero"),
# "Dolphin3.0 Mistral 24B (BlackboxAI)": lambda user_input: communicate_with_BlackboxAI(user_input, "Dolphin3.0 Mistral 24B"),
# "Dolphin3.0 R1 Mistral 24B (BlackboxAI)": lambda user_input: communicate_with_BlackboxAI(user_input, "Dolphin3.0 R1 Mistral 24B"),
# "Flash 3 (BlackboxAI)": lambda user_input: communicate_with_BlackboxAI(user_input, "Flash 3"),
# "Gemini 2.0 Flash Experimental (BlackboxAI)": lambda user_input: communicate_with_BlackboxAI(user_input, "Gemini 2.0 Flash Experimental"),
# "Gemma 2 9B (BlackboxAI)": lambda user_input: communicate_with_BlackboxAI(user_input, "Gemma 2 9B"),
# "Gemma 3 12B (BlackboxAI)": lambda user_input: communicate_with_BlackboxAI(user_input, "Gemma 3 12B"),
# "Gemma 3 1B (BlackboxAI)": lambda user_input: communicate_with_BlackboxAI(user_input, "Gemma 3 1B"),
# "Gemma 3 27B (BlackboxAI)": lambda user_input: communicate_with_BlackboxAI(user_input, "Gemma 3 27B"),
# "Gemma 3 4B (BlackboxAI)": lambda user_input: communicate_with_BlackboxAI(user_input, "Gemma 3 4B"),
# "Kimi VL A3B Thinking (BlackboxAI)": lambda user_input: communicate_with_BlackboxAI(user_input, "Kimi VL A3B Thinking"),
# "Llama 3.1 8B Instruct (BlackboxAI)": lambda user_input: communicate_with_BlackboxAI(user_input, "Llama 3.1 8B Instruct"),
# "Llama 3.1 Nemotron Ultra 253B v1 (BlackboxAI)": lambda user_input: communicate_with_BlackboxAI(user_input, "Llama 3.1 Nemotron Ultra 253B v1"),
# "Llama 3.2 11B Vision Instruct (BlackboxAI)": lambda user_input: communicate_with_BlackboxAI(user_input, "Llama 3.2 11B Vision Instruct"),
# "Llama 3.2 1B Instruct (BlackboxAI)": lambda user_input: communicate_with_BlackboxAI(user_input, "Llama 3.2 1B Instruct"),
# "Llama 3.2 3B Instruct (BlackboxAI)": lambda user_input: communicate_with_BlackboxAI(user_input, "Llama 3.2 3B Instruct"),
# "Llama 3.3 70B Instruct (BlackboxAI)": lambda user_input: communicate_with_BlackboxAI(user_input, "Llama 3.3 70B Instruct"),
# "Llama 3.3 Nemotron Super 49B v1 (BlackboxAI)": lambda user_input: communicate_with_BlackboxAI(user_input, "Llama 3.3 Nemotron Super 49B v1"),
# "Llama 4 Maverick (BlackboxAI)": lambda user_input: communicate_with_BlackboxAI(user_input, "Llama 4 Maverick"),
# "Llama 4 Scout (BlackboxAI)": lambda user_input: communicate_with_BlackboxAI(user_input, "Llama 4 Scout"),
# "Mistral 7B Instruct (BlackboxAI)": lambda user_input: communicate_with_BlackboxAI(user_input, "Mistral 7B Instruct"),
# "Mistral Nemo (BlackboxAI)": lambda user_input: communicate_with_BlackboxAI(user_input, "Mistral Nemo"),
# "Mistral Small 3 (BlackboxAI)": lambda user_input: communicate_with_BlackboxAI(user_input, "Mistral Small 3"),
# "Mistral Small 3.1 24B (BlackboxAI)": lambda user_input: communicate_with_BlackboxAI(user_input, "Mistral Small 3.1 24B"),
# "Molmo 7B D (BlackboxAI)": lambda user_input: communicate_with_BlackboxAI(user_input, "Molmo 7B D"),
# "Moonlight 16B A3B Instruct (BlackboxAI)": lambda user_input: communicate_with_BlackboxAI(user_input, "Moonlight 16B A3B Instruct"),
# "Qwen2.5 72B Instruct (BlackboxAI)": lambda user_input: communicate_with_BlackboxAI(user_input, "Qwen2.5 72B Instruct"),
# "Qwen2.5 7B Instruct (BlackboxAI)": lambda user_input: communicate_with_BlackboxAI(user_input, "Qwen2.5 7B Instruct"),
# "Qwen2.5 Coder 32B Instruct (BlackboxAI)": lambda user_input: communicate_with_BlackboxAI(user_input, "Qwen2.5 Coder 32B Instruct"),
# "Qwen2.5 VL 32B Instruct (BlackboxAI)": lambda user_input: communicate_with_BlackboxAI(user_input, "Qwen2.5 VL 32B Instruct"),
# "Qwen2.5 VL 3B Instruct (BlackboxAI)": lambda user_input: communicate_with_BlackboxAI(user_input, "Qwen2.5 VL 3B Instruct"),
# "Qwen2.5 VL 72B Instruct (BlackboxAI)": lambda user_input: communicate_with_BlackboxAI(user_input, "Qwen2.5 VL 72B Instruct"),
# "Qwen2.5-VL 7B Instruct (BlackboxAI)": lambda user_input: communicate_with_BlackboxAI(user_input, "Qwen2.5-VL 7B Instruct"),
# "Qwerky 72B (BlackboxAI)": lambda user_input: communicate_with_BlackboxAI(user_input, "Qwerky 72B"),
# "QwQ 32B (BlackboxAI)": lambda user_input: communicate_with_BlackboxAI(user_input, "QwQ 32B"),
# "QwQ 32B Preview (BlackboxAI)": lambda user_input: communicate_with_BlackboxAI(user_input, "QwQ 32B Preview"),
# "QwQ 32B RpR v1 (BlackboxAI)": lambda user_input: communicate_with_BlackboxAI(user_input, "QwQ 32B RpR v1"),
# "R1 (BlackboxAI)": lambda user_input: communicate_with_BlackboxAI(user_input, "R1"),
# "R1 Distill Llama 70B (BlackboxAI)": lambda user_input: communicate_with_BlackboxAI(user_input, "R1 Distill Llama 70B"),
# "R1 Distill Qwen 14B (BlackboxAI)": lambda user_input: communicate_with_BlackboxAI(user_input, "R1 Distill Qwen 14B"),
# "R1 Distill Qwen 32B (BlackboxAI)": lambda user_input: communicate_with_BlackboxAI(user_input, "R1 Distill Qwen 32B"),
"gpt-4o (Refact)": lambda user_input: communicate_with_Refact(user_input, "gpt-4o"),
"gpt-4o-mini (Refact)": lambda user_input: communicate_with_Refact(user_input, "gpt-4o-mini"),
"gpt-4.1 (Refact)": lambda user_input: communicate_with_Refact(user_input, "gpt-4.1"),
"gpt-4.1-mini (Refact)": lambda user_input: communicate_with_Refact(user_input, "gpt-4.1-mini"),
"gpt-4.1-nano (Refact)": lambda user_input: communicate_with_Refact(user_input, "gpt-4.1-nano"),
"gpt-5 (Refact)": lambda user_input: communicate_with_Refact(user_input, "gpt-5"),
"gpt-5-mini (Refact)": lambda user_input: communicate_with_Refact(user_input, "gpt-5-mini"),
"gpt-5-nano (Refact)": lambda user_input: communicate_with_Refact(user_input, "gpt-5-nano"),
"claude-sonnet-4 (Refact)": lambda user_input: communicate_with_Refact(user_input, "claude-sonnet-4"),
"claude-opus-4 (Refact)": lambda user_input: communicate_with_Refact(user_input, "claude-opus-4"),
"claude-opus-4.1 (Refact)": lambda user_input: communicate_with_Refact(user_input, "claude-opus-4.1"),
"gemini-2.5-pro (Refact)": lambda user_input: communicate_with_Refact(user_input, "gemini-2.5-pro"),
"gemini-2.5-pro-preview (Refact)": lambda user_input: communicate_with_Refact(user_input, "gemini-2.5-pro-preview"),
"llama-3.1-70b-instruct (LLMChat)": lambda user_input: communicate_with_LLMChat(user_input, "@cf/meta/llama-3.1-70b-instruct"),
"llama-3.1-8b-instruct (LLMChat)": lambda user_input: communicate_with_LLMChat(user_input, "@cf/meta/llama-3.1-8b-instruct"),
"llama-3.2-3b-instruct (LLMChat)": lambda user_input: communicate_with_LLMChat(user_input, "@cf/meta/llama-3.2-3b-instruct"),
"llama-3.2-1b-instruct (LLMChat)": lambda user_input: communicate_with_LLMChat(user_input, "@cf/meta/llama-3.2-1b-instruct"),
"llama-3.3-70b-instruct-fp8-fast (LLMChat)": lambda user_input: communicate_with_LLMChat(user_input, "@cf/meta/llama-3.3-70b-instruct-fp8-fast"),
"deepseek-ai/deepseek-r1-distill-qwen-32b (LLMChat)": lambda user_input: communicate_with_LLMChat(user_input, "@cf/deepseek-ai/deepseek-r1-distill-qwen-32b"),
"meta/llama-4-scout-17b-16e-instruct (LLMChat)": lambda user_input: communicate_with_LLMChat(user_input, "@cf/meta/llama-4-scout-17b-16e-instruct"),
"mistralai/mistral-small-3.1-24b-instruct (LLMChat)": lambda user_input: communicate_with_LLMChat(user_input, "@cf/mistralai/mistral-small-3.1-24b-instruct"),
"google/gemma-3-12b-it (LLMChat)": lambda user_input: communicate_with_LLMChat(user_input, "@cf/google/gemma-3-12b-it"),
"valkyrie-49b-v1 (Netwrck)": lambda user_input: communicate_with_Netwrck(user_input, "thedrummer/valkyrie-49b-v1"),
"l3-euryale-70b": lambda user_input: communicate_with_Netwrck(user_input, "sao10k/l3-euryale-70b"),
"deepseek-chat (Netwrck)": lambda user_input: communicate_with_Netwrck(user_input, "deepseek/deepseek-chat"),
"deepseek-r1 (Netwrck)": lambda user_input: communicate_with_Netwrck(user_input, "deepseek/deepseek-r1"),
"gpt-4.1-mini (Netwrck)": lambda user_input: communicate_with_Netwrck(user_input, "openai/gpt-4.1-mini"),
"mythomax-l2-13b (Netwrck)": lambda user_input: communicate_with_Netwrck(user_input, "gryphe/mythomax-l2-13b"),
"gemini-pro-1.5 (Netwrck)": lambda user_input: communicate_with_Netwrck(user_input, "google/gemini-pro-1.5"),
"gemini-2.5-flash-preview-04-17 (Netwrck)": lambda user_input: communicate_with_Netwrck(user_input, "google/gemini-2.5-flash-preview-04-17"),
"llama-3.1-nemotron-70b (Netwrck)": lambda user_input: communicate_with_Netwrck(user_input, "nvidia/llama-3.1-nemotron-70b-instruct"),
# "exaanswer (ExaChat)": lambda user_input: communicate_with_ExaChat(user_input, "exaanswer"),
# "gemini-2.0-flash (ExaChat)": lambda user_input: communicate_with_ExaChat(user_input, "gemini-2.0-flash"),
# "gemini-2.0-flash-thinking-exp-01-21 (ExaChat)": lambda user_input: communicate_with_ExaChat(user_input,"gemini-2.0-flash-thinking-exp-01-21"),
# "gemini-2.5-pro-exp-03-25 (ExaChat)": lambda user_input: communicate_with_ExaChat(user_input,"gemini-2.5-pro-exp-03-25"),
# "gemini-2.0-pro-exp-02-05 (ExaChat)": lambda user_input: communicate_with_ExaChat(user_input,"gemini-2.0-pro-exp-02-05"),
# "mistralai/mistral-small-3.1-24b-instruct:free (ExaChat)": lambda user_input: communicate_with_ExaChat(user_input,"mistralai/mistral-small-3.1-24b-instruct:free"),
# "deepseek/deepseek-r1:free (ExaChat)": lambda user_input: communicate_with_ExaChat(user_input,"deepseek/deepseek-r1:free"),
# "deepseek/deepseek-chat-v3-0324:free (ExaChat)": lambda user_input: communicate_with_ExaChat(user_input,"deepseek/deepseek-chat-v3-0324:free"),
# "google/gemma-3-27b-it:free (ExaChat)": lambda user_input: communicate_with_ExaChat(user_input,"google/gemma-3-27b-it:free"),
# "deepseek-r1-distill-llama-70b (ExaChat)": lambda user_input: communicate_with_ExaChat(user_input,"deepseek-r1-distill-llama-70b"),
# "deepseek-r1-distill-qwen-32b (ExaChat)": lambda user_input: communicate_with_ExaChat(user_input,"deepseek-r1-distill-qwen-32b"),
# "gemma2-9b-it (ExaChat)": lambda user_input: communicate_with_ExaChat(user_input, "gemma2-9b-it"),
# "llama-3.1-8b-instant (ExaChat)": lambda user_input: communicate_with_ExaChat(user_input, "llama-3.1-8b-instant"),
# "llama-3.2-1b-preview (ExaChat)": lambda user_input: communicate_with_ExaChat(user_input, "llama-3.2-1b-preview"),
# "llama-3.2-3b-preview (ExaChat)": lambda user_input: communicate_with_ExaChat(user_input, "llama-3.2-3b-preview"),
# "llama-3.2-90b-vision-preview (ExaChat)": lambda user_input: communicate_with_ExaChat(user_input,"llama-3.2-90b-vision-preview"),
# "llama-3.3-70b-specdec (ExaChat)": lambda user_input: communicate_with_ExaChat(user_input, "llama-3.3-70b-specdec"),
# "llama-3.3-70b-versatile (ExaChat)": lambda user_input: communicate_with_ExaChat(user_input,"llama-3.3-70b-versatile"),
# "llama3-70b-8192 (ExaChat)": lambda user_input: communicate_with_ExaChat(user_input, "llama3-70b-8192"),
# "llama3-8b-8192 (ExaChat)": lambda user_input: communicate_with_ExaChat(user_input, "llama3-8b-8192"),
# "qwen-2.5-32b (ExaChat)": lambda user_input: communicate_with_ExaChat(user_input, "qwen-2.5-32b"),
# "qwen-2.5-coder-32b (ExaChat)": lambda user_input: communicate_with_ExaChat(user_input, "qwen-2.5-coder-32b"),
# "qwen-qwq-32b (ExaChat)": lambda user_input: communicate_with_ExaChat(user_input, "qwen-qwq-32b"),
# "llama3.1-8b (ExaChat)": lambda user_input: communicate_with_ExaChat(user_input, "llama3.1-8b"),
# "llama-3.3-70b (ExaChat)": lambda user_input: communicate_with_ExaChat(user_input, "llama-3.3-70b"),
"gpt-oss-120b (GPTOSS)": lambda user_input: communicate_with_GptOss(user_input, "gpt-oss-120b"),
"gpt-oss-20b (GPTOSS)": lambda user_input: communicate_with_GptOss(user_input, "gpt-oss-20b"),
"gemini-2.5-flash (Toolbaz)": lambda user_input: communicate_with_Toolbaz(user_input, "gemini-2.5-flash"),
"gemini-2.0-flash-thinking (Toolbaz)": lambda user_input: communicate_with_Toolbaz(user_input, "gemini-2.0-flash-thinking"),
"gemini-2.0-flash (Toolbaz)": lambda user_input: communicate_with_Toolbaz(user_input, "gemini-2.0-flash"),
"gemini-1.5-flash (Toolbaz)": lambda user_input: communicate_with_Toolbaz(user_input, "gemini-1.5-flash"),
"gpt-4o-latest (Toolbaz)": lambda user_input: communicate_with_Toolbaz(user_input, "gpt-4o-latest"),
"gpt-4o (Toolbaz)": lambda user_input: communicate_with_Toolbaz(user_input, "gpt-4o"),
"deepseek-r1 (Toolbaz)": lambda user_input: communicate_with_Toolbaz(user_input, "deepseek-r1"),
"Llama-4-Maverick (Toolbaz)": lambda user_input: communicate_with_Toolbaz(user_input, "Llama-4-Maverick"),
"Llama-4-Scout (Toolbaz)": lambda user_input: communicate_with_Toolbaz(user_input, "Llama-4-Scout"),
"Llama-3.3-70B (Toolbaz)": lambda user_input: communicate_with_Toolbaz(user_input, "Llama-3.3-70B"),
"Qwen2.5-72B (Toolbaz)": lambda user_input: communicate_with_Toolbaz(user_input, "Qwen2.5-72B"),
"grok-2-1212 (Toolbaz)": lambda user_input: communicate_with_Toolbaz(user_input, "grok-2-1212"),
"grok-3-beta (Toolbaz)": lambda user_input: communicate_with_Toolbaz(user_input, "grok-3-beta"),
"toolbaz_v3.5_pro (Toolbaz)": lambda user_input: communicate_with_Toolbaz(user_input, "toolbaz_v3.5_pro"),
"toolbaz_v3 (Toolbaz)": lambda user_input: communicate_with_Toolbaz(user_input, "toolbaz_v3"),
"mixtral_8x22b (Toolbaz)": lambda user_input: communicate_with_Toolbaz(user_input, "mixtral_8x22b"),
"L3-70B-Euryale-v2.1 (Toolbaz)": lambda user_input: communicate_with_Toolbaz(user_input, "L3-70B-Euryale-v2.1"),
"midnight-rose (Toolbaz)": lambda user_input: communicate_with_Toolbaz(user_input, "midnight-rose"),
"unity (Toolbaz)": lambda user_input: communicate_with_Toolbaz(user_input, "unity"),
"unfiltered_x (Toolbaz)": lambda user_input: communicate_with_Toolbaz(user_input, "unfiltered_x"),
"r1-1776 (PerplexityLabs)": lambda user_input: communicate_with_PerplexityLabs(user_input, "r1-1776"),
"sonar-pro (PerplexityLabs)": lambda user_input: communicate_with_PerplexityLabs(user_input, "sonar-pro"),
"sonar (PerplexityLabs)": lambda user_input: communicate_with_PerplexityLabs(user_input, "sonar"),
"sonar-reasoning-pro (PerplexityLabs)": lambda user_input: communicate_with_PerplexityLabs(user_input, "sonar-reasoning-pro"),
"sonar-reasoning (PerplexityLabs)": lambda user_input: communicate_with_PerplexityLabs(user_input, "sonar-reasoning"),
"chat-model-small (WiseCat)": lambda user_input: communicate_with_WiseCat(user_input, "chat-model-small"),
"chat-model-large (WiseCat)": lambda user_input: communicate_with_WiseCat(user_input, "chat-model-large"),
"chat-model-reasoning (WiseCat)": lambda user_input: communicate_with_WiseCat(user_input, "chat-model-reasoning"),
"tulu3-405b (AllenAI)": lambda user_input: communicate_with_AllenAI(user_input, "tulu3-405b"),
"olmo-2-0325-32b-instruct (AllenAI)": lambda user_input: communicate_with_AllenAI(user_input, "olmo-2-0325-32b-instruct"),
"gemini-2.0-flash-001 (HeckAI)": lambda user_input: communicate_with_HeckAI(user_input, "google/gemini-2.0-flash-001"),
"deepseek-chat (HeckAI)": lambda user_input: communicate_with_HeckAI(user_input, "deepseek/deepseek-chat"),
"deepseek-r1 (HeckAI)": lambda user_input: communicate_with_HeckAI(user_input, "deepseek/deepseek-r1"),
"gpt-4o-mini (HeckAI)": lambda user_input: communicate_with_HeckAI(user_input, "openai/gpt-4o-mini"),
"gpt-4.1-mini (HeckAI)": lambda user_input: communicate_with_HeckAI(user_input, "openai/gpt-4.1-mini"),
"grok-3-mini-beta (HeckAI)": lambda user_input: communicate_with_HeckAI(user_input, "x-ai/grok-3-mini-beta"),
"llama-4-scout (HeckAI)": lambda user_input: communicate_with_HeckAI(user_input, "meta-llama/llama-4-scout"),
"Deepseek R1 Latest (FreeAiChat)": lambda user_input: communicate_with_FreeAIChat(user_input, "Deepseek R1 Latest"),
"GPT 4o (FreeAiChat)": lambda user_input: communicate_with_FreeAIChat(user_input, "GPT 4o"),
"O4 Mini (FreeAiChat)": lambda user_input: communicate_with_FreeAIChat(user_input, "O4 Mini"),
"O4 Mini High (FreeAiChat)": lambda user_input: communicate_with_FreeAIChat(user_input, "O4 Mini High"),
"QwQ Plus (FreeAiChat)": lambda user_input: communicate_with_FreeAIChat(user_input, "QwQ Plus"),
"Llama 4 Maverick (FreeAiChat)": lambda user_input: communicate_with_FreeAIChat(user_input, "Llama 4 Maverick"),
"Grok 3 (FreeAiChat)": lambda user_input: communicate_with_FreeAIChat(user_input, "Grok 3"),
"GPT 4o mini (FreeAiChat)": lambda user_input: communicate_with_FreeAIChat(user_input, "GPT 4o mini"),
"Deepseek v3 0324 (FreeAiChat)": lambda user_input: communicate_with_FreeAIChat(user_input, "Deepseek v3 0324"),
"Grok 3 Mini (FreeAiChat)": lambda user_input: communicate_with_FreeAIChat(user_input, "Grok 3 Mini"),
"GPT 4.1 (FreeAiChat)": lambda user_input: communicate_with_FreeAIChat(user_input, "GPT 4.1"),
"GPT 4.1 Mini (FreeAiChat)": lambda user_input: communicate_with_FreeAIChat(user_input, "GPT 4.1 Mini"),
"Claude 3.7 Sonnet (Thinking) (FreeAiChat)": lambda user_input: communicate_with_FreeAIChat(user_input, "Claude 3.7 Sonnet (Thinking)"),
"Llama 4 Scout (FreeAiChat)": lambda user_input: communicate_with_FreeAIChat(user_input, "Llama 4 Scout"),
"O3 High (FreeAiChat)": lambda user_input: communicate_with_FreeAIChat(user_input, "O3 High"),
"Gemini 2.5 Pro (FreeAiChat)": lambda user_input: communicate_with_FreeAIChat(user_input, "Gemini 2.5 Pro"),
"Magistral Medium 2506 (FreeAiChat)": lambda user_input: communicate_with_FreeAIChat(user_input, "Magistral Medium 2506"),
"O3 (FreeAiChat)": lambda user_input: communicate_with_FreeAIChat(user_input, "O3"),
"Gemini 2.5 Flash (FreeAiChat)": lambda user_input: communicate_with_FreeAIChat(user_input, "Gemini 2.5 Flash"),
"Qwen 3 235B A22B (FreeAiChat)": lambda user_input: communicate_with_FreeAIChat(user_input, "Qwen 3 235B A22B"),
"Claude 4 Sonnet (FreeAiChat)": lambda user_input: communicate_with_FreeAIChat(user_input, "Claude 4 Sonnet"),
"Claude 4 Sonnet (Thinking) (FreeAiChat)": lambda user_input: communicate_with_FreeAIChat(user_input, "Claude 4 Sonnet (Thinking)"),
"Claude 4 Opus (FreeAiChat)": lambda user_input: communicate_with_FreeAIChat(user_input, "Claude 4 Opus"),
"Claude 4 Opus (Thinking) (FreeAiChat)": lambda user_input: communicate_with_FreeAIChat(user_input, "Claude 4 Opus (Thinking)"),
"Gemini 2.5 Pro (thinking) (FreeAiChat)": lambda user_input: communicate_with_FreeAIChat(user_input, "Google: Gemini 2.5 Pro (thinking)"),
"(Venice) Mistral-31-24b": lambda user_input: communicate_with_Venice(user_input, "mistral-31-24b"),
"(Venice) llama-3.2-3b-akash_Web": lambda user_input: communicate_with_Venice(user_input, "llama-3.2-3b-akash"),
"(Venice) qwen2dot5-coder-32b_Web": lambda user_input: communicate_with_Venice(user_input, "qwen2dot5-coder-32b"),
"(Venice) deepseek-coder-v2-lite": lambda user_input: communicate_with_Venice(user_input, "deepseek-coder-v2-lite"),
"(Scira) Grok3_Web": lambda user_input: communicate_with_Scira(user_input, "scira-default"),
"(Scira) Grok3-mini_Web": lambda user_input: communicate_with_Scira(user_input, "scira-grok-3-mini"),
"(Scira) Grok2-Vision_Web": lambda user_input: communicate_with_Scira(user_input, "scira-vision"),
"(Scira) Sonnet-3.7_Web": lambda user_input: communicate_with_Scira(user_input, "scira-claude"),
"(Scira) optimus_Web": lambda user_input: communicate_with_Scira(user_input, "scira-optimus"),
"KoboldAI": communicate_with_KoboldAI,
"TurboSeek_Web":communicate_with_TurboSeek,
"Marcus_Web":communicate_with_Marcus,
}
talk_please = {
"ru":"Пожалуйста, говорите",
"en":"Please speak"
}
select_image_message_errors = {
"ru":"Картинка не выбрана!",
"en":"The picture is not selected!"
}
select_image_title_errors = {
"ru":"Внимание!",
"en":"Attention!"
}
error_messages = {
"ru":"Ошибка получения данных от провайдера, пожалуйста, выберите другого провайдера или модель",
"en":"Error receiving data from provider, please select another provider or model"
}
tesseract_not_found_messages = {
"ru":"Tesseract OCR не найден. Нажмите 'Да' для открытия ссылки на скачивание.\n\nВы можете:\n1. Установить Tesseract через стандартный инсталлятор\n2. Поместить tesseract.exe в папку с программой\n3. Добавить Tesseract в PATH",
"en":"Tesseract OCR not found. Click 'Yes' to open download link.\n\nYou can:\n1. Install Tesseract via standard installer\n2. Place tesseract.exe in the program folder\n3. Add Tesseract to PATH"
}
error_gen_img_messages = {
"ru":"Генерация изображения не удалась, получен пустой ответ.",
"en":"Image generation failed, blank response received."
}
save_img_messages = {
"ru":"Картинка сохранена в: ",
"en":"The picture is saved in: "
}
text_recognition_error_messages = {
"ru": "Ошибка при распознавании текста.",
"en": "Error during text recognition."
}
image_load_error_messages = {
"ru": "Не удалось загрузить изображение. Проверьте название файла. Попробуйте переименовать например в 2.png",
"en": "Failed to load the image. Check the file name. Try renaming, for example, to 2.png"
}
no_text_recognized_messages = {
"ru": "Текст не распознан.",
"en": "No text recognized."
}
micro_error_message={
"ru":"Микрофон не доступен!",
"en":"Microphone is not available!"
}
API_message={
"ru":"API Mode включен, скоро откроется ссылка в браузере",
"en":"API Mode enabled, a link will open soon in the browser"
}
def get_API_message(is_translate):
return API_message["ru" if not is_translate else "en"]
def get_micro_error_message(is_translate):
return micro_error_message["ru" if not is_translate else "en"]
def get_talk_please(is_translate):
return talk_please["ru" if not is_translate else "en"]
def get_text_recognition_error_message(is_translate):
return text_recognition_error_messages["ru" if not is_translate else "en"]
def get_image_load_error_message(is_translate):
return image_load_error_messages["ru" if not is_translate else "en"]
def get_no_text_recognized_message(is_translate):
return no_text_recognized_messages["ru" if not is_translate else "en"]
def get_select_image_message_errors(is_translate):
return select_image_message_errors["ru" if not is_translate else "en"]
def get_image_title_errors(is_translate):
return select_image_title_errors["ru" if not is_translate else "en"]
def get_tesseract_not_found_messages(is_translate):
return tesseract_not_found_messages["ru" if not is_translate else "en"]
def get_save_img_messages(is_translate):
return save_img_messages["ru" if not is_translate else "en"]
def get_error_message(is_translate):
return error_messages["ru" if not is_translate else "en"]
def get_error_gen_img_messages(is_translate):
return error_gen_img_messages["ru" if not is_translate else "en"]
def gen_img(user_input, model):
"""Генерация изображения для GUI приложения (сохраняет локально)"""
try:
# Кодируем промпт для URL
import urllib.parse
encoded_prompt = urllib.parse.quote(user_input)
# Формируем URL для запроса
url = f"https://image.pollinations.ai/prompt/{encoded_prompt}?model={model}"
resp = requests.get(url, timeout=30)
if resp.ok:
if not os.path.exists(img_folder):
os.makedirs(img_folder)
now = datetime.now()
saved_images = [] # Список для хранения путей сохраненных изображений
# Сохраняем изображение
image_path = os.path.join(img_folder, f'{user_input}_{now.strftime("%d.%m.%Y_%H.%M.%S")}.png')
with open(image_path, 'wb') as img_file:
img_file.write(resp.content) # Сохраняем содержимое ответа как изображение
saved_images.append(image_path) # Добавляем путь к сохраненному изображению в список
is_translate = main_app.is_translate if main_app else False
return f"{get_save_img_messages(is_translate)}{', '.join(saved_images)}"
else:
is_translate = main_app.is_translate if main_app else False
return f"{get_error_gen_img_messages(is_translate)}: {resp.status_code}"
except Exception as e:
is_translate = main_app.is_translate if main_app else False
return f"{get_error_message(is_translate)}: {str(e)}"
def gen_img_for_bot(user_input, model):
"""Генерация изображения для бота (возвращает URL)"""
try:
# Кодируем промпт для URL
import urllib.parse
encoded_prompt = urllib.parse.quote(user_input)
# Формируем URL для запроса
url = f"https://image.pollinations.ai/prompt/{encoded_prompt}?model={model}"
resp = requests.get(url, timeout=30)
if resp.ok:
# Для бота возвращаем URL изображения
return url
else:
return f"Ошибка генерации изображения: {resp.status_code}"
except Exception as e:
return f"Ошибка: {str(e)}"
def get_bool_val(val):
if val in ["True", "true"]:
return True
else:
return False
class ChatApp(ctk.CTk):
def __init__(self):
try:
super().__init__()
if mode_val is not None:
ctk.set_appearance_mode(mode_val)
else:
ctk.set_appearance_mode("dark")
if def_color_them_val is not None:
ctk.set_default_color_theme(def_color_them_val)
else:
ctk.set_default_color_theme("green")
# Определение пути к Tesseract в зависимости от платформы
if platform.system() == "Windows":
self.tesseract_cmd = resource_path('tesseract.exe')
else:
self.tesseract_cmd = "/usr/bin/tesseract"
pytesseract.pytesseract.tesseract_cmd = self.tesseract_cmd
self.is_listening = False # Флаг для отслеживания состояния прослушивания
self.stop_listening = None # Объект для остановки прослушивания
if is_translate_val is not None:
self.is_translate = get_bool_val(is_translate_val)
else:
self.is_translate = False
self.server_process = None
self.uvicorn_server = None
self.api_running = False
self.tray_icon = None
self.tray_icon_thread = None # Добавляем явную инициализацию
self.local_ip = self.get_local_ip()
# Инициализация переменных для Telegram бота
self.telegram_bot = None
self.bot_running = False
if self.is_translate:
self.title("AI Chat")
else:
self.title("Чат с ИИ")
self.geometry("{}x{}+0+0".format(self.winfo_screenwidth(), self.winfo_screenheight()))
if font_size_val is not None:
font_size = int(font_size_val)
else:
font_size = int(min(self.winfo_screenwidth(), self.winfo_screenheight()) / 100) + 8
# Поднимаем окно на передний план
self.lift()
self.focus_force() # Устанавливаем фокус на окно
# Устанавливаем окно всегда на переднем плане
self.attributes("-topmost", True)
# Устанавливаем окно в полноэкранный режим
# self.attributes("-fullscreen", True)
# Загрузка иконки через resource_path
if platform.system() == "Windows":
icon_path = resource_path("icon.ico")
self.iconbitmap(icon_path)
else:
icon_path = resource_path("icon.png")
# Для Linux и macOS используем PhotoImage
icon = PhotoImage(file=icon_path)
self.iconphoto(True, icon)
# Привязываем событие закрытия окна
if platform.system() == "Windows":
self.protocol("WM_DELETE_WINDOW", self.hide_window)
# Инициализация TTS движка
self.engine = None
self.engine = pyttsx3.init()
self.engine.setProperty('rate', 170) # Скорость речи
# Создание виджета chat_history с прокруткой
self.chat_history_frame = ctk.CTkFrame(self)
self.chat_history_frame.pack(fill="both", expand=True, padx=10, pady=10)
button_height = 30 if self.winfo_screenheight() >= 900 else 20
self.chat_history = ctk.CTkTextbox(self.chat_history_frame, font=("Consolas", font_size))
self.chat_history.pack(fill="both", expand=True)
self.chat_history.configure(state="disabled")
self.chat_history.configure(wrap="word")
# Добавление контекстного меню для chat_history
self.chat_history.bind("<Button-3>", self.show_context_menu)
self.chat_history_context_menu = tk.Menu(self, tearoff=0)
self.chat_history_context_menu.add_command(label="Выделить всё", command=self.select_all)
self.chat_history_context_menu.add_command(label="Копировать", command=self.copy_text)
self.input_frame = ctk.CTkFrame(self)
self.input_frame.pack(fill="x", padx=10, pady=10)
# Метка для выбора модели
self.model_label = ctk.CTkLabel(self.input_frame, text="Выберите модель:", font=("Consolas", font_size))
self.model_label.pack(side="left", padx=5)
# Комбобокс для выбора модели
self.model_var = tk.StringVar()
self.model_combobox = ctk.CTkOptionMenu(self.input_frame, variable=self.model_var, font=("Consolas", font_size),
values=list(model_functions.keys()))
self.model_combobox.pack(side="left", padx=5)
if model_val is not None:
self.model_combobox.set(list(model_functions.keys())[int(model_val)])
else:
self.model_combobox.set(list(model_functions.keys())[0]) # Модель по умолчанию