Spaces:
Runtime error
Runtime error
Upload 14 files
Browse files- .env +1 -0
- .gitignore +0 -0
- Asistente virtual.iss +24 -0
- Bella.pdf +0 -0
- Galatea D-ID.jpg +0 -0
- LICENSE +21 -0
- README.md +57 -13
- botidinamix-g.json +13 -0
- installer.cfg +26 -0
- main.py +144 -0
- multiagentes.py +4 -0
- pinocho.pdf +0 -0
- requirements.txt +58 -0
- style.css +54 -0
.env
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
OPENAI_API_KEY ='sk-proj-3LjZDUxPCK7NOxAGsBrcT3BlbkFJPwq200vDWf5JG2YWgAsx'
|
.gitignore
ADDED
|
File without changes
|
Asistente virtual.iss
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[Setup]
|
| 2 |
+
AppName=Asistente Virtual-Openai
|
| 3 |
+
AppVersion=1.0
|
| 4 |
+
DefaultDirName={pf}\Mi Aplicación Streamlit
|
| 5 |
+
OutputDir=c:\Users\Usuario
|
| 6 |
+
OutputBaseFilename=mi_aplicacion_setup
|
| 7 |
+
|
| 8 |
+
[Files]
|
| 9 |
+
Source: "C:\Users\Usuario\Asistente virtual-Openai\chat.py"; DestDir: "{app}"
|
| 10 |
+
Source:"C:\Users\Usuario\AppData\Local\Programs\Python\Python312\python.exe";DestDir: "{app}"
|
| 11 |
+
Source: "C:\Users\Usuario\Asistente virtual-Openai\style.css"; DestDir: "{app}"
|
| 12 |
+
Source: "C:\Users\Usuario\Asistente virtual-Openai\index.html"; DestDir: "{app}"
|
| 13 |
+
Source: "C:\Users\Usuario\Asistente virtual-Openai\requirements.txt"; DestDir: "{app}"
|
| 14 |
+
Source: "C:\Users\Usuario\Asistente virtual-Openai\.env"; DestDir: "{app}"
|
| 15 |
+
Source: "C:\Users\Usuario\Asistente virtual-Openai\Logo Omardent.png"; DestDir: "{app}"
|
| 16 |
+
Source: "C:\Users\Usuario\Asistente virtual-Openai\Galatea D-ID.jpg"; DestDir: "{app}"
|
| 17 |
+
Source: "C:\Users\Usuario\Asistente virtual-Openai\.gitignore"; DestDir: "{app}"
|
| 18 |
+
; ... (otras dependencias - cada archivo en una línea separada)
|
| 19 |
+
|
| 20 |
+
[Icons]
|
| 21 |
+
Name: "{group}\Asistente Virtual-Openai"; Filename: "{app}\chat.py"
|
| 22 |
+
|
| 23 |
+
[Run]
|
| 24 |
+
Filename: "{app}\python.exe"; Parameters: "streamlit run chat.py"
|
Bella.pdf
ADDED
|
Binary file (71.1 kB). View file
|
|
|
Galatea D-ID.jpg
ADDED
|
LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MIT License
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2024 _J_V_
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 6 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 7 |
+
in the Software without restriction, including without limitation the rights
|
| 8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 9 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 10 |
+
furnished to do so, subject to the following conditions:
|
| 11 |
+
|
| 12 |
+
The above copyright notice and this permission notice shall be included in all
|
| 13 |
+
copies or substantial portions of the Software.
|
| 14 |
+
|
| 15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 21 |
+
SOFTWARE.
|
README.md
CHANGED
|
@@ -1,13 +1,57 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Chatbot con OpenAI
|
| 2 |
+
|
| 3 |
+
Este proyecto consiste en un chatbot desarrollado utilizando la API de OpenAI. El chatbot es capaz de responder preguntas sobre un texto proporcionado por el usuario, utilizando modelos de lenguaje avanzados de OpenAI.
|
| 4 |
+
|
| 5 |
+
## Descripción
|
| 6 |
+
|
| 7 |
+
El chatbot puede cargar un documento PDF, extraer su contenido de texto, preprocesarlo y luego responder preguntas sobre ese texto utilizando la API de OpenAI. Los usuarios pueden seleccionar diferentes modelos de lenguaje de OpenAI para generar respuestas.
|
| 8 |
+
|
| 9 |
+
## Instalación
|
| 10 |
+
|
| 11 |
+
Para ejecutar este proyecto localmente, sigue estos pasos:
|
| 12 |
+
|
| 13 |
+
1. Clona este repositorio en tu máquina local utilizando Git:
|
| 14 |
+
|
| 15 |
+
```bash
|
| 16 |
+
git clone https://github.com/tu_usuario/tu_repositorio.git
|
| 17 |
+
```
|
| 18 |
+
|
| 19 |
+
2. Navega al directorio del proyecto:
|
| 20 |
+
|
| 21 |
+
```bash
|
| 22 |
+
cd tu_repositorio
|
| 23 |
+
```
|
| 24 |
+
|
| 25 |
+
3. Instala las dependencias necesarias utilizando pip:
|
| 26 |
+
|
| 27 |
+
```bash
|
| 28 |
+
pip install -r requirements.txt
|
| 29 |
+
```
|
| 30 |
+
|
| 31 |
+
4. Configura tu clave de API de OpenAI. Puedes hacerlo estableciendo la variable de entorno `OPENAI_API_KEY` o directamente en el archivo `chat.py`.
|
| 32 |
+
|
| 33 |
+
## Uso
|
| 34 |
+
|
| 35 |
+
Una vez que hayas configurado el proyecto y las dependencias, puedes ejecutar el chatbot utilizando el siguiente comando:
|
| 36 |
+
|
| 37 |
+
```bash
|
| 38 |
+
streamlit run chat.py
|
| 39 |
+
```
|
| 40 |
+
## Dependencias
|
| 41 |
+
|
| 42 |
+
Este proyecto utiliza las siguientes dependencias de Python:
|
| 43 |
+
|
| 44 |
+
- Streamlit: Para la interfaz de usuario interactiva.
|
| 45 |
+
- OpenAI: Para acceder a la API de OpenAI y obtener respuestas del chatbot.
|
| 46 |
+
- NLTK: Para el preprocesamiento de texto, incluyendo tokenización y eliminación de palabras vacías.
|
| 47 |
+
- PyPDF2: Para extraer texto de documentos PDF.
|
| 48 |
+
|
| 49 |
+
Puedes encontrar las versiones específicas de las dependencias en el archivo `requirements.txt`.
|
| 50 |
+
|
| 51 |
+
## Contribuciones
|
| 52 |
+
|
| 53 |
+
Las contribuciones son bienvenidas. Si deseas contribuir a este proyecto, por favor, abre un issue para discutir los cambios propuestos antes de enviar un pull request.
|
| 54 |
+
|
| 55 |
+
## Licencia
|
| 56 |
+
|
| 57 |
+
Este proyecto está bajo la Licencia MIT. Para más detalles, consulta el archivo `LICENSE`.
|
botidinamix-g.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"type": "service_account",
|
| 3 |
+
"project_id": "assistant-9nteod",
|
| 4 |
+
"private_key_id": "2a6b434c79db1c61fd01a4aa0fdb4581abd03134",
|
| 5 |
+
"private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQDf3Kus0HiXPybh\n06C05KvyuM/LfHBQXIMdMRDHaCp8Wj17h8HOmND7P+e/DcM45AevY2xfvq5ZOMCa\nCEFGXQHaiy6kDYpBiEzBYaLK2mfamUdkURejsE4yZr3piZkhJ4+lGke+jouAey01\nxwM5bVaCUSP1iWcryHrohaOr9rhbniCDheXu4J7d+q/ajyC8iw2UHKbL2RXwuK1y\nl7BAUxEGxLtu4yREWBo3dK0f9z/s3Vpva4zUuDbXqflgazDm0ak5ruRqAk/x6Xqy\nz9jhX3IuJc+MDlGiGDtNo40obT9jyknkbD03lmdRLlPeFNqNoiOeUOWIFX+YtsA0\noB0LixiHAgMBAAECggEAHdKn8PUG6Qip6pIxydeK9reF60hv2AIzGhZOyMSeSwRk\nm3U0WGHFuYBuebvgzaPx8tIj08Td35dZb/Z4kmH9R2WdDZBGN8EWOfmtYSk5MQc+\n2mTulB5+lGVZQz2oWkvgbZuI16CQLMomyuVxObB7bWSs4zRDu91Qo8h7S63/Kn6F\nwt41fHsJmRwSV21ZMzrYtFXrmYuNZxsfhzLV1JFiPF+LgJT+AojhZO1r4FtDS+kI\nBtoD8QZn+T5+TDgj7NLDL+kMn8EWQU2o+PQDtbi69hQxHTo4rxdXB5z6BmZbPt9B\n7jLIRS/rfeaPgvdjSi0z7IsJWEbZlu9KSeUfkgZoxQKBgQD1XU/7sGZqiF7GO9yr\ncm2rAvFh1e+/jOd1iwQ48KJ8lITO52lEyLq53T+OAJbULWseHXi0VQNsd7kzs0Zl\nIVImOuHsG087vXVrxk75yzJBuwPCBMakBKRtkcpETEti477yo+Szw3mKEmsBfHYr\nMW5+MISaWbPzqQ7O51Fx0h1MjQKBgQDpkMFs7ID+ski1sRm4K1Szo+RWhm1ag8Mb\nIYJhcL0K1WRFfIyTyzm5krrXsUQTydX/oNinMtv/hS379CgyqobWO85+YBh3kYbZ\nn8FOJOhJ176sE4soti8p5aktyQSpqjVVtsf7OKw50CgGE5lAxxGOolQTD4d8zYjL\n9y7o8QP2YwKBgEvRYLS6Rntm1jpVJxQHUOIGD8aWj/XVuXP12AEsQllSn1M76Khr\nil+CgXAEuJapzi7JFpJKrrsmp6DVJcx8JmFP0p3dtncUTSNXbPH9GvN6sWeTiDoI\ngTKmWSUPmj/ddhSOFk6B+Z1zoYMdDXq9VJJDtcXoMBX7yGqgyebs8UbFAoGAAY6y\ni3xkO86Kh5OfvUekr/H20tDgp8rbITIvAWFUEV9s5L243j9rqh4dWtTWxF8DK0oy\nR6MiLmj/7n8pSXUzovgRH2yanSl+QbM8Ab5jQiLLJbCXq/TTCa97Wk/N1SfKZUDr\nwnQVSelmauv0iKcLKe1RLDNdTuq778g9KtZ4lUsCgYBebKvZbG8S9xHZcUNBxEty\nKCtknf2DoO3cvQ6zCEaIaMbdRH+NEuBxgGYKX2brHLSxJSOaAWoX+yiIxFlHdAAz\n0BiMkgqnJThevrfEs30zTYQBU78HP8WUnzUqsqwooqr7ry4hq5z78RXL0NP8BepH\nBavhIQYovXSFy6l0m6JFng==\n-----END PRIVATE KEY-----\n",
|
| 6 |
+
"client_email": "botidinamix@assistant-9nteod.iam.gserviceaccount.com",
|
| 7 |
+
"client_id": "104652076455278864571",
|
| 8 |
+
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
|
| 9 |
+
"token_uri": "https://oauth2.googleapis.com/token",
|
| 10 |
+
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
|
| 11 |
+
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/botidinamix%40assistant-9nteod.iam.gserviceaccount.com",
|
| 12 |
+
"universe_domain": "googleapis.com"
|
| 13 |
+
}
|
installer.cfg
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[Application]
|
| 2 |
+
name=Mi Aplicación Streamlit
|
| 3 |
+
version=1.0
|
| 4 |
+
|
| 5 |
+
[Python]
|
| 6 |
+
version=3.11.0
|
| 7 |
+
bitness=64
|
| 8 |
+
|
| 9 |
+
[Include]
|
| 10 |
+
# Dependencias de Python (copiadas de tu requirements.txt)
|
| 11 |
+
pypi_wheels = altair==5.3.0, annotated-types==0.6.0, anyio==4.3.0, attrs==23.2.0, blinker==1.7.0, cachetools==5.3.3, certifi==2024.2.2, charset-normalizer==3.3.2, click==8.1.7, distro==1.9.0, exceptiongroup==1.2.0, gitdb==4.0.11, GitPython==3.1.43, h11==0.14.0, httpcore==1.0.5, httpx==0.27.0, idna==3.6, Jinja2==3.1.3, joblib==1.3.2, jsonschema==4.21.1, jsonschema-specifications==2023.12.1, markdown-it-py==3.0.0, MarkupSafe==2.1.5, mdurl==0.1.2, nltk==3.8.1, numpy==1.26.4, openai==1.16.1, packaging==23.2, pandas==2.2.1, pillow==10.3.0, protobuf==4.25.3, pyarrow==15.0.2, pydantic==2.6.4, pydantic_core==2.16.3, pydeck==0.8.1b0, Pygments==2.17.2, PyPDF2==3.0.1, python-dateutil==2.9.0.post0, pytz==2024.1, referencing==0.34.0, regex==2023.12.25, requests==2.31.0, rich==13.7.1, rpds-py==0.18.0, six==1.16.0, smmap==5.0.1, sniffio==1.3.1, streamlit==1.32.2, tenacity==8.2.3, toml==0.10.2, toolz==0.12.1, tornado==6.4, tqdm==4.66.2, typing_extensions==4.10.0, tzdata==2024.1, urllib3==2.2.1, watchdog==4.0.0
|
| 12 |
+
|
| 13 |
+
[Build]
|
| 14 |
+
directory=chat.py
|
| 15 |
+
=style.css
|
| 16 |
+
directory=Logo Omardent.png
|
| 17 |
+
directory=Galatea D-ID.jpg
|
| 18 |
+
directory=.env
|
| 19 |
+
directory=requirements.txt
|
| 20 |
+
directory=index.html
|
| 21 |
+
|
| 22 |
+
[Environment]
|
| 23 |
+
path=%PATH%;$INSTDIR
|
| 24 |
+
|
| 25 |
+
[Command]
|
| 26 |
+
entry_point=$INSTDIR\chat.py
|
main.py
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import os
|
| 3 |
+
import openai
|
| 4 |
+
from utils.data_manager import (
|
| 5 |
+
extraer_texto_pdf,
|
| 6 |
+
preprocesar_texto,
|
| 7 |
+
obtener_respuesta
|
| 8 |
+
)
|
| 9 |
+
import speech_recognition as sr
|
| 10 |
+
|
| 11 |
+
# Configuración de la clave API
|
| 12 |
+
openai.api_key = "sk-proj-3LjZDUxPCK7NOxAGsBrcT3BlbkFJPwq200vDWf5JG2YWgAsx" # Reemplaza esto con tu clave API real
|
| 13 |
+
|
| 14 |
+
def inicializar_estado():
|
| 15 |
+
"""Inicializa el estado de la sesión si no está ya inicializado."""
|
| 16 |
+
if 'modelo' not in st.session_state:
|
| 17 |
+
st.session_state['modelo'] = "gpt-3.5-turbo-16k"
|
| 18 |
+
if 'temperatura' not in st.session_state:
|
| 19 |
+
st.session_state['temperatura'] = 0.5
|
| 20 |
+
if 'mensajes_chat' not in st.session_state:
|
| 21 |
+
st.session_state['mensajes_chat'] = []
|
| 22 |
+
|
| 23 |
+
def barra_lateral():
|
| 24 |
+
ruta_logo = os.path.join("assets", "Logo Omardent.png")
|
| 25 |
+
if os.path.exists(ruta_logo):
|
| 26 |
+
st.sidebar.image(ruta_logo, use_column_width=True)
|
| 27 |
+
else:
|
| 28 |
+
st.sidebar.warning(f"Error: No se pudo encontrar la imagen en la ruta: {ruta_logo}")
|
| 29 |
+
|
| 30 |
+
st.sidebar.title("🤖 Galatea OMARDENT")
|
| 31 |
+
st.sidebar.markdown("---")
|
| 32 |
+
st.sidebar.subheader("🧠 Configuración del Modelo")
|
| 33 |
+
st.session_state['modelo'] = st.sidebar.selectbox(
|
| 34 |
+
"Selecciona el modelo:",
|
| 35 |
+
["gpt-3.5-turbo", "gpt-4", "gpt-4-32k","gpt-4o"],
|
| 36 |
+
index=0,
|
| 37 |
+
key='modelo_selectbox', # Clave única
|
| 38 |
+
help="Elige el modelo de lenguaje de OpenAI que prefieras."
|
| 39 |
+
)
|
| 40 |
+
st.sidebar.markdown("---")
|
| 41 |
+
st.session_state['temperatura'] = st.sidebar.slider(
|
| 42 |
+
"🌡️ Temperatura",
|
| 43 |
+
min_value=0.0, max_value=1.0,
|
| 44 |
+
value=st.session_state['temperatura'],
|
| 45 |
+
step=0.1,
|
| 46 |
+
key='temperatura_slider' # Clave única
|
| 47 |
+
)
|
| 48 |
+
|
| 49 |
+
def mostrar_mensajes_chat():
|
| 50 |
+
for mensaje in st.session_state['mensajes_chat']:
|
| 51 |
+
with st.chat_message(mensaje["role"]):
|
| 52 |
+
st.markdown(mensaje["content"])
|
| 53 |
+
|
| 54 |
+
def manejar_pregunta_usuario(pregunta_usuario, archivo_pdf):
|
| 55 |
+
st.session_state['mensajes_chat'].append({"role": "user", "content": pregunta_usuario})
|
| 56 |
+
with st.chat_message("user"):
|
| 57 |
+
st.markdown(pregunta_usuario)
|
| 58 |
+
|
| 59 |
+
texto_preprocesado = ""
|
| 60 |
+
if archivo_pdf:
|
| 61 |
+
texto_pdf = extraer_texto_pdf(archivo_pdf)
|
| 62 |
+
texto_preprocesado = preprocesar_texto(texto_pdf)
|
| 63 |
+
|
| 64 |
+
respuesta = obtener_respuesta(pregunta_usuario, texto_preprocesado, st.session_state['modelo'], st.session_state['temperatura'])
|
| 65 |
+
st.session_state['mensajes_chat'].append({"role": "assistant", "content": respuesta})
|
| 66 |
+
with st.chat_message("assistant"):
|
| 67 |
+
st.markdown(respuesta)
|
| 68 |
+
|
| 69 |
+
def manejar_captura_de_voz(audio_capturado):
|
| 70 |
+
recognizer = sr.Recognizer()
|
| 71 |
+
with sr.AudioFile(audio_capturado) as source:
|
| 72 |
+
audio = recognizer.record(source)
|
| 73 |
+
try:
|
| 74 |
+
texto_extraido = recognizer.recognize_google(audio, language='es-ES')
|
| 75 |
+
st.markdown("### Texto extraído del audio:")
|
| 76 |
+
st.write(texto_extraido)
|
| 77 |
+
except sr.UnknownValueError:
|
| 78 |
+
st.markdown("### No se pudo entender el audio.")
|
| 79 |
+
except sr.RequestError as e:
|
| 80 |
+
st.markdown(f"### Error en el servicio de reconocimiento: {e}")
|
| 81 |
+
|
| 82 |
+
def main():
|
| 83 |
+
inicializar_estado()
|
| 84 |
+
barra_lateral()
|
| 85 |
+
|
| 86 |
+
st.title("VIRTUAL OMARDENT AI-BOTIDINAMIX")
|
| 87 |
+
st.markdown(
|
| 88 |
+
f"""
|
| 89 |
+
<style>
|
| 90 |
+
#video-container {{
|
| 91 |
+
position: relative;
|
| 92 |
+
width: 100%;
|
| 93 |
+
padding-bottom: 56.25%;
|
| 94 |
+
background-color: lightblue;
|
| 95 |
+
overflow: hidden;
|
| 96 |
+
}}
|
| 97 |
+
#background-video {{
|
| 98 |
+
position: absolute;
|
| 99 |
+
top: 0;
|
| 100 |
+
left: 0;
|
| 101 |
+
width: 100%;
|
| 102 |
+
height: 100%;
|
| 103 |
+
}}
|
| 104 |
+
</style>
|
| 105 |
+
<div id="video-container">
|
| 106 |
+
<video id="background-video" autoplay loop muted playsinline>
|
| 107 |
+
<source src="https://dnznrvs05pmza.cloudfront.net/7683e8bc-0726-4c9d-9c80-80d3fec180a4.mp4?_jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJrZXlIYXNoIjoiNWI3OTlhZGM5MjZiZTFkMyIsImJ1Y2tldCI6InJ1bndheS10YXNrLWFydGlmYWN0cyIsInN0YWdlIjoicHJvZCIsImV4cCI6MTcxODg0MTYwMH0.yNjCqJp69vdoPlNCOaQktiiynUbCQRINWzCFD7JY-MQ" type="video/mp4">
|
| 108 |
+
</video>
|
| 109 |
+
</div>
|
| 110 |
+
""",
|
| 111 |
+
unsafe_allow_html=True,
|
| 112 |
+
)
|
| 113 |
+
|
| 114 |
+
archivo_pdf = st.file_uploader("📂 Cargar PDF", type='pdf', key='chat_pdf')
|
| 115 |
+
|
| 116 |
+
# Sidebar para navegación
|
| 117 |
+
st.sidebar.title("Navegación")
|
| 118 |
+
page = st.sidebar.radio("Ir a", ["Página Principal", "Gestión de Trabajos", "Gestión de Insumos", "Registro de Radiografías", "Buscar Datos", "Notificaciones", "Recomendaciones"])
|
| 119 |
+
|
| 120 |
+
# Importar páginas
|
| 121 |
+
if page == "Página Principal":
|
| 122 |
+
from pages import home
|
| 123 |
+
home.show()
|
| 124 |
+
elif page == "Gestión de Trabajos":
|
| 125 |
+
from pages import trabajos
|
| 126 |
+
trabajos.show()
|
| 127 |
+
elif page == "Gestión de Insumos":
|
| 128 |
+
from pages import insumos
|
| 129 |
+
insumos.show()
|
| 130 |
+
elif page == "Registro de Radiografías":
|
| 131 |
+
from pages import radiografias
|
| 132 |
+
radiografias.show()
|
| 133 |
+
elif page == "Buscar Datos":
|
| 134 |
+
from pages import buscar_datos
|
| 135 |
+
buscar_datos.show()
|
| 136 |
+
elif page == "Notificaciones":
|
| 137 |
+
from pages import notificaciones
|
| 138 |
+
notificaciones.show()
|
| 139 |
+
elif page == "Recomendaciones":
|
| 140 |
+
from pages import recomendaciones
|
| 141 |
+
recomendaciones.show()
|
| 142 |
+
|
| 143 |
+
if __name__ == "__main__":
|
| 144 |
+
main()
|
multiagentes.py
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
|
| 3 |
+
if __name__ == "__main__":
|
| 4 |
+
main()
|
pinocho.pdf
ADDED
|
Binary file (80.7 kB). View file
|
|
|
requirements.txt
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
altair==5.3.0
|
| 2 |
+
annotated-types==0.6.0
|
| 3 |
+
anyio==4.3.0
|
| 4 |
+
attrs==23.2.0
|
| 5 |
+
blinker==1.7.0
|
| 6 |
+
cachetools==5.3.3
|
| 7 |
+
certifi==2024.2.2
|
| 8 |
+
charset-normalizer==3.3.2
|
| 9 |
+
click==8.1.7
|
| 10 |
+
distro==1.9.0
|
| 11 |
+
exceptiongroup==1.2.0
|
| 12 |
+
gitdb==4.0.11
|
| 13 |
+
GitPython==3.1.43
|
| 14 |
+
h11==0.14.0
|
| 15 |
+
httpcore==1.0.5
|
| 16 |
+
httpx==0.27.0
|
| 17 |
+
idna==3.6
|
| 18 |
+
Jinja2==3.1.3
|
| 19 |
+
joblib==1.3.2
|
| 20 |
+
jsonschema==4.21.1
|
| 21 |
+
jsonschema-specifications==2023.12.1
|
| 22 |
+
markdown-it-py==3.0.0
|
| 23 |
+
MarkupSafe==2.1.5
|
| 24 |
+
mdurl==0.1.2
|
| 25 |
+
nltk==3.8.1
|
| 26 |
+
numpy==1.26.4
|
| 27 |
+
openai==1.16.1
|
| 28 |
+
packaging==23.2
|
| 29 |
+
pandas==2.2.1
|
| 30 |
+
pillow==10.3.0
|
| 31 |
+
protobuf==4.25.3
|
| 32 |
+
pyarrow==15.0.2
|
| 33 |
+
pydantic==2.6.4
|
| 34 |
+
pydantic_core==2.16.3
|
| 35 |
+
pydeck==0.8.1b0
|
| 36 |
+
Pygments==2.17.2
|
| 37 |
+
PyPDF2==3.0.1
|
| 38 |
+
python-dateutil==2.9.0.post0
|
| 39 |
+
python-docx==0.8.11
|
| 40 |
+
pytz==2024.1
|
| 41 |
+
referencing==0.34.0
|
| 42 |
+
regex==2023.12.25
|
| 43 |
+
requests==2.31.0
|
| 44 |
+
rich==13.7.1
|
| 45 |
+
rpds-py==0.18.0
|
| 46 |
+
six==1.16.0
|
| 47 |
+
smmap==5.0.1
|
| 48 |
+
sniffio==1.3.1
|
| 49 |
+
streamlit==1.32.2
|
| 50 |
+
tenacity==8.2.3
|
| 51 |
+
toml==0.10.2
|
| 52 |
+
toolz==0.12.1
|
| 53 |
+
tornado==6.4
|
| 54 |
+
tqdm==4.66.2
|
| 55 |
+
typing_extensions==4.10.0
|
| 56 |
+
tzdata==2024.1
|
| 57 |
+
urllib3==2.2.1
|
| 58 |
+
watchdog==4.0.0
|
style.css
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* Estilos generales */
|
| 2 |
+
body {
|
| 3 |
+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
| 4 |
+
background-color: #f4f4f4;
|
| 5 |
+
margin: 0;
|
| 6 |
+
padding: 0;
|
| 7 |
+
}
|
| 8 |
+
|
| 9 |
+
/* Estilos para el contenedor del chat */
|
| 10 |
+
.stApp {
|
| 11 |
+
max-width: 800px;
|
| 12 |
+
margin: 20px auto;
|
| 13 |
+
padding: 20px;
|
| 14 |
+
border-radius: 10px;
|
| 15 |
+
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
/* Estilos para los mensajes del chat */
|
| 19 |
+
.stChatMessage {
|
| 20 |
+
padding: 15px;
|
| 21 |
+
border-radius: 8px;
|
| 22 |
+
margin-bottom: 10px;
|
| 23 |
+
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); /* Sombra sutil */
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
/* Estilos para los mensajes del usuario */
|
| 27 |
+
.stChatMessage [data-testid="chat-message-text"]:first-of-type {
|
| 28 |
+
background-color: #e0f2f1; /* Color de fondo claro para el usuario */
|
| 29 |
+
color: #333; /* Texto oscuro */
|
| 30 |
+
text-align: left;
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
/* Estilos para los mensajes del asistente */
|
| 34 |
+
.stChatMessage:not([data-testid="chat-message-text"]:first-of-type) {
|
| 35 |
+
background-color: #fff; /* Color de fondo blanco para el asistente */
|
| 36 |
+
color: #333; /* Texto oscuro */
|
| 37 |
+
text-align: left;
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
/* Estilos para el área de entrada de texto */
|
| 41 |
+
.stChatInputContainer {
|
| 42 |
+
padding: 10px;
|
| 43 |
+
background-color: #fff;
|
| 44 |
+
border-top: 1px solid #ddd;
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
.stChatInputContainer textarea {
|
| 48 |
+
width: 100%;
|
| 49 |
+
padding: 10px;
|
| 50 |
+
border: 1px solid #ccc;
|
| 51 |
+
border-radius: 5px;
|
| 52 |
+
resize: vertical;
|
| 53 |
+
}
|
| 54 |
+
|