fix couple of bugs
This commit is contained in:
parent
7ea2129c93
commit
f2aa98b712
1 changed files with 4 additions and 4 deletions
8
app.py
8
app.py
|
@ -27,12 +27,12 @@ def ask(text, model):
|
||||||
print("Formatted History: ", formatted_history)
|
print("Formatted History: ", formatted_history)
|
||||||
return formatted_history, ""
|
return formatted_history, ""
|
||||||
|
|
||||||
def clear_history():
|
def clear_history(model):
|
||||||
global chat_history
|
global chat_history
|
||||||
chat_history = []
|
chat_history = []
|
||||||
# Reset the conversation on the server side
|
# Reset the conversation on the server side
|
||||||
client.chat.completions.create(
|
client.chat.completions.create(
|
||||||
model="llama3.2",
|
model=model,
|
||||||
messages=[{"role": "system", "content": "Reset conversation"}]
|
messages=[{"role": "system", "content": "Reset conversation"}]
|
||||||
)
|
)
|
||||||
return ""
|
return ""
|
||||||
|
@ -40,7 +40,7 @@ def clear_history():
|
||||||
|
|
||||||
with gr.Blocks() as server:
|
with gr.Blocks() as server:
|
||||||
with gr.Tab("Chatbot LF6"):
|
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)
|
chatbox = gr.Textbox(label="Chat History", lines=10, interactive=False)
|
||||||
input_text = gr.Textbox(label="Input Text", placeholder="Enter your text here...")
|
input_text = gr.Textbox(label="Input Text", placeholder="Enter your text here...")
|
||||||
submit_button = gr.Button("Submit")
|
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])
|
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
|
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()
|
server.launch()
|
Loading…
Add table
Reference in a new issue