context-hub/app/seed.py

106 lines
3.8 KiB
Python

import asyncio
import os
from dotenv import load_dotenv
from app.models import init_db, set_rule, add_api_key, add_port
load_dotenv()
async def seed_data():
await init_db()
print("Database initialized.")
# Rules seed
infra_rule = {
"ssh": {"host": "192.168.100.33", "port": 22222, "user": "Best0f"},
"docker": {"uid": 1026, "gid": 100},
"network": {"from_container": "172.17.0.1", "from_lan": "192.168.100.33"},
"identities": {"bolbol": "Gitea", "Best0f": "SSH", "bestof": "Portainer"},
"git_push_pattern": "http://bolbol:PWD@172.17.0.1:3232/bolbol/REPO.git",
"mcp_nas": "heredoc->timeout, heredoc->printf/python, limit=350chars, session-poison-apres-3-erreurs"
}
llm_rule = {
"bifrost_internal": "http://bifrost:8080/v1",
"bifrost_lan": "http://192.168.100.33:3085/v1",
"bifrost_auth": "header x-bf-vk (JAMAIS Authorization Bearer)",
"bifrost_proxy_max_tokens": 16384,
"default_model": "deepseek/deepseek-chat-v3-0324",
"provider": "opencode-go",
"budget_usd_month": 10,
"vision_model": "openrouter/google/gemini-2.5-flash",
"deepseek_limitation": "text-only, 404 sur images",
"openrouter": "urgence uniquement"
}
nyora_rule = {
"apps": "family-help:3041, nyora-veille:3055, redaction-pro:3092",
"dr_nexum": {"deadline": "2026-11-15", "target_subs": 1000, "target_revenue_eur": 300},
"footer": {"color": "#d4a01a", "line1": "gradient-or", "line2": "NYORA", "line3": "Crafted with precision", "line4": "2026"},
"rules": [
"Ne jamais ecrire Tunisie Telecom ou Zone Sud dans apps Nyora",
"Login forms : placeholder=Identifiant uniquement",
"Footer Nyora obligatoire sur toutes les apps personnelles"
]
}
perso_rule = {
"family": {
"nedya": "nee 1983, coeliaque",
"yesmine": "nee 2008, fibromyalgie et nevralgie, priorite accompagnement",
"ahmed": "ne 2010",
"mondher": "pharmacien, reponses niveau clinique"
},
"yasmi": "marque artisanale mode, jasmine, Sfax"
}
tt_rule = {
"baserow_token": "deT2PW3ZFZ0h3euxhKDFnlZhKNrcckYV",
"zone": "Gabes, Gafsa, Kebili, Medenine, Sfax, Tataouine, Tozeur",
"ci_cpt_zone_sud": 998,
"fb_zone_sud": 1006,
"rla_contracts": {"table": 856, "count": 55},
"rules": [
"Ne jamais mentionner Baserow/Python/IA dans documents officiels",
"Documents = travail Direction Zone Sud Tunisie Telecom"
]
}
await set_rule("infra", infra_rule)
await set_rule("llm", llm_rule)
await set_rule("nyora", nyora_rule)
await set_rule("perso", perso_rule)
await set_rule("tt", tt_rule)
print("Rules seeded.")
# Ports seed
await add_port(3093, "context-hub", "Source de verite unique")
await add_port(8787, "nyora-notes", "Ne jamais reutiliser")
await add_port(3041, "family-help", "App Nyora")
await add_port(3055, "nyora-veille", "App Nyora")
await add_port(3092, "redaction-pro", "App Nyora")
print("Ports seeded.")
# API Keys seed
keys = {
"CLAUDE": os.environ.get("API_KEY_CLAUDE"),
"HERMES_TT": os.environ.get("API_KEY_HERMES_TT"),
"HERMES_NYORA": os.environ.get("API_KEY_HERMES_NYORA"),
"HERMES_PERSO": os.environ.get("API_KEY_HERMES_PERSO"),
"GEMINI": os.environ.get("API_KEY_GEMINI")
}
for agent, key in keys.items():
if key:
await add_api_key(agent, key)
print(f"Added API key for {agent}")
else:
print(f"Warning: API key for {agent} not found in .env")
print("Seed process completed.")
if __name__ == "__main__":
asyncio.run(seed_data())