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
sock.emit('join', json.dumps({'uuid': 'clientpc'}))
# Listen for messages from the server
@sock.on('message_from_assistant')
def on_message_from_jarvis(data):

2
run.py
View File

@ -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

View File

@ -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

View File

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

View File

@ -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

View File

@ -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
);

View File

@ -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 <drink name>"
Then mycroft reply should contain "<ingredient>"
When the user says "how do I mix a <drink name>"
Then mycroft reply should contain "<ingredient>"
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 <drink name>"
Then mycroft reply should contain "<ingredient>"
When the user says "how do I mix a <drink name>"
Then mycroft reply should contain "<ingredient>"
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 <drink name>"
Then mycroft reply should contain "<ingredient>"
When the user says "how do I make a <drink name>"
Then mycroft reply should contain "<ingredient>"
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 <drink name>"
Then mycroft reply should contain "<ingredient>"
When the user says "how to make a <drink name>"
Then mycroft reply should contain "<ingredient>"
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 <drink name>"
Then "cocktails" should reply with dialog from "NotFound.dialog"
When the user says "how to make a <drink name>"
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 |