File size: 506 Bytes
f30715f 088c9cc f30715f f370b92 f30715f f370b92 172c1a7 f370b92 088c9cc |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
from typing import Dict, List, Any
from transformers import pipeline
class EndpointHandler():
def __init__(self, path=""):
# 初始化方法,加载模型
self.pipeline = pipeline("text-classification", model=path)
def __call__(self, data: Dict[str, Any]) -> List[Dict[str, Any]]:
# 处理输入数据并返回预测结果
inputs = data.get("inputs", "")
prediction = self.pipeline(inputs)
return {"response": conversation.generated_responses[0]}
|