neuralworm commited on
Commit
edb28d0
·
verified ·
1 Parent(s): 38ed5e5

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -0
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from huggingface_hub.utils import HfHubHTTPError
3
+
4
+ def predict(message, history):
5
+ try:
6
+ response = gr.Interface.load(
7
+ "models/meta-llama/Meta-Llama-3.1-8B"
8
+ ).predict(message, history)
9
+ history.append((message, response))
10
+ return "", history
11
+ except HfHubHTTPError as e:
12
+ if e.response.status_code == 504:
13
+ return "Server überlastet. Bitte später erneut versuchen.", history
14
+ else:
15
+ raise e
16
+
17
+ with gr.Blocks() as demo:
18
+ chatbot = gr.Chatbot()
19
+ msg = gr.Textbox()
20
+ clear = gr.ClearButton([msg, chatbot])
21
+
22
+ msg.submit(predict, [msg, chatbot], [msg, chatbot])
23
+
24
+ demo.launch()