This repository has been archived on 2025-11-27. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
Fitz_Studio/backend/services/text_manager.py
T

30 lines
1.1 KiB
Python

from src.TextManager.biblioteca import Biblioteca
from src.TextManager.biblioteca_mmr import BibliotecaRepo
from src.Llms.Embedders.Openai_embedder import OpenAIEmbedder
from src.ApiKeys.openai_apikey_mmr import OpenAICredencialRepo
from src.ConexionSql.Postgres_conexion import PostgresConexion
from backend.db.conexion import get_conexion
def crear_biblioteca(nombre_biblioteca: str, conexion: PostgresConexion, descripcion: str):
cred_repo = OpenAICredencialRepo(conexion)
credencial = cred_repo.get_by_id("OPAK20250510-ac2cea8af3110632314")
embedder = OpenAIEmbedder(credencial, model="text-embedding-3-large")
biblioteca = Biblioteca(nombre=nombre_biblioteca,
embedder=embedder,
descripcion=descripcion)
repo = BibliotecaRepo(conexion)
repo.add(biblioteca=biblioteca)
biblioteca.generar_modelo_notas(conexion)
return {
"mensaje": f"Biblioteca '{nombre_biblioteca}' creada con éxito.",
"id": biblioteca.id
}
if __name__ == "__main__":
crear_biblioteca("hola_intento5")