Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,20 +1,31 @@
|
|
1 |
import gradio as gr
|
2 |
from huggingface_hub.utils import HfHubHTTPError
|
3 |
|
|
|
4 |
def predict(message, history):
|
5 |
try:
|
6 |
-
#
|
7 |
-
iface = gr.Interface
|
8 |
-
|
9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
history.append((message, response))
|
11 |
return "", history
|
|
|
12 |
except HfHubHTTPError as e:
|
13 |
if e.response.status_code == 504:
|
14 |
return "Server overloaded. Please try again later.", history
|
15 |
else:
|
16 |
raise e
|
17 |
|
|
|
18 |
with gr.Blocks() as demo:
|
19 |
chatbot = gr.Chatbot()
|
20 |
msg = gr.Textbox()
|
|
|
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 |
+
iface = gr.Interface(
|
9 |
+
fn=gr.ChatInterface.load("models/meta-llama/Meta-Llama-3.1-8B"),
|
10 |
+
inputs="textbox",
|
11 |
+
outputs="textbox",
|
12 |
+
)
|
13 |
+
|
14 |
+
# Launch the interface and get the prediction function
|
15 |
+
with iface:
|
16 |
+
fn = iface.predict
|
17 |
+
|
18 |
+
response = fn(message, history)
|
19 |
history.append((message, response))
|
20 |
return "", history
|
21 |
+
|
22 |
except HfHubHTTPError as e:
|
23 |
if e.response.status_code == 504:
|
24 |
return "Server overloaded. Please try again later.", history
|
25 |
else:
|
26 |
raise e
|
27 |
|
28 |
+
|
29 |
with gr.Blocks() as demo:
|
30 |
chatbot = gr.Chatbot()
|
31 |
msg = gr.Textbox()
|