changes
This commit is contained in:
parent
3b086d4c03
commit
3e0773ee1e
@ -26,7 +26,7 @@ class Chatter:
|
|||||||
self.chatbot = ChatBot(
|
self.chatbot = ChatBot(
|
||||||
"ChatterBot",
|
"ChatterBot",
|
||||||
storage_adapter='chatter.chatterbot.storage.SQLStorageAdapter',
|
storage_adapter='chatter.chatterbot.storage.SQLStorageAdapter',
|
||||||
database='chatter/database/database.sqlite3'
|
database='./database.sqlite3'
|
||||||
)
|
)
|
||||||
self.chatbot.set_trainer(ListTrainer)
|
self.chatbot.set_trainer(ListTrainer)
|
||||||
|
|
||||||
@ -95,16 +95,17 @@ class Chatter:
|
|||||||
async def backup(self, ctx, backupname):
|
async def backup(self, ctx, backupname):
|
||||||
"""
|
"""
|
||||||
Backup your training data to a json for later use
|
Backup your training data to a json for later use
|
||||||
:param ctx:
|
|
||||||
:param backupname:
|
|
||||||
:return:
|
|
||||||
"""
|
"""
|
||||||
|
await ctx.send("Backing up data, this may take a while")
|
||||||
|
future = await self.loop.run_in_executor(None, self.chatbot.trainer.export_for_training, './{}.json'.format(backupname))
|
||||||
|
|
||||||
self.chatbot.trainer.export_for_training('./{}.json'.format(backupname))
|
if future:
|
||||||
|
await ctx.send("Backup successful!")
|
||||||
|
else:
|
||||||
|
await ctx.send("Error occurred :(")
|
||||||
|
|
||||||
@chatter.command()
|
@chatter.command()
|
||||||
async def train(self, ctx: commands.Context, channel: discord.TextChannel = None):
|
async def train(self, ctx: commands.Context, channel: discord.TextChannel):
|
||||||
"""
|
"""
|
||||||
Trains the bot based on language in this guild
|
Trains the bot based on language in this guild
|
||||||
"""
|
"""
|
||||||
@ -146,7 +147,9 @@ class Chatter:
|
|||||||
return
|
return
|
||||||
text = text.replace(to_strip, "", 1)
|
text = text.replace(to_strip, "", 1)
|
||||||
async with channel.typing():
|
async with channel.typing():
|
||||||
response = self.chatbot.get_response(text)
|
future = await self.loop.run_in_executor(None, self.chatbot.get_response, text)
|
||||||
if not response:
|
|
||||||
response = ":thinking:"
|
if future:
|
||||||
await channel.send(response)
|
await channel.send(str(future))
|
||||||
|
else:
|
||||||
|
await channel.send(':thinking:')
|
||||||
|
@ -85,7 +85,7 @@ class Trainer(object):
|
|||||||
import json
|
import json
|
||||||
export = {'conversations': self._generate_export_data()}
|
export = {'conversations': self._generate_export_data()}
|
||||||
with open(file_path, 'w+') as jsonfile:
|
with open(file_path, 'w+') as jsonfile:
|
||||||
json.dump(export, jsonfile, ensure_ascii=False)
|
json.dump(export, jsonfile, ensure_ascii=True)
|
||||||
|
|
||||||
|
|
||||||
class ListTrainer(Trainer):
|
class ListTrainer(Trainer):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user