From 9f5d1afc31a71d2ba2fabaa350fb44f28de27d03 Mon Sep 17 00:00:00 2001 From: zhenkaivip Date: Sat, 20 May 2023 01:19:22 +0800 Subject: [PATCH] =?UTF-8?q?fix=20bug=20:=201=E3=80=81=E5=8E=86=E5=8F=B2?= =?UTF-8?q?=E6=9C=80=E5=90=8E=E4=B8=80=E6=9D=A1=E4=B8=A2=E5=A4=B1=EF=BC=9B?= =?UTF-8?q?2=E3=80=81=E4=B8=8A=E4=B8=8B=E4=B8=A4=E8=A1=8C=E8=BF=9E?= =?UTF-8?q?=E8=AF=BB=E9=80=A0=E6=88=90=E6=AD=A7=E4=B9=89=20(#415)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix _call bug * fix * fix bug : 上下两行连读造成歧义 --- chains/local_doc_qa.py | 2 +- models/chatglm_llm.py | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/chains/local_doc_qa.py b/chains/local_doc_qa.py index d4cdcb0..6921ef8 100644 --- a/chains/local_doc_qa.py +++ b/chains/local_doc_qa.py @@ -121,7 +121,7 @@ def similarity_search_with_score_by_vector( else: _id0 = self.index_to_docstore_id[id] doc0 = self.docstore.search(_id0) - doc.page_content += doc0.page_content + doc.page_content += " " + doc0.page_content if not isinstance(doc, Document): 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]]]) diff --git a/models/chatglm_llm.py b/models/chatglm_llm.py index 49ce97c..a63a3d1 100644 --- a/models/chatglm_llm.py +++ b/models/chatglm_llm.py @@ -69,19 +69,17 @@ class ChatGLM(LLM): history: List[List[str]] = [], streaming: bool = STREAMING): # -> Tuple[str, List[List[str]]]: if streaming: - for inum, (stream_resp, _) in enumerate(self.model.stream_chat( + history += [[]] + for stream_resp, _ in self.model.stream_chat( self.tokenizer, prompt, history=history[-self.history_len:-1] if self.history_len > 0 else [], max_length=self.max_token, temperature=self.temperature, top_p=self.top_p, - )): + ): torch_gc() - if inum == 0: - history += [[prompt, stream_resp]] - else: - history[-1] = [prompt, stream_resp] + history[-1] = [prompt, stream_resp] yield stream_resp, history torch_gc() else: