Mir-2002's picture
added handler for inference endpoint
79f0ea0
import json
from handler import EndpointHandler
# Instantiate the handler with a dummy model_dir (replace with actual path if needed)
# Since we are testing the handler logic and not loading a real model here,
# we can initialize it with a placeholder. If your __init__ requires a valid path,
# you might need to adjust this or mock the AutoTokenizer and AutoModelForSeq2SeqLM calls.
# For a basic test of the __call__ method's structure, this might suffice.
# If model loading is essential for your test, you'll need to handle that.
handler = EndpointHandler(model_dir=".")
# Example function without a docstring
def multiply(a, b):
return a * b
# Prepare the data in the expected format for the handler
test_data = {"inputs": ["def multiply(a, b):\n return a * b"]}
# Call the handler
try:
response = handler(test_data)
print(json.dumps(response, indent=2))
except Exception as e:
print(f"An error occurred: {e}")