bugfix
This commit is contained in:
parent
3817955fa4
commit
0e2bf3fb80
@ -95,26 +95,32 @@ async def uapi_request(request, llm, sor):
|
|||||||
uapi = UAPI(request, sor=sor)
|
uapi = UAPI(request, sor=sor)
|
||||||
userid = await get_owner_userid(sor, llm)
|
userid = await get_owner_userid(sor, llm)
|
||||||
txt = ''
|
txt = ''
|
||||||
async for l in uapi.stream_linify(llm.upappid, llm.apiname, userid,
|
try:
|
||||||
params=env.params_kw):
|
async for l in uapi.stream_linify(llm.upappid, llm.apiname, userid,
|
||||||
if l and l != '[DONE]':
|
params=env.params_kw):
|
||||||
yield_it = False
|
if l and l != '[DONE]':
|
||||||
d = {}
|
yield_it = False
|
||||||
try:
|
d = {}
|
||||||
d = json.loads(l)
|
try:
|
||||||
except Exception as e:
|
d = json.loads(l)
|
||||||
debug(f'json.loads({l}) error({e})')
|
except Exception as e:
|
||||||
continue
|
debug(f'json.loads({l}) error({e})')
|
||||||
if d.get('reasoning_content'):
|
continue
|
||||||
txt += d.get('reasoning_content')
|
if d.get('reasoning_content'):
|
||||||
yield_it = True
|
txt += d.get('reasoning_content')
|
||||||
if d.get('content'):
|
yield_it = True
|
||||||
txt = txt + d['content']
|
if d.get('content'):
|
||||||
yield_it = True
|
txt = txt + d['content']
|
||||||
if yield_it:
|
yield_it = True
|
||||||
yield l
|
if yield_it:
|
||||||
else:
|
yield l
|
||||||
debug(f'{l} not yield')
|
else:
|
||||||
|
debug(f'{l} not yield')
|
||||||
|
except Exception as e:
|
||||||
|
exception(f'{e=},{format_exc()}')
|
||||||
|
yield f'{{"content": f"ERROR:{e=}"}}\n'
|
||||||
|
return
|
||||||
|
|
||||||
debug(f'{txt=}')
|
debug(f'{txt=}')
|
||||||
|
|
||||||
async def async_uapi_request(request, llm, sor):
|
async def async_uapi_request(request, llm, sor):
|
||||||
@ -123,7 +129,13 @@ async def async_uapi_request(request, llm, sor):
|
|||||||
callerid = await env.get_user()
|
callerid = await env.get_user()
|
||||||
uapi = UAPI(request, sor=sor)
|
uapi = UAPI(request, sor=sor)
|
||||||
userid = await get_owner_userid(sor, llm)
|
userid = await get_owner_userid(sor, llm)
|
||||||
b = await uapi.call(llm.upappid, llm.apiname, userid, params=env.params_kw)
|
b = None
|
||||||
|
try:
|
||||||
|
b = await uapi.call(llm.upappid, llm.apiname, userid, params=env.params_kw)
|
||||||
|
except Exception as e:
|
||||||
|
exception(f'{e=},{format_exc()}')
|
||||||
|
yield f'{{"content": f"ERROR:{e=}"}}\n'
|
||||||
|
return
|
||||||
if isinstance(b, bytes):
|
if isinstance(b, bytes):
|
||||||
b = b.decode('utf-8')
|
b = b.decode('utf-8')
|
||||||
debug(f'task sumbited:{b}')
|
debug(f'task sumbited:{b}')
|
||||||
@ -134,11 +146,18 @@ async def async_uapi_request(request, llm, sor):
|
|||||||
return
|
return
|
||||||
uapi = UAPI(request, sor=sor)
|
uapi = UAPI(request, sor=sor)
|
||||||
while True:
|
while True:
|
||||||
b = await uapi.call(llm.upappid, llm.query_apiname, userid,
|
b = None
|
||||||
params={
|
try:
|
||||||
"taskid": d.get('taskid')
|
b = await uapi.call(llm.upappid, llm.query_apiname, userid,
|
||||||
}
|
params={
|
||||||
)
|
"taskid": d.get('taskid')
|
||||||
|
}
|
||||||
|
)
|
||||||
|
except Exception as e:
|
||||||
|
exception(f'{e=},{format_exc()}')
|
||||||
|
yield f'{{"content": f"ERROR:{e=}"}}\n'
|
||||||
|
return
|
||||||
|
|
||||||
if isinstance(b, bytes):
|
if isinstance(b, bytes):
|
||||||
b = b.decode('utf-8')
|
b = b.decode('utf-8')
|
||||||
b = ''.join(b.split('\n'))
|
b = ''.join(b.split('\n'))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user