16 lines
702 B
Plaintext

ns = params_kw.copy()
db = DBPools()
dbname = get_module_dbname('rag')
async with db.sqlorContext(dbname) as sor:
import uuid
dir_id = uuid.uuid4().hex[:16]
name = ns.get("name", "")
parent_id = ns.get("parentid", "")
kb_id = ns.get("kb_id", "")
await sor.sqlExe(
"INSERT INTO document_chunks (id, doc_id, kb_id, chunk_index, chunk_type, content, description, created_at) "
"VALUES (${id}$, '', ${kb_id}$, 0, 'directory', ${name}$, ${parentid}$, NOW())",
{"id": dir_id, "kb_id": kb_id, "name": name, "parentid": parent_id})
result = {"widgettype": "Message", "options": {"user_data": {"id": dir_id, "label": name, "parentid": parent_id}}}
result