From f2aa98b7129fd3019a22f089de5f5e9b5555a534 Mon Sep 17 00:00:00 2001 From: Mika Bomm Date: Wed, 8 Jan 2025 11:23:41 +0100 Subject: [PATCH] fix couple of bugs --- app.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app.py b/app.py index ea4cbe4..c5f2fba 100644 --- a/app.py +++ b/app.py @@ -27,12 +27,12 @@ def ask(text, model): print("Formatted History: ", formatted_history) return formatted_history, "" -def clear_history(): +def clear_history(model): global chat_history chat_history = [] # Reset the conversation on the server side client.chat.completions.create( - model="llama3.2", + model=model, messages=[{"role": "system", "content": "Reset conversation"}] ) return "" @@ -40,7 +40,7 @@ def clear_history(): with gr.Blocks() as server: with gr.Tab("Chatbot LF6"): - model_dropdown = gr.Dropdown(label="Select Model", choices=get_models(), value="llama3.2") + model_dropdown = gr.Dropdown(label="Select Model", choices=get_models()) chatbox = gr.Textbox(label="Chat History", lines=10, interactive=False) input_text = gr.Textbox(label="Input Text", placeholder="Enter your text here...") submit_button = gr.Button("Submit") @@ -48,6 +48,6 @@ with gr.Blocks() as server: submit_button.click(fn=lambda text, model: ask(text, model), inputs=[input_text, model_dropdown], outputs=[chatbox, input_text]) input_text.submit(fn=lambda text, model: ask(text, model), inputs=[input_text, model_dropdown], outputs=[chatbox, input_text]) # Submit on Enter key press - clear_button.click(fn=clear_history, inputs=None, outputs=chatbox) + clear_button.click(fn=clear_history, inputs=model_dropdown, outputs=chatbox) server.launch() \ No newline at end of file