-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
100 lines (77 loc) · 2.01 KB
/
main.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
from functools import partial
from urllib import response
from taipy.gui import Gui, notify
from datetime import datetime as dt
import keyboard as kb
import openai
datetime = dt.now()
test = "Enter Input";
stylekit = {
"color_primary": "#BADA55",
"color_secondary": "#C0FFE",
}
# Set your OpenAI API key
# MY_API_KEY = "[Inset_API_KEY_HERE]";
# Initialize the OpenAI API client
openai.api_key = MY_API_KEY
def chat_with_chatgpt(prompt):
response = openai.Completion.create(
engine="text-davinci-002",
prompt=prompt,
max_tokens=500 # You can adjust the response length as needed
)
return response.choices[0].text
section_1 ="""
![Test image](bot.png) *ChooseUrBot*
===========================================
"""
response = " "
section_2 = """
<|layout|columns= 1 1 1 |
<|card|
![Test image](md2.png)
<|Medic|button|on_action=medicClick|>
|>
<|card|
![Test image](ms.png)
<|Ghost|button|on_action=drunkClick|>
|>
<|card|
![Test image](wt.png)
<|Witch|button|on_action=soldierClick|>
|>
|>
<|card|
<|{response}|>
|>
<|card|
<|{test} |label = Enter Text|input||>
<|{enter}|button|label = Enter|on_action=enterButtion|>
|>
"""
def on_init(state):
state.response = test
def medicClick(state):
state.prompt = ""
state.prompt = "You are a mental health support assistant.\nChatbot:"
notify(state,"info","Medic Selected.")
def drunkClick(state):
prompt = ""
state.prompt = "You are a ghost.\nChatbot:"
notify(state,"info","Ghost Selected.")
def soldierClick(state):
prompt = ""
state.prompt = "You are a witch.\nChatbot:"
notify(state,"info","Witch Selected.")
def enterButtion(state):
state.prompt += f"{state.test}\nChatBot:"
temp = chat_with_chatgpt(state.prompt)
#state.enter = input()
state.response = temp
def on_change(state, var, val):
if(var == "test"):
state.test = val
prompt = ""
enter = ""
test = response
Gui(page=section_1+section_2).run(use_reloader = True)