AndreasThinks commited on
Commit
d0077e2
·
verified ·
1 Parent(s): 1f438dd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -4
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"""### Instruction: {instruction}
 
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'].strip()
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