Dialogflow์ web nodejs ์ฐ๋๋ฒ
KoGPT-2์ web nodejs ์ฐ๋๋ฒ
์ด ํ ๋ฅํ ๋ฅ ํ๋ก์ ํธ๋ ๋ถ์ ์ฅ์ ๋ฅผ ๋ง๊ธฐ ์ํด ๊ฐ๋ฐ๋ ์น ๊ธฐ๋ฐ API์ ๋๋ค. ๋ถ์ ์ ๋ ๊ฒ์ฌ, ๋ถ์ ์์ธ ๊ฒ์ฌ, ๋ฅ๋ฌ๋ ๊ธฐ๋ฐ ์ฑ๋ด๊ณผ์ ์์ ๋ก์ด ๋ํ๋ฅผ ํตํด ๋ถ์ํ ๊ฐ์ ์ ํ์ธํ๊ณ ์น์ ํ ์ ์์ต๋๋ค.
- Dialog flow๋ฅผ ํตํด ์ ํด์ง ์ง์ ์๋ต์ ์์ฑ (WIKI ์ฐธ์กฐ)
- Dialog flow API๋ฅผ ์ฌ์ฉํ๊ธฐ ์ํด์ Google Cloud Platform์์ ํด๋น Dialogflow project ์ฐพ์ ํ์ ์ธ์ฆ ํค ๋ฐ๊ธ (https://github.com/googleapis/nodejs-dialogflow ์ฐธ์กฐ)
- Json ํ์ผ ๋ฐ๊ธ ํ public ํ์ผ ์์ ๋ฃ์ด์ค๋๋ค. (Chatbot ํ์ผ๊ณผ ๊ฐ์ ์์น์)
- ๋ผ์ด๋ธ๋ฌ๋ฆฌ ์ค์น (ํด๋น ๋๋ ํ ๋ฆฌ(Chatbot) ๊ฒฝ๋ก ๋ณ๊ฒฝ ํ ์ค์น)
npm init
npm I dialogflow
npm install uuid express body-parser
- ์๋ ํด๋น ์ฃผ์ ์์น์ ๋ด์ฉ ์ถ๊ฐ
var serviceAccount = require("") // firebase json file position
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
databaseURL: "" // firebase database url
});
- child ๋ด๋ถ์ ์์ ์ firebase uid ์ถ๊ฐ
db.ref('anxiety information').child('').push().set(newContact2); //myUid
db.ref('anxiety information for report').child('').set(newContact2); //myuid
- ์๋ function์ ์ฃผ์ ์์น์ ์ ๋ณด ์ถ๊ฐ
async function runSample(msg, projectId = '') { // project name
const sessionClient = new dialogflow.SessionsClient({
keyFilename:"" //json file position
});
const sessionPath = sessionClient.projectAgentSessionPath(projectId, sessionId);
const request = {
session: sessionPath,
queryInput: {
text: {
text: msg,
languageCode: 'en-US',
},
},
};
- cmd์์ chatbot.js๊ฐ ์๋ ๋๋ ํ ๋ฆฌ๋ก ์ด๋
- ๋ค์๊ณผ ๊ฐ์ ๋ช ๋ น์ด ์คํ
node chatbot api.js
- first_counsel.html / second_html ์ ๋ค์ด๊ฐ์ ์ํ๋ ๋ง์ ์ ๋๋ค
- ์ดํ์ rule๋ chatbot ๋๋ต์ ํ์ธํ ์ ์๋ค.
(KoGPT2 training ๋ฐฉ๋ฒ https://github.com/haven-jeon/KoGPT2-chatbot ์ฐธ์กฐ)
- answering.py ์คํ
- nodejs์ local ์๋ฒ ์คํ
- deep_counsel.html์ ์ํ๋ ๋ง์ ์ ๋๋ค.
- ์ผ์ ์๊ฐ ํ์ ๋ฅ๋ฌ๋ Chatbot์ ๋๋ต์ ํ์ธํ ํ ์ ์์
โป ๋ฐ์ดํฐ ์ ์ข ๋ฅ
- AI Hub(https://aihub.or.kr/) ์ฐ๋์ค ๋ํ ๋ฐ์ดํฐ ์
- ChatbotData(https://github.com/songys/Chatbot_data) ๋ํ ๋ฐ์ดํฐ ์
- AI Hub(https://aihub.or.kr/) ๊ฐ์ฑ ๋ง๋ญ์น ๋ฐ์ดํฐ ์ (์ ์ฒ๋ฆฌ)