Spaces:
Runtime error
Runtime error
File size: 44,090 Bytes
2be7027 5b4883b a6e9dcf 2be7027 5878e59 2be7027 ca1ec44 ead2c56 2be7027 4e3506b 2be7027 5b4883b ead2c56 5b4883b de1e889 2be7027 de1e889 2be7027 4e3506b ef77fe1 2be7027 de1e889 2be7027 12ebd07 2be7027 c68742b c2662fd c68742b c2662fd c68742b a6e9dcf 2be7027 a6e9dcf 2be7027 5b4883b 2be7027 d5e7c71 2be7027 d5e7c71 2be7027 de1e889 2be7027 22fbfd8 2be7027 22fbfd8 2be7027 22fbfd8 2be7027 ef77fe1 d5e7c71 ef77fe1 5b26a24 2be7027 4e3506b 2be7027 de1e889 2be7027 12ebd07 2be7027 a6e9dcf a2fc860 24ad60b a2fc860 24ad60b a2fc860 24ad60b a2fc860 24ad60b a2fc860 24ad60b a2fc860 24ad60b a2fc860 24ad60b a2fc860 24ad60b a2fc860 24ad60b a2fc860 24ad60b a2fc860 24ad60b a2fc860 a6e9dcf d5e7c71 a6e9dcf f9fbbeb d5e7c71 f9fbbeb d5e7c71 f9fbbeb 2be7027 a6e9dcf 2be7027 4718607 d5e7c71 2be7027 de1e889 2be7027 8bccb40 ef77fe1 4e3506b 2be7027 12ebd07 2be7027 a6e9dcf 5878e59 a6e9dcf 3fc87fd 9fa8e9b 3fc87fd 9fa8e9b 3fc87fd 9fa8e9b 3fc87fd 3c3e4d8 d30415d 3c3e4d8 3fc87fd 9fa8e9b 3fc87fd a6e9dcf 2be7027 2937c86 d5e7c71 2be7027 d5e7c71 2be7027 de1e889 2be7027 5b4883b d5bf3db cafedbd 6189b61 e1dc908 d797f64 f7cb4e5 2be7027 e3d0541 |
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 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 |
import chainlit as cl
from gradio_client import Client
from openai import OpenAI
from groq import Groq
import requests
from chainlit.input_widget import Select, Slider
import os
import cohere
from huggingface_hub import InferenceClient
hf_token = os.environ.get("HF_TOKEN")
hf_token_llama_3_1 = os.environ.get('HF_TOKEN_FOR_31')
openai_api_key = os.environ.get('OPENAI_API_KEY')
groq_api_key = os.environ.get('GROQ_API_KEY')
cohere_api_key = os.environ.get('COHERE_API_KEY')
hf_text_client = Client("Artin2009/text-generation", hf_token=hf_token)
# hf_image_client = Client('Artin2009/image-generation')
openai_client = OpenAI(api_key=openai_api_key)
groq_client = Groq(api_key=groq_api_key)
co = cohere.Client(
api_key=cohere_api_key,
)
# API_URL = "https://api-inference.huggingface.co/models/PartAI/TookaBERT-Large"
# headers = {"Authorization": f"Bearer {hf_token}"}
# def query(payload):
# response = requests.post(API_URL, headers=headers, json=payload)
# return response.json()
@cl.set_chat_profiles
async def chat_profile():
return [
cl.ChatProfile(
name="None",
markdown_description="None",
),
cl.ChatProfile(
name="neural-brain-AI",
markdown_description="The main model of neural brain",
),
cl.ChatProfile(
name="Dorna-AI",
markdown_description="One of the open-sourced models that neural brain team fine-tuned",
),
# cl.ChatProfile(
# name='Image-Generation',
# markdown_description='Our image generation model, has a performance like midjourney',
# ),
cl.ChatProfile(
name="gpt4-o-mini",
markdown_description="The best state of the art openai model",
),
cl.ChatProfile(
name="GPT-4",
markdown_description="OpenAI's GPT-4 model",
),
cl.ChatProfile(
name="gpt-3.5-turbo",
markdown_description="OpenAI's GPT-3.5 Turbo model",
),
# cl.ChatProfile(
# name="GPT-3.5-turbo-0125",
# markdown_description="OpenAI's GPT-3.5 Turbo 0125 model",
# ),
cl.ChatProfile(
name="gpt-3.5-turbo-1106",
markdown_description="OpenAI's GPT-3.5 Turbo 1106 model",
),
# cl.ChatProfile(
# name="davinci-002",
# markdown_description="OpenAI's Davinci-002 model",
# ),
cl.ChatProfile(
name="TTS",
markdown_description="OpenAI's Text-to-Speech model",
),
cl.ChatProfile(
name="Qwen2-57B",
markdown_description="Qwen second generation model with 57B parameters",
),
cl.ChatProfile(
name="Qwen2-7B",
markdown_description="Qwen second generation model with 7B parameters",
),
cl.ChatProfile(
name="Qwen2-1.5B",
markdown_description="Qwen second generation model with 1.5B parameters",
),
cl.ChatProfile(
name="Qwen2-0.5B",
markdown_description="Qwen second generation model with 0.5B parameters",
),
cl.ChatProfile(
name="Qwen1.5-110B",
markdown_description="Qwen first generation improved model with 110B parameters",
),
cl.ChatProfile(
name="Qwen1.5-72B",
markdown_description="Qwen first generation improved model with 72B parameters",
),
cl.ChatProfile(
name="Qwen1.5-32B",
markdown_description="Qwen first generation improved model with 32B parameters",
),
cl.ChatProfile(
name="Qwen1.5-2.7B",
markdown_description="Qwen first generation improved model with 2.7B parameters",
),
cl.ChatProfile(
name="Qwen-72B",
markdown_description="Qwen first generation model with 72B parameters",
),
cl.ChatProfile(
name="Qwen-14B",
markdown_description="Qwen first generation model with 14B parameters",
),
cl.ChatProfile(
name="Qwen-7B",
markdown_description="Qwen first generation model with 7B parameters",
),
cl.ChatProfile(
name="Llama-3.1-405B",
markdown_description="Meta Open Source Model Llama with 405B parameters",
),
cl.ChatProfile(
name="Llama-3.1-70B",
markdown_description="Meta Open Source Model Llama with 70B parameters",
),
cl.ChatProfile(
name="Llama-3.1-8B",
markdown_description="Meta Open Source Model Llama with 8B parameters",
),
cl.ChatProfile(
name="Llama-3-70B",
markdown_description="Meta Open Source model Llama-3 with 70B parameters",
),
cl.ChatProfile(
name='Aya-23B',
markdown_description='Cohere open sourced AI model with 23B parameters'
),
cl.ChatProfile(
name="Llama-3-8B",
markdown_description="Meta Open Source model Llama-2 with 7B parameters",
),
cl.ChatProfile(
name = "gemma2-9B",
markdown_description = 'Google Generation 2 Open Source LLM with 9B parameters'
),
cl.ChatProfile(
name = "gemma-7B",
markdown_description = 'Google Generation 1 Open Source LLM with 7B parameters'
),
cl.ChatProfile(
name="zephyr-7B",
markdown_description="Open Source model Zephyr with 7B parameters",
),
cl.ChatProfile(
name='mistral-7B',
markdown_description = 'mistral open source LLM with 7B parameters'
),
# cl.ChatProfile(
# name="Toka-353M",
# markdown_description="PartAI Open Source model Toka with 353M parameters",
# )
]
@cl.on_chat_start
async def on_chat_start():
chat_profile = cl.user_session.get("chat_profile")
if not chat_profile:
await cl.Message(
content='please choose a model to start'
).send()
if chat_profile == 'neural-brain-AI':
await cl.ChatSettings(
[
Select(
id="NB-Model",
label="NeuralBrain - Models",
values=["Neural Brain AI"],
initial_index=0,
)
]
).send()
await cl.Message(
content="Hello, I am the main model of neural brain team, i am an instance of ChatGPT-4, This team finetuned me and i am ready to help you"
).send()
if chat_profile == 'Dorna-AI':
await cl.ChatSettings(
[
Select(
id="param_3",
label="Parameter 3",
values=["512"], # Only one selectable value
initial_index=0,
tooltip="Config parameter 3 (e.g., max tokens)",
),
Select(
id="param_4",
label="Parameter 4",
values=["0.7"], # Only one selectable value
initial_index=0,
tooltip="Config parameter 4 (e.g., temperature)",
),
Select(
id="param_5",
label="Parameter 5",
values=["0.95"], # Only one selectable value
initial_index=0,
tooltip="Config parameter 5 (e.g., top_p)",
),
Select(
id="api_name",
label="API Name",
values=["/chat"],
initial_index=0,
),
]
).send()
await cl.Message(
content='my name is Dorna, Your AI Assistant designed by neural nexus team. i was made by Artin Daneshvar and Sadra Noadoust, 2 iranian students!'
).send()
if chat_profile == 'gpt4-o-mini':
await cl.ChatSettings(
[
Select(
id="OpenAI-Model",
label="OpenAI - Model",
values=["gpt4-o-mini"],
initial_index=0,
),
Slider(
id="Temperature",
label="Model Temperature",
initial=0.7,
min=0,
max=1,
step=0.1,
),
]
).send()
await cl.Message(
content="Im one of the best models openai have released and i am configured by two iranian boys to help you."
).send()
# if chat_profile == 'Image-Generation':
# image = cl.Image(path='cat.png', name="result", display="inline")
# await cl.Message(
# content="I can make high quality & resoloution images for you, This is an example of what i can do!",
# elements=[image],
# ).send()
if chat_profile == 'GPT-4':
await cl.ChatSettings(
[
Select(
id="OpenAI-Model",
label="OpenAI - Model",
values=["gpt-4"],
initial_index=0,
),
Slider(
id="Temperature",
label="Model Temperature",
initial=0.7,
min=0,
max=1,
step=0.1,
),
]
).send()
await cl.Message(
content="Im OpenAI's latest and biggest model. i was configured by Artin Daneshvar and Sadra Noadoust, 2 iranian students to help you, how can i assist you today ? "
).send()
if chat_profile == 'gpt-3.5-turbo':
await cl.ChatSettings(
[
Select(
id="OpenAI-Model",
label="OpenAI - Model",
values=["gpt-3.5-turbo"],
initial_index=0,
),
Slider(
id="Temperature",
label="Model Temperature",
initial=0.7,
min=0,
max=1,
step=0.1,
),
]
).send()
await cl.Message(
content="Im one of the OpenAI's models. one of the best models. i was configured by Artin Daneshvar and Sadra Noadoust, 2 iranian students to help you, how can i assist you today ? "
).send()
# if chat_profile == 'GPT-3.5-turbo-0125':
# await cl.ChatSettings(
# [
# Select(
# id="OpenAI-Model",
# label="OpenAI - Model",
# values=["gpt-3.5-turbo-0125"],
# initial_index=0,
# ),
# Slider(
# id="Temperature",
# label="Model Temperature",
# initial=0.7,
# min=0,
# max=1,
# step=0.1,
# ),
# ]
# ).send()
# await cl.Message(
# content="Im one of the OpenAI's models. one of the best models. i was configured by Artin Daneshvar and Sadra Noadoust, 2 iranian students to help you, how can i assist you today ? "
# ).send()
if chat_profile == 'gpt-3.5-turbo-1106':
await cl.ChatSettings(
[
Select(
id="OpenAI-Model",
label="OpenAI - Model",
values=["gpt-3.5-turbo-1106"],
initial_index=0,
),
Slider(
id="Temperature",
label="Model Temperature",
initial=0.7,
min=0,
max=1,
step=0.1,
),
]
).send()
await cl.Message(
content="Im one of the OpenAI's models. one of the best models. i was configured by Artin Daneshvar and Sadra Noadoust, 2 iranian students to help you, how can i assist you today ? "
).send()
# if chat_profile == 'davinci-002':
# await cl.ChatSettings(
# [
# Select(
# id="OpenAI-Model",
# label="OpenAI - Model",
# values=["davinci-002"],
# initial_index=0,
# ),
# Slider(
# id="Temperature",
# label="Model Temperature",
# initial=0.7,
# min=0,
# max=1,
# step=0.1,
# ),
# ]
# ).send()
# await cl.Message(
# content="Im one of the OpenAI's models. i was configured by Artin Daneshvar and Sadra Noadoust, 2 iranian students to help you, how can i assist you today ? "
# ).send()
if chat_profile == 'TTS':
await cl.Message(
content="Im TTS. of the best models OpenAI ever created. i can convert text to speech! . i was configured by Artin Daneshvar and Sadra Noadoust, 2 iranian students to help you, how can i assist you today ? "
).send()
if chat_profile == 'Qwen2-57B':
await cl.ChatSettings(
[
Select(
id="Qwen-Model",
label="Qwen - Model",
values=["Qwen2-57B"],
initial_index=0,
),
Slider(
id="Temperature",
label="Model Temperature",
initial=0.7,
min=0,
max=1,
step=0.1,
),
]
).send()
await cl.Message(
content='Im Qwens second generation second large model and i am configured by two iranian boys Artin Daneshvar and Sadra Noadoust to help you out!',
).send()
if chat_profile == 'Qwen2-7B':
await cl.ChatSettings(
[
Select(
id="Qwen-Model",
label="Qwen - Model",
values=["Qwen2-7B"],
initial_index=0,
),
Slider(
id="Temperature",
label="Model Temperature",
initial=0.7,
min=0,
max=1,
step=0.1,
),
]
).send()
await cl.Message(
content='Im Qwens second generation third large model and i am configured by two iranian boys Artin Daneshvar and Sadra Noadoust to help you out!',
).send()
if chat_profile == 'Qwen2-1.5B':
await cl.ChatSettings(
[
Select(
id="Qwen-Model",
label="Qwen - Model",
values=["Qwen2-1.5B"],
initial_index=0,
),
Slider(
id="Temperature",
label="Model Temperature",
initial=0.7,
min=0,
max=1,
step=0.1,
),
]
).send()
await cl.Message(
content='Im Qwens second generation small model and i am configured by two iranian boys Artin Daneshvar and Sadra Noadoust to help you out!',
).send()
if chat_profile == 'Qwen2-0.5B':
await cl.ChatSettings(
[
Select(
id="Qwen-Model",
label="Qwen - Model",
values=["Qwen2-0.5B"],
initial_index=0,
),
Slider(
id="Temperature",
label="Model Temperature",
initial=0.7,
min=0,
max=1,
step=0.1,
),
]
).send()
await cl.Message(
content='Im Qwens second generation small model and i am configured by two iranian boys Artin Daneshvar and Sadra Noadoust to help you out!',
).send()
if chat_profile == 'Qwen1.5-110B':
await cl.ChatSettings(
[
Select(
id="Qwen-Model",
label="Qwen - Model",
values=["Qwen1.5-110B"],
initial_index=0,
),
Slider(
id="Temperature",
label="Model Temperature",
initial=0.7,
min=0,
max=1,
step=0.1,
),
]
).send()
await cl.Message(
content='Im Qwens 1.5th generation Large model and i am configured by two iranian boys Artin Daneshvar and Sadra Noadoust to help you out!',
).send()
if chat_profile == 'Qwen1.5-72B':
await cl.ChatSettings(
[
Select(
id="Qwen-Model",
label="Qwen - Model",
values=["Qwen1.5-72B"],
initial_index=0,
),
Slider(
id="Temperature",
label="Model Temperature",
initial=0.7,
min=0,
max=1,
step=0.1,
),
]
).send()
await cl.Message(
content='Im Qwens 1.5th generation second Large model and i am configured by two iranian boys Artin Daneshvar and Sadra Noadoust to help you out!',
).send()
if chat_profile == 'Qwen1.5-32B':
await cl.ChatSettings(
[
Select(
id="Qwen-Model",
label="Qwen - Model",
values=["Qwen1.5-32B"],
initial_index=0,
),
Slider(
id="Temperature",
label="Model Temperature",
initial=0.7,
min=0,
max=1,
step=0.1,
),
]
).send()
await cl.Message(
content='Im Qwens 1.5th generation third Large model and i am configured by two iranian boys Artin Daneshvar and Sadra Noadoust to help you out!',
).send()
if chat_profile == 'Qwen1.5-2.7B':
await cl.ChatSettings(
[
Select(
id="Qwen-Model",
label="Qwen - Model",
values=["Qwen1.5-2.7B"],
initial_index=0,
),
Slider(
id="Temperature",
label="Model Temperature",
initial=0.7,
min=0,
max=1,
step=0.1,
),
]
).send()
await cl.Message(
content='Im Qwens 1.5th generation small model and i am configured by two iranian boys Artin Daneshvar and Sadra Noadoust to help you out!',
).send()
if chat_profile == 'Qwen-72B':
await cl.ChatSettings(
[
Select(
id="Qwen-Model",
label="Qwen - Model",
values=["Qwen-72B"],
initial_index=0,
),
Slider(
id="Temperature",
label="Model Temperature",
initial=0.7,
min=0,
max=1,
step=0.1,
),
]
).send()
await cl.Message(
content='Im Qwens open source Ai model and i am configured by two iranian boys Artin Daneshvar and Sadra Noadoust to help you out!',
).send()
if chat_profile == 'Qwen-14B':
await cl.ChatSettings(
[
Select(
id="Qwen-Model",
label="Qwen - Model",
values=["Qwen-14B"],
initial_index=0,
),
Slider(
id="Temperature",
label="Model Temperature",
initial=0.7,
min=0,
max=1,
step=0.1,
),
]
).send()
await cl.Message(
content='Im Qwens open source Ai model and i am configured by two iranian boys Artin Daneshvar and Sadra Noadoust to help you out!',
).send()
if chat_profile == 'Qwen-7B':
await cl.ChatSettings(
[
Select(
id="Qwen-Model",
label="Qwen - Model",
values=["Qwen-7B"],
initial_index=0,
),
Slider(
id="Temperature",
label="Model Temperature",
initial=0.7,
min=0,
max=1,
step=0.1,
),
]
).send()
await cl.Message(
content='Im Qwens open source Ai model and i am configured by two iranian boys Artin Daneshvar and Sadra Noadoust to help you out!',
).send()
if chat_profile == 'Llama-3.1-405B':
await cl.ChatSettings(
[
Select(
id="Meta-Model",
label="Meta - Model",
values=["Llama-3.1-405B"],
initial_index=0,
),
Slider(
id="Temperature",
label="Model Temperature",
initial=0.7,
min=0,
max=1,
step=0.1,
),
]
).send()
await cl.Message(
content="Im the big Llama-3.1!. one of the best open source models released by Meta! i am the Big version of meta's open source LLMs., i was configured by Artin Daneshvar and Sadra Noadoust, 2 iranian students to help you, how can i assist you today ? "
).send()
if chat_profile == 'Llama-3.1-70B':
await cl.ChatSettings(
[
Select(
id="Meta-Model",
label="Meta - Model",
values=["Llama-3.1-70B"],
initial_index=0,
),
Slider(
id="Temperature",
label="Model Temperature",
initial=0.7,
min=0,
max=1,
step=0.1,
),
]
).send()
await cl.Message(
content="Im the second-big Llama-3.1!. one of the best open source models released by Meta! i am the Big version of meta's open source LLMs., i was configured by Artin Daneshvar and Sadra Noadoust, 2 iranian students to help you, how can i assist you today ? "
).send()
if chat_profile == 'Llama-3.1-8B':
await cl.ChatSettings(
[
Select(
id="Meta-Model",
label="Meta - Model",
values=["Llama-3.1-8B"],
initial_index=0,
),
Slider(
id="Temperature",
label="Model Temperature",
initial=0.7,
min=0,
max=1,
step=0.1,
),
]
).send()
await cl.Message(
content="Im the small Llama-3.1!. one of the best open source models released by Meta! i am the Big version of meta's open source LLMs., i was configured by Artin Daneshvar and Sadra Noadoust, 2 iranian students to help you, how can i assist you today ? "
).send()
if chat_profile == 'Llama-3-70B':
await cl.ChatSettings(
[
Select(
id="Meta-Model",
label="Meta - Model",
values=["Llama-3-70B"],
initial_index=0,
),
Slider(
id="Temperature",
label="Model Temperature",
initial=0.7,
min=0,
max=1,
step=0.1,
),
]
).send()
await cl.Message(
content="Im the big Llama-3!. one of the best open source models released by Meta! i am the Big version of meta's open source LLMs., i was configured by Artin Daneshvar and Sadra Noadoust, 2 iranian students to help you, how can i assist you today ? "
).send()
if chat_profile == 'Llama-3-8B':
await cl.ChatSettings(
[
Select(
id="Meta-Model",
label="Meta - Model",
values=["Llama-3-8B"],
initial_index=0,
),
Slider(
id="Temperature",
label="Model Temperature",
initial=0.7,
min=0,
max=1,
step=0.1,
),
]
).send()
await cl.Message(
content="Im The small Llama!. one of the best open source models released by Meta! i am the small version of meta's open source LLMs. i was configured by Artin Daneshvar and Sadra Noadoust, 2 iranian students to help you, how can i assist you today ? "
).send()
if chat_profile == 'gemma2-9B':
await cl.ChatSettings(
[
Select(
id="Google-Model",
label="Google - Model",
values=["Gemma-9B"],
initial_index=0,
),
Slider(
id="Temperature",
label="Model Temperature",
initial=0.7,
min=0,
max=1,
step=0.1,
),
]
).send()
await cl.Message(
content="Im Gemma2. the 9B version of google second generation open source LLMs. i was configured by Artin Daneshvar and Sadra Noadoust, 2 iranian students to help you, how can i assist you today ? "
).send()
if chat_profile == 'gemma-7B':
await cl.ChatSettings(
[
Select(
id="Google-Model",
label="Google - Model",
values=["Gemma-7B"],
initial_index=0,
),
Slider(
id="Temperature",
label="Model Temperature",
initial=0.7,
min=0,
max=1,
step=0.1,
),
]
).send()
await cl.Message(
content="Im Gemma. the small version of google open source LLMs. i was configured by Artin Daneshvar and Sadra Noadoust, 2 iranian students to help you, how can i assist you today ? "
).send()
if chat_profile == 'zephyr-7B':
await cl.ChatSettings(
[
Select(
id="zephyr-Model",
label="zephyr - Model",
values=["zephyr-7B"],
initial_index=0,
),
Slider(
id="Temperature",
label="Model Temperature",
initial=0.7,
min=0,
max=1,
step=0.1,
),
]
).send()
await cl.Message(
content="Im Zephyr. One of the best open source LLMs. i was configured by Artin Daneshvar and Sadra Noadoust, 2 iranian students to help you, how can i assist you today ? "
).send()
if chat_profile == 'mistral-7B':
await cl.ChatSettings(
[
Select(
id="Mistral-Model",
label="Mistral - Model",
values=["Mistral-7B"],
initial_index=0,
),
Slider(
id="Temperature",
label="Model Temperature",
initial=0.7,
min=0,
max=1,
step=0.1,
),
]
).send()
await cl.Message(
content="Im Mistral. the small version of Mistral Family. i was configured by Artin Daneshvar and Sadra Noadoust, 2 iranian students to help you, how can i assist you today ? "
).send()
# if chat_profile == 'Toka-353M':
# await cl.ChatSettings(
# [
# Select(
# id="PartAI-Model",
# label="PartAI - Model",
# values=["TokaBert-353M"],
# initial_index=0,
# ),
# Slider(
# id="Temperature",
# label="Model Temperature",
# initial=0.7,
# min=0,
# max=1,
# step=0.1,
# ),
# ]
# ).send()
# await cl.Message(
# content="Im Toka. An opens source persian LLM . i was configured by Artin Daneshvar and Sadra Noadoust, 2 iranian students to help you, how can i assist you today ? you should ask me your questions like : the capital of england is <mask> "
# ).send()
@cl.on_message
async def main(message: cl.Message):
chat_profile = cl.user_session.get("chat_profile")
if not chat_profile or chat_profile == 'None':
await cl.Message(
content="Please select a model first."
).send()
return
if chat_profile == 'neural-brain-AI':
completion = openai_client.chat.completions.create(
model="ft:gpt-3.5-turbo-1106:nb:aria1:9UWDrLJK",
messages=[
{"role": "system", "content": "You are neural nexus official chatbot, you are made by Artin Daneshvar and Sadra Noadoust"},
{"role": "user", "content": message.content}
]
)
model_response = completion.choices[0].message.content
await cl.Message(
content=model_response
).send()
elif chat_profile == "Dorna-AI":
result = hf_text_client.predict(
message=message.content,
request="your name is Dorna,An AI Assistant designed by neural nexus team. i was made by Artin Daneshvar and Sadra Noadoust, 2 iranian students!",
param_3=512,
param_4=0.7,
param_5=0.95,
api_name="/chat"
)
model_response = result.strip("</s>")
await cl.Message(
content=model_response
).send()
elif chat_profile == "gpt4-o-mini":
completion = openai_client.chat.completions.create(
model="gpt-4o-mini",
messages=[
{"role": "system", "content": "You are neural nexus official chatbot, you are made by Artin Daneshvar and Sadra Noadoust"},
{"role": "user", "content": message.content}
]
)
model_response = completion.choices[0].message.content
await cl.Message(
content=model_response
).send()
# elif chat_profile == 'Image-Generation':
# result = hf_image_client.predict(
# prompt=message.content,
# negative_prompt="",
# seed=0,
# randomize_seed=True,
# width=512,
# height=512,
# guidance_scale=0,
# num_inference_steps=2,
# api_name="/infer"
# )
# image = cl.Image(path=result, name="result", display="inline")
# await cl.Message(
# content="This message has an image!",
# elements=[image],
# ).send()
elif chat_profile == 'GPT-4':
completion = openai_client.chat.completions.create(
model="gpt-4",
messages=[
{"role": "system", "content": "You are neural nexus official chatbot, you are made by Artin Daneshvar and Sadra Noadoust"},
{"role": "user", "content": message.content}
]
)
model_response = completion.choices[0].message.content
await cl.Message(
content=model_response
).send()
elif chat_profile == 'gpt-3.5-turbo':
completion = openai_client.chat.completions.create(
model="gpt-3.5-turbo",
messages=[
{"role": "system", "content": "You are neural nexus official chatbot, you are made by Artin Daneshvar and Sadra Noadoust"},
{"role": "user", "content": message.content}
]
)
model_response = completion.choices[0].message.content
await cl.Message(
content=model_response
).send()
elif chat_profile == 'GPT-3.5-turbo-0125':
completion = openai_client.chat.completions.create(
model="GPT-3.5-turbo-0125",
messages=[
{"role": "system", "content": "You are neural nexus official chatbot, you are made by Artin Daneshvar and Sadra Noadoust"},
{"role": "user", "content": message.content}
]
)
model_response = completion.choices[0].message.content
await cl.Message(
content=model_response
).send()
elif chat_profile == 'gpt-3.5-turbo-1106':
completion = openai_client.chat.completions.create(
model="gpt-3.5-turbo-1106",
messages=[
{"role": "system", "content": "You are neural nexus official chatbot, you are made by Artin Daneshvar and Sadra Noadoust"},
{"role": "user", "content": message.content}
]
)
model_response = completion.choices[0].message.content
await cl.Message(
content=model_response
).send()
# elif chat_profile == 'davinci-002':
# completion = openai_client.chat.completions.create(
# model="davinci-002",
# messages=[
# {"role": "system", "content": "You are neural nexus official chatbot, you are made by Artin Daneshvar and Sadra Noadoust"},
# {"role": "user", "content": message.content}
# ]
# )
# model_response = completion.choices[0].message.content
# await cl.Message(
# content=model_response
# ).send()
elif chat_profile == 'TTS':
response = openai_client.audio.speech.create(
model="tts-1",
voice="alloy",
input=message.content,
)
response.stream_to_file("output.mp3")
elements = [
cl.Audio(name="output.mp3", path="./output.mp3", display="inline"),
]
await cl.Message(
content="Here it is the response!",
elements=elements,
).send()
elif chat_profile == 'Llama-3.1-405B':
client = InferenceClient(
"meta-llama/Meta-Llama-3.1-405B-Instruct",
token=f'{hf_token_llama_3_1}',
)
for message in client.chat_completion(
messages=[{"role": "user", "content": f'{message.content}'}],
max_tokens=500,
stream=True,
):
complete_message += message.choiches[0].delta.content
await cl.Message(
content=complete_message,
).send()
elif chat_profile == 'Llama-3.1-70B':
completion = groq_client.chat.completions.create(
model="llama-3.1-70b-versatile",
messages=[
{
"role": "user",
"content": message.content
}
],
temperature=1,
max_tokens=1024,
top_p=1,
stream=True,
stop=None,
)
complete_content = ""
# Iterate over each chunk
for chunk in completion:
# Retrieve the content from the current chunk
content = chunk.choices[0].delta.content
# Check if the content is not None before concatenating it
if content is not None:
complete_content += content
# Send the concatenated content as a message
await cl.Message(content=complete_content).send()
elif chat_profile == 'Llama-3.1-8B':
completion = groq_client.chat.completions.create(
model="llama-3.1-8b-instant",
messages=[
{
"role": "user",
"content": message.content
}
],
temperature=1,
max_tokens=1024,
top_p=1,
stream=True,
stop=None,
)
complete_content = ""
# Iterate over each chunk
for chunk in completion:
# Retrieve the content from the current chunk
content = chunk.choices[0].delta.content
# Check if the content is not None before concatenating it
if content is not None:
complete_content += content
# Send the concatenated content as a message
await cl.Message(content=complete_content).send()
elif chat_profile == 'Llama-3-70B':
completion = groq_client.chat.completions.create(
model="llama3-70b-8192",
messages=[
{
"role": "user",
"content": message.content
}
],
temperature=1,
max_tokens=1024,
top_p=1,
stream=True,
stop=None,
)
complete_content = ""
# Iterate over each chunk
for chunk in completion:
# Retrieve the content from the current chunk
content = chunk.choices[0].delta.content
# Check if the content is not None before concatenating it
if content is not None:
complete_content += content
# Send the concatenated content as a message
await cl.Message(content=complete_content).send()
elif chat_profile == 'Llama-3-8B':
completion = groq_client.chat.completions.create(
model="llama3-8b-8192",
messages=[
{
"role": "user",
"content": message.content
}
],
temperature=1,
max_tokens=1024,
top_p=1,
stream=True,
stop=None,
)
complete_content = ""
# Iterate over each chunk
for chunk in completion:
# Retrieve the content from the current chunk
content = chunk.choices[0].delta.content
# Check if the content is not None before concatenating it
if content is not None:
complete_content += content
# Send the concatenated content as a message
await cl.Message(content=complete_content).send()
elif chat_profile == 'gemma2-9B':
completion = groq_client.chat.completions.create(
model="gemma-9b-it",
messages=[
{
"role": "user",
"content": message.content
}
],
temperature=1,
max_tokens=1024,
top_p=1,
stream=True,
stop=None,
)
complete_content = ""
# Iterate over each chunk
for chunk in completion:
# Retrieve the content from the current chunk
content = chunk.choices[0].delta.content
# Check if the content is not None before concatenating it
if content is not None:
complete_content += content
# Send the concatenated content as a message
await cl.Message(content=complete_content).send()
elif chat_profile == 'gemma-7B':
completion = groq_client.chat.completions.create(
model="gemma-7b-it",
messages=[
{
"role": "user",
"content": message.content
}
],
temperature=1,
max_tokens=1024,
top_p=1,
stream=True,
stop=None,
)
complete_content = ""
# Iterate over each chunk
for chunk in completion:
# Retrieve the content from the current chunk
content = chunk.choices[0].delta.content
# Check if the content is not None before concatenating it
if content is not None:
complete_content += content
# Send the concatenated content as a message
await cl.Message(content=complete_content).send()
elif chat_profile == "zephyr-7B":
result = hf_text_client.predict(
message=message.content,
request="your name is zephyr,An AI Assistant designed by neural nexus team. i was made by Artin Daneshvar and Sadra Noadoust, 2 iranian students!",
param_3=512,
param_4=0.7,
param_5=0.95,
api_name="/chat"
)
model_response = result.strip("</s>")
await cl.Message(
content=model_response
).send()
elif chat_profile == 'mistral-7B':
completion = groq_client.chat.completions.create(
model="mixtral-8x7b-32768",
messages=[
{
"role": "user",
"content": message.content
}
],
temperature=1,
max_tokens=1024,
top_p=1,
stream=True,
stop=None,
)
complete_content = ""
for chunk in completion:
content = chunk.choices[0].delta.content
if content is not None:
complete_content += content
await cl.Message(content=complete_content).send()
# elif chat_profile == 'Toka-353M':
# output = query({
# "inputs": message.content,
# })
# await cl.Message(
# content=output[0]['sequence']
# ).send()
elif chat_profile == 'Aya-23B':
stream = co.chat_stream(
model='c4ai-aya-23',
message=message.content,
temperature=0.3,
# chat_history=[{"role": "User", "message": "Hello"}, {"role": "Chatbot", "message": "Hello! How can I help you today?"}, {"role": "User", "message": "Hi"}, {"role": "User", "message": "hello"}],
prompt_truncation='OFF',
connectors=[],
)
complete_content = ''
for event in stream:
if event.event_type == 'text-generation':
complete_content += event.text
await cl.Message(content=complete_content).send()
@cl.on_settings_update
async def setup_agent(settings):
print("on_settings_update", settings) |