Пример #1
0
def main(mode):
    fibot = Fibot()
    if mode == "train": fibot.qa.load(train=True)
    if mode == "manual":
        fibot.qa.load(train=False)
        fibot.qa.train_manual()
    return
Пример #2
0
def main():
    parser = argparse.ArgumentParser(description='')
    parser.add_argument('--nlu',
                        nargs=1,
                        required=False,
                        choices=['es', 'ca', 'en', 'n'],
                        action='append',
                        help='Language for the interpretation')
    parser.add_argument('--dialog',
                        nargs=1,
                        required=False,
                        choices=['y', 'n'],
                        default=[],
                        help='File for the interpreter to use')
    args = parser.parse_args()
    print(args)
    trainNLU = False
    trainNLG = False
    languages = []
    if args.nlu:
        languages = [i[0] for i in args.nlu]
        trainNLU = True
    if args.dialog: trainNLG = bool(args.dialog[0] == 'y')

    config = tf.ConfigProto()
    config.gpu_options.allow_growth = True
    tf.Session(config=config)

    fibot = Fibot()
    fibot.qa.load(trainNLG=trainNLG, trainNLU=trainNLU, train_list=languages)
    return
Пример #3
0
def main():
    CHAT_ID = None
    parser = argparse.ArgumentParser(description='')
    parser.add_argument('--thread_log',
                        action='store_true',
                        help='Whether to log the threads info')
    parser.add_argument('--chat_id',
                        required=False,
                        type=int,
                        default=469557458,
                        help="Chat_id for the conversation")
    parser.add_argument('--no_debug',
                        action='store_true',
                        required=False,
                        help="Prints debug information about queries")
    args = parser.parse_args()

    if args.chat_id:
        CHAT_ID = args.chat_id
    debug = not args.no_debug

    fibot = Fibot(local=True, debug=debug)

    if args.thread_log: print(colored("LOG: Thread logging activo", 'cyan'))
    else: print(colored("LOG: Thread logging inactivo", 'cyan'))

    fibot.load_components(thread_logging=bool(args.thread_log))

    print(colored("LOG: Todo inicializado", 'cyan'))
    print(
        colored(
            "INFO: Simulando conversación como usuario con chat_id {}".format(
                CHAT_ID), 'red'))
    print(colored("INFO: Escribe 'quit' para terminar conversación", 'red'))

    message = input('> ')
    while not message == 'quit':
        fibot.process_income_message(CHAT_ID, message)
        message = input('> ')
Пример #4
0
from telegram import ReplyKeyboardMarkup, ChatAction
from telegram.ext import (Updater, CommandHandler, MessageHandler, Filters,
                          RegexHandler, ConversationHandler)

#-- Local imports --#
from Fibot.fibot import Fibot

# States of the ConversationHandler
MESSAGE_INCOME, TRAINING, CORR_INCORR, GET_CORRECT = range(4)

#Custom Keyboard for training models
reply_keyboard = [['Sí', 'No']]
markup = ReplyKeyboardMarkup(reply_keyboard, one_time_keyboard=True)

#The main object of the bot, see Fibot/fibot.py to understand the implementation
Fibot = Fibot()
"""
	Function that responds to the /start command
"""


def start(bot, update):
    global Fibot
    chat_id = update.message.chat_id
    if Fibot.chats.user_has_data(chat_id):
        Fibot.send_preset_message(chat_id, "start_known",
                                  Fibot.chats.get_chat(chat_id)['name'])
    else:
        user_name = update.message.from_user.first_name
        data = {
            'name': user_name,