I swear I know what I'm doing

This commit is contained in:
Cyberes 2023-08-29 14:57:49 -06:00
parent 06b52c7648
commit 2d9ec15302
2 changed files with 8 additions and 4 deletions

View File

@ -66,6 +66,8 @@ def log_prompt(ip, token, prompt, response, gen_time, parameters, headers, backe
# TODO: test and verify this works as expected
response = None
print(response)
timestamp = int(time.time())
conn = sqlite3.connect(opts.database_path)
c = conn.cursor()

View File

@ -114,12 +114,13 @@ def generate():
backend_err = True
error_type = response_json_body.get('error_type')
error_type_string = 'returned an error' if opts.mode == 'oobabooga' else f'returned {indefinite_article(error_type)} {error_type} error'
backend_response = format_sillytavern_err(
f'Backend ({opts.mode}) {error_type_string}: {response_json_body.get("error")}',
'error')
response_json_body = {
'results': [
{
'text': format_sillytavern_err(
f'Backend ({opts.mode}) {error_type_string}: {response_json_body.get("error")}',
'error')
'text': backend_response
}
]
}
@ -133,6 +134,7 @@ def generate():
}
else:
raise Exception
if not backend_err:
redis.incr('proompts')
log_prompt(client_ip, token, request_json_body['prompt'], backend_response, elapsed_time if not backend_err else None, parameters, dict(request.headers), response.status_code if response else 0, response_json_body.get('details', {}).get('generated_tokens'), is_error=backend_err)
return jsonify({