aaaaa
Browse files
app.py
CHANGED
@@ -46,7 +46,7 @@ def respond(
|
|
46 |
):
|
47 |
token = output['generated_text'][-1]['content']
|
48 |
response += token
|
49 |
-
yield response #
|
50 |
|
51 |
else:
|
52 |
# API-based inference (ignoring history)
|
@@ -71,7 +71,8 @@ def respond(
|
|
71 |
break
|
72 |
token = message_chunk.choices[0].delta.content
|
73 |
response += token
|
74 |
-
yield response #
|
|
|
75 |
|
76 |
def cancel_inference():
|
77 |
global stop_inference
|
@@ -145,6 +146,7 @@ with gr.Blocks(css=custom_css) as demo:
|
|
145 |
|
146 |
# Adjusted to ensure history is maintained and passed correctly
|
147 |
user_input.submit(respond, [user_input, chat_history, system_message, max_tokens, temperature, top_p, use_local_model], chat_history)
|
|
|
148 |
cancel_button.click(cancel_inference)
|
149 |
|
150 |
if __name__ == "__main__":
|
|
|
46 |
):
|
47 |
token = output['generated_text'][-1]['content']
|
48 |
response += token
|
49 |
+
yield history + [(message, response)] # Yield history + new response
|
50 |
|
51 |
else:
|
52 |
# API-based inference (ignoring history)
|
|
|
71 |
break
|
72 |
token = message_chunk.choices[0].delta.content
|
73 |
response += token
|
74 |
+
yield history + [(message, response)] # Yield history + new response
|
75 |
+
|
76 |
|
77 |
def cancel_inference():
|
78 |
global stop_inference
|
|
|
146 |
|
147 |
# Adjusted to ensure history is maintained and passed correctly
|
148 |
user_input.submit(respond, [user_input, chat_history, system_message, max_tokens, temperature, top_p, use_local_model], chat_history)
|
149 |
+
|
150 |
cancel_button.click(cancel_inference)
|
151 |
|
152 |
if __name__ == "__main__":
|