File size: 584 Bytes
f30715f
 
088c9cc
f30715f
9fd3b68
 
cc8eed6
f30715f
f370b92
 
172c1a7
9fd3b68
 
 
eb224c5
 
9fd3b68
 
8984244
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from typing import Dict, List, Any
from transformers import pipeline

class EndpointHandler():
    def __init__(self, path="zemuwen/14B_lora_ze"):
        # 初始化方法,加载文本分类模型
        self.pipeline = pipeline("question-answering", model=path)

    def __call__(self, data: Dict[str, Any]) -> List[Dict[str, Any]]:
        # 处理输入数据并返回预测结果
        inputs = data.get("inputs", "")
        
        # 使用分类模型生成响应
        results = self.pipeline(inputs)
        
        # 返回模型的响应
        return results