Spaces:
Runtime error
Runtime error
File size: 808 Bytes
edb28d0 ee0b947 6a006b5 22cbf8a ee0b947 edb28d0 fdae6e7 edb28d0 a5ad114 edb28d0 6a006b5 edb28d0 e4278da |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
import gradio as gr
from huggingface_hub.utils import HfHubHTTPError
def predict(message, history):
try:
# Define the model interface directly using the load method
chat_interface = gr.ChatInterface.load("models/meta-llama/Meta-Llama-3.1-8B")
# Use the interface to get predictions
response = chat_interface(message, history)
history.append((message, response))
return "", history
except HfHubHTTPError as e:
if e.response.status_code == 504:
return "Server overloaded. Please try again later.", history
else:
raise e
with gr.Blocks() as demo:
chatbot = gr.Chatbot()
msg = gr.Textbox()
clear = gr.ClearButton([msg, chatbot])
msg.submit(predict, [msg, chatbot], [msg, chatbot])
demo.launch() |