Spaces:
Running
Running
Commit
·
adb4162
1
Parent(s):
97bc1cd
changes
Browse files
app.py
CHANGED
@@ -5,7 +5,7 @@ from huggingface_hub import InferenceClient
|
|
5 |
For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
|
6 |
"""
|
7 |
englishToFinnishClient = InferenceClient("Helsinki-NLP/opus-mt-en-fi")
|
8 |
-
englishToSwedishClient = InferenceClient("facebook/nllb-200-1.3B")#"facebook/nllb-200-1.3B")
|
9 |
|
10 |
|
11 |
def respond(
|
@@ -24,17 +24,29 @@ def respond(
|
|
24 |
|
25 |
print("the text",message, 'the source',sourceLanguage,"the target",targetLanguage)
|
26 |
|
27 |
-
|
28 |
-
|
|
|
29 |
message,
|
30 |
#max_new_tokens=100
|
31 |
tgt_lang= targetLanguage,
|
32 |
src_lang=sourceLanguage
|
33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
|
35 |
-
|
36 |
-
|
37 |
-
return response#..translation_text
|
38 |
|
39 |
"""
|
40 |
For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
|
@@ -52,8 +64,8 @@ demo = gr.ChatInterface(
|
|
52 |
step=0.05,
|
53 |
label="Top-p (nucleus sampling)",
|
54 |
),
|
55 |
-
gr.Textbox(value="
|
56 |
-
gr.Textbox(value="
|
57 |
],
|
58 |
)
|
59 |
|
|
|
5 |
For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
|
6 |
"""
|
7 |
englishToFinnishClient = InferenceClient("Helsinki-NLP/opus-mt-en-fi")
|
8 |
+
englishToSwedishClient = InferenceClient("google/flan-t5-large")#"facebook/nllb-200-1.3B")#"facebook/nllb-200-1.3B")
|
9 |
|
10 |
|
11 |
def respond(
|
|
|
24 |
|
25 |
print("the text",message, 'the source',sourceLanguage,"the target",targetLanguage)
|
26 |
|
27 |
+
|
28 |
+
if(isFinnish):
|
29 |
+
response= client.translation(
|
30 |
message,
|
31 |
#max_new_tokens=100
|
32 |
tgt_lang= targetLanguage,
|
33 |
src_lang=sourceLanguage
|
34 |
+
)
|
35 |
+
|
36 |
+
print('the finnish response',response)
|
37 |
+
|
38 |
+
return response
|
39 |
+
else:
|
40 |
+
text="Translate to "f"{targetLanguage}: "f"{message}"
|
41 |
+
print("the text",text)
|
42 |
+
response= client.text_generation(
|
43 |
+
text
|
44 |
+
)
|
45 |
+
|
46 |
+
print('the other language response',response)
|
47 |
|
48 |
+
return response
|
49 |
+
|
|
|
50 |
|
51 |
"""
|
52 |
For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
|
|
|
64 |
step=0.05,
|
65 |
label="Top-p (nucleus sampling)",
|
66 |
),
|
67 |
+
gr.Textbox(value="Finnish", label="Source Language"),
|
68 |
+
gr.Textbox(value="English", label="Target Language"),
|
69 |
],
|
70 |
)
|
71 |
|