Commit
·
77c181e
1
Parent(s):
b27faad
Do not change initial message
Browse files
app.py
CHANGED
|
@@ -45,6 +45,7 @@ instructions = {
|
|
| 45 |
def grad_demo():
|
| 46 |
with gr.Blocks() as demo:
|
| 47 |
gpt_history = []
|
|
|
|
| 48 |
def user(user_message, history):
|
| 49 |
gpt_history.append({"role": ChatRoles.USER, "content": user_message})
|
| 50 |
print(f"Length of gpt_history: {gpt_history}")
|
|
@@ -54,14 +55,19 @@ def grad_demo():
|
|
| 54 |
print(f"STEP: {step}")
|
| 55 |
if step in instructions:
|
| 56 |
gpt_history.append({"role": ChatRoles.SYSTEM, "content": instructions[step]})
|
| 57 |
-
bot_message =
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
history[-1][1] = bot_message
|
| 59 |
gpt_history.append({"role": ChatRoles.ASSISTANT, "content": bot_message})
|
| 60 |
print(f"Length of gpt_history: {gpt_history}")
|
| 61 |
return history
|
| 62 |
def initialize():
|
| 63 |
gpt_history.clear()
|
| 64 |
-
|
|
|
|
| 65 |
chatbot = gr.Chatbot(value = initialize)
|
| 66 |
msg = gr.Textbox()
|
| 67 |
clear = gr.Button("Clear")
|
|
|
|
| 45 |
def grad_demo():
|
| 46 |
with gr.Blocks() as demo:
|
| 47 |
gpt_history = []
|
| 48 |
+
initial_message = ""
|
| 49 |
def user(user_message, history):
|
| 50 |
gpt_history.append({"role": ChatRoles.USER, "content": user_message})
|
| 51 |
print(f"Length of gpt_history: {gpt_history}")
|
|
|
|
| 55 |
print(f"STEP: {step}")
|
| 56 |
if step in instructions:
|
| 57 |
gpt_history.append({"role": ChatRoles.SYSTEM, "content": instructions[step]})
|
| 58 |
+
bot_message = ""
|
| 59 |
+
if step == 1 and initial_message:
|
| 60 |
+
bot_message = initial_message
|
| 61 |
+
else:
|
| 62 |
+
bot_message = get_assistant_response(gpt_history)
|
| 63 |
history[-1][1] = bot_message
|
| 64 |
gpt_history.append({"role": ChatRoles.ASSISTANT, "content": bot_message})
|
| 65 |
print(f"Length of gpt_history: {gpt_history}")
|
| 66 |
return history
|
| 67 |
def initialize():
|
| 68 |
gpt_history.clear()
|
| 69 |
+
history = bot([[None, None]])
|
| 70 |
+
return history
|
| 71 |
chatbot = gr.Chatbot(value = initialize)
|
| 72 |
msg = gr.Textbox()
|
| 73 |
clear = gr.Button("Clear")
|