v2.0.2: fix SQLite — UUID in all INSERTs, now()→datetime, ::jsonb cleanup
Deploy contracts-flask / validate (push) Successful in 0s
Deploy contracts-flask / validate (push) Successful in 0s
This commit is contained in:
+12
-9
@@ -1,5 +1,6 @@
|
||||
"""Prompts CRUD."""
|
||||
from db.connection import query, execute, execute_returning
|
||||
import uuid
|
||||
from db.connection import query, execute
|
||||
|
||||
|
||||
def _serialize(row):
|
||||
@@ -46,8 +47,8 @@ def seed_defaults():
|
||||
"ТЕКСТ ДОКУМЕНТА:\n---\n{doc_text}\n---"
|
||||
)
|
||||
execute(
|
||||
"INSERT INTO prompts (role, name, body, is_active, notes) VALUES (%s, %s, %s, %s, %s)",
|
||||
("extract", "default-v1", extract_body, True, "Авто-создан из llm_prompt.py _build_initial"),
|
||||
"INSERT INTO prompts (id, role, name, body, is_active, notes) VALUES (%s, %s, %s, %s, %s, %s)",
|
||||
(str(uuid.uuid4()), "extract", "default-v1", extract_body, True, "Авто-создан из llm_prompt.py _build_initial"),
|
||||
)
|
||||
|
||||
if "diff" not in existing_roles:
|
||||
@@ -75,8 +76,8 @@ def seed_defaults():
|
||||
"ТЕКСТ ДОПСОГЛАШЕНИЯ:\n---\n{doc_text}\n---"
|
||||
)
|
||||
execute(
|
||||
"INSERT INTO prompts (role, name, body, is_active, notes) VALUES (%s, %s, %s, %s, %s)",
|
||||
("diff", "default-v1", diff_body, True, "Авто-создан из llm_prompt.py _build_diff"),
|
||||
"INSERT INTO prompts (id, role, name, body, is_active, notes) VALUES (%s, %s, %s, %s, %s, %s)",
|
||||
(str(uuid.uuid4()), "diff", "default-v1", diff_body, True, "Авто-создан из llm_prompt.py _build_diff"),
|
||||
)
|
||||
_ensure_classify_prompt()
|
||||
|
||||
@@ -97,11 +98,13 @@ def save_new_version(role, name, body, notes="", is_active=True):
|
||||
"""Save new prompt version. Deactivates all others for this role, inserts new one."""
|
||||
if is_active:
|
||||
execute("UPDATE prompts SET is_active=false WHERE role=%s", (role,))
|
||||
return execute_returning(
|
||||
"""INSERT INTO prompts (role, name, body, is_active, notes)
|
||||
VALUES (%s, %s, %s, %s, %s) RETURNING *""",
|
||||
(role, name, body, is_active, notes),
|
||||
pid = str(uuid.uuid4())
|
||||
execute(
|
||||
"""INSERT INTO prompts (id, role, name, body, is_active, notes)
|
||||
VALUES (%s, %s, %s, %s, %s, %s)""",
|
||||
(pid, role, name, body, is_active, notes),
|
||||
)
|
||||
return get(pid)
|
||||
|
||||
|
||||
def activate(prompt_id):
|
||||
|
||||
Reference in New Issue
Block a user