Spaces:
Runtime error
Runtime error
Commit
·
5385efe
1
Parent(s):
ddaf3fe
Update app.py
Browse files
app.py
CHANGED
@@ -65,7 +65,7 @@ def chat_accordion():
|
|
65 |
return model, temperature, top_p
|
66 |
|
67 |
|
68 |
-
def format_chat_prompt(message: str, chat_history, bot_name: str
|
69 |
print(bot_name)
|
70 |
instructions = INSTRUCTIONS_MAPPING[bot_name].strip(" ").strip("\n")
|
71 |
prompt = instructions
|
@@ -119,9 +119,8 @@ def chat():
|
|
119 |
interactive=True,
|
120 |
label="Character",
|
121 |
)
|
122 |
-
instructions=''
|
123 |
|
124 |
-
def run_chat(message: str, chat_history, bot_name: str,
|
125 |
if not message or (message == RETRY_COMMAND and len(chat_history) == 0):
|
126 |
yield chat_history
|
127 |
return
|
@@ -131,7 +130,7 @@ def chat():
|
|
131 |
user_message, _ = prev_turn
|
132 |
message = user_message
|
133 |
|
134 |
-
prompt = format_chat_prompt(message, chat_history, bot_name
|
135 |
model_output = run_model(
|
136 |
prompt,
|
137 |
model=model,
|
@@ -148,15 +147,15 @@ def chat():
|
|
148 |
chat_history.pop(-1)
|
149 |
return {chatbot: gr.update(value=chat_history)}
|
150 |
|
151 |
-
def run_retry(message: str, chat_history, bot_name,
|
152 |
-
yield from run_chat(RETRY_COMMAND, chat_history, bot_name,
|
153 |
|
154 |
def clear_chat():
|
155 |
return []
|
156 |
|
157 |
inputs.submit(
|
158 |
run_chat,
|
159 |
-
[inputs, chatbot, bot_name,
|
160 |
outputs=[chatbot],
|
161 |
show_progress=False,
|
162 |
)
|
@@ -164,7 +163,7 @@ def chat():
|
|
164 |
delete_turn_button.click(delete_last_turn, inputs=[chatbot], outputs=[chatbot])
|
165 |
retry_button.click(
|
166 |
run_retry,
|
167 |
-
[inputs, chatbot, bot_name,
|
168 |
outputs=[chatbot],
|
169 |
show_progress=False,
|
170 |
)
|
|
|
65 |
return model, temperature, top_p
|
66 |
|
67 |
|
68 |
+
def format_chat_prompt(message: str, chat_history, bot_name: str) -> str:
|
69 |
print(bot_name)
|
70 |
instructions = INSTRUCTIONS_MAPPING[bot_name].strip(" ").strip("\n")
|
71 |
prompt = instructions
|
|
|
119 |
interactive=True,
|
120 |
label="Character",
|
121 |
)
|
|
|
122 |
|
123 |
+
def run_chat(message: str, chat_history, bot_name: str, model: str, temperature: float, top_p: float):
|
124 |
if not message or (message == RETRY_COMMAND and len(chat_history) == 0):
|
125 |
yield chat_history
|
126 |
return
|
|
|
130 |
user_message, _ = prev_turn
|
131 |
message = user_message
|
132 |
|
133 |
+
prompt = format_chat_prompt(message, chat_history, bot_name)
|
134 |
model_output = run_model(
|
135 |
prompt,
|
136 |
model=model,
|
|
|
147 |
chat_history.pop(-1)
|
148 |
return {chatbot: gr.update(value=chat_history)}
|
149 |
|
150 |
+
def run_retry(message: str, chat_history, bot_name, model: str, temperature: float, top_p: float):
|
151 |
+
yield from run_chat(RETRY_COMMAND, chat_history, bot_name, model, temperature, top_p)
|
152 |
|
153 |
def clear_chat():
|
154 |
return []
|
155 |
|
156 |
inputs.submit(
|
157 |
run_chat,
|
158 |
+
[inputs, chatbot, bot_name, model, temperature, top_p],
|
159 |
outputs=[chatbot],
|
160 |
show_progress=False,
|
161 |
)
|
|
|
163 |
delete_turn_button.click(delete_last_turn, inputs=[chatbot], outputs=[chatbot])
|
164 |
retry_button.click(
|
165 |
run_retry,
|
166 |
+
[inputs, chatbot, bot_name, model, temperature, top_p],
|
167 |
outputs=[chatbot],
|
168 |
show_progress=False,
|
169 |
)
|