From 0fcae7a20fbdd00ab7d7b64cbd4cbfd714992fc6 Mon Sep 17 00:00:00 2001 From: Mathieu Broillet Date: Mon, 6 Nov 2023 21:38:38 +0100 Subject: [PATCH] refactor code --- basic_test_client.py | 1 + run.py | 2 +- setup.py | 5 +- src/database/db_utils.py | 1 - src/get_path_file.py | 2 +- src/network/api.py | 2 +- src/resources/create_empty_database.sql | 14 +++-- .../cocktails/test/behave/cocktails.feature | 60 +++++++++---------- 8 files changed, 45 insertions(+), 42 deletions(-) diff --git a/basic_test_client.py b/basic_test_client.py index 534df6c..c6338b0 100644 --- a/basic_test_client.py +++ b/basic_test_client.py @@ -17,6 +17,7 @@ if __name__ == '__main__': # Join the room sock.emit('join', json.dumps({'uuid': 'clientpc'})) + # Listen for messages from the server @sock.on('message_from_assistant') def on_message_from_jarvis(data): diff --git a/run.py b/run.py index 084331a..9b09d68 100644 --- a/run.py +++ b/run.py @@ -1,8 +1,8 @@ import logging from src.audio import audio_utils -from src.database import db_utils from src.constants import TTSEngine, STTEngine +from src.database import db_utils from src.network import api # import lingua_franca diff --git a/setup.py b/setup.py index 509e421..16391c6 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,8 @@ # Always prefer setuptools over distutils -from setuptools import setup, find_packages import pathlib +from setuptools import setup, find_packages + here = pathlib.Path(__file__).parent.resolve() # Get the long description from the README file @@ -181,4 +182,4 @@ setup( "Say Thanks!": "http://saythanks.io/to/example", "Source": "https://github.com/pypa/sampleproject/", }, -) \ No newline at end of file +) diff --git a/src/database/db_utils.py b/src/database/db_utils.py index c364703..9bbb2a2 100644 --- a/src/database/db_utils.py +++ b/src/database/db_utils.py @@ -1,7 +1,6 @@ import logging import os.path import sqlite3 -from pathlib import Path from src.get_path_file import project_path diff --git a/src/get_path_file.py b/src/get_path_file.py index f3e3d19..543d552 100644 --- a/src/get_path_file.py +++ b/src/get_path_file.py @@ -1,3 +1,3 @@ import pathlib -project_path = pathlib.Path(__file__).parent.resolve() \ No newline at end of file +project_path = pathlib.Path(__file__).parent.resolve() diff --git a/src/network/api.py b/src/network/api.py index 599f67d..bc8fc75 100644 --- a/src/network/api.py +++ b/src/network/api.py @@ -5,8 +5,8 @@ import openai from flask import Flask, request from flask_socketio import SocketIO -from src.network import endpoint_handler, socket_handler 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 # different async modes, or leave it set to None for the application to choose diff --git a/src/resources/create_empty_database.sql b/src/resources/create_empty_database.sql index c9b29de..6a81ab4 100644 --- a/src/resources/create_empty_database.sql +++ b/src/resources/create_empty_database.sql @@ -1,14 +1,16 @@ --- Create a commands table that contains all the already executed commandes and the simplified version by ChatGPT DROP TABLE IF EXISTS commands; -CREATE TABLE commands ( - id INTEGER PRIMARY KEY, - original_command VARCHAR NOT NULL, +CREATE TABLE commands +( + id INTEGER PRIMARY KEY, + original_command VARCHAR NOT NULL, simplified_command VARCHAR NOT NULL, - response INT NOT NULL + response INT NOT NULL ); DROP TABLE IF EXISTS responses; -CREATE TABLE responses ( - id INTEGER PRIMARY KEY, +CREATE TABLE responses +( + id INTEGER PRIMARY KEY, response VARCHAR NOT NULL ); \ No newline at end of file diff --git a/src/skills/cocktails/test/behave/cocktails.feature b/src/skills/cocktails/test/behave/cocktails.feature index b0f5626..ca8929f 100644 --- a/src/skills/cocktails/test/behave/cocktails.feature +++ b/src/skills/cocktails/test/behave/cocktails.feature @@ -2,51 +2,51 @@ Feature: Cocktail functionality Scenario Outline: how do I mix a drink Given an english speaking user - When the user says "how do I mix a " - Then mycroft reply should contain "" + When the user says "how do I mix a " + Then mycroft reply should contain "" - Examples: drink examples - | drink name | ingredient | - | moscow mule | lime juice | - | gin and tonic | gin | + Examples: drink examples + | drink name | ingredient | + | moscow mule | lime juice | + | gin and tonic | gin | @xfail Scenario Outline: Failing: how do I mix a drink Given an english speaking user - When the user says "how do I mix a " - Then mycroft reply should contain "" + When the user says "how do I mix a " + Then mycroft reply should contain "" - Examples: drink examples - | drink name | ingredient | - | margarita | tequila | + Examples: drink examples + | drink name | ingredient | + | margarita | tequila | Scenario Outline: how do I make a drink Given an english speaking user - When the user says "how do I make a " - Then mycroft reply should contain "" + When the user says "how do I make a " + Then mycroft reply should contain "" - Examples: drink examples - | drink name | ingredient | - | margarita | tequila | - | moscow mule | lime juice | - | gin and tonic | gin | + Examples: drink examples + | drink name | ingredient | + | margarita | tequila | + | moscow mule | lime juice | + | gin and tonic | gin | Scenario Outline: how to make a drink Given an english speaking user - When the user says "how to make a " - Then mycroft reply should contain "" + When the user says "how to make a " + Then mycroft reply should contain "" - Examples: drink examples - | drink name | ingredient | - | old fashioned | sugar | - | long island iced tea | coca-cola | + Examples: drink examples + | drink name | ingredient | + | old fashioned | sugar | + | long island iced tea | coca-cola | Scenario Outline: how to make a missing drink Given an english speaking user - When the user says "how to make a " - Then "cocktails" should reply with dialog from "NotFound.dialog" + When the user says "how to make a " + Then "cocktails" should reply with dialog from "NotFound.dialog" - Examples: drink examples - | drink name | - | old fnord wrangler | - | smashed fore-head | + Examples: drink examples + | drink name | + | old fnord wrangler | + | smashed fore-head |