13 lines
585 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]
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": ns.get("kb_id",""), "name": ns.get("name",""), "parentid": ns.get("parentid","")})
return {"status": "SUCCEEDED", "id": dir_id}
return {"error": "failed"}