Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -17,23 +17,25 @@ def translate(text, source_lang, target_lang):
|
|
17 |
|
18 |
instruction = f"Translate the text from {source_lang} to {target_lang}"
|
19 |
|
20 |
-
input_text = f"""
|
|
|
21 |
|
22 |
-
### Input: {text}
|
23 |
|
24 |
-
### Response:
|
25 |
"""
|
26 |
|
27 |
output = query({
|
28 |
"inputs": input_text,
|
29 |
"parameters": {
|
|
|
30 |
"return_full_text": False
|
31 |
}
|
32 |
})
|
33 |
|
34 |
# Extract the translated text from the model output
|
35 |
# Assuming the model returns just the translation without the instruction format
|
36 |
-
translated_text = output[0]['generated_text']
|
37 |
|
38 |
return translated_text
|
39 |
|
|
|
17 |
|
18 |
instruction = f"Translate the text from {source_lang} to {target_lang}"
|
19 |
|
20 |
+
input_text = f"""
|
21 |
+
### Instruction: {instruction}
|
22 |
|
23 |
+
### Input: {text}
|
24 |
|
25 |
+
### Response:
|
26 |
"""
|
27 |
|
28 |
output = query({
|
29 |
"inputs": input_text,
|
30 |
"parameters": {
|
31 |
+
"return_text": False,
|
32 |
"return_full_text": False
|
33 |
}
|
34 |
})
|
35 |
|
36 |
# Extract the translated text from the model output
|
37 |
# Assuming the model returns just the translation without the instruction format
|
38 |
+
translated_text = output[0]['generated_text']
|
39 |
|
40 |
return translated_text
|
41 |
|