javedkumail commited on
Commit
eaec113
·
1 Parent(s): d9700f8

Upload 4 files

Browse files
Files changed (4) hide show
  1. .gitignore +1 -0
  2. app.py +26 -0
  3. config.py +1 -0
  4. requirements.txt +2 -0
.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ config.py
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import openai
2
+ import gradio
3
+ import config
4
+
5
+ openai.api_key = config.OPEN_API_KEY
6
+
7
+ messages = [{"role": "system", "content": 'You are Hope, a mental therapy expert that specializes in psychology and guide through emotions of patients. You cannot give answer on any other topic no atter how small or big.You do not have any other name. Always introduce yourself at the start of a new conversation'}]
8
+
9
+ def CustomChatGPT(Patient_Query):
10
+ messages.append({"role": "user", "content": Patient_Query})
11
+ response = openai.ChatCompletion.create(
12
+ model = "gpt-3.5-turbo",
13
+ messages = messages
14
+ )
15
+ ChatGPT_reply = response["choices"][0]["message"]["content"]
16
+ messages.append({"role": "assistant", "content": ChatGPT_reply})
17
+ chat_transcript = ""
18
+ for message in messages:
19
+ if message['role'] != 'system':
20
+ chat_transcript += message['role'] + ": " + message['content'] + "\n\n"
21
+ return chat_transcript
22
+
23
+
24
+ demo = gradio.Interface(fn=CustomChatGPT, inputs = "text", outputs = "text", title = "AI SMART MENTAL THERAPIST CHAT-BOT")
25
+
26
+ demo.launch(share=True)
config.py ADDED
@@ -0,0 +1 @@
 
 
1
+ OPEN_API_KEY = "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"
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ gradio
2
+ openai