diff --git a/jarvis/main.py b/jarvis/main.py index e00b07c..d091282 100644 --- a/jarvis/main.py +++ b/jarvis/main.py @@ -2,11 +2,12 @@ import flask import lingua_franca from flask import Flask, request, jsonify, Response -from jarvis.ia import process from jarvis.skills import intent_manager +from jarvis.skills.entertainement.jokes import JokesSkill from jarvis.skills.entertainement.spotify import SpotifySkill +from jarvis.skills.research.wikipedia import WikipediaSkill from jarvis.utils import languages_utils -from utils import config_utils, flask_utils, intents_utils, utils +from utils import config_utils, flask_utils, utils app = Flask(__name__) @@ -18,21 +19,7 @@ def process_request(): if 'sentence' not in data or not data['sentence']: flask.abort(Response('You must provide a \'sentence\' parameter (not empty aswell)!')) - sentence = data['sentence'] - tag_for_request = process.get_tag_for_sentence(sentence) - - print("SENTENCE : " + sentence + " /// TAG : " + tag_for_request) - - # stop here if the sentence isn't understood - if tag_for_request == 'dont_understand': - return jsonify("I didn't get that.") - - path_of_intent = intents_utils.get_path(tag_for_request) - path_of_intent = path_of_intent.split('/skills/')[1].replace('/', '.') - path_of_intent = "skills." + path_of_intent + "intent" - - method = utils.import_method_from_string(path_of_intent, tag_for_request) - return jsonify(method()) + return {} if __name__ == '__main__': @@ -41,17 +28,19 @@ if __name__ == '__main__': lingua_franca.load_language(lang=languages_utils.get_language().split("-")[0]) # Tests - # WikipediaSkill().register() - # JokesSkill().register() + WikipediaSkill().register() + JokesSkill().register() SpotifySkill().register() intent_manager.process_handlers() - # intent_manager.recognise("cherche sur wikipedia Elon Musk") # TO CHECK + intent_manager.recognise("cherche sur wikipédia Elon Musk") # TO CHECK + intent_manager.recognise("c'est qui Elon Musk") # TO CHECK + intent_manager.recognise("cherche Elon Musk sur wikipédia") # TO CHECK # intent_manager.recognise("raconte moi une blague") # WORKING # intent_manager.recognise("joue le morceau crazy crazy nights de KISS sur spotify") # WORKING # intent_manager.recognise("coupe la musique") # WORKING - intent_manager.recognise("c'est quoi le nom de cette chanson ?") + # intent_manager.recognise("c'est quoi le nom de cette chanson ?") # WORKING # start the flask server app.config['JSON_AS_ASCII'] = False diff --git a/jarvis/skills/entertainement/spotify/__init__.py b/jarvis/skills/entertainement/spotify/__init__.py index 05c7e6f..049c22b 100644 --- a/jarvis/skills/entertainement/spotify/__init__.py +++ b/jarvis/skills/entertainement/spotify/__init__.py @@ -35,9 +35,9 @@ class SpotifySkill(Skill, metaclass=SkillRegistering): song_name = current_playback['item']['name'] artist = current_playback['item']['artists'][0]['name'] - print(song_name + " from " + artist) - - print("[INFO INTENT] - Current playback : music for Spotify") + print("[INFO INTENT] - Current playback : " + song_name + " from " + artist + " on Spotify") + else: + print("Nothing is playing") def create_skill(): diff --git a/jarvis/skills/research/wikipedia/__init__.py b/jarvis/skills/research/wikipedia/__init__.py index db101ea..9c40026 100644 --- a/jarvis/skills/research/wikipedia/__init__.py +++ b/jarvis/skills/research/wikipedia/__init__.py @@ -1,15 +1,14 @@ -from adapt.intent import IntentBuilder - from jarvis.skills import Skill, SkillRegistering -from jarvis.skills.decorators import intent_handler +from jarvis.skills.decorators import intent_file_handler class WikipediaSkill(Skill, metaclass=SkillRegistering): def __init__(self): super().__init__("WikipediaSkill") - @intent_handler(IntentBuilder("WikipediaQueryIntent").require("Wikipedia").require("ArticleTitle")) + @intent_file_handler("search.wikipedia.intent", "WikipediaQueryIntent") def handle_wikipedia_query_intent(self, data): + print(data) print("Handle Wikipedia Query Intent Method") diff --git a/jarvis/skills/research/wikipedia/vocab/fr-fr/search.wikipedia.intent b/jarvis/skills/research/wikipedia/vocab/fr-fr/search.wikipedia.intent new file mode 100644 index 0000000..b45844f --- /dev/null +++ b/jarvis/skills/research/wikipedia/vocab/fr-fr/search.wikipedia.intent @@ -0,0 +1,6 @@ +Chercher {query} sur wikipédia +C'est qui {query} +Donne moi plus d'infos sur {query} +C'est quoi {query} +Cherche sur wikipédia {query} +Cherche {query} sur wikipédia \ No newline at end of file