поправил правила хранения промтов
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2026-04-11 14:06:12 +10:00
parent 7e05dda3cb
commit 38ec470b67

View File

@@ -118,8 +118,7 @@ def create_table_config_gpt():
with conn.cursor() as cur:
cur.execute("""
CREATE TABLE IF NOT EXISTS config_gpt (
url TEXT PRIMARY KEY,
name VARCHAR(20),
name VARCHAR(20) PRIMARY KEY,
promt TEXT
);
""")
@@ -127,17 +126,16 @@ def create_table_config_gpt():
finally:
pass
def update_promt(url: str, name: str, promt: str):
def update_promt(name: str, promt: str):
conn = get_connection()
try:
with conn.cursor() as cur:
cur.execute("""
INSERT INTO config_gpt (url, name, promt)
VALUES (%s, %s, %s)
ON CONFLICT (url) DO UPDATE SET
name = EXCLUDED.name,
VALUES ( %s, %s)
ON CONFLICT (name) DO UPDATE SET
promt = EXCLUDED.promt
""", (url, name, promt))
""", (name, promt))
conn.commit()
finally:
pass
@@ -146,7 +144,7 @@ def get_promt(promt_name_url):
conn = get_connection()
try:
with conn.cursor(cursor_factory=RealDictCursor) as cur:
cur.execute("SELECT promt FROM config_gpt WHERE url = %s", (promt_name_url,))
cur.execute("SELECT promt FROM config_gpt WHERE name = %s", (promt_name_url,))
promt = cur.fetchone()
return promt['promt']
finally:
@@ -160,7 +158,7 @@ def get_all_promt():
cur.execute("SELECT * FROM config_gpt")
rows = cur.fetchall()
sources = [{"url": row["url"], "name": row["name"], "promt": row["promt"]} for row in rows]
sources = [{"name": row["name"], "promt": row["promt"]} for row in rows]
return {"sources": sources}
finally:
pass