Spaces:
Runtime error
Runtime error
fix history shit + 4096 output
Browse files
app.py
CHANGED
@@ -139,7 +139,7 @@ with gr.Blocks(theme='gradio/monochrome') as demo:
|
|
139 |
frequency_penalty = gr.Slider(-2, 2, value=0, step=0.1, label="Frequency Penalty")
|
140 |
presence_penalty = gr.Slider(-2, 2, value=0, step=0.1, label="Presence Penalty")
|
141 |
repetition_penalty = gr.Slider(0.01, 5, value=1.1, step=0.01, label="Repetition Penalty")
|
142 |
-
max_tokens = gr.Slider(1,
|
143 |
|
144 |
def user(user_message, history):
|
145 |
print(f"{get_timestamp()} <|user|> {user_message}")
|
@@ -163,13 +163,13 @@ with gr.Blocks(theme='gradio/monochrome') as demo:
|
|
163 |
stop_generation.clear()
|
164 |
|
165 |
def regenerate_response(history, system_prompt, temperature, top_p, top_k, frequency_penalty, presence_penalty, repetition_penalty, max_tokens):
|
166 |
-
if len(history) > 0:
|
167 |
last_user_message = history[-1][0]
|
168 |
history[-1][1] = None
|
169 |
for new_history in bot(history, system_prompt, temperature, top_p, top_k, frequency_penalty, presence_penalty, repetition_penalty, max_tokens):
|
170 |
yield new_history
|
171 |
else:
|
172 |
-
yield history
|
173 |
|
174 |
def import_chat_wrapper(custom_format_string):
|
175 |
imported_history, imported_system_prompt = import_chat(custom_format_string)
|
@@ -198,4 +198,4 @@ with gr.Blocks(theme='gradio/monochrome') as demo:
|
|
198 |
stop_btn.click(stop_generation_func, inputs=[], outputs=[])
|
199 |
|
200 |
if __name__ == "__main__":
|
201 |
-
demo.launch(debug=True)
|
|
|
139 |
frequency_penalty = gr.Slider(-2, 2, value=0, step=0.1, label="Frequency Penalty")
|
140 |
presence_penalty = gr.Slider(-2, 2, value=0, step=0.1, label="Presence Penalty")
|
141 |
repetition_penalty = gr.Slider(0.01, 5, value=1.1, step=0.01, label="Repetition Penalty")
|
142 |
+
max_tokens = gr.Slider(1, 4096, value=256, step=1, label="Max Output (max_tokens)")
|
143 |
|
144 |
def user(user_message, history):
|
145 |
print(f"{get_timestamp()} <|user|> {user_message}")
|
|
|
163 |
stop_generation.clear()
|
164 |
|
165 |
def regenerate_response(history, system_prompt, temperature, top_p, top_k, frequency_penalty, presence_penalty, repetition_penalty, max_tokens):
|
166 |
+
if history is not None and len(history) > 0:
|
167 |
last_user_message = history[-1][0]
|
168 |
history[-1][1] = None
|
169 |
for new_history in bot(history, system_prompt, temperature, top_p, top_k, frequency_penalty, presence_penalty, repetition_penalty, max_tokens):
|
170 |
yield new_history
|
171 |
else:
|
172 |
+
yield [] if history is None else history
|
173 |
|
174 |
def import_chat_wrapper(custom_format_string):
|
175 |
imported_history, imported_system_prompt = import_chat(custom_format_string)
|
|
|
198 |
stop_btn.click(stop_generation_func, inputs=[], outputs=[])
|
199 |
|
200 |
if __name__ == "__main__":
|
201 |
+
demo.launch(debug=True)
|