fix database error
This commit is contained in:
parent
839bb115c6
commit
2543db87e8
|
@ -48,6 +48,11 @@ def log_prompt(ip, token, prompt, response, gen_time, parameters, headers, backe
|
|||
prompt_tokens = len(tokenizer.encode(prompt))
|
||||
response_tokens = len(tokenizer.encode(response))
|
||||
|
||||
# Sometimes we may want to insert null into the DB but
|
||||
# usually we want to insert a float.
|
||||
if gen_time:
|
||||
gen_time = round(gen_time, 3)
|
||||
|
||||
if not opts.log_prompts:
|
||||
prompt = response = None
|
||||
|
||||
|
@ -55,7 +60,7 @@ def log_prompt(ip, token, prompt, response, gen_time, parameters, headers, backe
|
|||
conn = sqlite3.connect(opts.database_path)
|
||||
c = conn.cursor()
|
||||
c.execute("INSERT INTO prompts VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
||||
(ip, token, prompt, prompt_tokens, response, response_tokens, backend_response_code, round(gen_time, 3), json.dumps(parameters), json.dumps(headers), timestamp))
|
||||
(ip, token, prompt, prompt_tokens, response, response_tokens, backend_response_code, gen_time, json.dumps(parameters), json.dumps(headers), timestamp))
|
||||
conn.commit()
|
||||
conn.close()
|
||||
|
||||
|
|
Reference in New Issue