From 4bc140bafeb268da5ebb5cad9aae75778d498ec2 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Mon, 8 Jul 2024 20:30:57 +0800 Subject: [PATCH] bugfix --- ahserver/baseProcessor.py | 4 ++++ ahserver/llm_client.py | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ahserver/baseProcessor.py b/ahserver/baseProcessor.py index ab64993..888010d 100755 --- a/ahserver/baseProcessor.py +++ b/ahserver/baseProcessor.py @@ -97,6 +97,10 @@ class BaseProcessor(AppLogger): if self.retResponse is not None: self.set_response_headers(self.retResponse) return self.retResponse + elif isinstance(self.content, Response): + return self.content + elif isinstance(self.content, StreamResponse): + return self.content elif isinstance(self.content, DictObject): self.content = json.dumps(self.content, indent=4) jsonflg = True diff --git a/ahserver/llm_client.py b/ahserver/llm_client.py index 682b20d..6024f38 100644 --- a/ahserver/llm_client.py +++ b/ahserver/llm_client.py @@ -41,7 +41,7 @@ class StreamLlmProxy: if '[DONE]' in ll: return try: - print('write_chunk(),l=', ll) + # print('write_chunk(),l=', ll) l = self.line_chunk_match(ll) d = DictObject(** json.loads(l)) j = {} @@ -66,6 +66,7 @@ class StreamLlmProxy: print_exc() async def stream_handle(self, chunk): + print('chunk=', chunk) chunk = chunk.decode('utf-8') chunk = self.remain_str + chunk lines = chunk.split('\n')