Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating multiple bots on same server instance without sharing training data #1232

Open
sebscholl opened this issue Mar 3, 2018 · 3 comments
Labels

Comments

@sebscholl
Copy link

sebscholl commented Mar 3, 2018

I've been struggling with this a bit and feel like I'm right on the cusp but keep falling back to first base.

In the project I'm building, I want to be able to create many unique bots that can be queried using some sort of unique identifier. The bots name attribute seems irrelevant in this pursuit. Here is a simple example showing the current behavior:

./train-bots.py

from chatterbot import ChatBot
from chatterbot.trainers import ListTrainer

bot1 = ChatBot("Bob")
bot2 = ChatBot("Jose")

bot1.set_trainer(ListTrainer) 
bot2.set_trainer(ListTrainer) 

bot1.train(['Hi', 'Bye'])
bot2.train(['Hola', 'Adios'])

./bots.py

bot1 = ChatBot("Bob")
bot2 = ChatBot("Jose")

bot1.get_response('Hola')
OUTPUT>> <Statement text:Adios>
bot2.get_response('Hi')
OUTPUT>> <Statement text:Bye>

Please note how one bot can respond with the others training data.

Ideally, using some sort of unique identifier, in the example I just shared I would be able to train each bot separately and persist them, so that in a following instance I could query the bot and not have it aware of other bots training data.

Is there a clean or standard way of creating bot objects that can be persisted along with their own unique knowledge graphs? I'm running my Django application with a Postgres database. My users will be communicating with bots the a REST API. So it's important that I'm able to retrieve the correct Bot in my controller (ideally something like, ChatBot.objects.get(pk=#)) where it could then be passed the incoming message and conversation_id.

Really would appreciate any thoughts or guidance on how to accomplish this (without creating a new/unique database for every new bot...).

If someone is able to help me solve this, I promise to write up some clean documentation for it!

Thank you!

@pylobot
Copy link

pylobot commented Mar 4, 2018

What if you used a different database_uri for each chat bot? I see you can set either database or database_uri for the chat bot's storage adapters http://chatterbot.readthedocs.io/en/latest/storage/index.html#sql-storage-adapter

If your chat bots are using the default sqlite then it would just be two .sqlite3 files with different names.

@sebscholl
Copy link
Author

@pylobot nice to be chatting with a fellow emoji... 😄

Thanks for the idea. One thing I'm looking at now is if I can pass a parameter along with the database_uri (like: postgresql://something@localhost/test?BOT=) that can then either scope queries or be added as meta data to the relevant rows. I'm trying to avoid having multiple database files, being that managing multiple migrations would probably be a nightmare and also to continuing adding up and up doesn't seem practical.

A new Bot class that inherits from ChatBot but allows me to create ManyToMany relationships with its Statements/Responses is another idea I'm toying with. I'm still reading through the code base though to better understand exactly how it's working before I venture down that path.

@CallumHemsley
Copy link

@sebscholl I'm curious if you got any further with this? Thinking of doing something similar.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants