Update app.py
Browse files
app.py
CHANGED
|
@@ -1,11 +1,11 @@
|
|
| 1 |
# app.py
|
| 2 |
import gradio as gr
|
| 3 |
-
from chat import
|
| 4 |
from config import MODEL_LIST, MAX_TOKENS, TEMPERATURE
|
| 5 |
|
| 6 |
def chat_interface(user_input, max_tokens, temperature, model_name):
|
| 7 |
-
switch_model(model_name)
|
| 8 |
-
return
|
| 9 |
|
| 10 |
iface = gr.Interface(
|
| 11 |
fn=chat_interface,
|
|
@@ -15,9 +15,9 @@ iface = gr.Interface(
|
|
| 15 |
gr.Slider(minimum=0.1, maximum=1.0, step=0.1, label="Temperature", value=TEMPERATURE),
|
| 16 |
gr.Dropdown(list(MODEL_LIST.keys()), label="Choose Model", value="ChatGpt Tune Base")
|
| 17 |
],
|
| 18 |
-
outputs="
|
| 19 |
-
title="ChatGpt Tune Multi-Model",
|
| 20 |
-
description="Chat with multiple Hugging Face/safetensor models!"
|
| 21 |
)
|
| 22 |
|
| 23 |
reset_iface = gr.Interface(
|
|
|
|
| 1 |
# app.py
|
| 2 |
import gradio as gr
|
| 3 |
+
from chat import generate_response_stream, reset_conversation, switch_model
|
| 4 |
from config import MODEL_LIST, MAX_TOKENS, TEMPERATURE
|
| 5 |
|
| 6 |
def chat_interface(user_input, max_tokens, temperature, model_name):
|
| 7 |
+
switch_model(model_name)
|
| 8 |
+
return generate_response_stream(user_input, max_length=max_tokens, temperature=temperature)
|
| 9 |
|
| 10 |
iface = gr.Interface(
|
| 11 |
fn=chat_interface,
|
|
|
|
| 15 |
gr.Slider(minimum=0.1, maximum=1.0, step=0.1, label="Temperature", value=TEMPERATURE),
|
| 16 |
gr.Dropdown(list(MODEL_LIST.keys()), label="Choose Model", value="ChatGpt Tune Base")
|
| 17 |
],
|
| 18 |
+
outputs=gr.Textbox(label="AI Response"),
|
| 19 |
+
title="ChatGpt Tune Multi-Model Streaming",
|
| 20 |
+
description="Chat with multiple Hugging Face/safetensor models with streaming responses!"
|
| 21 |
)
|
| 22 |
|
| 23 |
reset_iface = gr.Interface(
|