27 lines
955 B
Python
27 lines
955 B
Python
"""Инициализация: применить schema.sql + создать коллекцию Qdrant."""
|
|
import sys, pathlib
|
|
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
|
|
|
|
from pegas_memory import config, db, qdrant_store
|
|
|
|
def main():
|
|
print("Применяю schema.sql к", config.PG_DSN.split('@')[-1])
|
|
sql = pathlib.Path(__file__).resolve().parents[1] / "schema.sql"
|
|
conn = db.connect()
|
|
with conn.cursor() as cur:
|
|
cur.execute(sql.read_text())
|
|
conn.commit()
|
|
print(" -> schema OK")
|
|
|
|
print("Создаю коллекцию Qdrant", config.QDRANT_COLLECTION, "(dim=%d)" % config.EMBED_DIM)
|
|
qdrant_store.ensure_collection()
|
|
print(" -> collection OK")
|
|
|
|
# проверить эмбеддинг
|
|
v = __import__('pegas_memory.embedding', fromlist=['embed']).embed("проверка")
|
|
print(" -> embedding dim:", len(v))
|
|
print("DONE")
|
|
|
|
if __name__ == "__main__":
|
|
main()
|