From fc9b5e67dbcd3019610a0bf33a517994d0358f17 Mon Sep 17 00:00:00 2001 From: KevinHuSh Date: Fri, 7 Jun 2024 09:56:14 +0800 Subject: [PATCH] fix bug in api (#1088) ### What problem does this PR solve? #1075 ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --- api/apps/api_app.py | 2 +- rag/llm/embedding_model.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/api/apps/api_app.py b/api/apps/api_app.py index e7ffcdeac34..324ff93eab7 100644 --- a/api/apps/api_app.py +++ b/api/apps/api_app.py @@ -208,7 +208,7 @@ def stream(): try: for ans in chat(dia, msg, True, **req): fillin_conv(ans) - rename_field(rename_field) + rename_field(ans) yield "data:" + json.dumps({"retcode": 0, "retmsg": "", "data": ans}, ensure_ascii=False) + "\n\n" API4ConversationService.append_message(conv.id, conv.to_dict()) except Exception as e: diff --git a/rag/llm/embedding_model.py b/rag/llm/embedding_model.py index 328e43bac8a..91c2e77eeb6 100644 --- a/rag/llm/embedding_model.py +++ b/rag/llm/embedding_model.py @@ -140,7 +140,7 @@ def encode(self, texts: list, batch_size=10): token_count += resp["usage"]["total_tokens"] return np.array(res), token_count except Exception as e: - raise Exception("Account abnormal. Please ensure it's on good standing.") + raise Exception("Account abnormal. Please ensure it's on good standing to use QWen's "+self.model_name) return np.array([]), 0 def encode_queries(self, text): @@ -153,7 +153,7 @@ def encode_queries(self, text): return np.array(resp["output"]["embeddings"][0] ["embedding"]), resp["usage"]["total_tokens"] except Exception as e: - raise Exception("Account abnormal. Please ensure it's on good standing.") + raise Exception("Account abnormal. Please ensure it's on good standing to use QWen's "+self.model_name) return np.array([]), 0