Unverified 提交 9f5d1afc 作者: zhenkaivip 提交者: GitHub

fix bug : 1、历史最后一条丢失;2、上下两行连读造成歧义 (#415)

* fix _call bug

* fix

* fix bug : 上下两行连读造成歧义
上级 18d6b686
...@@ -121,7 +121,7 @@ def similarity_search_with_score_by_vector( ...@@ -121,7 +121,7 @@ def similarity_search_with_score_by_vector(
else: else:
_id0 = self.index_to_docstore_id[id] _id0 = self.index_to_docstore_id[id]
doc0 = self.docstore.search(_id0) doc0 = self.docstore.search(_id0)
doc.page_content += doc0.page_content doc.page_content += " " + doc0.page_content
if not isinstance(doc, Document): if not isinstance(doc, Document):
raise ValueError(f"Could not find document for id {_id}, got {doc}") raise ValueError(f"Could not find document for id {_id}, got {doc}")
doc_score = min([scores[0][id] for id in [indices[0].tolist().index(i) for i in id_seq if i in indices[0]]]) doc_score = min([scores[0][id] for id in [indices[0].tolist().index(i) for i in id_seq if i in indices[0]]])
......
...@@ -69,18 +69,16 @@ class ChatGLM(LLM): ...@@ -69,18 +69,16 @@ class ChatGLM(LLM):
history: List[List[str]] = [], history: List[List[str]] = [],
streaming: bool = STREAMING): # -> Tuple[str, List[List[str]]]: streaming: bool = STREAMING): # -> Tuple[str, List[List[str]]]:
if streaming: if streaming:
for inum, (stream_resp, _) in enumerate(self.model.stream_chat( history += [[]]
for stream_resp, _ in self.model.stream_chat(
self.tokenizer, self.tokenizer,
prompt, prompt,
history=history[-self.history_len:-1] if self.history_len > 0 else [], history=history[-self.history_len:-1] if self.history_len > 0 else [],
max_length=self.max_token, max_length=self.max_token,
temperature=self.temperature, temperature=self.temperature,
top_p=self.top_p, top_p=self.top_p,
)): ):
torch_gc() torch_gc()
if inum == 0:
history += [[prompt, stream_resp]]
else:
history[-1] = [prompt, stream_resp] history[-1] = [prompt, stream_resp]
yield stream_resp, history yield stream_resp, history
torch_gc() torch_gc()
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论