30 lines
1.1 KiB
Python
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") |