This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const config = require('../../config') | |
const axios = require('axios') | |
const md5 = require('md5') | |
class Olami { | |
constructor(appKey = config.olami.appKey, appSecret = config.olami.appSectet, inputType = 1) { | |
this.URL = 'https://tw.olami.ai/cloudservice/api' | |
this.appKey = appKey | |
this.appSecret = appSecret | |
this.inputType = inputType |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const {LineHandler} = require('bottender') | |
const olami = require('./nlp/Olami') | |
exports.lineHandler = new LineHandler() | |
.onText(async context => { | |
const text = context.event.text | |
const userId = context._session.user.id | |
const reply = await olami.nli(text, userId) | |
await context.replyText(reply) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const config = require('../../config') | |
const axios = require('axios') | |
const md5 = require('md5') | |
class Olami { | |
constructor(appKey = config.olami.appKey, appSecret = config.olami.appSectet, inputType = 1) { | |
this.URL = 'https://tw.olami.ai/cloudservice/api' | |
this.appKey = appKey | |
this.appSecret = appSecret | |
this.inputType = inputType |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const {LineHandler} = require('bottender') | |
exports.lineHandler = new LineHandler() | |
.onText(async context => { | |
const text = context.event.text | |
const reply = text | |
await context.replyText(reply) | |
} | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express') | |
const bodyParser = require('body-parser') | |
const {LineBot} = require('bottender') | |
const {registerRoutes} = require('bottender/express') | |
const {lineHandler} = require('./handler') | |
const config = require('../config') | |
const server = new express() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
web: gunicorn main:app --log-file - |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+from telegram import ReplyKeyboardMarkup | |
+from telegram.ext import Dispatcher, CommandHandler, MessageHandler, Filters | |
+ | |
+welcome_message = '親愛的主人,您可以問我\n' \ | |
+ '天氣,例如:「高雄天氣如何」\n' \ | |
+ '百科,例如:「川普是誰」\n' \ | |
+ '新聞,例如:「今日新聞」\n' \ | |
+ '音樂,例如:「我想聽周杰倫的等你下課」\n' \ | |
+ '日曆,例如:「現在時間」\n' \ | |
+ '詩詞,例如:「我想聽水調歌頭這首詩」\n' \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import configparser | |
import logging | |
import telegram | |
from flask import Flask, request | |
from telegram import ReplyKeyboardMarkup | |
from telegram.ext import Dispatcher, CommandHandler, MessageHandler, Filters | |
from nlp.olami import Olami |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import configparser | |
import json | |
import logging | |
import time | |
from hashlib import md5 | |
from api.kkbox import KKBOX | |
import requests | |
config = configparser.ConfigParser() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+from api.kkbox import KKBOX | |
class Olami: | |
def intent_detection(self, nli_obj): | |
+ def handle_music_kkbox_type(semantic): | |
+ music_type = semantic['modifier'][0].split('_')[2] | |
+ slots = semantic['slots'] | |
+ kkbox = KKBOX() | |
+ | |
+ def get_slot_value_by_key(key): |