Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate the project into client and server and implement the api #113

Draft
wants to merge 21 commits into
base: develop
Choose a base branch
from
Draft
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
24 changes: 24 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
version: "3.8"

services:
web:
build:
context: .
dockerfile: ./docker/dockerfile
command: uvicorn server.core.processor:app --reload --host 0.0.0.0
volumes:
- .:/app
ports:
- 8008:8000

mongodb_container:
image: mongo:latest
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: rootpassword
ports:
- 27017:27017
volumes:
- mongodb_data_container:/data/db
volumes:
mongodb_data_container:
21 changes: 21 additions & 0 deletions docker/dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Dockerfile

# pull the official docker image
FROM python:3.9.4

# set work directory
WORKDIR /app

# set env variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

# install dependencies
COPY requirements.txt .
RUN pip install -r requirements.txt
RUN pip install --no-cache-dir numpy scikit-learn
RUN python3 -c "import nltk; nltk.download('punkt'); nltk.download('averaged_perceptron_tagger')"
# copy project
COPY . .

WORKDIR /app/src/jarvis
18 changes: 3 additions & 15 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,51 +1,39 @@
appdirs==1.4.3
APScheduler==3.6.0
backports.entry-points-selectable==1.1.0
beautifulsoup4==4.7.1
bs4==0.0.1
certifi==2019.3.9
chardet==3.0.4
Click==7.0
colorize==1.1.0
Cython==0.29.24
distlib==0.3.3
filelock==3.3.0
geojson==2.4.1
google==2.0.2
gTTS-token==1.1.3
idna==2.8
inflect==2.1.0
jaraco.itertools==4.4.2
joblib==0.14.0
lxml==4.6.3
mock==3.0.5
more-itertools==7.0.0
nltk==3.4.5
numpy==1.16.4
patch==1.16
platformdirs==2.4.0
playsound==1.2.2
psutil==5.6.6
PTable==0.9.2
PyAudio==0.2.11
pycairo==1.20.1
PyGObject==3.42.0
pymongo==3.10.1
pyowm==2.10.0
pyttsx3==2.71
pytz==2019.1
requests==2.21.0
scipy==1.5.4
nltk
six==1.12.0
soupsieve==1.9.1
SpeechRecognition==3.8.1
speedtest-cli==2.1.1
textblob==0.15.3
tzlocal==1.5.1
urllib3==1.24.3
virtualenv==20.8.1
web-cache==1.1.0
wikipedia==1.4.0
wolframalpha==3.0.1
word2number==1.1
xmltodict==0.12.0
fastapi
uvicorn
File renamed without changes.
14 changes: 14 additions & 0 deletions src/jarvis/client/api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from enum import Enum

class Status_code(Enum):
Success = 200
Server_Error = 500
Client_Error = 400


class api_manager:
def __init__(self) -> None:
pass

def post_user_input(transcript: str) -> Status_code:
pass
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
import psutil
import logging

from jarvis import settings
from jarvis.utils.mongoDB import db
from jarvis.utils.console import jarvis_logo, start_text, OutputStyler, headerize
from jarvis.enumerations import MongoCollections, InputMode
from server import settings
from server.utils.mongoDB import db
from server.utils.console import jarvis_logo, start_text, OutputStyler, headerize
from server.enumerations import MongoCollections, InputMode


class ConsoleManager:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
import logging
import speech_recognition as sr

import jarvis
from jarvis.core.console import ConsoleManager
import server
from server.core.console import ConsoleManager


class STTEngine:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import pyttsx3
import queue

from jarvis.core.console import ConsoleManager
from server.core.console import ConsoleManager


class TTS:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
# SOFTWARE.

import logging
from jarvis.core.console import ConsoleManager
from jarvis.utils.console import user_input
from server.core.console import ConsoleManager
from server.utils.console import user_input


class TTTEngine:
Expand Down
19 changes: 19 additions & 0 deletions src/jarvis/client/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import engines
from api import api_manager

class Client:
def __init__(self, console_manager) -> None:
self.console_manager = console_manager
self.api_manger = api_manager()

def run() -> None:
"""
Assistant starting point.

- STEP 1: Get user input based on the input mode (voice or text)
- STEP 2: Send the user input to the api
- STEP 3: Get api response and either execute a local skill or give the user a respone

"""
transcript = engines.input_engine.recognize_input()
self.api_manger.post_user_input(transcript)
122 changes: 0 additions & 122 deletions src/jarvis/jarvis/core/processor.py

This file was deleted.

14 changes: 6 additions & 8 deletions src/jarvis/jarvis/__init__.py → src/jarvis/server/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,10 @@

from logging import config

from jarvis import settings
from jarvis.settings import ROOT_LOG_CONF
from jarvis.utils.mongoDB import db
from jarvis.utils.startup import configure_MongoDB
from jarvis.enumerations import InputMode
import jarvis.engines as engines
import server.settings
from server.settings import ROOT_LOG_CONF
from server.utils.mongoDB import db
from server.utils.startup import configure_MongoDB

# ----------------------------------------------------------------------------------------------------------------------
# Create a Console & Rotating file logger
Expand Down Expand Up @@ -55,5 +53,5 @@
# ----------------------------------------------------------------------------------------------------------------------
# Create assistant input and output engine instances
# ----------------------------------------------------------------------------------------------------------------------
input_engine = engines.STTEngine() if input_mode == InputMode.VOICE.value else engines.TTTEngine()
output_engine = engines.TTSEngine() if response_in_speech else engines.TTTEngine()
#input_engine = engines.STTEngine() if input_mode == InputMode.VOICE.value else engines.TTTEngine()
#output_engine = engines.TTSEngine() if response_in_speech else engines.TTTEngine()
File renamed without changes.
File renamed without changes.
Loading