munzirmuneer commited on
Commit
b0227dc
·
verified ·
1 Parent(s): fdad04a

Update handler.py

Browse files
Files changed (1) hide show
  1. handler.py +6 -1
handler.py CHANGED
@@ -17,10 +17,15 @@ class EndpointHandler:
17
  base_model = AutoModelForSequenceClassification.from_pretrained(model_name)
18
  self.model = PeftModel.from_pretrained(base_model, model_name)
19
 
20
- def __call__(self, input_text):
21
  """
22
  Perform inference on the input text and return predictions.
23
  """
 
 
 
 
 
24
  # Tokenize input
25
  inputs = self.tokenizer(input_text, return_tensors="pt", truncation=True, padding=True)
26
 
 
17
  base_model = AutoModelForSequenceClassification.from_pretrained(model_name)
18
  self.model = PeftModel.from_pretrained(base_model, model_name)
19
 
20
+ def __call__(self, input_data):
21
  """
22
  Perform inference on the input text and return predictions.
23
  """
24
+ # Extract the URL from the input_data dictionary
25
+ if 'inputs' in input_data:
26
+ input_text = input_data['inputs'] # Expecting a single URL as a string
27
+ else:
28
+ raise ValueError("Input data must contain the 'inputs' key with a URL.")
29
  # Tokenize input
30
  inputs = self.tokenizer(input_text, return_tensors="pt", truncation=True, padding=True)
31