ismailhakki37 commited on
Commit
5dbcc99
·
verified ·
1 Parent(s): 8e76cea

updata handle trh

Browse files
Files changed (1) hide show
  1. handler.py +23 -1
handler.py CHANGED
@@ -532,8 +532,30 @@ def get_model_info():
532
  "device": str(model.device) if model else "Unknown"
533
  }
534
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
535
  # For backward compatibility and testing
536
  if __name__ == "__main__":
537
  print("Handler module loaded successfully!")
538
  print("This handler is now ready for Hugging Face endpoints.")
539
- print("Use the 'query' function as the main endpoint.")
 
 
532
  "device": str(model.device) if model else "Unknown"
533
  }
534
 
535
+ # Hugging Face EndpointHandler class
536
+ class EndpointHandler:
537
+ """Hugging Face endpoint handler class"""
538
+
539
+ def __init__(self, model_dir):
540
+ """Initialize the endpoint handler"""
541
+ self.model_dir = model_dir
542
+ print(f"EndpointHandler initialized with model_dir: {model_dir}")
543
+
544
+ def __call__(self, payload):
545
+ """Main endpoint function - delegates to query function"""
546
+ return query(payload)
547
+
548
+ def health_check(self):
549
+ """Health check endpoint"""
550
+ return health_check()
551
+
552
+ def get_model_info(self):
553
+ """Get model information"""
554
+ return get_model_info()
555
+
556
  # For backward compatibility and testing
557
  if __name__ == "__main__":
558
  print("Handler module loaded successfully!")
559
  print("This handler is now ready for Hugging Face endpoints.")
560
+ print("Use the 'query' function as the main endpoint.")
561
+ print("Or use EndpointHandler class for Hugging Face compatibility.")