Hi, I am fairly new to github and software development. I am able to run the examples inside a virtual environment. My question is how can I keep the chatbot alive longer, once I ask it a question it鈥檚 game over . I want to be able to continue to conversate with it. I ran the training_example_corpus.py in the terminal. Any advice will be greatly appreciated
@swiss809 you have to train your bot . See more information on training https://chatterbot.readthedocs.io/en/stable/training.html
I get the idea of training the bot but do i have to train the bot for every question? is there a way i can train the bot once an be able to ask multiple questions?
@swiss809 Are you looking this type of example https://github.com/gunthercox/ChatterBot/blob/master/examples/convert_units.py
@swiss809 You're correct, you only need to train the bot once.
Thanks @gunthercox,
After I train my bot I can only ask 1 question, then i have to restart the bot and train it again before I can ask another question. Essentially I have to run a new bot for every question. Is there something I鈥檓 doing wrong?
There is a number of things that could cause this. Is your bot successfully saving trained statements to it's database? How many statements are you training your bot with?
Posting an example of your data or the code you are using might help me suggest a solution.
from chatterbot import ChatBot
from chatterbot.trainers import ChatterBotCorpusTrainer
from chatterbot.logic import LogicAdapter
from chatterbot.storage import StorageAdapter
from chatterbot.adapters import Adapter
import logging
logging.basicConfig(level=logging.INFO)
bot = ChatBot(
'Crystal',
trainer= 'chatterbot.trainers.ChatterbotCorpusTrainer',
storage_adapters="chatterbot.storage.SQLStorageAdapter",
logic_adapters=[
"chatterbot.logic.MathematicalEvaluation",
"chatterbot.logic.TimeLogicAdapter",
"chatterbot.logic.BestMatch"
],
input_adapter="chatterbot.input.TerminalAdapter",
output_adapter="chatterbot.output.TerminalAdapter"
)
bot.train(
'chatterbot.corpus.english.greetings',
)
response = chatbot.get_response(input(":"))
print(response)
Theres some bugs im still working out, you will probably find a few things wrong. Iwant to only train this bot once. Thanks for the help
@swiss809 Chatterbot training process will be persisted into sqlite database with name sqllite.db in current directory, you could separate training process and learning process for example
train.py
from chatterbot import ChatBot
from chatterbot.trainers import ChatterBotCorpusTrainer
from chatterbot.logic import LogicAdapter
from chatterbot.storage import StorageAdapter
from chatterbot.adapters import Adapter
import logging
logging.basicConfig(level=logging.INFO)
bot = ChatBot(
'Crystal',
trainer= 'chatterbot.trainers.ChatterbotCorpusTrainer',
storage_adapters="chatterbot.storage.SQLStorageAdapter",
logic_adapters=[
"chatterbot.logic.MathematicalEvaluation",
"chatterbot.logic.TimeLogicAdapter",
"chatterbot.logic.BestMatch"
],
input_adapter="chatterbot.input.TerminalAdapter",
output_adapter="chatterbot.output.TerminalAdapter"
)
bot.train(
'chatterbot.corpus.english.greetings',
)
learn.py
from chatterbot import ChatBot
response = chatbot.get_response(input(":"))
print(response)
needed to look at the memory_sql_example.py thats all i was trying to figure out. Thanks for helping tho
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.