From 653c759d8d4e1c410a78a5380f28afefcf34dfab Mon Sep 17 00:00:00 2001 From: KevinHuSh <kevinhu.sh@gmail.com> Date: Tue, 9 Apr 2024 16:16:10 +0800 Subject: [PATCH] resolve issure to call ZH?IPUAI (#277) ### What problem does this PR solve? Issue link:#265 ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --- api/apps/conversation_app.py | 5 ++++- rag/llm/chat_model.py | 1 + rag/nlp/query.py | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/api/apps/conversation_app.py b/api/apps/conversation_app.py index 6ece253..2379d30 100644 --- a/api/apps/conversation_app.py +++ b/api/apps/conversation_app.py @@ -360,7 +360,10 @@ def use_sql(question, field_map, tenant_id, chat_mdl): "|" for r in tbl["rows"]] if not docid_idx or not docnm_idx: chat_logger.warning("SQL missing field: " + sql) - return "\n".join([clmns, line, "\n".join(rows)]), [] + return { + "answer": "\n".join([clmns, line, rows]), + "reference": {"chunks": [], "doc_aggs": []} + } rows = "\n".join([r + f" ##{ii}$$ |" for ii, r in enumerate(rows)]) rows = re.sub(r"T[0-9]{2}:[0-9]{2}:[0-9]{2}(\.[0-9]+Z)?\|", "|", rows) diff --git a/rag/llm/chat_model.py b/rag/llm/chat_model.py index 98f6ce6..498595d 100644 --- a/rag/llm/chat_model.py +++ b/rag/llm/chat_model.py @@ -117,6 +117,7 @@ class ZhipuChat(Base): history.insert(0, {"role": "system", "content": system}) try: if "presence_penalty" in gen_conf: del gen_conf["presence_penalty"] + if "frequency_penalty" in gen_conf: del gen_conf["frequency_penalty"] response = self.client.chat.completions.create( model=self.model_name, messages=history, diff --git a/rag/nlp/query.py b/rag/nlp/query.py index 26753d7..e62fb9f 100644 --- a/rag/nlp/query.py +++ b/rag/nlp/query.py @@ -35,7 +35,7 @@ class EsQueryer: @staticmethod def rmWWW(txt): patts = [ - (r"ćŻ*(什äąć ·çš„|哪家|那家|ĺ•Ąć ·|ĺ’‹ć ·äş†|什äąć—¶ĺ€™|何时|何地|何人|ćŻĺ¦|ćŻä¸ŤćŻ|多少|哪里|怎äą|ĺ“Şĺ„ż|怎äąć ·|如何|ĺ“Şäş›|ćŻĺ•Ą|ĺ•ĄćŻ|ĺ•Š|ĺ—|呢|ĺ§|ĺ’‹|什äą|有没有|ĺ‘€)ćŻ*", ""), + (r"ćŻ*(什äąć ·çš„|哪家|一下|那家|ĺ•Ąć ·|ĺ’‹ć ·äş†|什äąć—¶ĺ€™|何时|何地|何人|ćŻĺ¦|ćŻä¸ŤćŻ|多少|哪里|怎äą|ĺ“Şĺ„ż|怎äąć ·|如何|ĺ“Şäş›|ćŻĺ•Ą|ĺ•ĄćŻ|ĺ•Š|ĺ—|呢|ĺ§|ĺ’‹|什äą|有没有|ĺ‘€)ćŻ*", ""), (r"(^| )(what|who|how|which|where|why)('re|'s)? ", " "), (r"(^| )('s|'re|is|are|were|was|do|does|did|don't|doesn't|didn't|has|have|be|there|you|me|your|my|mine|just|please|may|i|should|would|wouldn't|will|won't|done|go|for|with|so|the|a|an|by|i'm|it's|he's|she's|they|they're|you're|as|by|on|in|at|up|out|down)", " ") ] -- GitLab