check error

pull/4/head
Michael Yang 2023-10-14 13:46:00 -07:00
parent 23ceef4bb4
commit e999f3c8f4
1 changed files with 3 additions and 0 deletions

View File

@ -45,6 +45,9 @@ async def generate_response(prompt, context=[]):
async def buffered_generate_response(prompt, context=[]):
buffer = ''
async for part in generate_response(prompt, context):
if error := part.get('error'):
raise Exception(error)
if part['done']:
yield buffer, part
break