zemuwen commited on
Commit
fe31f10
·
verified ·
1 Parent(s): cc8eed6

Update handler.py

Browse files
Files changed (1) hide show
  1. handler.py +7 -7
handler.py CHANGED
@@ -2,18 +2,18 @@ from typing import Dict, List, Any
2
  from transformers import pipeline
3
 
4
  class EndpointHandler():
5
- def __init__(self, path="zemuwen/14B_lora_ze"):
6
- # 初始化方法,加载文本分类模型
7
  self.pipeline = pipeline("question-answering", 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
-
 
2
  from transformers import pipeline
3
 
4
  class EndpointHandler():
5
+ def __init__(self, path="zemuwen/14B_lora_ze"):
6
+ # 初始化方法,加载问答模型
7
  self.pipeline = pipeline("question-answering", model=path)
8
 
9
  def __call__(self, data: Dict[str, Any]) -> List[Dict[str, Any]]:
10
+ # 确保输入数据包含 "question" 和 "context"
11
+ question = data.get("question", "")
12
+ context = data.get("context", "")
13
 
14
+ # 使用问答模型生成响应
15
+ results = self.pipeline(question=question, context=context)
16
 
17
  # 返回模型的响应
18
  return results
19