|
|
|
import gradio as gr |
|
import os |
|
import logging |
|
from modules.ui.landing_ui import create_landing_interface |
|
from modules.ui.login_ui import create_login_interface |
|
from modules.auth.auth import authenticate_user |
|
from modules.database.database_init import initialize_database_connections |
|
import spaces |
|
import torch |
|
|
|
zero = torch.Tensor([0]).cuda() |
|
print(zero.device) |
|
|
|
@spaces.GPU |
|
def greet(n): |
|
print(zero.device) |
|
return f"Hello {zero + n} Tensor" |
|
|
|
|
|
|
|
logging.basicConfig(level=logging.INFO) |
|
logger = logging.getLogger(__name__) |
|
|
|
|
|
COSMOS_ENDPOINT = os.getenv("COSMOS_ENDPOINT") |
|
COSMOS_KEY = os.getenv("COSMOS_KEY") |
|
|
|
if not COSMOS_ENDPOINT or not COSMOS_KEY: |
|
raise ValueError("Faltan las variables de entorno COSMOS_ENDPOINT y COSMOS_KEY.") |
|
|
|
|
|
if not initialize_database_connections(): |
|
raise ValueError("No se pudo inicializar la conexi贸n a la base de datos.") |
|
|
|
|
|
def app_main(): |
|
""" |
|
Inicializa la aplicaci贸n con Gradio. |
|
""" |
|
logger.info("Iniciando AIdeaText") |
|
landing_page = create_landing_interface() |
|
login_page = create_login_interface() |
|
|
|
|
|
def navigate_to_login(): |
|
return gr.update(visible=True), gr.update(visible=False) |
|
|
|
def navigate_to_landing(): |
|
return gr.update(visible=False), gr.update(visible=True) |
|
|
|
|
|
with gr.Blocks() as app_interface: |
|
landing_container = gr.Group(visible=True) |
|
login_container = gr.Group(visible=False) |
|
|
|
with landing_container: |
|
landing_page.render(navigate_to_login) |
|
|
|
with login_container: |
|
login_page.render(navigate_to_landing) |
|
|
|
app_interface.launch(server_name="0.0.0.0", server_port=7860, auth=None) |
|
|
|
if __name__ == "__main__": |
|
app_main() |
|
|