refactor code

This commit is contained in:
Mathieu Broillet 2023-11-06 21:38:38 +01:00
parent 23c9f95fce
commit 0fcae7a20f
Signed by: mathieu
GPG Key ID: C0E9E0E95AF03319
8 changed files with 45 additions and 42 deletions

View File

@ -17,6 +17,7 @@ if __name__ == '__main__':
# Join the room # Join the room
sock.emit('join', json.dumps({'uuid': 'clientpc'})) sock.emit('join', json.dumps({'uuid': 'clientpc'}))
# Listen for messages from the server # Listen for messages from the server
@sock.on('message_from_assistant') @sock.on('message_from_assistant')
def on_message_from_jarvis(data): def on_message_from_jarvis(data):

2
run.py
View File

@ -1,8 +1,8 @@
import logging import logging
from src.audio import audio_utils from src.audio import audio_utils
from src.database import db_utils
from src.constants import TTSEngine, STTEngine from src.constants import TTSEngine, STTEngine
from src.database import db_utils
from src.network import api from src.network import api
# import lingua_franca # import lingua_franca

View File

@ -1,7 +1,8 @@
# Always prefer setuptools over distutils # Always prefer setuptools over distutils
from setuptools import setup, find_packages
import pathlib import pathlib
from setuptools import setup, find_packages
here = pathlib.Path(__file__).parent.resolve() here = pathlib.Path(__file__).parent.resolve()
# Get the long description from the README file # Get the long description from the README file
@ -181,4 +182,4 @@ setup(
"Say Thanks!": "http://saythanks.io/to/example", "Say Thanks!": "http://saythanks.io/to/example",
"Source": "https://github.com/pypa/sampleproject/", "Source": "https://github.com/pypa/sampleproject/",
}, },
) )

View File

@ -1,7 +1,6 @@
import logging import logging
import os.path import os.path
import sqlite3 import sqlite3
from pathlib import Path
from src.get_path_file import project_path from src.get_path_file import project_path

View File

@ -1,3 +1,3 @@
import pathlib import pathlib
project_path = pathlib.Path(__file__).parent.resolve() project_path = pathlib.Path(__file__).parent.resolve()

View File

@ -5,8 +5,8 @@ import openai
from flask import Flask, request from flask import Flask, request
from flask_socketio import SocketIO from flask_socketio import SocketIO
from src.network import endpoint_handler, socket_handler
from src.constants import Endpoints, Sockets from src.constants import Endpoints, Sockets
from src.network import endpoint_handler, socket_handler
# Set this variable to "threading", "eventlet" or "gevent" to test the # Set this variable to "threading", "eventlet" or "gevent" to test the
# different async modes, or leave it set to None for the application to choose # different async modes, or leave it set to None for the application to choose

View File

@ -1,14 +1,16 @@
--- Create a commands table that contains all the already executed commandes and the simplified version by ChatGPT --- Create a commands table that contains all the already executed commandes and the simplified version by ChatGPT
DROP TABLE IF EXISTS commands; DROP TABLE IF EXISTS commands;
CREATE TABLE commands ( CREATE TABLE commands
id INTEGER PRIMARY KEY, (
original_command VARCHAR NOT NULL, id INTEGER PRIMARY KEY,
original_command VARCHAR NOT NULL,
simplified_command VARCHAR NOT NULL, simplified_command VARCHAR NOT NULL,
response INT NOT NULL response INT NOT NULL
); );
DROP TABLE IF EXISTS responses; DROP TABLE IF EXISTS responses;
CREATE TABLE responses ( CREATE TABLE responses
id INTEGER PRIMARY KEY, (
id INTEGER PRIMARY KEY,
response VARCHAR NOT NULL response VARCHAR NOT NULL
); );

View File

@ -2,51 +2,51 @@ Feature: Cocktail functionality
Scenario Outline: how do I mix a drink Scenario Outline: how do I mix a drink
Given an english speaking user Given an english speaking user
When the user says "how do I mix a <drink name>" When the user says "how do I mix a <drink name>"
Then mycroft reply should contain "<ingredient>" Then mycroft reply should contain "<ingredient>"
Examples: drink examples Examples: drink examples
| drink name | ingredient | | drink name | ingredient |
| moscow mule | lime juice | | moscow mule | lime juice |
| gin and tonic | gin | | gin and tonic | gin |
@xfail @xfail
Scenario Outline: Failing: how do I mix a drink Scenario Outline: Failing: how do I mix a drink
Given an english speaking user Given an english speaking user
When the user says "how do I mix a <drink name>" When the user says "how do I mix a <drink name>"
Then mycroft reply should contain "<ingredient>" Then mycroft reply should contain "<ingredient>"
Examples: drink examples Examples: drink examples
| drink name | ingredient | | drink name | ingredient |
| margarita | tequila | | margarita | tequila |
Scenario Outline: how do I make a drink Scenario Outline: how do I make a drink
Given an english speaking user Given an english speaking user
When the user says "how do I make a <drink name>" When the user says "how do I make a <drink name>"
Then mycroft reply should contain "<ingredient>" Then mycroft reply should contain "<ingredient>"
Examples: drink examples Examples: drink examples
| drink name | ingredient | | drink name | ingredient |
| margarita | tequila | | margarita | tequila |
| moscow mule | lime juice | | moscow mule | lime juice |
| gin and tonic | gin | | gin and tonic | gin |
Scenario Outline: how to make a drink Scenario Outline: how to make a drink
Given an english speaking user Given an english speaking user
When the user says "how to make a <drink name>" When the user says "how to make a <drink name>"
Then mycroft reply should contain "<ingredient>" Then mycroft reply should contain "<ingredient>"
Examples: drink examples Examples: drink examples
| drink name | ingredient | | drink name | ingredient |
| old fashioned | sugar | | old fashioned | sugar |
| long island iced tea | coca-cola | | long island iced tea | coca-cola |
Scenario Outline: how to make a missing drink Scenario Outline: how to make a missing drink
Given an english speaking user Given an english speaking user
When the user says "how to make a <drink name>" When the user says "how to make a <drink name>"
Then "cocktails" should reply with dialog from "NotFound.dialog" Then "cocktails" should reply with dialog from "NotFound.dialog"
Examples: drink examples Examples: drink examples
| drink name | | drink name |
| old fnord wrangler | | old fnord wrangler |
| smashed fore-head | | smashed fore-head |