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/entrypoint/init_db.py
T
egutierrez c47b9474f4 feat: Implement text manager API and database connection
- Added `text_manager.py` to handle the creation of text libraries via FastAPI.
- Introduced database connection management in `conexion.py` using PostgreSQL credentials from environment variables.
- Created abstract base class `EmbedderABC` in `Base_Embedder.py` for embedding models.
- Developed `OpenAIEmbedder` class to generate embeddings using OpenAI's API.
- Implemented `OpenAIEmbedderModel` and repository pattern for managing OpenAI embedders in `Openai_embedder_mmr.py`.
- Established `Biblioteca` class for managing text libraries and their associated notes in `biblioteca.py`.
- Created SQLAlchemy models and mappers for `Biblioteca` and `Nota` in `biblioteca_mmr.py` and `notas_biblioteca_mmr.py`.
- Added functionality for dynamic table generation for notes associated with libraries.
- Included comprehensive methods for adding, retrieving, and managing notes and libraries in their respective repositories.
2025-05-10 17:52:43 +02:00

50 lines
1.4 KiB
Python

# entrypoint/init_db.py
from src.base import Base
from src.ConexionSql.Postgres_conexion import PostgresConexion # Asegúrate de tener esta clase implementada correctamente
from src.Credenciales.postgres_credencial import PostgresCredencial # Asegúrate de tener esta clase implementada correctamente
from src.Credenciales.postgres_credencial_mmr import PostgresCredencialModel
from src.ApiKeys.openai_apikey_mmr import OpenAICredencialModel
from src.Llms.Modelos.Openai_model_mmr import ModeloOpenAIConfigModel
from src.TextManager.biblioteca_mmr import BibliotecaModel
from src.Llms.Embedders.Openai_embedder_mmr import OpenAIEmbedderModel
from dotenv import load_dotenv
import os
from entrypoint import ENV_PATH
# Ruta específica al archivo .env
dotenv_path = ENV_PATH
# Cargar el archivo
load_dotenv(dotenv_path)
titulo = os.getenv('DB_TITLE')
usuario = os.getenv('DB_USER')
passwrd = os.getenv('DB_PASSWORD')
host = os.getenv('DB_HOST')
port = os.getenv('DB_PORT')
db_name = os.getenv('DB_NAME')
db_credencial = PostgresCredencial(
titulo=titulo,
user=usuario,
password=passwrd,
host=host,
port=port,
dbname=db_name
)
def init_db():
# Crear engine desde la clase de conexión PostgreSQL
conexion = PostgresConexion(db_credencial)
engine = conexion.engine # Recuperamos el engine directamente
print("Creando tablas...")
Base.metadata.create_all(engine)
print("¡Listo!")