Commit 646de298 by 范立洲

fix: check score type

parent 9fe2708d
...@@ -18,7 +18,7 @@ POST_SCHEMA = { ...@@ -18,7 +18,7 @@ POST_SCHEMA = {
"properties": { "properties": {
"prompt": {"type": "string"}, "prompt": {"type": "string"},
"limit": {"type": "integer"}, "limit": {"type": "integer"},
"score": {"type": "integer"}, "score": {"type": "number"},
"stream": {"type": "boolean"}, "stream": {"type": "boolean"},
}, },
"required": ["prompt"], "required": ["prompt"],
......
...@@ -20,8 +20,8 @@ class IntentBot(BaseQDBot): ...@@ -20,8 +20,8 @@ class IntentBot(BaseQDBot):
# self.data_source = data_source # self.data_source = data_source
self.embdder = embedder self.embdder = embedder
self.collection = collection self.collection = collection
self.score = float(score) self.score = score
self.limit = int(limit) self.limit = limit
def formatter(self, line: List) -> Dict: def formatter(self, line: List) -> Dict:
# line format: 问题,答案, type, 意图 # line format: 问题,答案, type, 意图
......
...@@ -12,20 +12,20 @@ class QABot(BaseQDBot): ...@@ -12,20 +12,20 @@ class QABot(BaseQDBot):
data_source: QDDataSource, data_source: QDDataSource,
embedder: Embedding, embedder: Embedding,
collection: str, collection: str,
score: int, score: float,
limit: int, limit: int,
): ):
super(QABot, self).__init__(data_source) super(QABot, self).__init__(data_source)
self.embdder = embedder self.embdder = embedder
self.collection = collection self.collection = collection
self.score = float(score) self.score = score
self.limit = int(limit) self.limit = limit
def formatter(self, line: List) -> Dict: def formatter(self, line: List) -> Dict:
# line format: 问题,答案, type, 意图 # line format: 问题,答案, type, 意图
return BotPayload(question=line[0], answer=line[1], type=line[2]).to_dict() return BotPayload(question=line[0], answer=line[1], type=line[2]).to_dict()
def complete(self, prompt: str, score: int = 0, limit: int = 0) -> BotPayload: def complete(self, prompt: str, score: float = 0, limit: int = 0) -> BotPayload:
_limit = self.limit if limit == 0 else limit _limit = self.limit if limit == 0 else limit
_score = self.score if score == 0 else score _score = self.score if score == 0 else score
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论