From b07a6f4e27e79e2aa7b12e1300f07eb925d22c30 Mon Sep 17 00:00:00 2001 From: Michelle <97082656+MichelleMa8@users.noreply.github.com> Date: Mon, 11 Dec 2023 14:08:11 +0800 Subject: [PATCH] [colossalqa] fix pangu api (#5170) * fix pangu api * add comment --- applications/ColossalQA/colossalqa/memory.py | 2 +- .../ColossalQA/examples/webui_demo/server.py | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/applications/ColossalQA/colossalqa/memory.py b/applications/ColossalQA/colossalqa/memory.py index 255df68a3..7a5512281 100644 --- a/applications/ColossalQA/colossalqa/memory.py +++ b/applications/ColossalQA/colossalqa/memory.py @@ -154,7 +154,7 @@ class ConversationBufferWithSummary(ConversationSummaryMemory): remain = self.max_tokens - prompt_length while self.get_conversation_length() > remain: if len(self.buffered_history.messages) <= 2: - raise RuntimeError("Exeeed max_tokens, trunck size of retrieved documents is too large") + raise RuntimeError("Exceed max_tokens, trunk size of retrieved documents is too large") temp = self.buffered_history.messages.pop(0) self.summarized_history_temp.messages.append(temp) temp = self.buffered_history.messages.pop(0) diff --git a/applications/ColossalQA/examples/webui_demo/server.py b/applications/ColossalQA/examples/webui_demo/server.py index 050994567..3b0f82845 100644 --- a/applications/ColossalQA/examples/webui_demo/server.py +++ b/applications/ColossalQA/examples/webui_demo/server.py @@ -77,12 +77,16 @@ if __name__ == "__main__": colossal_api = ColossalAPI(model_name, all_config["model"]["model_path"]) llm = ColossalLLM(n=1, api=colossal_api) elif all_config["model"]["mode"] == "api": - all_config["chain"]["mem_llm_kwargs"] = None - all_config["chain"]["disambig_llm_kwargs"] = None - all_config["chain"]["gen_llm_kwargs"] = None if model_name == "pangu_api": from colossalqa.local.pangu_llm import Pangu - llm = Pangu(id=1) + + gen_config = { + "user": "User", + "max_tokens": all_config["chain"]["disambig_llm_kwargs"]["max_new_tokens"], + "temperature": all_config["chain"]["disambig_llm_kwargs"]["temperature"], + "n": 1 # the number of responses generated + } + llm = Pangu(gen_config=gen_config) llm.set_auth_config() # verify user's auth info here elif model_name == "chatgpt_api": from langchain.llms import OpenAI