fix accessing None function_call
This commit is contained in:
parent
e950411b8b
commit
b6ff08a291
1 changed files with 3 additions and 3 deletions
|
@ -292,18 +292,18 @@ def chat_completions():
|
||||||
if (not stream):
|
if (not stream):
|
||||||
data = requests.request("POST", urllib.parse.urljoin(args.llama_api, "/completion"), data=json.dumps(postData))
|
data = requests.request("POST", urllib.parse.urljoin(args.llama_api, "/completion"), data=json.dumps(postData))
|
||||||
print(data.json())
|
print(data.json())
|
||||||
resData = make_resData(data.json(), chat=True, promptToken=promptToken, function_call=body.get("function_call"))
|
resData = make_resData(data.json(), chat=True, promptToken=promptToken, function_call=body.get("function_call", {}))
|
||||||
return jsonify(resData)
|
return jsonify(resData)
|
||||||
else:
|
else:
|
||||||
def generate():
|
def generate():
|
||||||
data = requests.request("POST", urllib.parse.urljoin(args.llama_api, "/completion"), data=json.dumps(postData), stream=True)
|
data = requests.request("POST", urllib.parse.urljoin(args.llama_api, "/completion"), data=json.dumps(postData), stream=True)
|
||||||
time_now = int(time.time())
|
time_now = int(time.time())
|
||||||
resData = make_resData_stream({}, chat=True, time_now=time_now, start=True, function_call=body.get("function_call"))
|
resData = make_resData_stream({}, chat=True, time_now=time_now, start=True, function_call=body.get("function_call", {}))
|
||||||
yield 'data: {}\n'.format(json.dumps(resData))
|
yield 'data: {}\n'.format(json.dumps(resData))
|
||||||
for line in data.iter_lines():
|
for line in data.iter_lines():
|
||||||
if line:
|
if line:
|
||||||
decoded_line = line.decode('utf-8')
|
decoded_line = line.decode('utf-8')
|
||||||
resData = make_resData_stream(json.loads(decoded_line[6:]), chat=True, time_now=time_now, function_call=body.get("function_call"))
|
resData = make_resData_stream(json.loads(decoded_line[6:]), chat=True, time_now=time_now, function_call=body.get("function_call", {}))
|
||||||
yield 'data: {}\n'.format(json.dumps(resData))
|
yield 'data: {}\n'.format(json.dumps(resData))
|
||||||
return Response(generate(), mimetype='text/event-stream')
|
return Response(generate(), mimetype='text/event-stream')
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue