Aim

Make a chatbot that barely knows anything, but Courius. It will ask questions about anything it doesn’t know. Gradually, it learns new knowledge through dialog with the user. This new knowledge is stored in a database and the robot will use the stored content to communicate in future conversations.

Problem Break down

Make a chatbot (Discord.js, Node.js) that barely knows anything, but Courius. It will ask questions about anything it doesn’t know. (Data processing, Tokenization) Gradually, it learns new knowledge through dialog with the user. (Discord.js Functions) This new knowledge is stored in a database (Firebase)and the robot will use the stored content to communicate (Text generation) in future conversations.

Solutions

Hugging face

Auto Tokenization based on the intent of the sentence

https://huggingface.co/blaze999/Medical-NER

API:

import fetch from "node-fetch";//hugging face api
async function query(data) {
	const response = await fetch(
		"<https://api-inference.huggingface.co/models/blaze999/Medical-NER>",
		{
			headers: {
				Authorization: "Bearer hf_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
				"Content-Type": "application/json",
			},
			method: "POST",
			body: JSON.stringify(data),
		}
	);
	const result = await response.json();
	return result;
}

query({"inputs": "My name is Sarah Jessica Parker but you can call me Jessica"}).then((response) => {
	console.log(JSON.stringify(response));
});

Firestore

API:

import admin from "firebase-admin";
const admin = require("firebase-admin");

const serviceAccount = require("path/to/serviceAccountKey.json");

admin.initializeApp({
  credential: admin.credential.cert(serviceAccount)
});

Read Data .get()

const Dataname = db.collection('collection name').doc('ID');
const doc = await cityRef.get();
if (!doc.exists) {
  console.log('No such document!');
} else {
  console.log('Document data:', doc.data());
}

Write Data