angelLino commited on
Commit
6a27466
·
verified ·
1 Parent(s): 3f128d6

Update handler.py

Browse files

Change the attribute of the text when extracting the text from the inputs.

Files changed (1) hide show
  1. handler.py +2 -2
handler.py CHANGED
@@ -4,7 +4,7 @@ from transformers import AutoModelForSeq2SeqLM, NllbTokenizer
4
  from transformers import pipeline
5
 
6
  class EndpointHandler():
7
- def __init__(self, path="angelLino/nllb-es-agr-V2"):
8
  # Initialize the pre-trained translation pipeline
9
  self.model = AutoModelForSeq2SeqLM.from_pretrained(path)
10
  self.tokenizer = NllbTokenizer.from_pretrained(path)
@@ -20,7 +20,7 @@ class EndpointHandler():
20
  Returns:
21
  List[Dict[str, Any]]: A list of dictionaries containing translated sentences.
22
  """
23
- text = data.get("text", "")
24
 
25
  parameters = data.get("parameters", {})
26
  src_lang = parameters.get("src_lang", "spa_Latn").strip()
 
4
  from transformers import pipeline
5
 
6
  class EndpointHandler():
7
+ def __init__(self, path="."):
8
  # Initialize the pre-trained translation pipeline
9
  self.model = AutoModelForSeq2SeqLM.from_pretrained(path)
10
  self.tokenizer = NllbTokenizer.from_pretrained(path)
 
20
  Returns:
21
  List[Dict[str, Any]]: A list of dictionaries containing translated sentences.
22
  """
23
+ text = data.get("inputs", "")
24
 
25
  parameters = data.get("parameters", {})
26
  src_lang = parameters.get("src_lang", "spa_Latn").strip()