Spaces:
Runtime error
Runtime error
Update app.py
Browse files
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
|
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,
|
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
|
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 = "
|
84 |
-
human_invitation = "
|
85 |
-
return [[" \n",invitation+"
|
86 |
|
87 |
def user(user_message, history):
|
88 |
-
invitation = "
|
89 |
-
human_invitation = "
|
90 |
return "", history +[[human_invitation+user_message, None]]
|
91 |
|
92 |
def bot(history):
|
93 |
-
invitation = "
|
94 |
-
human_invitation = "
|
95 |
print(history)
|
96 |
|
97 |
|
98 |
question = ""
|
99 |
for each_ques in history:
|
100 |
-
question = question+ each_ques[0].replace("
|
101 |
|
102 |
-
response = csv_prompter(question
|
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
|