yizhangliu commited on
Commit
38f360b
·
1 Parent(s): 2f30cc1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -29
app.py CHANGED
@@ -7,25 +7,6 @@ import random
7
  session_token = os.environ.get('SessionToken')
8
  logger.info(f"session_token_: {session_token}")
9
 
10
- # def chat(text):
11
- # try:
12
- # api = ChatGPT(session_token)
13
- # resp = api.send_message(text)
14
- # api.refresh_auth()
15
- # api.reset_conversation()
16
- # response = resp['message']
17
- # logger.info(f"response_: {response}")
18
- # except:
19
- # response = "Sorry, I'm am tired."
20
- # return response
21
-
22
-
23
- # demo = gr.Interface(chat,
24
- # inputs = [gr.Textbox(label = 'Input: ')],
25
- # outputs = gr.outputs.Textbox(type="text",label="from ChatGPT:"),
26
- # title = "Talk with ChatGPT",
27
- # description= "")
28
-
29
  def get_response_from_chatbot(text):
30
  try:
31
  api = ChatGPT(session_token)
@@ -41,19 +22,10 @@ def get_response_from_chatbot(text):
41
  def chat(message, history):
42
  history = history or []
43
  response = get_response_from_chatbot(message)
44
- # message = message.lower()
45
- # if message.startswith("how many"):
46
- # response = random.randint(1, 10)
47
- # elif message.startswith("how"):
48
- # response = random.choice(["Great", "Good", "Okay", "Bad"])
49
- # elif message.startswith("where"):
50
- # response = random.choice(["Here", "There", "Somewhere"])
51
- # else:
52
- # response = "I don't know"
53
  history.append((message, response))
54
  return history, history
55
 
56
- chatbot = gr.Chatbot().style(color_map=("green", "pink"))
57
  demo = gr.Interface(
58
  chat,
59
  ["text", "state"],
 
7
  session_token = os.environ.get('SessionToken')
8
  logger.info(f"session_token_: {session_token}")
9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  def get_response_from_chatbot(text):
11
  try:
12
  api = ChatGPT(session_token)
 
22
  def chat(message, history):
23
  history = history or []
24
  response = get_response_from_chatbot(message)
 
 
 
 
 
 
 
 
 
25
  history.append((message, response))
26
  return history, history
27
 
28
+ chatbot = gr.Chatbot().style(color_map=("gray", "pink"))
29
  demo = gr.Interface(
30
  chat,
31
  ["text", "state"],