This commit is contained in:
yumoqing 2024-07-08 20:30:57 +08:00
parent 8b57dadd04
commit 4bc140bafe
2 changed files with 6 additions and 1 deletions

View File

@ -97,6 +97,10 @@ class BaseProcessor(AppLogger):
if self.retResponse is not None: if self.retResponse is not None:
self.set_response_headers(self.retResponse) self.set_response_headers(self.retResponse)
return 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): elif isinstance(self.content, DictObject):
self.content = json.dumps(self.content, indent=4) self.content = json.dumps(self.content, indent=4)
jsonflg = True jsonflg = True

View File

@ -41,7 +41,7 @@ class StreamLlmProxy:
if '[DONE]' in ll: if '[DONE]' in ll:
return return
try: try:
print('write_chunk(),l=', ll) # print('write_chunk(),l=', ll)
l = self.line_chunk_match(ll) l = self.line_chunk_match(ll)
d = DictObject(** json.loads(l)) d = DictObject(** json.loads(l))
j = {} j = {}
@ -66,6 +66,7 @@ class StreamLlmProxy:
print_exc() print_exc()
async def stream_handle(self, chunk): async def stream_handle(self, chunk):
print('chunk=', chunk)
chunk = chunk.decode('utf-8') chunk = chunk.decode('utf-8')
chunk = self.remain_str + chunk chunk = self.remain_str + chunk
lines = chunk.split('\n') lines = chunk.split('\n')