Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .devcontainer/compose-extend.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: '3.9'

services:
asistente:
build:
dockerfile: Dockerfile
context: ../
target: base
volumes:
- ../.:/workspace:cached
ports:
- 5000:5000
env_file:
- ../.env

42 changes: 42 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"name": "Asistente virtual en flask",
"service": "asistente",

"dockerComposeFile": [
"compose-extend.yaml"
],

"remoteEnv": {
"PYTHONUNBUFFERED": "1"
},


"workspaceFolder": "/workspace",

"forwardPorts": [5000],

"shutdownAction": "stopCompose",

"postCreateCommand": "pip3 install autopep8",
"postStartCommand": "python app.py",

"customizations": {
"vscode": {
"extensions": [
"mutantdino.resourcemonitor",
"ms-python.autopep8",
"ms-python.python",
"ms-python.vscode-pylance"
],
"settings": {
"editor.defaultFormatter": "ms-python.autopep8",
"editor.formatOnSave": false,
"editor.codeActionsOnSave": {
"source.organizeImports": false
}
}
}
},
"overrideCommand": true,
"remoteUser": "root"
}
37 changes: 37 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Include any files or directories that you don't want to be copied to your
# container here (e.g., local build artifacts, temporary files, etc.).
#
# For more help, visit the .dockerignore file reference guide at
# https://docs.docker.com/engine/reference/builder/#dockerignore-file

**/.DS_Store
**/__pycache__
**/.venv
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/bin
**/charts
**/docker-compose*
**/compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
**/.devcontainer
**/*.mp3

LICENSE
README.md
32 changes: 32 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

ARG PYTHON_VERSION=3.11

FROM python:${PYTHON_VERSION}-slim as base

RUN --mount=type=cache,target=/root/.cache/pip,mode=775 pip3 install --upgrade pip
RUN --mount=type=cache,target=/root/.cache/pip,mode=775\
--mount=type=bind,source=requirements.txt,target=requirements.txt \
pip3 install -r requirements.txt


FROM base as final
RUN --mount=type=cache,target=/root/.cache/pip,mode=775 \
pip3 install gunicorn

ARG UID=10001
RUN adduser \
--disabled-password \
--gecos "" \
--home "/opt/appuser" \
--shell "/sbin/nologin" \
--uid "${UID}" \
appuser

USER appuser
WORKDIR /opt/appuser/src

COPY --chown=appuser:users . .

EXPOSE 5000

CMD gunicorn app:app --bind=0.0.0.0:5000
10 changes: 6 additions & 4 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from llm import LLM
from weather import Weather
from tts import TTS
from pc_command import PcCommand

#Cargar llaves del archivo .env
load_dotenv()
Expand Down Expand Up @@ -48,10 +47,9 @@ def audio():
return {"result": "ok", "text": final_response, "file": tts_file}

elif function_name == "open_chrome":
PcCommand().open_chrome(args["website"])
final_response = "Listo, ya abrí chrome en el sitio " + args["website"]
tts_file = TTS().process(final_response)
return {"result": "ok", "text": final_response, "file": tts_file}
return {"result": "ok", "text": final_response, "file": tts_file, "website": args["website"]}

elif function_name == "dominate_human_race":
final_response = "No te creas. Suscríbete al canal!"
Expand All @@ -60,4 +58,8 @@ def audio():
else:
final_response = "No tengo idea de lo que estás hablando, Ringa Tech"
tts_file = TTS().process(final_response)
return {"result": "ok", "text": final_response, "file": tts_file}
return {"result": "ok", "text": final_response, "file": tts_file}


if __name__ == "__main__":
app.run(debug=True, host="0.0.0.0")
13 changes: 13 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: '3.9'

services:
asistente:
build:
dockerfile: Dockerfile
context: .
target: final
ports:
- 5000:5000
env_file:
- .env

6 changes: 6 additions & 0 deletions static/recorder.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ function doPreview() {
body: fd,
})
.then((response) => response.json())
.then((response) => {
if (!!response?.website) {
window.open(response.website)
}
return response
})
.then(audioResponseHandler)
.catch(err => {
//Puedes hacer algo más inteligente aquí
Expand Down