Update handler.py
Browse files- handler.py +9 -6
handler.py
CHANGED
@@ -2,15 +2,18 @@ from typing import Dict, List, Any
|
|
2 |
from transformers import pipeline
|
3 |
|
4 |
class EndpointHandler():
|
5 |
-
def __init__(self, path=""):
|
6 |
-
#
|
7 |
-
self.pipeline = pipeline("
|
8 |
|
9 |
def __call__(self, data: Dict[str, Any]) -> List[Dict[str, Any]]:
|
10 |
# 处理输入数据并返回预测结果
|
11 |
inputs = data.get("inputs", "")
|
12 |
-
|
13 |
-
|
|
|
14 |
|
15 |
# 返回模型的响应
|
16 |
-
return
|
|
|
|
|
|
2 |
from transformers import pipeline
|
3 |
|
4 |
class EndpointHandler():
|
5 |
+
def __init__(self, path="zemuwen/14B_lora_ze"):
|
6 |
+
# 初始化方法,加载文本分类模型
|
7 |
+
self.pipeline = pipeline("conversational ", model=path)
|
8 |
|
9 |
def __call__(self, data: Dict[str, Any]) -> List[Dict[str, Any]]:
|
10 |
# 处理输入数据并返回预测结果
|
11 |
inputs = data.get("inputs", "")
|
12 |
+
|
13 |
+
# 使用分类模型生成响应
|
14 |
+
results = self.pipeline(inputs)
|
15 |
|
16 |
# 返回模型的响应
|
17 |
+
return results
|
18 |
+
|
19 |
+
print(result)
|