as-cle-bert commited on
Commit
1a0db62
1 Parent(s): 07542a0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -20
app.py CHANGED
@@ -1,21 +1,21 @@
1
- import gradio as gr
2
- from load_model import pipe
3
- from utils import Translation
4
-
5
-
6
-
7
- def reply(message, history):
8
- txt = Translation(message, "en")
9
- if txt.original == "en":
10
- response = pipe(message)
11
- return response[0]["generated_text"]
12
- else:
13
- translation = txt.translatef()
14
- response = pipe(translation)
15
- t = Translation(response[0]["generated_text"], txt.original)
16
- res = t.translatef()
17
- return res
18
-
19
-
20
- demo = gr.ChatInterface(fn=reply, title="Multilingual-Bloom Bot")
21
  demo.launch()
 
1
+ import gradio as gr
2
+ from load_model import pipe
3
+ from utils import Translation
4
+
5
+
6
+ @spaces.GPU
7
+ def reply(message, history):
8
+ txt = Translation(message, "en")
9
+ if txt.original == "en":
10
+ response = pipe(message)
11
+ return response[0]["generated_text"]
12
+ else:
13
+ translation = txt.translatef()
14
+ response = pipe(translation)
15
+ t = Translation(response[0]["generated_text"], txt.original)
16
+ res = t.translatef()
17
+ return res
18
+
19
+
20
+ demo = gr.ChatInterface(fn=reply, title="Multilingual-Bloom Bot")
21
  demo.launch()