jdgalvan commited on
Commit
b821e25
·
verified ·
1 Parent(s): d577b03

add custom handler

Browse files
Files changed (1) hide show
  1. handler.py +12 -0
handler.py ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Dict, List, Any
2
+ from transformers import pipeline
3
+
4
+ class EndpointHandler():
5
+ def __init__(self, path=""):
6
+ # Load model directly
7
+ self.pipeline = pipeline("text-generation", model="jdgalvan/Phi-3-mini-128k-instruct", trust_remote_code=True)
8
+
9
+ def __call__(self, messages: List[Dict[str, Any]]) -> List[Dict[str, Any]]:
10
+ # execute pipeline
11
+ response = self.pipeline(messages)
12
+ return response