VicGerardoPR commited on
Commit
fe0c779
·
verified ·
1 Parent(s): 4a414c7

Upload 5 files

Browse files
Files changed (5) hide show
  1. Dockerfile +19 -14
  2. README.md +38 -19
  3. asistente_cuantico_pymes_app.py +65 -0
  4. huggingface.yml +6 -0
  5. requirements.txt +8 -2
Dockerfile CHANGED
@@ -1,21 +1,26 @@
1
- FROM python:3.9-slim
2
 
3
- WORKDIR /app
 
4
 
5
- RUN apt-get update && apt-get install -y \
6
- build-essential \
7
- curl \
8
- software-properties-common \
9
- git \
10
- && rm -rf /var/lib/apt/lists/*
11
 
12
- COPY requirements.txt ./
13
- COPY src/ ./src/
14
 
15
- RUN pip3 install -r requirements.txt
 
 
 
16
 
17
- EXPOSE 8501
 
 
18
 
19
- HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
 
20
 
21
- ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]
 
 
 
1
 
2
+ # Imagen base ligera con Python
3
+ FROM python:3.10-slim
4
 
5
+ # Variables de entorno para Streamlit
6
+ ENV PYTHONUNBUFFERED=1
7
+ ENV STREAMLIT_PORT=7860
8
+ ENV STREAMLIT_BROWSER_GATHER_USAGE_STATS=false
 
 
9
 
10
+ # Crear directorio de trabajo
11
+ WORKDIR /app
12
 
13
+ # Copiar archivos
14
+ COPY requirements.txt ./
15
+ COPY asistente_cuantico_pymes_app.py ./app.py
16
+ COPY README.md ./
17
 
18
+ # Instalar dependencias
19
+ RUN pip install --upgrade pip \
20
+ && pip install --no-cache-dir -r requirements.txt
21
 
22
+ # Puerto para Hugging Face Spaces
23
+ EXPOSE 7860
24
 
25
+ # Comando de inicio
26
+ CMD ["streamlit", "run", "app.py", "--server.port=7860", "--server.enableCORS=false"]
README.md CHANGED
@@ -1,19 +1,38 @@
1
- ---
2
- title: PYMESAssistant
3
- emoji: 🚀
4
- colorFrom: red
5
- colorTo: red
6
- sdk: docker
7
- app_port: 8501
8
- tags:
9
- - streamlit
10
- pinned: false
11
- short_description: Streamlit template space
12
- ---
13
-
14
- # Welcome to Streamlit!
15
-
16
- Edit `/src/streamlit_app.py` to customize this app to your heart's desire. :heart:
17
-
18
- If you have any questions, checkout our [documentation](https://docs.streamlit.io) and [community
19
- forums](https://discuss.streamlit.io).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ # 🤖 Asistente Cuántico para PYMES
3
+
4
+ Este proyecto es un asistente inteligente que ayuda a pequeñas empresas a tomar decisiones estratégicas basadas en datos financieros y operativos. Combina:
5
+
6
+ - **LLMs Open Source** (Mistral-7B vía Hugging Face)
7
+ - **Simulación Cuántica con Qiskit**
8
+ - **Interfaz amigable con Streamlit**
9
+
10
+ ## 🚀 Cómo ejecutar
11
+
12
+ 1. Clona este repositorio
13
+ 2. Instala las dependencias:
14
+
15
+ ```bash
16
+ pip install -r requirements.txt
17
+ ```
18
+
19
+ 3. Ejecuta la aplicación:
20
+
21
+ ```bash
22
+ streamlit run asistente_cuantico_pymes_app.py
23
+ ```
24
+
25
+ ## 🧠 ¿Qué hace?
26
+
27
+ - Sube un archivo CSV con tus datos de negocio
28
+ - Haz una pregunta en lenguaje natural
29
+ - El sistema responderá con sugerencias estratégicas basadas en LLM
30
+ - También ejecuta una evaluación cuántica (simulada)
31
+
32
+ ## 🛠️ Tecnologías
33
+
34
+ - `Streamlit`
35
+ - `LangChain`
36
+ - `Transformers`
37
+ - `Qiskit`
38
+ - `Pandas`
asistente_cuantico_pymes_app.py ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import streamlit as st
3
+ from langchain.llms import HuggingFaceHub
4
+ from langchain.chains import LLMChain
5
+ from langchain.prompts import PromptTemplate
6
+ import pandas as pd
7
+ from qiskit import QuantumCircuit, Aer, execute
8
+
9
+ # Cargar datos financieros/operativos
10
+ def load_data(uploaded_file):
11
+ if uploaded_file is not None:
12
+ return pd.read_csv(uploaded_file)
13
+ return None
14
+
15
+ # Crear circuito cuántico simple (placeholder para lógica futura)
16
+ def run_quantum_logic():
17
+ qc = QuantumCircuit(1, 1)
18
+ qc.h(0)
19
+ qc.measure(0, 0)
20
+ backend = Aer.get_backend('qasm_simulator')
21
+ job = execute(qc, backend, shots=1024)
22
+ result = job.result().get_counts()
23
+ return result
24
+
25
+ # Configurar LLM con Hugging Face (puedes usar local más adelante)
26
+ def get_llm():
27
+ return HuggingFaceHub(
28
+ repo_id="mistralai/Mistral-7B-Instruct-v0.1",
29
+ model_kwargs={"temperature": 0.5, "max_new_tokens": 200}
30
+ )
31
+
32
+ # Prompt base
33
+ template = """
34
+ Eres un asesor estratégico experto en pequeñas empresas. Con base en los siguientes datos, sugiere decisiones importantes:
35
+
36
+ {data}
37
+
38
+ Pregunta del usuario: {question}
39
+ """
40
+
41
+ prompt = PromptTemplate(input_variables=["data", "question"], template=template)
42
+
43
+ # Main app
44
+ st.title("🤖 Asistente Cuántico para PYMES")
45
+ uploaded_file = st.file_uploader("Sube tu archivo de datos financieros (CSV)", type=["csv"])
46
+ df = load_data(uploaded_file)
47
+
48
+ if df is not None:
49
+ st.write("Vista previa de los datos:")
50
+ st.dataframe(df.head())
51
+
52
+ question = st.text_input("¿Qué deseas preguntar sobre tu negocio?")
53
+ if question:
54
+ llm = get_llm()
55
+ chain = LLMChain(llm=llm, prompt=prompt)
56
+ response = chain.run(data=df.head(3).to_string(), question=question)
57
+
58
+ st.subheader("🔍 Recomendación del Asistente:")
59
+ st.write(response)
60
+
61
+ st.subheader("⚛️ Evaluación Cuántica:")
62
+ result = run_quantum_logic()
63
+ st.write("Resultados del circuito cuántico (simulado):", result)
64
+ else:
65
+ st.info("Por favor, sube un archivo CSV con tus datos empresariales.")
huggingface.yml ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+
2
+ # Archivo de configuración para Hugging Face Spaces
3
+ title: Asistente Cuántico para PYMES
4
+ sdk: streamlit
5
+ python_version: 3.10
6
+ app_file: app.py
requirements.txt CHANGED
@@ -1,3 +1,9 @@
1
- altair
 
 
 
 
 
 
2
  pandas
3
- streamlit
 
1
+
2
+ streamlit
3
+ langchain
4
+ openai
5
+ transformers
6
+ accelerate
7
+ qiskit
8
  pandas
9
+ huggingface_hub