File size: 2,657 Bytes
276ef31
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38e1109
276ef31
 
38e1109
276ef31
 
 
 
 
 
 
 
 
 
38e1109
276ef31
38e1109
276ef31
 
38e1109
276ef31
 
 
 
 
 
 
 
 
 
38e1109
276ef31
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
"""Seed script: idempotent, useful for first-run dev data."""

from __future__ import annotations

import asyncio
from datetime import datetime, timezone

from app.core.config import get_settings
from app.core.security import hash_password
from app.db import mongo


async def main() -> None:
    await mongo.connect()
    now = datetime.now(tz=timezone.utc)
    s = get_settings()

    if await mongo.users().count_documents({"email": "admin@teteffd.hf.space"}) == 0:
        await mongo.users().insert_one({
            "username": "admin",
            "email": "admin@teteffd.hf.space",
            "passwordHash": hash_password("Admin123!"),
            "role": "superadmin",
            "status": "approved",
            "avatar": None,
            "createdAt": now,
            "updatedAt": now,
            "lastLogin": None,
            "failedLoginAttempts": 0,
            "lockedUntil": None,
        })
        print("seeded superadmin admin@teteffd.hf.space / Admin123!")

    if await mongo.users().count_documents({"email": "developer@teteffd.hf.space"}) == 0:
        await mongo.users().insert_one({
            "username": "developer",
            "email": "developer@teteffd.hf.space",
            "passwordHash": hash_password("Dev123!"),
            "role": "developer",
            "status": "approved",
            "avatar": None,
            "createdAt": now,
            "updatedAt": now,
            "lastLogin": None,
            "failedLoginAttempts": 0,
            "lockedUntil": None,
        })
        print("seeded developer developer@teteffd.hf.space / Dev123!")

    if await mongo.system_prompts().count_documents({"name": "WormGPT Default"}) == 0:
        await mongo.system_prompts().insert_one({
            "name": "WormGPT Default",
            "description": "Helpful, accurate, concise assistant.",
            "content": "You are WormGPT, a helpful, accurate, and concise AI assistant. "
                       "When unsure, say you don't know. Cite sources when relevant.",
            "tags": ["general"],
            "active": True,
            "currentVersion": 1,
            "versions": [{
                "version": 1, "content": "You are WormGPT, a helpful, accurate, and concise AI assistant. "
                                          "When unsure, say you don't know. Cite sources when relevant.",
                "changelog": "initial", "createdAt": now,
            }],
            "createdAt": now,
            "updatedAt": now,
        })
        print("seeded system prompt 'WormGPT Default'")

    print("done")
    await mongo.disconnect()


if __name__ == "__main__":
    asyncio.run(main())