43 lines
1.0 KiB
Python
43 lines
1.0 KiB
Python
from llm_server.database.conn import db_pool
|
|
|
|
|
|
def create_db():
|
|
conn = db_pool.connection()
|
|
cursor = conn.cursor()
|
|
cursor.execute('''
|
|
CREATE TABLE IF NOT EXISTS prompts (
|
|
ip TEXT,
|
|
token TEXT DEFAULT NULL,
|
|
model TEXT,
|
|
backend_mode TEXT,
|
|
backend_url TEXT,
|
|
request_url TEXT,
|
|
generation_time FLOAT,
|
|
prompt TEXT,
|
|
prompt_tokens INTEGER,
|
|
response TEXT,
|
|
response_tokens INTEGER,
|
|
response_status INTEGER,
|
|
parameters TEXT,
|
|
CHECK (parameters IS NULL OR JSON_VALID(parameters)),
|
|
headers TEXT,
|
|
CHECK (headers IS NULL OR JSON_VALID(headers)),
|
|
timestamp INTEGER
|
|
)
|
|
''')
|
|
cursor.execute('''
|
|
CREATE TABLE IF NOT EXISTS token_auth (
|
|
token TEXT,
|
|
UNIQUE (token),
|
|
type TEXT NOT NULL,
|
|
priority INTEGER DEFAULT 9999,
|
|
uses INTEGER DEFAULT 0,
|
|
max_uses INTEGER,
|
|
expire INTEGER,
|
|
disabled BOOLEAN DEFAULT 0
|
|
)
|
|
''')
|
|
conn.commit()
|
|
cursor.close()
|
|
|