fix UnboundLocalError: local variable 'response' referenced before assignment

This commit is contained in:
josc146 2023-06-08 13:30:34 +08:00
parent 39a7eee8ea
commit 635767408f

View File

@ -138,6 +138,7 @@ The following is a coherent verbose detailed conversation between a girl named {
set_rwkv_config(model, global_var.get(global_var.Model_Config))
set_rwkv_config(model, body)
if body.stream:
response = ""
for response, delta in model.generate(
completion_text,
stop=f"\n\n{user}" if body.stop is None else body.stop,
@ -188,7 +189,7 @@ The following is a coherent verbose detailed conversation between a girl named {
)
yield "[DONE]"
else:
response = None
response = ""
for response, delta in model.generate(
completion_text,
stop=f"\n\n{user}" if body.stop is None else body.stop,
@ -282,6 +283,7 @@ async def completions(body: CompletionBody, request: Request):
set_rwkv_config(model, global_var.get(global_var.Model_Config))
set_rwkv_config(model, body)
if body.stream:
response = ""
for response, delta in model.generate(body.prompt, stop=body.stop):
if await request.is_disconnected():
break
@ -329,7 +331,7 @@ async def completions(body: CompletionBody, request: Request):
)
yield "[DONE]"
else:
response = None
response = ""
for response, delta in model.generate(body.prompt, stop=body.stop):
if await request.is_disconnected():
break