Spaces:
Sleeping
Sleeping
Download src/components/inputs.py from NextAI-cl/waterpolice-test: direct link, hf CLI and curl.
- Browser
- Download file 1.71 kB
-
https://huggingface.co/spaces/NextAI-cl/waterpolice-test/resolve/main/src/components/inputs.py
- Command line
-
hf download hf://spaces/NextAI-cl/waterpolice-test/src/components/inputs.py
-
curl -L -o inputs.py https://huggingface.co/spaces/NextAI-cl/waterpolice-test/resolve/main/src/components/inputs.py
1.71 kB
| """Input rendering components.""" | |
| import streamlit as st | |
| def render_variable_inputs(template): | |
| """Renderiza los inputs dinamicos segun el template de variables.""" | |
| st.header("2. Ingresar Variables") | |
| variables_ingresadas = {} | |
| # Organizar en columnas | |
| cols = st.columns(2) | |
| for idx, (var_name, var_config) in enumerate(template.items()): | |
| with cols[idx % 2]: | |
| if var_config['tipo'] == 'float': | |
| variables_ingresadas[var_name] = st.number_input( | |
| f"{var_name.replace('_', ' ').title()}:", | |
| value=var_config['default'], | |
| min_value=var_config.get('min'), | |
| max_value=var_config.get('max'), | |
| step=var_config.get('step', 0.01), | |
| format="%.4f", | |
| help=var_config.get('descripcion', '') | |
| ) | |
| elif var_config['tipo'] == 'int': | |
| variables_ingresadas[var_name] = st.number_input( | |
| f"{var_name.replace('_', ' ').title()}:", | |
| value=int(var_config['default']), | |
| min_value=int(var_config.get('min', 0)), | |
| max_value=int(var_config.get('max', 100)), | |
| step=int(var_config.get('step', 1)), | |
| help=var_config.get('descripcion', '') | |
| ) | |
| elif var_config['tipo'] == 'text': | |
| variables_ingresadas[var_name] = st.text_input( | |
| f"{var_name.replace('_', ' ').title()}:", | |
| value=var_config['default'], | |
| help=var_config.get('descripcion', '') | |
| ) | |
| return variables_ingresadas |