Update handler.py
Browse files- 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,
|
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 |
|