kenton-li commited on
Commit
ee6fbcc
·
1 Parent(s): 948174f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -17
app.py CHANGED
@@ -8,11 +8,9 @@ openai_api_key_textbox = ""
8
  model = None
9
  tokenizer = None
10
  generator = None
11
- csv_name = "disease_database_mini.csv"
12
- df = pd.read_csv(csv_name)
13
  openai.api_key = "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"
14
 
15
- def csv_prompter(question,csv_name):
16
  json_file = open('order.json')
17
  json_data = json.load(json_file)
18
  json_data = json_data['records']
@@ -48,7 +46,7 @@ def csv_prompter(question,csv_name):
48
 
49
 
50
 
51
- fulltext = fulltext+'Based on the above dialogue and menu, output the dishes ordered by the customer. Note that some dishes have sub-options (e.g. some are set meals, some are a la carte)'
52
  print(fulltext)
53
  messages = [
54
  {"role": "system", "content": ""},
@@ -65,14 +63,11 @@ def csv_prompter(question,csv_name):
65
 
66
  print(response)
67
 
68
- return answer_llm
69
 
70
 
71
 
72
  with gr.Blocks() as demo:
73
- gr.Markdown("# Autonomous ChatDoctor (openai version), based on disease database knowledge")
74
- gr.Markdown("## Example: If I have frontal headache, fever, and painful sinuses, what disease should I have, and what medical test should I take?")
75
- gr.Markdown("Our model will answer based on the content of the excel below, so please try to ask questions based on the table content.")
76
 
77
  chatbot = gr.Chatbot()
78
  msg = gr.Textbox()
@@ -80,26 +75,26 @@ with gr.Blocks() as demo:
80
  Initialization = gr.Button("Initialization")
81
 
82
  def restart(history):
83
- invitation = "ChatDoctor: "
84
- human_invitation = "Patient: "
85
- return [[" \n",invitation+" I am ChatDoctor, what medical questions do you have?"]]
86
 
87
  def user(user_message, history):
88
- invitation = "ChatDoctor: "
89
- human_invitation = "Patient: "
90
  return "", history +[[human_invitation+user_message, None]]
91
 
92
  def bot(history):
93
- invitation = "ChatDoctor: "
94
- human_invitation = "Patient: "
95
  print(history)
96
 
97
 
98
  question = ""
99
  for each_ques in history:
100
- question = question+ each_ques[0].replace("Patient: ","")+" \n"
101
 
102
- response = csv_prompter(question,csv_name)
103
 
104
  response = invitation+ response
105
  history[-1][1] = response
 
8
  model = None
9
  tokenizer = None
10
  generator = None
 
 
11
  openai.api_key = "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"
12
 
13
+ def csv_prompter(question):
14
  json_file = open('order.json')
15
  json_data = json.load(json_file)
16
  json_data = json_data['records']
 
46
 
47
 
48
 
49
+ fulltext = fulltext+'Based on the above dialogue and menu, If you were a waiter, what would you answer next?'
50
  print(fulltext)
51
  messages = [
52
  {"role": "system", "content": ""},
 
63
 
64
  print(response)
65
 
66
+ return response
67
 
68
 
69
 
70
  with gr.Blocks() as demo:
 
 
 
71
 
72
  chatbot = gr.Chatbot()
73
  msg = gr.Textbox()
 
75
  Initialization = gr.Button("Initialization")
76
 
77
  def restart(history):
78
+ invitation = "Waiter: "
79
+ human_invitation = "Customer: "
80
+ return [[" \n",invitation+"Taste of China, may I help you?"]]
81
 
82
  def user(user_message, history):
83
+ invitation = "Waiter: "
84
+ human_invitation = "Customer: "
85
  return "", history +[[human_invitation+user_message, None]]
86
 
87
  def bot(history):
88
+ invitation = "Waiter: "
89
+ human_invitation = "Customer: "
90
  print(history)
91
 
92
 
93
  question = ""
94
  for each_ques in history:
95
+ question = question+ each_ques[0].replace("Customer: ","")+" \n"
96
 
97
+ response = csv_prompter(question)
98
 
99
  response = invitation+ response
100
  history[-1][1] = response