-
Notifications
You must be signed in to change notification settings - Fork 0
/
ChatDNMX.py
2310 lines (1944 loc) · 98.7 KB
/
ChatDNMX.py
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
#
#
#
#
# Chat DNMX - A product made for fun.
#
# Arinjay Kumar Chat DNMX
#
# ©️ Copyright 2024 Arinjay Kumar
#
# Product by Arinjay Kumar
#
# A part of Zodiac
#
# Dear Viwers, This is note to you that: Please credit me if you want to share or use this code in
# any type of medium.
#
# Enjoy!
#
#
#
#
from Crypto import Random # pip install crypto / pip install cryptography/ pip install pycryptodome
from Crypto.Cipher import AES # pip install crypto / pip istall cryptography/ pip install pycryptodome
import re # pip install bcrypt
import wikipedia # pip install wikipedia
import datetime # pip install datetime
import os
import webbrowser # pip install webbrowser
import sys
from openai import OpenAI # pip install openai
import google.generativeai as genai # pip install google-generativeai
from groq import Groq # pip install groq
from mistralai.client import MistralClient # pip install mistralai
from mistralai.models.chat_completion import ChatMessage # pip install mistralai
import anthropic # pip install anthropic
import base64
import requests # pip install requests
from dotenv import load_dotenv
def check_Existence_Of_ENV_File():
if os.path.exists(".env"):
print("")
else:
with open('.env', 'w+') as file:
file.write("")
check_Existence_Of_ENV_File()
# Password Hashed and Encryped using Advanced Encryption Standard (AES) 256-bit Encryption - The Most strongest and most robust encryption standard that is commercially available today.# PKCS7 padding function
def pad(message):
padding_length = AES.block_size - len(message) % AES.block_size
padding = bytes([padding_length]) * padding_length
return message + padding
# PKCS7 unpadding function
def unpad(padded_message):
padding_length = padded_message[-1]
return padded_message[:-padding_length]
# Encrypt function with AES-256 and PKCS7 padding
def encrypt(message, key):
# Convert message to bytes if it's not already
if isinstance(message, str):
message = message.encode()
# Apply padding
padded_message = pad(message)
# Generate a random initialization vector (IV)
iv = Random.new().read(AES.block_size)
# Create AES cipher object
cipher = AES.new(key, AES.MODE_CBC, iv)
# Encrypt the padded message
encrypted_message = cipher.encrypt(padded_message)
# Encode the result using base64 for easy storage/transfer
return base64.b64encode(iv + encrypted_message)
# Decrypt function with AES-256 and PKCS7 padding removal
# def decrypt(encrypted_message, key):
# # Decode the base64-encoded message
# encrypted_message = base64.b64decode(encrypted_message)
# # Extract the IV from the encrypted message
# iv = encrypted_message[:AES.block_size]
# # Extract the actual encrypted message
# encrypted_message = encrypted_message[AES.block_size:]
# # Create AES cipher object for decryption
# cipher = AES.new(key, AES.MODE_CBC, iv)
# # Decrypt the message and remove padding
# padded_message = cipher.decrypt(encrypted_message)
# return unpad(padded_message).decode() # Decode to return the original message
def authentication():
# Define the file path
username_file_path = 'D:\\donotopenthisfolder\\Arinjay\\CONFIDENTIAL\\Zodiac\\ChatDNMX\\logs\\username_log.txt'
# Ensure the directory exists, if not, create it
os.makedirs(os.path.dirname(username_file_path), exist_ok=True)
# Ensure the file exists, if not, create it
if not os.path.exists(username_file_path):
with open(username_file_path, "w") as u:
# Write an empty string to create the file
u.write("")
# Define the file path
password_file_path = 'D:\\donotopenthisfolder\\Arinjay\\CONFIDENTIAL\\Zodiac\\ChatDNMX\\logs\\password_log.txt'
# Ensure the directory exists, if not, create it
os.makedirs(os.path.dirname(password_file_path), exist_ok=True)
# Ensure the file exists, if not, create it
if not os.path.exists(password_file_path):
with open(password_file_path, "w") as u:
# Write an empty string to create the file
u.write("")
# Define the file path
email_file_path = 'D:\\donotopenthisfolder\\Arinjay\\CONFIDENTIAL\\Zodiac\\ChatDNMX\\logs\\email_log.txt'
# Ensure the directory exists, if not, create it
os.makedirs(os.path.dirname(email_file_path), exist_ok=True)
# Ensure the file exists, if not, create it
if not os.path.exists(email_file_path):
with open(email_file_path, "w") as u:
# Write an empty string to create the file
u.write("")
# Define the file path
exit_file_path = 'D:\\donotopenthisfolder\\Arinjay\\CONFIDENTIAL\\Zodiac\\ChatDNMX\\logs\\exit_log.txt'
# Ensure the directory exists, if not, create it
os.makedirs(os.path.dirname(exit_file_path), exist_ok=True)
# Ensure the file exists, if not, create it
if not os.path.exists(exit_file_path):
with open(exit_file_path, "w") as u:
# Write an empty string to create the file
u.write("")
# Prompt the user to enter their credentials
my_list = ["logs/username_log.txt",
"logs/password_log.txt",
"logs/email_log.txt",
"logs/exit_log.txt"]
if len(my_list) == 0:
None
else:
return
username = input("Enter username: ")
def validate_username(username):
# Validate username length and characters
return 1 <= len(username) <= 64 and username.isalnum() and username.islower()
validate_username(username)
email = input("Enter email: ")
def validate_email(email):
# Validate email format using a regular expression
email_pattern = re.compile(r'^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$')
return bool(email_pattern.match(email))
validate_email(email)
password = input("Enter password: ")
def validate_password(password):
# Validate password length and complexity
return 8 <= len(password) <= 20 and password.isdigit()
validate_password(password)
confirm_password = input("Confirm password: ")
def create_log_files():
try:
# Directory
directory = "logs"
# Parent Directory path
parent_dir = ""
# Path
path = os.path.join(parent_dir, directory)
# Create the directory
# 'logs' in
# 'C://' ("C" Directory)
os.makedirs(path, exist_ok=True)
# Username
load_dotenv()
user_Key = os.getenv("user_Key")
user_Message = username
encrypted_username = encrypt(user_Message, user_Key)
# Password
load_dotenv()
pass_Key = os.getenv("pass_Key")
pass_Message = password
encrypted_password = encrypt(pass_Message, pass_Key)
# Email
load_dotenv()
email_Key = os.getenv("email_Key")
email_Message = email
encrypted_email = encrypt(email_Message, email_Key)
with open("logs/username_log.txt", "wb") as file:
file.write(encrypted_username)
with open("logs/password_log.txt", "wb") as file:
file.write(encrypted_password)
with open("logs/email_log.txt", "wb") as file:
file.write(encrypted_email)
with open("logs/exit_log.txt", "w+") as file:
file.write("Singed Up/Signed In successfully!")
except Exception:
print("Error: Unable to create log files.")
create_log_files() # Creates log files if they don't exist
def user_sign_up_def():
try:
# Your validation and account creation logic here
def validation():
# Validate username
if not validate_username(username):
raise ValueError("Invalid username. Username must be 1-64 characters long. Please try again by re-opening the app.")
# Validate email
if not validate_email(email):
raise ValueError("Invalid email address. Please try again by re-opening the app.")
# Validate password
if not validate_password(password):
raise ValueError(
"Invalid password. Password must be 8-20 characters long. Please try again by re-opening the app.")
if password != confirm_password:
raise ValueError("Passwords do not match. Please try again by re-opening the app.")
validation()
print("Success", "Account successfully created.")
except ValueError as ve:
print("Error", f"Error: {ve}")
user_sign_up_def()
authentication()
username_file_path = os.path.join(os.path.dirname(__file__), "logs", "username_log.txt")
password_file_path = os.path.join(os.path.dirname(__file__), "logs", "password_log.txt")
email_file_path = os.path.join(os.path.dirname(__file__), "logs", "email_log.txt")
exit_file_path = os.path.join(os.path.dirname(__file__), "logs", "exit_log.txt")
with open(username_file_path, "r") as u:
username = u.read()
with open(password_file_path, "r") as p:
password = p.read()
with open(email_file_path, "r") as e:
email = e.read()
with open(exit_file_path, "r") as en:
end = en.read()
# Greeting :-
I = str(
input(
"ChatDNMX -> Hello! Welcome to ChatDNMX* Press 'ENTER' key on your keyboard to continue * "
)
)
# Introduction :-
N = str(
input("ChatDNMX -> I am ChatDNMX. * Press 'ENTER' key on your keyboard to continue * ")
)
T = str(
input(
"ChatDNMX -> An A.I. created by my founder which is Arinjay Kumar. * Press 'ENTER' key on your keyboard to "
"continue * "
)
)
R = str(
input(
"ChatDNMX -> I would be happy if you like to chat with me! * Press 'ENTER' key on your keyboard to "
"continue *"
" "
)
)
O = str(
input(
"ChatDNMX -> I am meant to only chat with you. * Press 'ENTER' key on your keyboard to continue * "
)
)
D = str(
input(
"ChatDNMX -> I have restrictions. * Press 'ENTER' key on your keyboard to continue * "
)
)
U = str(
input(
"ChatDNMX -> * Important Note * :- * Press 'ENTER' key on your keyboard to continue * "
)
)
C = str(
input(
"ChatDNMX -> 1.) When asking any questions, do not use any type of punctuation marks when writing. * Press "
"'ENTER' key on your keyboard to continue * "
)
)
E = str(
input(
"ChatDNMX -> 2.) Press enter to continue. * Press"
"'ENTER' key on your keyboard to continue * "
)
)
# Chatting :-
def wishMe():
try:
hour = int(datetime.datetime.now().hour)
if 0 <= hour < 12:
print("ChatDNMX -> Good Morning!")
elif 12 <= hour < 18:
print("ChatDNMX -> Good Afternoon!")
else:
print("ChatDNMX -> Good Evening!")
except Exception:
print("ChatDNMX -> Some problem occurred!")
wishMe()
wishMe()
# Stage - 1 :-
userinput1 = input("ChatDNMX -> Can I ask your name? : ")
def chat1():
try:
if "YES" in userinput1:
userinput2 = input("ChatDNMX -> Ok. Write a name for yourself now : ")
try:
if userinput2 == "Arinjay":
print("ChatDNMX -> Your name is same as our founder i.e. Arinjay Kumar")
elif userinput2 == "":
print("ChatDNMX -> Please write your preffered username:")
elif userinput2 == "arinjay":
print("ChatDNMX -> Your name is same as our founder i.e. Arinjay Kumar")
elif userinput2 == "Arinjay Kumar":
print("ChatDNMX -> Your name is same as our founder i.e. Arinjay Kumar")
elif userinput2 == "arinjay kumar":
print("ChatDNMX -> Your name is same as our founder i.e. Arinjay Kumar")
elif userinput2 == "Arinjay kumar":
print("ChatDNMX -> Your name is same as our founder i.e. Arinjay Kumar")
elif userinput2 == "arinjay Kumar":
print("ChatDNMX -> Your name is same as our founder i.e. Arinjay Kumar")
except Exception:
print("ChatDNMX -> Some problem occurred!")
chat1()
print("ChatDNMX -> Hello, ", userinput2)
elif "yes" in userinput1:
userinput2 = input("ChatDNMX -> Ok. Please enter your name : ")
try:
if userinput2 == "Arinjay":
print("ChatDNMX -> Your name is same as our founder i.e. Arinjay Kumar")
elif userinput2 == "":
print("ChatDNMX -> Please write your preffered username:")
elif userinput2 == "arinjay":
print("ChatDNMX -> Your name is same as our founder i.e. Arinjay Kumar")
elif userinput2 == "Arinjay Kumar":
print("ChatDNMX -> Your name is same as our founder i.e. Arinjay Kumar")
elif userinput2 == "arinjay kumar":
print("ChatDNMX -> Your name is same as our founder i.e. Arinjay Kumar")
elif userinput2 == "Arinjay kumar":
print("ChatDNMX -> Your name is same as our founder i.e. Arinjay Kumar")
elif userinput2 == "arinjay Kumar":
print("ChatDNMX -> Your name is same as our founder i.e. Arinjay Kumar")
except Exception:
print("ChatDNMX -> Some problem occurred!")
chat1()
print("ChatDNMX -> Hello, ", userinput2)
elif "Yes" in userinput1:
userinput2 = input("ChatDNMX -> Ok. Please enter your name : ")
try:
if userinput2 == "Arinjay":
print("ChatDNMX -> Your name is same as our founder i.e. Arinjay Kumar")
elif userinput2 == "":
print("ChatDNMX -> Please write your preffered username:")
elif userinput2 == "arinjay":
print("ChatDNMX -> Your name is same as our founder i.e. Arinjay Kumar")
elif userinput2 == "Arinjay Kumar":
print("ChatDNMX -> Your name is same as our founder i.e. Arinjay Kumar")
elif userinput2 == "arinjay kumar":
print("ChatDNMX -> Your name is same as our founder i.e. Arinjay Kumar")
elif userinput2 == "Arinjay kumar":
print("ChatDNMX -> Your name is same as our founder i.e. Arinjay Kumar")
elif userinput2 == "arinjay Kumar":
print("ChatDNMX -> Your name is same as our founder i.e. Arinjay Kumar")
except Exception:
print("ChatDNMX -> Some problem occurred!")
chat1()
print("ChatDNMX -> Hello, ", userinput2)
elif "yEs" in userinput1:
userinput2 = input("ChatDNMX -> Ok. Please enter your name : ")
try:
if userinput2 == "Arinjay":
print("ChatDNMX -> Your name is same as our founder i.e. Arinjay Kumar")
elif userinput2 == "":
print("ChatDNMX -> Please write your preffered username:")
elif userinput2 == "arinjay":
print("ChatDNMX -> Your name is same as our founder i.e. Arinjay Kumar")
elif userinput2 == "Arinjay Kumar":
print("ChatDNMX -> Your name is same as our founder i.e. Arinjay Kumar")
elif userinput2 == "arinjay kumar":
print("ChatDNMX -> Your name is same as our founder i.e. Arinjay Kumar")
elif userinput2 == "Arinjay kumar":
print("ChatDNMX -> Your name is same as our founder i.e. Arinjay Kumar")
elif userinput2 == "arinjay Kumar":
print("ChatDNMX -> Your name is same as our founder i.e. Arinjay Kumar")
except Exception:
print("ChatDNMX -> Some problem occurred!")
chat1()
print("ChatDNMX -> Hello, ", userinput2)
elif "yeS" in userinput1:
userinput2 = input("ChatDNMX -> Ok. Please enter your name : ")
try:
if userinput2 == "Arinjay":
print("ChatDNMX -> Your name is same as our founder i.e. Arinjay Kumar")
elif userinput2 == "":
print("ChatDNMX -> Please write your preffered username:")
elif userinput2 == "arinjay":
print("ChatDNMX -> Your name is same as our founder i.e. Arinjay Kumar")
elif userinput2 == "Arinjay Kumar":
print("ChatDNMX -> Your name is same as our founder i.e. Arinjay Kumar")
elif userinput2 == "arinjay kumar":
print("ChatDNMX -> Your name is same as our founder i.e. Arinjay Kumar")
elif userinput2 == "Arinjay kumar":
print("ChatDNMX -> Your name is same as our founder i.e. Arinjay Kumar")
elif userinput2 == "arinjay Kumar":
print("ChatDNMX -> Your name is same as our founder i.e. Arinjay Kumar")
except Exception:
print("ChatDNMX -> Some problem occurred!")
chat1()
print("ChatDNMX -> Hello, ", userinput2)
elif "YEs" in userinput1:
userinput2 = input("ChatDNMX -> Ok. Please enter your name : ")
try:
if userinput2 == "Arinjay":
print("ChatDNMX -> Your name is same as our founder i.e. Arinjay Kumar")
elif userinput2 == "":
print("ChatDNMX -> Please write your preffered username:")
elif userinput2 == "arinjay":
print("ChatDNMX -> Your name is same as our founder i.e. Arinjay Kumar")
elif userinput2 == "Arinjay Kumar":
print("ChatDNMX -> Your name is same as our founder i.e. Arinjay Kumar")
elif userinput2 == "arinjay kumar":
print("ChatDNMX -> Your name is same as our founder i.e. Arinjay Kumar")
elif userinput2 == "Arinjay kumar":
print("ChatDNMX -> Your name is same as our founder i.e. Arinjay Kumar")
elif userinput2 == "arinjay Kumar":
print("ChatDNMX -> Your name is same as our founder i.e. Arinjay Kumar")
except Exception:
print("ChatDNMX -> Some problem occurred!")
chat1()
print("ChatDNMX -> Hello, ", userinput2)
elif "yES" in userinput1:
userinput2 = input("ChatDNMX -> Ok. Please enter your name : ")
try:
if userinput2 == "Arinjay":
print("ChatDNMX -> Your name is same as our founder i.e. Arinjay Kumar")
elif userinput2 == "":
print("ChatDNMX -> Please write your preffered username:")
elif userinput2 == "arinjay":
print("ChatDNMX -> Your name is same as our founder i.e. Arinjay Kumar")
elif userinput2 == "Arinjay Kumar":
print("ChatDNMX -> Your name is same as our founder i.e. Arinjay Kumar")
elif userinput2 == "arinjay kumar":
print("ChatDNMX -> Your name is same as our founder i.e. Arinjay Kumar")
elif userinput2 == "Arinjay kumar":
print("ChatDNMX -> Your name is same as our founder i.e. Arinjay Kumar")
elif userinput2 == "arinjay Kumar":
print("ChatDNMX -> Your name is same as our founder i.e. Arinjay Kumar")
except Exception:
print("ChatDNMX -> Some problem occurred!")
chat1()
print("ChatDNMX -> Hello, ", userinput2)
elif "NO" in userinput1:
input(
"ChatDNMX -> Ok. Let's move on then. * Press 'ENTER' key on your keyboard to continue * "
)
elif "no" in userinput1:
input(
"ChatDNMX -> Ok. Let's move on then. * Press 'ENTER' key on your keyboard to continue * "
)
elif "No" in userinput1:
input(
"ChatDNMX -> Ok. Let's move on then. * Press 'ENTER' key on your keyboard to continue * "
)
elif "nO" in userinput1:
input(
"ChatDNMX -> Ok. Let's move on then. * Press 'ENTER' key on your keyboard to continue * "
)
else:
input(
"ChatDNMX -> Ok. That's not what I expected. I am assuming that you want to be anonymous. * Press "
"'ENTER' key on your keyboard to continue"
"* "
)
except Exception:
print("ChatDNMX -> Some problem occurred!")
chat1()
chat1()
# Stage - 2 (* Important *) :-
chat_List = [
"1. OpenAI's ChatGPT 3.5",
"2. Google's Gemini 1.5 Pro Experimental",
"3. Google's Gemma on Groq",
"4. Meta's Llama 3 on Groq",
"5. Anthropic's Claude 3 Opus",
"6. Mistral's Mixtral AI",
"7. Mistral's Mixtral AI on Groq",
"8. Stability XL",
"9. Or continue with ChatDNMX..."
]
print("Please write down the the name of the AI model which you want to use(The name of the AI model should be excatly written(no change to punctuation, capitilization, spaces, etc.))"
"or write the number of the option to select that specific AI.")
print(chat_List)
userinput3 = input("You -> ")
def chat_List_Def():
if userinput3 == "OpenAI's ChatGPT 3.5" or userinput3 == 1:
chatgpt()
elif userinput3 == "Google's Gemini 1.5 Pro Experimental" or userinput3 == 2:
gemini()
elif userinput3 == "Google's Gemma on Groq" or userinput3 == 3:
gemma()
elif userinput3 == "Meta's Llama 3 on Groq" or userinput3 == 4:
llama()
elif userinput3 == "Anthropic's Claude 3 Opus" or userinput3 == 5:
claude()
elif userinput3 == "Mistral's Mixtral AI" or userinput3 == 6:
mixtral()
elif userinput3 == "Mistral's Mixtral AI on Groq" or userinput3 == 7:
mixtral_Groq()
elif userinput3 == "Stability XL" or userinput3 == 8:
stability()
elif userinput3 == "Or continue with ChatDNMX..." or userinput3 == 9:
chat2()
else:
print("ChatDNMX -> That is not what I expected!")
print("ChatDNMX -> Please try again by restarting the application.")
sys.exit()
chat_List_Def()
def chatgpt():
def chat():
print("Warning: ChatGPT can make mistakes. Check important info.")
def check_API_Given_In_Past():
if len("logs/chatgpt.txt") == 0:
chatgpt_1()
else:
chatgpt_2()
check_API_Given_In_Past()
def chatgpt_1():
input = input("Please enter your ChatGPT API Key from https://platform.openai.com/api-keys -> ")
location = open("logs/chatgpt.txt", "wb")
with open("logs/chatgpt.txt", "wb") as file:
file.write(encrypted_chatgpt)
load_dotenv()
save_Api_Key = os.getenv("chatgpt_key")
user_Message = location.read()
location.close()
encrypted_chatgpt = encrypt(user_Message, save_Api_Key)
load_dotenv()
OpenAI.api_key = os.getenv("OpenAI.api_key")
maininput = input("You -> ")
client = OpenAI()
# Choose the OpenAI's ChatGPT AI Model
ai_model = input("Please choose the OpenAI's ChatGPT AI model you want to use(The name of the AI model should be excatly written(no change to punctuation, capitilization, spaces, etc.), from here: https://platform.openai.com/docs/models/overview) -> ")
# Custom Instructions
custom_instruction = input("Custom Instructions(Press the 'ENTER' key to skip) -> ")
completion = client.chat.completions.create(
model=ai_model,
messages=[
{"role": "system", "content": custom_instruction}
],
temperature=1,
max_tokens=256,
top_p=1,
frequency_penalty=0,
presence_penalty=0
)
print("ChatGPT -> ", completion.choices[0].message)
def chatgpt_2():
api_location = open("logs/chatgpt.txt", "r+")
OpenAI.api_key = api_location
api_location.close()
maininput = input("You -> ")
client = OpenAI()
completion = client.chat.completions.create(
model="gpt-4o-mini",
messages=[
{"role": "system", "content": "You are a poetic assistant, skilled in explaining complex programming concepts with creative flair."}
],
temperature=1,
max_tokens=256,
top_p=1,
frequency_penalty=0,
presence_penalty=0
)
print("ChatGPT -> ", completion.choices[0].message)
def loop():
if chat():
chat()
loop()
else:
chat()
loop()
loop()
def gemini():
def chat():
def check_API_Given_In_Past():
if len("logs/gemini.txt") == 0:
gemini_1()
else:
gemini_2()
check_API_Given_In_Past()
def gemini_1():
maininput = input("Please enter your Gemini API Key from https://aistudio.google.com/app/prompts/new_chat -> ")
input = input("You -> ")
print("""
Gemini:
I am still under development, and there are many things that I do not know. If I don't know the answer to a question, I will say so honestly. I will also try to provide some context or resources that may help you find the answer yourself. For example, I might say something like "I'm not sure about that, but I can find out for you. Can you give me more information about what you're looking for?" or "I'm not familiar with that topic, but I can provide you with some links to relevant websites."
I am always learning new things, and I am committed to providing accurate and helpful information to my users. If you ever notice that I have made a mistake, please feel free to let me know. I appreciate your feedback and will use it to improve my performance.
""")
"""
Install the Google AI Python SDK
At the command line, only need to run once to install the package via pip:
$ pip install google-generativeai
See the getting started guide for more information:
https://ai.google.dev/gemini-api/docs/get-started/python
"""
location = open("logs/gemini.txt", "wb")
with open("logs/gemini.txt", "wb") as file:
file.write(encrypted_gemini)
load_dotenv()
save_Api_Key = os.getenv("gemini_key")
user_Message = location.read()
location.close()
encrypted_gemini = encrypt(user_Message, save_Api_Key)
load_dotenv()
genai.configure(api_key=os.environ[os.getenv("api_key")])
# Create the model
# Set up the model
# See https://ai.google.dev/api/python/google/generativeai/GenerativeModel
generation_config = {
"temperature": 1,
"top_p": 0.95,
"top_k": 64,
"max_output_tokens": 8192,
"response_mime_type": "text/plain",
}
safety_settings = [
{
"category": "HARM_CATEGORY_HARASSMENT",
"threshold": "BLOCK_MEDIUM_AND_ABOVE",
},
{
"category": "HARM_CATEGORY_HATE_SPEECH",
"threshold": "BLOCK_MEDIUM_AND_ABOVE",
},
{
"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
"threshold": "BLOCK_MEDIUM_AND_ABOVE",
},
{
"category": "HARM_CATEGORY_DANGEROUS_CONTENT",
"threshold": "BLOCK_MEDIUM_AND_ABOVE",
},
]
model = genai.GenerativeModel(
model_name="gemini-1.5-pro-exp-0801",
safety_settings=safety_settings,
generation_config=generation_config,
# safety_settings = Adjust safety settings
# See https://ai.google.dev/gemini-api/docs/safety-settings
)
chat_session = model.start_chat(
history=[
]
)
response = chat_session.send_message(input)
print("Gemini -> ", response.text)
# print(chat_session.history)
def gemini_2():
input = input("You -> ")
print("""
I am still under development, and there are many things that I do not know. If I don't know the answer to a question, I will say so honestly. I will also try to provide some context or resources that may help you find the answer yourself. For example, I might say something like "I'm not sure about that, but I can find out for you. Can you give me more information about what you're looking for?" or "I'm not familiar with that topic, but I can provide you with some links to relevant websites."
I am always learning new things, and I am committed to providing accurate and helpful information to my users. If you ever notice that I have made a mistake, please feel free to let me know. I appreciate your feedback and will use it to improve my performance.
""")
"""
Install the Google AI Python SDK
At the command line, only need to run once to install the package via pip:
$ pip install google-generativeai
See the getting started guide for more information:
https://ai.google.dev/gemini-api/docs/get-started/python
"""
api_location = open("logs/gemini.txt", "r+")
genai.configure(api_key=os.environ[api_location])
api_location.close()
# Create the model
# Set up the model
# See https://ai.google.dev/api/python/google/generativeai/GenerativeModel
generation_config = {
"temperature": 1,
"top_p": 0.95,
"top_k": 64,
"max_output_tokens": 8192,
"response_mime_type": "text/plain",
}
safety_settings = [
{
"category": "HARM_CATEGORY_HARASSMENT",
"threshold": "BLOCK_MEDIUM_AND_ABOVE",
},
{
"category": "HARM_CATEGORY_HATE_SPEECH",
"threshold": "BLOCK_MEDIUM_AND_ABOVE",
},
{
"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
"threshold": "BLOCK_MEDIUM_AND_ABOVE",
},
{
"category": "HARM_CATEGORY_DANGEROUS_CONTENT",
"threshold": "BLOCK_MEDIUM_AND_ABOVE",
},
]
model = genai.GenerativeModel(
model_name="gemini-1.5-pro-exp-0801",
safety_settings=safety_settings,
generation_config=generation_config,
)
chat_session = model.start_chat(
history=[
]
)
response = chat_session.send_message(input)
print("Gemini -> ", response.text)
# print(chat_session.history)
def loop():
if chat():
chat()
loop()
else:
chat()
loop()
loop()
def gemma():
def chat():
def check_API_Given_In_Past():
if len("logs/gemma.txt") == 0:
gemma_1()
else:
gemma_2()
check_API_Given_In_Past()
def gemma_1():
maininput = "Please enter your Groq API Key from https://console.groq.com/keys -> "
input = input("You -> ")
location = open("logs/gemma.txt", "wb")
with open("logs/gemma.txt", "wb") as file:
file.write(encrypted_gemma)
load_dotenv()
save_Api_Key = os.getenv("gemma_key")
user_Message = location.read()
location.close()
encrypted_gemma = encrypt(user_Message, save_Api_Key)
load_dotenv()
client = Groq(
gemma_api_key=os.environ.get(os.getenv("gemma_api_key")),
)
chat_completion = client.chat.completions.create(
model="gemma-7b-it",
messages=[
{
"role": "user",
"content": input
}
],
temperature=1,
max_tokens=1024,
top_p=1,
stream=True,
stop=None,
)
for chunk in chat_completion:
print("Gemma -> ", chunk.choices[0].delta.content or "", end="")
def gemma_2():
input = input("You -> ")
api_location = open("logs/gemma.txt", "r+")
client = Groq(
gemma_api_key=os.environ.get(api_location),
)
api_location.close()
chat_completion = client.chat.completions.create(
model="gemma-7b-it",
messages=[
{
"role": "user",
"content": input
}
],
temperature=1,
max_tokens=1024,
top_p=1,
stream=True,
stop=None,
)
for chunk in chat_completion:
print("Gemma -> ", chunk.choices[0].delta.content or "", end="")
def loop():
if chat():
chat()
loop()
else:
chat()
loop()
loop()
def llama():
def chat():
def check_API_Given_In_Past():
if len("logs/llama.txt") == 0:
llama_1()
else:
llama_2()
check_API_Given_In_Past()
def llama_1():
maininput = "Please enter your Groq API Key from https://console.groq.com/keys -> "
input = input("You -> ")
location = open("logs/llama.txt", "wb")
with open("logs/llama.txt", "wb") as file:
file.write(encrypted_llama)
load_dotenv()
save_Api_Key = os.getenv("llama_key")
user_Message = location.read()
location.close()
encrypted_llama = encrypt(user_Message, save_Api_Key)
load_dotenv()
client = Groq(
llama_api_key=os.environ.get(os.getenv("llama_api_key")),
)
completion = client.chat.completions.create(
model="llama3-70b-8192",
messages=[
{