diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..f2481e8 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,5 @@ +include botiverse/models/TRIPPY/*.txt +include botiverse/gui/static/icons/*.png +include botiverse/gui/static/*.png +include botiverse/gui/static/*.css +include botiverse/gui/templates/*.html \ No newline at end of file diff --git a/botiverse/bots/VoiceBot/SpeechClassifier.py b/botiverse/bots/VoiceBot/SpeechClassifier.py index b1646ed..0f0b744 100644 --- a/botiverse/bots/VoiceBot/SpeechClassifier.py +++ b/botiverse/bots/VoiceBot/SpeechClassifier.py @@ -1,4 +1,12 @@ - +try: + import os + from botiverse.models import TTS + from playsound import playsound + from botiverse.models import LSTMClassifier + from botiverse.preprocessors import Vocalize, Wav2Vec, Frequency + from botiverse.bots.VoiceBot.utils import voice_input +except: + pass class SpeechClassifier(): ''' diff --git a/botiverse/bots/VoiceBot/VoiceBot.py b/botiverse/bots/VoiceBot/VoiceBot.py index 8a6858f..def3058 100644 --- a/botiverse/bots/VoiceBot/VoiceBot.py +++ b/botiverse/bots/VoiceBot/VoiceBot.py @@ -1,15 +1,16 @@ -import numpy as np -import json -from gtts import gTTS -import tempfile -import os -from botiverse.models import TTS -from playsound import playsound - -from botiverse.models import LSTMClassifier -from botiverse.preprocessors import Vocalize, Wav2Vec, Wav2Text, BertEmbedder, Frequency, BertSentenceEmbedder -from botiverse.bots.VoiceBot.utils import voice_input - +try: + import numpy as np + import json + from gtts import gTTS + import tempfile + import os + from botiverse.models import TTS + from playsound import playsound + from botiverse.models import LSTMClassifier + from botiverse.preprocessors import Vocalize, Wav2Vec, Wav2Text, BertEmbedder, Frequency, BertSentenceEmbedder + from botiverse.bots.VoiceBot.utils import voice_input +except: + pass class VoiceBot(): '''An interface for the vocalizer chatbot which simulates a call with a customer service bot.''' diff --git a/botiverse/bots/__init__.py b/botiverse/bots/__init__.py index e0e8789..5efe89e 100644 --- a/botiverse/bots/__init__.py +++ b/botiverse/bots/__init__.py @@ -1,5 +1,6 @@ from botiverse.bots.BasicBot.BasicBot import BasicBot from botiverse.bots.WhizBot.WhizBot import WhizBot +from botiverse.bots.ConverseBot.ConverseBot import ConverseBot from botiverse.bots.basic_TODS.basic_TODS import BasicTODS from botiverse.bots.deep_TODS.deep_TODS import DeepTODS from botiverse.bots.VoiceBot.SpeechClassifier import SpeechClassifier diff --git a/botiverse/models/LSTM/LSTMClassifier.pt b/botiverse/models/LSTM/LSTMClassifier.pt deleted file mode 100644 index 5391dea..0000000 Binary files a/botiverse/models/LSTM/LSTMClassifier.pt and /dev/null differ diff --git a/botiverse/models/SiameseNet/SiameseNet.py b/botiverse/models/SiameseNet/SiameseNet.py deleted file mode 100644 index 5277f9b..0000000 --- a/botiverse/models/SiameseNet/SiameseNet.py +++ /dev/null @@ -1,169 +0,0 @@ -from sklearn.decomposition import PCA -from umap import UMAP -import matplotlib.pyplot as plt -import torch -import torch.nn as nn -import numpy as np -from tqdm import tqdm - - -class TripletLoss(nn.Module): - def __init__(self, margin, γ): - super(TripletLoss, self).__init__() - self.margin = margin - self.γ = γ - - def forward(self, fa, fp, list_fn): - dist = lambda x1, x2: torch.sum((x1 - x2) ** 2, dim=2) # Compute distances along dim=2 - num_batch, num_n, emd_dim = list_fn.size() - - # Broadcast a and p to match the shape of list_n - list_fa = fa.unsqueeze(1).expand(num_batch, num_n, -1) - list_fp = fp.unsqueeze(1).expand(num_batch, num_n, -1) - - loss = torch.relu(self.γ*dist(list_fa, list_fp) - dist(list_fa, list_fn) + self.margin) - loss = loss.mean() # Take the mean across the batch and num_n dimensions - - return loss - - - -emb_dim = 30 -class EfficientNetBlock(nn.Module): - def __init__(self, in_channels, out_channels, kernel_size=3, stride=1, padding=1): - super(EfficientNetBlock, self).__init__() - - self.conv = nn.Conv2d(in_channels, out_channels, kernel_size, stride=stride, padding=padding) - self.bn = nn.BatchNorm2d(out_channels) - self.swish = Swish() - - def forward(self, x): - x = self.conv(x) - x = self.bn(x) - x = self.swish(x) - return x - -class Swish(nn.Module): - def forward(self, x): - return x * torch.sigmoid(x) - -class CNN(nn.Module): - def __init__(self, emb_dim=30, efficient=False): - super(CNN, self).__init__() - - self.efficient = efficient - - self.efficient_conv = nn.Sequential( - EfficientNetBlock(1, 32, 5, 1, 2), - EfficientNetBlock(32, 32, 5, 1, 2), - nn.MaxPool2d(2), - nn.Dropout(0.3), - EfficientNetBlock(32, 64, 5, 1, 2), - EfficientNetBlock(64, 64, 5, 1, 2), - nn.MaxPool2d(2), - nn.Dropout(0.3) - ) - - self.conv = nn.Sequential( - nn.Conv2d(1, 32, 3), - nn.PReLU(), - nn.MaxPool2d(2), - nn.Dropout(0.6), - nn.Conv2d(32, 64, 3), - nn.PReLU(), - nn.MaxPool2d(2), - nn.Dropout(0.6) - ) - - self.fc = nn.Sequential( - #nn.LazyLinear(4080), - #nn.PReLU(), - nn.LazyLinear(512), - nn.PReLU(), - nn.Linear(512, emb_dim) - ) - - def forward(self, x): - x = self.conv(x) if not self.efficient else self.efficient_conv(x) - x = x.view(x.size(0), -1) - x = self.fc(x) - return x - -def init_weights(m): - if isinstance(m, nn.Conv2d): - torch.nn.init.kaiming_normal_(m.weight) - -#model_graph = draw_graph(CNN(), input_size=(1,1,40,14), expand_nested=True) -#model_graph.visual_graph - - -def plot_loss(losses): - plt.style.use("dark_background") - plt.figure(dpi=125) - plt.plot(losses) - plt.xlabel("Epochs") - plt.ylabel("Loss") - plt.show(block=False) - -# add train method - -def get_embeddings(model, loader): - x_data_e, y_data_e = [], [] - model.eval() - with torch.no_grad(): - for i, img_lbl in enumerate(tqdm(loader)): - a, y = img_lbl[0], img_lbl[-1] - fa = model(a.to(device)).detach().cpu().numpy() - y = y.numpy() - - x_data_e.extend(fa) - y_data_e.extend(y) - return np.array(x_data_e), np.array(y_data_e) - - -# add final predict function (SVM) - -device = torch.device("cuda" if torch.cuda.is_available() else "cpu") - -def plot_pca_umap(x_train_e, y_train_e, x_val_e=None, y_val_e=None): - pca = PCA(n_components=2) - umap = UMAP(n_components=2, n_neighbors=10, random_state=42, min_dist=0.3) - - x_train_pca = pca.fit_transform(x_train_e) - x_train_umap = umap.fit_transform(x_train_e) - - is_val = x_val_e is not None and y_val_e is not None - if is_val: - x_val_pca = pca.transform(x_val_e) - x_val_umap = umap.transform(x_val_e) - - fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(20, 5)) - - # Plot PCA on Embeddings - scatter1 = ax1.scatter(x_train_pca[:, 0], x_train_pca[:, 1], c=y_train_e, cmap='tab20c', s=20) - if is_val: - ax1.scatter(x_val_pca[:, 0], x_val_pca[:, 1], c=y_val_e, cmap='tab20c', marker='s', s=20) - ax1.set_title("PCA on Embeddings") - - # Add legend for PCA - legend1 = ax1.legend(*scatter1.legend_elements(), title="Classes", loc='center left', bbox_to_anchor=(1.02, 0.5)) - ax1.add_artist(legend1) - - # Calculate information lost in PCA - pca_info_loss = (1 - sum(pca.explained_variance_ratio_)) * 100 - ax1.text(0.95, 0.05, f"Info Loss: {pca_info_loss:.2f}%", transform=ax1.transAxes, ha="right") - - # Plot UMAP on Embeddings - scatter2 = ax2.scatter(x_train_umap[:, 0], x_train_umap[:, 1], c=y_train_e, cmap='tab20c', s=20) - if is_val: - ax2.scatter(x_val_umap[:, 0], x_val_umap[:, 1], c=y_val_e, cmap='tab20c', marker='s', s=20) - ax2.set_title("UMAP on Embeddings") - - # Add legend for UMAP at the bottom - legend2 = ax2.legend(*scatter2.legend_elements(), title="Classes", loc='center left', bbox_to_anchor=(1.02, 0.5)) - ax2.add_artist(legend2) - - plt.subplots_adjust(right=0.85) # Adjust the right margin to make space for the legend - - plt.show() - diff --git a/botiverse/models/SiameseNet/__init__.py b/botiverse/models/SiameseNet/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/botiverse/models/TRIPPY/config.py b/botiverse/models/TRIPPY/config.py index a021939..1122527 100644 --- a/botiverse/models/TRIPPY/config.py +++ b/botiverse/models/TRIPPY/config.py @@ -4,7 +4,7 @@ import tokenizers import os - +import gdown # Trippy configuration class TRIPPYConfig(object): @@ -74,6 +74,11 @@ def __init__(self, self.dropout = dropout cur_dir = os.path.dirname(os.path.abspath(__file__)) self.vocab_path = os.path.join(cur_dir, vocab_path) + if not os.path.exists(self.vocab_path): + print("Downloading Vocab...") + f_id = '1f2iOTT-QiFbIc1naqGVZWX5wPVo7gUMS' + gdown.download(f'https://drive.google.com/uc?export=download&confirm=pbef&id={f_id}', self.vocab_path, quiet=False) + print("Done.") self.tokenizer = tokenizers.BertWordPieceTokenizer(self.vocab_path, lowercase=True) self.ignore_idx = ignore_idx self.oper2id = oper2id diff --git a/botiverse/models/__init__.py b/botiverse/models/__init__.py index 5ae9840..27a040d 100644 --- a/botiverse/models/__init__.py +++ b/botiverse/models/__init__.py @@ -11,4 +11,4 @@ from botiverse.models.TRIPPY.TRIPPY_DST import TRIPPYDST from botiverse.models.TRIPPY.config import TRIPPYConfig -from botiverse.models.LSTM.LSTM import LSTMClassifier +from botiverse.models.LSTM.LSTM import LSTMClassifier \ No newline at end of file diff --git a/botiverse/preprocessors/Frequency/Frequency.py b/botiverse/preprocessors/Frequency/Frequency.py index a35d1c6..352d2e1 100644 --- a/botiverse/preprocessors/Frequency/Frequency.py +++ b/botiverse/preprocessors/Frequency/Frequency.py @@ -1,13 +1,15 @@ -import torchaudio -import os -from tqdm import tqdm -import torch -import librosa -import numpy as np -import matplotlib.pyplot as plt -from torch.utils.data import Dataset -from audiomentations import Compose, AddGaussianNoise, TimeStretch, PitchShift, Shift - +try: + import torchaudio + import os + from tqdm import tqdm + import torch + import librosa + import numpy as np + import matplotlib.pyplot as plt + from torch.utils.data import Dataset + from audiomentations import Compose, AddGaussianNoise, TimeStretch, PitchShift, Shift +except: + pass class Frequency(): ''' An interface for transforming audio files into frequency domain representations. diff --git a/botiverse/preprocessors/Vocalize/Vocalize.py b/botiverse/preprocessors/Vocalize/Vocalize.py index 16041a6..b45861b 100644 --- a/botiverse/preprocessors/Vocalize/Vocalize.py +++ b/botiverse/preprocessors/Vocalize/Vocalize.py @@ -1,12 +1,15 @@ -from gtts import gTTS -import os -from tqdm import tqdm -from pydub import AudioSegment -import librosa -import random -import soundfile as sf -import gdown -import shutil +try: + from gtts import gTTS + import os + from tqdm import tqdm + from pydub import AudioSegment + import librosa + import random + import soundfile as sf + import gdown + import shutil +except: + print("You need to install pip install botiverse[voice] to use the Vocalize transformer.") class Vocalize(): ''' diff --git a/botiverse/preprocessors/Wav2Vec/Wav2Vec.py b/botiverse/preprocessors/Wav2Vec/Wav2Vec.py index 22b637c..4681f2b 100644 --- a/botiverse/preprocessors/Wav2Vec/Wav2Vec.py +++ b/botiverse/preprocessors/Wav2Vec/Wav2Vec.py @@ -1,12 +1,15 @@ -from audiomentations import Compose, AddGaussianNoise, TimeStretch, PitchShift, Shift -from transformers import Wav2Vec2Model, Wav2Vec2FeatureExtractor, Wav2Vec2Processor, Wav2Vec2ForCTC, Wav2Vec2PhonemeCTCTokenizer -import os -import torch -import torchaudio -from tqdm import tqdm -import numpy as np -# disable warnings from this file -from transformers import logging +try: + from audiomentations import Compose, AddGaussianNoise, TimeStretch, PitchShift, Shift + from transformers import Wav2Vec2Model, Wav2Vec2FeatureExtractor, Wav2Vec2Processor, Wav2Vec2ForCTC, Wav2Vec2PhonemeCTCTokenizer + import os + import torch + import torchaudio + from tqdm import tqdm + import numpy as np + # disable warnings from this file + from transformers import logging +except: + pass class Wav2Vec(): ''' diff --git a/examples/bots/BasicBot/BasicBot.ipynb b/examples/bots/BasicBot/BasicBot.ipynb index f7156b3..703458a 100644 --- a/examples/bots/BasicBot/BasicBot.ipynb +++ b/examples/bots/BasicBot/BasicBot.ipynb @@ -9,25 +9,20 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 1, "metadata": {}, "outputs": [ { - "name": "stdout", - "output_type": "stream", - "text": [ - "Model finished training with accuracy 1.0\n" + "ename": "ModuleNotFoundError", + "evalue": "No module named 'BasicBot'", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[1], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mbotiverse\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mbots\u001b[39;00m \u001b[39mimport\u001b[39;00m BasicBot\n\u001b[1;32m 2\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mbotiverse\u001b[39;00m \u001b[39mimport\u001b[39;00m chat_gui\n\u001b[1;32m 4\u001b[0m bot \u001b[39m=\u001b[39m BasicBot(machine\u001b[39m=\u001b[39m\u001b[39m'\u001b[39m\u001b[39msvm\u001b[39m\u001b[39m'\u001b[39m, \u001b[39mrepr\u001b[39m\u001b[39m=\u001b[39m\u001b[39m'\u001b[39m\u001b[39mtf-idf\u001b[39m\u001b[39m'\u001b[39m)\n", + "File \u001b[0;32m~/Documents/GitHub/Botiverse/botiverse/bots/__init__.py:1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mBasicBot\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mBasicBot\u001b[39;00m \u001b[39mimport\u001b[39;00m BasicBot\n\u001b[1;32m 2\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mWhizBot\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mWhizBot\u001b[39;00m \u001b[39mimport\u001b[39;00m WhizBot\n\u001b[1;32m 3\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mConverseBot\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mConverseBot\u001b[39;00m \u001b[39mimport\u001b[39;00m ConverseBot\n", + "\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'BasicBot'" ] - }, - { - "data": { - "text/plain": [ - "\"The tuition fees for our university vary depending on the program and academic level. You can find detailed information about the costs on our website's 'Tuition and Financial Aid' section. Additionally, we provide various financial aid options to assist eligible students in managing their education expenses.\"" - ] - }, - "execution_count": 13, - "metadata": {}, - "output_type": "execute_result" } ], "source": [ @@ -124,7 +119,7 @@ "transform = GloVe()\n", "bot = BasicBot(machine=model, repr=transform)\n", "bot.read_data('dataset.json')\n", - "bot.train( batch_size=1, epochs=30, λ = 0.02, eval_train=True, val_split=0.0)\n" + "bot.train(batch_size=1, epochs=30, λ = 0.02, eval_train=True, val_split=0.0)\n" ] }, { diff --git a/examples/bots/TaskBot/sim-R_demo/label_maps.json b/examples/bots/TaskBot/sim-R_demo/label_maps.json new file mode 100644 index 0000000..64d29cb --- /dev/null +++ b/examples/bots/TaskBot/sim-R_demo/label_maps.json @@ -0,0 +1,3 @@ +{ + +} \ No newline at end of file diff --git a/examples/bots/TaskBot/sim-R_demo/sim-R_demo.ipynb b/examples/bots/TaskBot/sim-R_demo/sim-R_demo.ipynb index a1e964c..777c9ff 100644 --- a/examples/bots/TaskBot/sim-R_demo/sim-R_demo.ipynb +++ b/examples/bots/TaskBot/sim-R_demo/sim-R_demo.ipynb @@ -11,7 +11,75 @@ "cell_type": "code", "execution_count": 1, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Downloading Vocab...\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "Downloading...\n", + "From: https://drive.google.com/uc?export=download&confirm=pbef&id=1f2iOTT-QiFbIc1naqGVZWX5wPVo7gUMS\n", + "To: /Users/essam/Documents/GitHub/Botiverse/botiverse/models/TRIPPY/vocab.txt\n", + "100%|██████████| 231k/231k [00:00<00:00, 558kB/s]\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Done.\n", + "Downloading Vocab...\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "Downloading...\n", + "From: https://drive.google.com/uc?export=download&confirm=pbef&id=1f2iOTT-QiFbIc1naqGVZWX5wPVo7gUMS\n", + "To: /Users/essam/Documents/GitHub/Botiverse/botiverse/models/TRIPPY/vocab.txt\n", + "100%|██████████| 231k/231k [00:01<00:00, 197kB/s]\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Done.\n", + "Downloading Vocab...\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "Downloading...\n", + "From: https://drive.google.com/uc?export=download&confirm=pbef&id=1f2iOTT-QiFbIc1naqGVZWX5wPVo7gUMS\n", + "To: /Users/essam/Documents/GitHub/Botiverse/botiverse/models/TRIPPY/vocab.txt\n", + "100%|██████████| 231k/231k [00:01<00:00, 137kB/s]" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Done.\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "\n" + ] + } + ], "source": [ "from botiverse import chat_gui\n", "from botiverse.bots import DeepTODS\n", @@ -30,7 +98,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 2, "metadata": {}, "outputs": [ { @@ -55,14 +123,31 @@ }, { "cell_type": "code", - "execution_count": 51, + "execution_count": 3, "metadata": {}, "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "Downloading...\n", + "From: https://drive.google.com/uc?export=download&confirm=pbef&id=15guVrztM12KMMDp6jgu53ivUU945iRNp\n", + "To: /Users/essam/Documents/GitHub/Botiverse/examples/bots/TaskBot/sim-R_demo/label_maps.json\n", + "100%|██████████| 7.00/7.00 [00:00<00:00, 7.94kB/s]" + ] + }, { "name": "stdout", "output_type": "stream", "text": [ - "Label maps already exists. Skipping download.\n" + "Label maps downloaded successfully.\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "\n" ] } ], @@ -80,14 +165,24 @@ }, { "cell_type": "code", - "execution_count": 52, + "execution_count": 4, "metadata": {}, "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "Downloading...\n", + "From: https://drive.google.com/uc?export=download&confirm=pbef&id=1POjBULmqxBrebvINfl989bskAstV3Zld\n", + "To: /Users/essam/Documents/GitHub/Botiverse/examples/bots/TaskBot/sim-R_demo/model.pt\n", + "100%|██████████| 439M/439M [04:29<00:00, 1.63MB/s] \n" + ] + }, { "name": "stdout", "output_type": "stream", "text": [ - "Model already exists. Skipping download.\n" + "Model downloaded successfully.\n" ] } ], @@ -113,9 +208,41 @@ }, { "cell_type": "code", - "execution_count": 53, + "execution_count": 5, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Downloading Vocab...\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "Downloading...\n", + "From: https://drive.google.com/uc?export=download&confirm=pbef&id=1f2iOTT-QiFbIc1naqGVZWX5wPVo7gUMS\n", + "To: /Users/essam/Documents/GitHub/Botiverse/botiverse/models/TRIPPY/vocab.txt\n", + "100%|██████████| 231k/231k [00:01<00:00, 205kB/s]" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Done.\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "\n" + ] + } + ], "source": [ "CHATBOT_NAME = 'Tody'\n", "\n", @@ -191,24 +318,35 @@ }, { "cell_type": "code", - "execution_count": 54, + "execution_count": 6, "metadata": {}, "outputs": [ { - "name": "stderr", - "output_type": "stream", - "text": [ - "Some weights of the model checkpoint at bert-base-uncased were not used when initializing BertModel: ['cls.predictions.transform.dense.bias', 'cls.seq_relationship.weight', 'cls.predictions.decoder.weight', 'cls.predictions.transform.LayerNorm.weight', 'cls.predictions.transform.LayerNorm.bias', 'cls.seq_relationship.bias', 'cls.predictions.transform.dense.weight', 'cls.predictions.bias']\n", - "- This IS expected if you are initializing BertModel from the checkpoint of a model trained on another task or with another architecture (e.g. initializing a BertForSequenceClassification model from a BertForPreTraining model).\n", - "- This IS NOT expected if you are initializing BertModel from the checkpoint of a model that you expect to be exactly identical (initializing a BertForSequenceClassification model from a BertForSequenceClassification model).\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Model loaded successfully.\n" - ] + "data": { + "text/html": [ + "
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮\n",
+       " in <module>:1                                                                                    \n",
+       "                                                                                                  \n",
+       " 1 tods = DeepTODS(CHATBOT_NAME, DOMAINS, ONTOLOGY_PATH, LABEL_MAPS_PATH, POLICY, START, TE     \n",
+       "   2 tods.load_dst_model(MODEL_PATH)                                                              \n",
+       "   3                                                                                              \n",
+       "╰──────────────────────────────────────────────────────────────────────────────────────────────────╯\n",
+       "NameError: name 'ONTOLOGY_PATH' is not defined\n",
+       "
\n" + ], + "text/plain": [ + "\u001b[31m╭─\u001b[0m\u001b[31m──────────────────────────────\u001b[0m\u001b[31m \u001b[0m\u001b[1;31mTraceback \u001b[0m\u001b[1;2;31m(most recent call last)\u001b[0m\u001b[31m \u001b[0m\u001b[31m───────────────────────────────\u001b[0m\u001b[31m─╮\u001b[0m\n", + "\u001b[31m│\u001b[0m in \u001b[92m\u001b[0m:\u001b[94m1\u001b[0m \u001b[31m│\u001b[0m\n", + "\u001b[31m│\u001b[0m \u001b[31m│\u001b[0m\n", + "\u001b[31m│\u001b[0m \u001b[31m❱ \u001b[0m1 tods = DeepTODS(CHATBOT_NAME, DOMAINS, ONTOLOGY_PATH, LABEL_MAPS_PATH, POLICY, START, TE \u001b[31m│\u001b[0m\n", + "\u001b[31m│\u001b[0m \u001b[2m2 \u001b[0mtods.load_dst_model(MODEL_PATH) \u001b[31m│\u001b[0m\n", + "\u001b[31m│\u001b[0m \u001b[2m3 \u001b[0m \u001b[31m│\u001b[0m\n", + "\u001b[31m╰──────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n", + "\u001b[1;91mNameError: \u001b[0mname \u001b[32m'ONTOLOGY_PATH'\u001b[0m is not defined\n" + ] + }, + "metadata": {}, + "output_type": "display_data" } ], "source": [ @@ -226,9 +364,43 @@ }, { "cell_type": "code", - "execution_count": 55, + "execution_count": 7, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/html": [ + "
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮\n",
+       " in <module>:9                                                                                    \n",
+       "                                                                                                  \n",
+       "    6                                                                                         \n",
+       "    7 return sys + '\\n' + ' state:' + str(tods.get_dialogue_state())                          \n",
+       "    8                                                                                             \n",
+       "  9 chat_gui = chat_gui(fun)                                                                    \n",
+       "   10 chat_gui.run()                                                                              \n",
+       "   11                                                                                             \n",
+       "╰──────────────────────────────────────────────────────────────────────────────────────────────────╯\n",
+       "TypeError: __init__() missing 1 required positional argument: 'chat_func'\n",
+       "
\n" + ], + "text/plain": [ + "\u001b[31m╭─\u001b[0m\u001b[31m──────────────────────────────\u001b[0m\u001b[31m \u001b[0m\u001b[1;31mTraceback \u001b[0m\u001b[1;2;31m(most recent call last)\u001b[0m\u001b[31m \u001b[0m\u001b[31m───────────────────────────────\u001b[0m\u001b[31m─╮\u001b[0m\n", + "\u001b[31m│\u001b[0m in \u001b[92m\u001b[0m:\u001b[94m9\u001b[0m \u001b[31m│\u001b[0m\n", + "\u001b[31m│\u001b[0m \u001b[31m│\u001b[0m\n", + "\u001b[31m│\u001b[0m \u001b[2m 6 \u001b[0m\u001b[2m│ \u001b[0m \u001b[31m│\u001b[0m\n", + "\u001b[31m│\u001b[0m \u001b[2m 7 \u001b[0m\u001b[2m│ \u001b[0m\u001b[94mreturn\u001b[0m sys + \u001b[33m'\u001b[0m\u001b[33m\\n\u001b[0m\u001b[33m'\u001b[0m + \u001b[33m'\u001b[0m\u001b[33m state:\u001b[0m\u001b[33m'\u001b[0m + \u001b[96mstr\u001b[0m(tods.get_dialogue_state()) \u001b[31m│\u001b[0m\n", + "\u001b[31m│\u001b[0m \u001b[2m 8 \u001b[0m \u001b[31m│\u001b[0m\n", + "\u001b[31m│\u001b[0m \u001b[31m❱ \u001b[0m 9 chat_gui = chat_gui(fun) \u001b[31m│\u001b[0m\n", + "\u001b[31m│\u001b[0m \u001b[2m10 \u001b[0mchat_gui.run() \u001b[31m│\u001b[0m\n", + "\u001b[31m│\u001b[0m \u001b[2m11 \u001b[0m \u001b[31m│\u001b[0m\n", + "\u001b[31m╰──────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n", + "\u001b[1;91mTypeError: \u001b[0m\u001b[1;35m__init__\u001b[0m\u001b[1m(\u001b[0m\u001b[1m)\u001b[0m missing \u001b[1;36m1\u001b[0m required positional argument: \u001b[32m'chat_func'\u001b[0m\n" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ "def fun(utter):\n", "\n", @@ -244,15 +416,35 @@ }, { "cell_type": "code", - "execution_count": 56, + "execution_count": 8, "metadata": {}, "outputs": [ { - "name": "stdout", - "output_type": "stream", - "text": [ - "{}\n" - ] + "data": { + "text/html": [ + "
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮\n",
+       " in <module>:1                                                                                    \n",
+       "                                                                                                  \n",
+       " 1 tods.reset()                                                                                 \n",
+       "   2 print(tods.get_dialogue_state())                                                             \n",
+       "   3                                                                                              \n",
+       "╰──────────────────────────────────────────────────────────────────────────────────────────────────╯\n",
+       "NameError: name 'tods' is not defined\n",
+       "
\n" + ], + "text/plain": [ + "\u001b[31m╭─\u001b[0m\u001b[31m──────────────────────────────\u001b[0m\u001b[31m \u001b[0m\u001b[1;31mTraceback \u001b[0m\u001b[1;2;31m(most recent call last)\u001b[0m\u001b[31m \u001b[0m\u001b[31m───────────────────────────────\u001b[0m\u001b[31m─╮\u001b[0m\n", + "\u001b[31m│\u001b[0m in \u001b[92m\u001b[0m:\u001b[94m1\u001b[0m \u001b[31m│\u001b[0m\n", + "\u001b[31m│\u001b[0m \u001b[31m│\u001b[0m\n", + "\u001b[31m│\u001b[0m \u001b[31m❱ \u001b[0m1 tods.reset() \u001b[31m│\u001b[0m\n", + "\u001b[31m│\u001b[0m \u001b[2m2 \u001b[0m\u001b[96mprint\u001b[0m(tods.get_dialogue_state()) \u001b[31m│\u001b[0m\n", + "\u001b[31m│\u001b[0m \u001b[2m3 \u001b[0m \u001b[31m│\u001b[0m\n", + "\u001b[31m╰──────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n", + "\u001b[1;91mNameError: \u001b[0mname \u001b[32m'tods'\u001b[0m is not defined\n" + ] + }, + "metadata": {}, + "output_type": "display_data" } ], "source": [ @@ -262,16 +454,37 @@ }, { "cell_type": "code", - "execution_count": 57, + "execution_count": 9, "metadata": {}, "outputs": [ { - "name": "stdout", - "output_type": "stream", - "text": [ - "{}\n", - "Hi I am Tody, I can help you reserve a restaurant?\n" - ] + "data": { + "text/html": [ + "
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮\n",
+       " in <module>:1                                                                                    \n",
+       "                                                                                                  \n",
+       " 1 response = tods.infer('')                                                                    \n",
+       "   2 print(tods.get_dialogue_state())                                                             \n",
+       "   3 print(response)                                                                              \n",
+       "   4                                                                                              \n",
+       "╰──────────────────────────────────────────────────────────────────────────────────────────────────╯\n",
+       "NameError: name 'tods' is not defined\n",
+       "
\n" + ], + "text/plain": [ + "\u001b[31m╭─\u001b[0m\u001b[31m──────────────────────────────\u001b[0m\u001b[31m \u001b[0m\u001b[1;31mTraceback \u001b[0m\u001b[1;2;31m(most recent call last)\u001b[0m\u001b[31m \u001b[0m\u001b[31m───────────────────────────────\u001b[0m\u001b[31m─╮\u001b[0m\n", + "\u001b[31m│\u001b[0m in \u001b[92m\u001b[0m:\u001b[94m1\u001b[0m \u001b[31m│\u001b[0m\n", + "\u001b[31m│\u001b[0m \u001b[31m│\u001b[0m\n", + "\u001b[31m│\u001b[0m \u001b[31m❱ \u001b[0m1 response = tods.infer(\u001b[33m'\u001b[0m\u001b[33m'\u001b[0m) \u001b[31m│\u001b[0m\n", + "\u001b[31m│\u001b[0m \u001b[2m2 \u001b[0m\u001b[96mprint\u001b[0m(tods.get_dialogue_state()) \u001b[31m│\u001b[0m\n", + "\u001b[31m│\u001b[0m \u001b[2m3 \u001b[0m\u001b[96mprint\u001b[0m(response) \u001b[31m│\u001b[0m\n", + "\u001b[31m│\u001b[0m \u001b[2m4 \u001b[0m \u001b[31m│\u001b[0m\n", + "\u001b[31m╰──────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n", + "\u001b[1;91mNameError: \u001b[0mname \u001b[32m'tods'\u001b[0m is not defined\n" + ] + }, + "metadata": {}, + "output_type": "display_data" } ], "source": [ @@ -282,16 +495,37 @@ }, { "cell_type": "code", - "execution_count": 58, + "execution_count": 10, "metadata": {}, "outputs": [ { - "name": "stdout", - "output_type": "stream", - "text": [ - "{'restaurant-meal': 'lunch'}\n", - "what type of food do you want and in what area?\n" - ] + "data": { + "text/html": [ + "
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮\n",
+       " in <module>:1                                                                                    \n",
+       "                                                                                                  \n",
+       " 1 response = tods.infer('Hi, I want to book a table for lunch.')                               \n",
+       "   2 print(tods.get_dialogue_state())                                                             \n",
+       "   3 print(response)                                                                              \n",
+       "   4                                                                                              \n",
+       "╰──────────────────────────────────────────────────────────────────────────────────────────────────╯\n",
+       "NameError: name 'tods' is not defined\n",
+       "
\n" + ], + "text/plain": [ + "\u001b[31m╭─\u001b[0m\u001b[31m──────────────────────────────\u001b[0m\u001b[31m \u001b[0m\u001b[1;31mTraceback \u001b[0m\u001b[1;2;31m(most recent call last)\u001b[0m\u001b[31m \u001b[0m\u001b[31m───────────────────────────────\u001b[0m\u001b[31m─╮\u001b[0m\n", + "\u001b[31m│\u001b[0m in \u001b[92m\u001b[0m:\u001b[94m1\u001b[0m \u001b[31m│\u001b[0m\n", + "\u001b[31m│\u001b[0m \u001b[31m│\u001b[0m\n", + "\u001b[31m│\u001b[0m \u001b[31m❱ \u001b[0m1 response = tods.infer(\u001b[33m'\u001b[0m\u001b[33mHi, I want to book a table for lunch.\u001b[0m\u001b[33m'\u001b[0m) \u001b[31m│\u001b[0m\n", + "\u001b[31m│\u001b[0m \u001b[2m2 \u001b[0m\u001b[96mprint\u001b[0m(tods.get_dialogue_state()) \u001b[31m│\u001b[0m\n", + "\u001b[31m│\u001b[0m \u001b[2m3 \u001b[0m\u001b[96mprint\u001b[0m(response) \u001b[31m│\u001b[0m\n", + "\u001b[31m│\u001b[0m \u001b[2m4 \u001b[0m \u001b[31m│\u001b[0m\n", + "\u001b[31m╰──────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n", + "\u001b[1;91mNameError: \u001b[0mname \u001b[32m'tods'\u001b[0m is not defined\n" + ] + }, + "metadata": {}, + "output_type": "display_data" } ], "source": [ @@ -302,16 +536,37 @@ }, { "cell_type": "code", - "execution_count": 59, + "execution_count": 11, "metadata": {}, "outputs": [ { - "name": "stdout", - "output_type": "stream", - "text": [ - "{'restaurant-meal': 'lunch', 'restaurant-category': 'egyptian', 'restaurant-location': 'cairo'}\n", - "what is your preferred price range and rating?\n" - ] + "data": { + "text/html": [ + "
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮\n",
+       " in <module>:1                                                                                    \n",
+       "                                                                                                  \n",
+       " 1 response = tods.infer('I would like to have egyptian food in cairo.')                        \n",
+       "   2 print(tods.get_dialogue_state())                                                             \n",
+       "   3 print(response)                                                                              \n",
+       "   4                                                                                              \n",
+       "╰──────────────────────────────────────────────────────────────────────────────────────────────────╯\n",
+       "NameError: name 'tods' is not defined\n",
+       "
\n" + ], + "text/plain": [ + "\u001b[31m╭─\u001b[0m\u001b[31m──────────────────────────────\u001b[0m\u001b[31m \u001b[0m\u001b[1;31mTraceback \u001b[0m\u001b[1;2;31m(most recent call last)\u001b[0m\u001b[31m \u001b[0m\u001b[31m───────────────────────────────\u001b[0m\u001b[31m─╮\u001b[0m\n", + "\u001b[31m│\u001b[0m in \u001b[92m\u001b[0m:\u001b[94m1\u001b[0m \u001b[31m│\u001b[0m\n", + "\u001b[31m│\u001b[0m \u001b[31m│\u001b[0m\n", + "\u001b[31m│\u001b[0m \u001b[31m❱ \u001b[0m1 response = tods.infer(\u001b[33m'\u001b[0m\u001b[33mI would like to have egyptian food in cairo.\u001b[0m\u001b[33m'\u001b[0m) \u001b[31m│\u001b[0m\n", + "\u001b[31m│\u001b[0m \u001b[2m2 \u001b[0m\u001b[96mprint\u001b[0m(tods.get_dialogue_state()) \u001b[31m│\u001b[0m\n", + "\u001b[31m│\u001b[0m \u001b[2m3 \u001b[0m\u001b[96mprint\u001b[0m(response) \u001b[31m│\u001b[0m\n", + "\u001b[31m│\u001b[0m \u001b[2m4 \u001b[0m \u001b[31m│\u001b[0m\n", + "\u001b[31m╰──────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n", + "\u001b[1;91mNameError: \u001b[0mname \u001b[32m'tods'\u001b[0m is not defined\n" + ] + }, + "metadata": {}, + "output_type": "display_data" } ], "source": [ @@ -322,16 +577,37 @@ }, { "cell_type": "code", - "execution_count": 60, + "execution_count": 12, "metadata": {}, "outputs": [ { - "name": "stdout", - "output_type": "stream", - "text": [ - "{'restaurant-meal': 'lunch', 'restaurant-category': 'egyptian', 'restaurant-location': 'cairo', 'restaurant-price_range': 'cheap', 'restaurant-rating': 'good'}\n", - "how many people will be in your party?\n" - ] + "data": { + "text/html": [ + "
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮\n",
+       " in <module>:1                                                                                    \n",
+       "                                                                                                  \n",
+       " 1 response = tods.infer('I want a cheap restaurant with good rating.')                         \n",
+       "   2 print(tods.get_dialogue_state())                                                             \n",
+       "   3 print(response)                                                                              \n",
+       "   4                                                                                              \n",
+       "╰──────────────────────────────────────────────────────────────────────────────────────────────────╯\n",
+       "NameError: name 'tods' is not defined\n",
+       "
\n" + ], + "text/plain": [ + "\u001b[31m╭─\u001b[0m\u001b[31m──────────────────────────────\u001b[0m\u001b[31m \u001b[0m\u001b[1;31mTraceback \u001b[0m\u001b[1;2;31m(most recent call last)\u001b[0m\u001b[31m \u001b[0m\u001b[31m───────────────────────────────\u001b[0m\u001b[31m─╮\u001b[0m\n", + "\u001b[31m│\u001b[0m in \u001b[92m\u001b[0m:\u001b[94m1\u001b[0m \u001b[31m│\u001b[0m\n", + "\u001b[31m│\u001b[0m \u001b[31m│\u001b[0m\n", + "\u001b[31m│\u001b[0m \u001b[31m❱ \u001b[0m1 response = tods.infer(\u001b[33m'\u001b[0m\u001b[33mI want a cheap restaurant with good rating.\u001b[0m\u001b[33m'\u001b[0m) \u001b[31m│\u001b[0m\n", + "\u001b[31m│\u001b[0m \u001b[2m2 \u001b[0m\u001b[96mprint\u001b[0m(tods.get_dialogue_state()) \u001b[31m│\u001b[0m\n", + "\u001b[31m│\u001b[0m \u001b[2m3 \u001b[0m\u001b[96mprint\u001b[0m(response) \u001b[31m│\u001b[0m\n", + "\u001b[31m│\u001b[0m \u001b[2m4 \u001b[0m \u001b[31m│\u001b[0m\n", + "\u001b[31m╰──────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n", + "\u001b[1;91mNameError: \u001b[0mname \u001b[32m'tods'\u001b[0m is not defined\n" + ] + }, + "metadata": {}, + "output_type": "display_data" } ], "source": [ @@ -342,16 +618,37 @@ }, { "cell_type": "code", - "execution_count": 61, + "execution_count": 13, "metadata": {}, "outputs": [ { - "name": "stdout", - "output_type": "stream", - "text": [ - "{'restaurant-meal': 'lunch', 'restaurant-category': 'egyptian', 'restaurant-location': 'cairo', 'restaurant-price_range': 'cheap', 'restaurant-rating': 'good', 'restaurant-num_people': '4'}\n", - "what time and date would you like to reserve a table for?\n" - ] + "data": { + "text/html": [ + "
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮\n",
+       " in <module>:1                                                                                    \n",
+       "                                                                                                  \n",
+       " 1 response = tods.infer('I have 4 people in my party.')                                        \n",
+       "   2 print(tods.get_dialogue_state())                                                             \n",
+       "   3 print(response)                                                                              \n",
+       "   4                                                                                              \n",
+       "╰──────────────────────────────────────────────────────────────────────────────────────────────────╯\n",
+       "NameError: name 'tods' is not defined\n",
+       "
\n" + ], + "text/plain": [ + "\u001b[31m╭─\u001b[0m\u001b[31m──────────────────────────────\u001b[0m\u001b[31m \u001b[0m\u001b[1;31mTraceback \u001b[0m\u001b[1;2;31m(most recent call last)\u001b[0m\u001b[31m \u001b[0m\u001b[31m───────────────────────────────\u001b[0m\u001b[31m─╮\u001b[0m\n", + "\u001b[31m│\u001b[0m in \u001b[92m\u001b[0m:\u001b[94m1\u001b[0m \u001b[31m│\u001b[0m\n", + "\u001b[31m│\u001b[0m \u001b[31m│\u001b[0m\n", + "\u001b[31m│\u001b[0m \u001b[31m❱ \u001b[0m1 response = tods.infer(\u001b[33m'\u001b[0m\u001b[33mI have 4 people in my party.\u001b[0m\u001b[33m'\u001b[0m) \u001b[31m│\u001b[0m\n", + "\u001b[31m│\u001b[0m \u001b[2m2 \u001b[0m\u001b[96mprint\u001b[0m(tods.get_dialogue_state()) \u001b[31m│\u001b[0m\n", + "\u001b[31m│\u001b[0m \u001b[2m3 \u001b[0m\u001b[96mprint\u001b[0m(response) \u001b[31m│\u001b[0m\n", + "\u001b[31m│\u001b[0m \u001b[2m4 \u001b[0m \u001b[31m│\u001b[0m\n", + "\u001b[31m╰──────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n", + "\u001b[1;91mNameError: \u001b[0mname \u001b[32m'tods'\u001b[0m is not defined\n" + ] + }, + "metadata": {}, + "output_type": "display_data" } ], "source": [ @@ -362,16 +659,37 @@ }, { "cell_type": "code", - "execution_count": 62, + "execution_count": 14, "metadata": {}, "outputs": [ { - "name": "stdout", - "output_type": "stream", - "text": [ - "{'restaurant-meal': 'lunch', 'restaurant-category': 'egyptian', 'restaurant-location': 'cairo', 'restaurant-price_range': 'cheap', 'restaurant-rating': 'good', 'restaurant-num_people': '4', 'restaurant-date': 'tuesday', 'restaurant-time': '4 am'}\n", - "May I suggest kfc restaurant?\n" - ] + "data": { + "text/html": [ + "
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮\n",
+       " in <module>:1                                                                                    \n",
+       "                                                                                                  \n",
+       " 1 response = tods.infer('4 am on the tuesday.')                                                \n",
+       "   2 print(tods.get_dialogue_state())                                                             \n",
+       "   3 print(response)                                                                              \n",
+       "   4                                                                                              \n",
+       "╰──────────────────────────────────────────────────────────────────────────────────────────────────╯\n",
+       "NameError: name 'tods' is not defined\n",
+       "
\n" + ], + "text/plain": [ + "\u001b[31m╭─\u001b[0m\u001b[31m──────────────────────────────\u001b[0m\u001b[31m \u001b[0m\u001b[1;31mTraceback \u001b[0m\u001b[1;2;31m(most recent call last)\u001b[0m\u001b[31m \u001b[0m\u001b[31m───────────────────────────────\u001b[0m\u001b[31m─╮\u001b[0m\n", + "\u001b[31m│\u001b[0m in \u001b[92m\u001b[0m:\u001b[94m1\u001b[0m \u001b[31m│\u001b[0m\n", + "\u001b[31m│\u001b[0m \u001b[31m│\u001b[0m\n", + "\u001b[31m│\u001b[0m \u001b[31m❱ \u001b[0m1 response = tods.infer(\u001b[33m'\u001b[0m\u001b[33m4 am on the tuesday.\u001b[0m\u001b[33m'\u001b[0m) \u001b[31m│\u001b[0m\n", + "\u001b[31m│\u001b[0m \u001b[2m2 \u001b[0m\u001b[96mprint\u001b[0m(tods.get_dialogue_state()) \u001b[31m│\u001b[0m\n", + "\u001b[31m│\u001b[0m \u001b[2m3 \u001b[0m\u001b[96mprint\u001b[0m(response) \u001b[31m│\u001b[0m\n", + "\u001b[31m│\u001b[0m \u001b[2m4 \u001b[0m \u001b[31m│\u001b[0m\n", + "\u001b[31m╰──────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n", + "\u001b[1;91mNameError: \u001b[0mname \u001b[32m'tods'\u001b[0m is not defined\n" + ] + }, + "metadata": {}, + "output_type": "display_data" } ], "source": [ @@ -382,16 +700,37 @@ }, { "cell_type": "code", - "execution_count": 63, + "execution_count": 15, "metadata": {}, "outputs": [ { - "name": "stdout", - "output_type": "stream", - "text": [ - "{'restaurant-meal': 'lunch', 'restaurant-category': 'egyptian', 'restaurant-location': 'cairo', 'restaurant-price_range': 'cheap', 'restaurant-rating': 'good', 'restaurant-num_people': '4', 'restaurant-date': 'tuesday', 'restaurant-time': '4 am', 'restaurant-restaurant_name': '§§kfc'}\n", - "ok done, here is your reservation number: 123456\n" - ] + "data": { + "text/html": [ + "
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮\n",
+       " in <module>:1                                                                                    \n",
+       "                                                                                                  \n",
+       " 1 response = tods.infer('ok, I love kfc.')                                                     \n",
+       "   2 print(tods.get_dialogue_state())                                                             \n",
+       "   3 print(response)                                                                              \n",
+       "   4                                                                                              \n",
+       "╰──────────────────────────────────────────────────────────────────────────────────────────────────╯\n",
+       "NameError: name 'tods' is not defined\n",
+       "
\n" + ], + "text/plain": [ + "\u001b[31m╭─\u001b[0m\u001b[31m──────────────────────────────\u001b[0m\u001b[31m \u001b[0m\u001b[1;31mTraceback \u001b[0m\u001b[1;2;31m(most recent call last)\u001b[0m\u001b[31m \u001b[0m\u001b[31m───────────────────────────────\u001b[0m\u001b[31m─╮\u001b[0m\n", + "\u001b[31m│\u001b[0m in \u001b[92m\u001b[0m:\u001b[94m1\u001b[0m \u001b[31m│\u001b[0m\n", + "\u001b[31m│\u001b[0m \u001b[31m│\u001b[0m\n", + "\u001b[31m│\u001b[0m \u001b[31m❱ \u001b[0m1 response = tods.infer(\u001b[33m'\u001b[0m\u001b[33mok, I love kfc.\u001b[0m\u001b[33m'\u001b[0m) \u001b[31m│\u001b[0m\n", + "\u001b[31m│\u001b[0m \u001b[2m2 \u001b[0m\u001b[96mprint\u001b[0m(tods.get_dialogue_state()) \u001b[31m│\u001b[0m\n", + "\u001b[31m│\u001b[0m \u001b[2m3 \u001b[0m\u001b[96mprint\u001b[0m(response) \u001b[31m│\u001b[0m\n", + "\u001b[31m│\u001b[0m \u001b[2m4 \u001b[0m \u001b[31m│\u001b[0m\n", + "\u001b[31m╰──────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n", + "\u001b[1;91mNameError: \u001b[0mname \u001b[32m'tods'\u001b[0m is not defined\n" + ] + }, + "metadata": {}, + "output_type": "display_data" } ], "source": [ @@ -402,9 +741,35 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 16, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/html": [ + "
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮\n",
+       " in <module>:1                                                                                    \n",
+       "                                                                                                  \n",
+       " 1 curr_dir = os.path.dirname(os.path.abspath(__file__))                                        \n",
+       "   2                                                                                              \n",
+       "╰──────────────────────────────────────────────────────────────────────────────────────────────────╯\n",
+       "NameError: name '__file__' is not defined\n",
+       "
\n" + ], + "text/plain": [ + "\u001b[31m╭─\u001b[0m\u001b[31m──────────────────────────────\u001b[0m\u001b[31m \u001b[0m\u001b[1;31mTraceback \u001b[0m\u001b[1;2;31m(most recent call last)\u001b[0m\u001b[31m \u001b[0m\u001b[31m───────────────────────────────\u001b[0m\u001b[31m─╮\u001b[0m\n", + "\u001b[31m│\u001b[0m in \u001b[92m\u001b[0m:\u001b[94m1\u001b[0m \u001b[31m│\u001b[0m\n", + "\u001b[31m│\u001b[0m \u001b[31m│\u001b[0m\n", + "\u001b[31m│\u001b[0m \u001b[31m❱ \u001b[0m1 curr_dir = os.path.dirname(os.path.abspath(\u001b[91m__file__\u001b[0m)) \u001b[31m│\u001b[0m\n", + "\u001b[31m│\u001b[0m \u001b[2m2 \u001b[0m \u001b[31m│\u001b[0m\n", + "\u001b[31m╰──────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n", + "\u001b[1;91mNameError: \u001b[0mname \u001b[32m'__file__'\u001b[0m is not defined\n" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ "curr_dir = os.path.dirname(os.path.abspath(__file__))" ] @@ -426,7 +791,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.6" + "version": "3.9.16" }, "orig_nbformat": 4 }, diff --git a/examples/bots/VoiceBot/SpeechClassifier.ipynb b/examples/bots/VoiceBot/SpeechClassifier.ipynb index de07244..9109269 100644 --- a/examples/bots/VoiceBot/SpeechClassifier.ipynb +++ b/examples/bots/VoiceBot/SpeechClassifier.ipynb @@ -7,7 +7,7 @@ "outputs": [], "source": [ "from botiverse.bots import SpeechClassifier\n", - "from botiverse.bots.Vocalizer.utils import voice_input" + "from botiverse.bots.VoiceBot.utils import voice_input" ] }, { diff --git a/requirements.txt b/requirements.txt index 643a75e..6e01b67 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,28 +1,19 @@ -audiomentations benepar cvxopt Flask gdown gensim -gtts -librosa matplotlib multiprocess nltk numpy pandas -playsound -# pyaudio -pydub scikit_learn scipy setuptools -soundfile spacy tokenizers torch -torchaudio tqdm transformers -umap -waveglow \ No newline at end of file +pyngrok \ No newline at end of file diff --git a/setup.py b/setup.py index 0fe857a..8ae4877 100644 --- a/setup.py +++ b/setup.py @@ -18,10 +18,19 @@ with open(path.join(HERE, 'README.md'), encoding='utf-8') as f: readme = f.read() +# requirements.txt +def read_requirements(name): + """Read requirements from requirements.txt.""" + with open(path.join(HERE, name), encoding='utf-8') as f: + requirements = f.read().splitlines() + return requirements + + + # This call to setup() does all the work setup( name="botiverse", - version="0.2.0", + version="0.4.4", description='''botiverse is a chatbot library that offers a high-level API to access a diverse set of chatbot models''', long_description=readme, @@ -41,9 +50,60 @@ "Programming Language :: Python :: 3.9", "Operating System :: OS Independent" ], - packages=["botiverse", "botiverse.bots", "botiverse.models", "botiverse.preprocessors"], - include_package_data=True, - install_requires=["numpy", "torch"] # just as was in requirements.txt + package_dir={ + "botiverse": "botiverse", + "botiverse.bots": "botiverse/bots", + "botiverse.models": "botiverse/models", + "botiverse.preprocessors": "botiverse/preprocessors", + }, + packages=["botiverse", + "botiverse.bots", + "botiverse.bots.BasicBot", + "botiverse.bots.ConverseBot", + "botiverse.bots.VoiceBot", + "botiverse.bots.WhizBot", + "botiverse.bots.basic_TODS", + "botiverse.bots.deep_TODS", + "botiverse.models", + "botiverse.preprocessors", + "botiverse.gui", + "botiverse.models.BERT", + "botiverse.models.FastSpeech1", + "botiverse.models.GRUClassifier", + "botiverse.models.LinearClassifier", + "botiverse.models.LSTM", + "botiverse.models.NN", + "botiverse.models.SVM", + "botiverse.models.T5Model", + "botiverse.models.TRIPPY", + "botiverse.preprocessors.BertEmbeddings", + "botiverse.preprocessors.BoW", + "botiverse.preprocessors.Frequency", + "botiverse.preprocessors.GloVe", + "botiverse.preprocessors.Special", + "botiverse.preprocessors.Special.ConverseBot_Preprocessor", + "botiverse.preprocessors.Special.WhizBot_BERT_Preprocessor", + "botiverse.preprocessors.Special.WhizBot_GRU_Preprocessor", + "botiverse.preprocessors.GloVe", + "botiverse.preprocessors.TF_IDF", + "botiverse.preprocessors.TF_IDF_GLOVE", + "botiverse.preprocessors.Vocalize", + "botiverse.preprocessors.Wav2Vec", + "botiverse.gui.static", + "botiverse.gui.static.icons", + "botiverse.gui.templates", + ], + include_package_data = True, + package_data={ + 'botiverse.gui':['*.zip', '*.png', '*pdf', '*jpeg','*ipynb', '*html', '*css', '*pkl', '*js'], + 'botiverse.gui.static':['*.zip', '*.png', '*pdf', '*jpeg','*ipynb', '*html', '*css', '*pkl', '*js'], + 'botiverse.gui.static.icons':['*.zip', '*.png', '*pdf', '*jpeg','*ipynb', '*html', '*css', '*pkl', '*js'], + 'botiverse.gui.templates':['*.zip', '*.png', '*pdf', '*jpeg','*ipynb', '*html', '*css', '*pkl', '*js'], + }, + install_requires=read_requirements('requirements.txt'), + extras_require={ + "voice": read_requirements("requirements_voice.txt"), + } )