Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,19 +1,13 @@
|
|
1 |
import gradio as gr
|
2 |
from huggingface_hub.utils import HfHubHTTPError
|
3 |
|
4 |
-
|
5 |
def predict(message, history):
|
6 |
try:
|
7 |
-
# Create the Interface object directly
|
8 |
-
|
9 |
-
|
10 |
-
chatbot=gr.Chatbot(),
|
11 |
-
inputs="textbox", # Specify input type
|
12 |
-
outputs="textbox", # Specify output type
|
13 |
-
)
|
14 |
-
|
15 |
# Launch the interface and get the prediction function
|
16 |
-
with iface:
|
17 |
fn = iface.predict
|
18 |
|
19 |
response = fn(message, history)
|
@@ -26,14 +20,11 @@ def predict(message, history):
|
|
26 |
else:
|
27 |
raise e
|
28 |
|
29 |
-
|
30 |
-
demo = gr.Blocks()
|
31 |
-
|
32 |
-
with demo:
|
33 |
chatbot = gr.Chatbot()
|
34 |
msg = gr.Textbox()
|
35 |
clear = gr.ClearButton([msg, chatbot])
|
36 |
|
37 |
msg.submit(predict, [msg, chatbot], [msg, chatbot])
|
38 |
|
39 |
-
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
from huggingface_hub.utils import HfHubHTTPError
|
3 |
|
|
|
4 |
def predict(message, history):
|
5 |
try:
|
6 |
+
# Create the Interface object using ChatInterface directly
|
7 |
+
chat_interface = gr.ChatInterface.load("models/meta-llama/Meta-Llama-3.1-8B")
|
8 |
+
|
|
|
|
|
|
|
|
|
|
|
9 |
# Launch the interface and get the prediction function
|
10 |
+
with chat_interface as iface:
|
11 |
fn = iface.predict
|
12 |
|
13 |
response = fn(message, history)
|
|
|
20 |
else:
|
21 |
raise e
|
22 |
|
23 |
+
with gr.Blocks() as demo:
|
|
|
|
|
|
|
24 |
chatbot = gr.Chatbot()
|
25 |
msg = gr.Textbox()
|
26 |
clear = gr.ClearButton([msg, chatbot])
|
27 |
|
28 |
msg.submit(predict, [msg, chatbot], [msg, chatbot])
|
29 |
|
30 |
+
demo.launch()
|