zemuwen commited on
Commit
f370b92
·
verified ·
1 Parent(s): 088c9cc

Update handler.py

Browse files
Files changed (1) hide show
  1. handler.py +5 -9
handler.py CHANGED
@@ -3,15 +3,11 @@ from transformers import pipeline
3
 
4
  class EndpointHandler():
5
  def __init__(self, path=""):
6
- # 初始化对话模型
7
- self.pipeline = pipeline("conversational", model=path)
8
 
9
- def __call__(self, data: Dict[str, Any]) -> Dict[str, Any]:
10
- # 从请求数据中获取输入文本
11
  inputs = data.get("inputs", "")
12
-
13
- # 使用对话模型生成响应
14
- conversation = self.pipeline(inputs)
15
-
16
- # 返回模型的响应
17
  return {"response": conversation.generated_responses[0]}
 
3
 
4
  class EndpointHandler():
5
  def __init__(self, path=""):
6
+ # 初始化方法,加载模型
7
+ self.pipeline = pipeline("text-classification", model=path)
8
 
9
+ def __call__(self, data: Dict[str, Any]) -> List[Dict[str, Any]]:
10
+ # 处理输入数据并返回预测结果
11
  inputs = data.get("inputs", "")
12
+ prediction = self.pipeline(inputs)
 
 
 
 
13
  return {"response": conversation.generated_responses[0]}