SoyAlekZen commited on
Commit
4fa2f73
·
verified ·
1 Parent(s): 5ed1294

Upload folder using huggingface_hub

Browse files
.github/workflows/deploy_app1.yaml ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Deploy App1 to Hugging Face Spaces
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ paths:
8
+ - 'app1/**'
9
+
10
+ jobs:
11
+ deploy:
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - name: Check out repository
15
+ uses: actions/checkout@v2
16
+
17
+ - name: Set up Python
18
+ uses: actions/setup-python@v2
19
+ with:
20
+ python-version: '3.8'
21
+
22
+ - name: Install dependencies
23
+ run: |
24
+ pip install -r app1/requirements.txt
25
+
26
+ - name: Deploy to Spaces
27
+ env:
28
+ HF_USERNAME: ${{ secrets.HF_USERNAME }}
29
+ HF_TOKEN: ${{ secrets.HF_TOKEN }}
30
+ run: |
31
+ huggingface-cli login ${{ secrets.HF_TOKEN }}
32
+ cd app1
33
+ gradio deploy
.github/workflows/deploy_app2.yaml ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Deploy App2 to Hugging Face Spaces
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ paths:
8
+ - 'app2/**'
9
+
10
+ jobs:
11
+ deploy:
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - name: Check out repository
15
+ uses: actions/checkout@v2
16
+
17
+ - name: Set up Python
18
+ uses: actions/setup-python@v2
19
+ with:
20
+ python-version: '3.8'
21
+
22
+ - name: Install dependencies
23
+ run: |
24
+ pip install -r app1/requirements.txt
25
+
26
+ - name: Deploy to Spaces
27
+ env:
28
+ HF_USERNAME: ${{ secrets.HF_USERNAME }}
29
+ HF_TOKEN: ${{ secrets.HF_TOKEN }}
30
+ run: |
31
+ huggingface-cli login ${{ secrets.HF_TOKEN }}
32
+ cd app2
33
+ gradio deploy
app1/app.py ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import requests
3
+
4
+ # Función para generar la respuesta usando tu API
5
+ def generate_response_api(message, thread_id, assistant_id):
6
+ base_url = "https://enjambre-api-mue2676eoa-uc.a.run.app"
7
+ url = f"{base_url}/v1/agents/{assistant_id}/completion"
8
+ response = requests.post(url, json={
9
+ "message": message,
10
+ "model": "gpt-3.5-turbo-0613",
11
+ "threadId": thread_id
12
+ })
13
+ response_json = response.json()
14
+ return response_json["message"], response_json["threadId"]
15
+
16
+ # Función para manejar el chat, ahora acepta dos argumentos
17
+ def chat_function(message, history):
18
+ global thread_id
19
+ assistant_id = "asst_vsm9RJaiFiWAcMFmwKF2u6Jd" # ID de tu asistente
20
+ response, new_thread_id = generate_response_api(message, thread_id, assistant_id)
21
+ thread_id = new_thread_id # Actualiza el thread_id global
22
+ return response
23
+
24
+ # Inicializa la variable global
25
+ thread_id = None
26
+
27
+ # Configuración de ChatInterface
28
+ demo = gr.ChatInterface(
29
+ fn=chat_function,
30
+ title="Proyectos MAC",
31
+ description="Soy un asistente virtual que conoce el proyecto de Magaña Arevalo Contadores a la perfección y te puedo ayudar con tus dudas o estrategias.",
32
+ theme="soft",
33
+ examples=[
34
+ "¿Cuál es el cronograma detallado de implementación para la transformación digital de MAC?",
35
+ "¿Qué capacitaciones están incluidas en el proyecto para el personal de MAC?",
36
+ "¿Cómo se integrarán las plataformas bancarias y el CRM en nuestra infraestructura actual?",
37
+ "¿Cuáles son los KPIs clave que los Dashboards de BI nos ayudarán a monitorear?",
38
+ "¿Qué medidas de soporte y mantenimiento ofrece Geek Studio tras la finalización del proyecto?"
39
+ ],
40
+
41
+ retry_btn=None,
42
+ undo_btn=None,
43
+ submit_btn="Enviar",
44
+ stop_btn="Detener"
45
+ ).queue()
46
+
47
+ if __name__ == "__main__":
48
+ demo.launch(share=True)
app1/requirements.txt ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ aiofiles==23.2.1
2
+ altair==5.2.0
3
+ annotated-types==0.6.0
4
+ anyio==4.2.0
5
+ attrs==23.2.0
6
+ certifi==2023.11.17
7
+ charset-normalizer==3.3.2
8
+ click==8.1.7
9
+ colorama==0.4.6
10
+ contourpy==1.2.0
11
+ cycler==0.12.1
12
+ fastapi==0.109.0
13
+ ffmpy==0.3.1
14
+ filelock==3.13.1
15
+ fonttools==4.47.2
16
+ fsspec==2023.12.2
17
+ gradio==4.16.0
18
+ gradio_client==0.8.1
19
+ h11==0.14.0
20
+ httpcore==1.0.2
21
+ httpx==0.26.0
22
+ huggingface-hub==0.20.3
23
+ idna==3.6
24
+ importlib-resources==6.1.1
25
+ Jinja2==3.1.3
26
+ jsonschema==4.21.1
27
+ jsonschema-specifications==2023.12.1
28
+ kiwisolver==1.4.5
29
+ markdown-it-py==3.0.0
30
+ MarkupSafe==2.1.4
31
+ matplotlib==3.8.2
32
+ mdurl==0.1.2
33
+ numpy==1.26.3
34
+ orjson==3.9.12
35
+ packaging==23.2
36
+ pandas==2.2.0
37
+ pillow==10.2.0
38
+ pydantic==2.6.0
39
+ pydantic_core==2.16.1
40
+ pydub==0.25.1
41
+ Pygments==2.17.2
42
+ pyparsing==3.1.1
43
+ python-dateutil==2.8.2
44
+ python-multipart==0.0.6
45
+ pytz==2023.4
46
+ PyYAML==6.0.1
47
+ referencing==0.33.0
48
+ requests==2.31.0
49
+ rich==13.7.0
50
+ rpds-py==0.17.1
51
+ ruff==0.1.15
52
+ semantic-version==2.10.0
53
+ shellingham==1.5.4
54
+ six==1.16.0
55
+ sniffio==1.3.0
56
+ starlette==0.35.1
57
+ tomlkit==0.12.0
58
+ toolz==0.12.1
59
+ tqdm==4.66.1
60
+ typer==0.9.0
61
+ typing_extensions==4.9.0
62
+ tzdata==2023.4
63
+ urllib3==2.2.0
64
+ uvicorn==0.27.0.post1
65
+ websockets==11.0.3
app2/app.py ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import requests
3
+
4
+ # Función para generar la respuesta usando tu API
5
+ def generate_response_api(message, thread_id, assistant_id):
6
+ base_url = "https://enjambre-api-mue2676eoa-uc.a.run.app"
7
+ url = f"{base_url}/v1/agents/{assistant_id}/completion"
8
+ response = requests.post(url, json={
9
+ "message": message,
10
+ "model": "gpt-3.5-turbo-0613",
11
+ "threadId": thread_id
12
+ })
13
+ response_json = response.json()
14
+ return response_json["message"], response_json["threadId"]
15
+
16
+ # Función para manejar el chat, ahora acepta dos argumentos
17
+ def chat_function(message, history):
18
+ global thread_id
19
+ assistant_id = "asst_vsm9RJaiFiWAcMFmwKF2u6Jd" # ID de tu asistente
20
+ response, new_thread_id = generate_response_api(message, thread_id, assistant_id)
21
+ thread_id = new_thread_id # Actualiza el thread_id global
22
+ return response
23
+
24
+ # Inicializa la variable global
25
+ thread_id = None
26
+
27
+ # Configuración de ChatInterface
28
+ demo = gr.ChatInterface(
29
+ fn=chat_function,
30
+ title="Proyectos MAC",
31
+ description="Soy un asistente virtual que conoce el proyecto de Magaña Arevalo Contadores a la perfección y te puedo ayudar con tus dudas o estrategias.",
32
+ theme="soft",
33
+ examples=[
34
+ "¿Cuál es el cronograma detallado de implementación para la transformación digital de MAC?",
35
+ "¿Qué capacitaciones están incluidas en el proyecto para el personal de MAC?",
36
+ "¿Cómo se integrarán las plataformas bancarias y el CRM en nuestra infraestructura actual?",
37
+ "¿Cuáles son los KPIs clave que los Dashboards de BI nos ayudarán a monitorear?",
38
+ "¿Qué medidas de soporte y mantenimiento ofrece Geek Studio tras la finalización del proyecto?"
39
+ ],
40
+
41
+ retry_btn=None,
42
+ undo_btn=None,
43
+ submit_btn="Enviar",
44
+ stop_btn="Detener"
45
+ ).queue()
46
+
47
+ if __name__ == "__main__":
48
+ demo.launch(share=True)
app2/requirements.txt ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ aiofiles==23.2.1
2
+ altair==5.2.0
3
+ annotated-types==0.6.0
4
+ anyio==4.2.0
5
+ attrs==23.2.0
6
+ certifi==2023.11.17
7
+ charset-normalizer==3.3.2
8
+ click==8.1.7
9
+ colorama==0.4.6
10
+ contourpy==1.2.0
11
+ cycler==0.12.1
12
+ fastapi==0.109.0
13
+ ffmpy==0.3.1
14
+ filelock==3.13.1
15
+ fonttools==4.47.2
16
+ fsspec==2023.12.2
17
+ gradio==4.16.0
18
+ gradio_client==0.8.1
19
+ h11==0.14.0
20
+ httpcore==1.0.2
21
+ httpx==0.26.0
22
+ huggingface-hub==0.20.3
23
+ idna==3.6
24
+ importlib-resources==6.1.1
25
+ Jinja2==3.1.3
26
+ jsonschema==4.21.1
27
+ jsonschema-specifications==2023.12.1
28
+ kiwisolver==1.4.5
29
+ markdown-it-py==3.0.0
30
+ MarkupSafe==2.1.4
31
+ matplotlib==3.8.2
32
+ mdurl==0.1.2
33
+ numpy==1.26.3
34
+ orjson==3.9.12
35
+ packaging==23.2
36
+ pandas==2.2.0
37
+ pillow==10.2.0
38
+ pydantic==2.6.0
39
+ pydantic_core==2.16.1
40
+ pydub==0.25.1
41
+ Pygments==2.17.2
42
+ pyparsing==3.1.1
43
+ python-dateutil==2.8.2
44
+ python-multipart==0.0.6
45
+ pytz==2023.4
46
+ PyYAML==6.0.1
47
+ referencing==0.33.0
48
+ requests==2.31.0
49
+ rich==13.7.0
50
+ rpds-py==0.17.1
51
+ ruff==0.1.15
52
+ semantic-version==2.10.0
53
+ shellingham==1.5.4
54
+ six==1.16.0
55
+ sniffio==1.3.0
56
+ starlette==0.35.1
57
+ tomlkit==0.12.0
58
+ toolz==0.12.1
59
+ tqdm==4.66.1
60
+ typer==0.9.0
61
+ typing_extensions==4.9.0
62
+ tzdata==2023.4
63
+ urllib3==2.2.0
64
+ uvicorn==0.27.0.post1
65
+ websockets==11.0.3