I’ve attempted so far with unsurprisingly unsatisfying results (I am still new to this). I’ve tried to find a way to get the bot to be able to reply but it always returns error when it reaches the part where it’s supposed to reply (usually “’module‘ object not callable”). Sometimes the game won’t work because a module refuses to be imported; I usually get to resolve this but still cannot get the bot to reply.
Rather than let curiosity burn me out, I figured I’d ask here. This might be really noobish of me (I'm also fairly certain I've coded a lot of things incorrectly), but I’m really interested to know if this is even possible, and if possible I would appreciate any help!
Errors:
The code bit for when the bot is supposed to respond (not seen here, but I made sure I imported the bot too):
Code: Select all
while True:
if user_input == "bye":
pause 1.0
jump end
$ s = renpy.input("Please type your response:")
$ r = chatbot().bot.get_response(s)
e "[r]"
Code: Select all
import chatterbot
from chatterbot import ChatBot
from chatterbot.trainers import ChatterBotCorpusTrainer
bot = ChatBot(
"chatbot",
preprocessors=[
"chatterbot.preprocessors.clean_whitespace"
],
storage_adapter="chatterbot.storage.SQLStorageAdapter",
input_adapter="chatterbot.input.InputAdapter",
output_adapter="chatterbot.output.OutputAdapter"
)
bot.set_trainer(ChatterBotCorpusTrainer)
bot.train("chatterbot.corpus.english")
CONVERSATION_ID = bot.storage.create_conversation()
def get_response(self, input_item, conversation_id=None):
if not conversation_id:
if not self.default_conversation_id:
self.default_conversation_id = self.storage.create_conversation()
conversation_id = self.default_conversation_id
input_statement = self.input.process_input_statement(input_item)
for preprocessor in self.preprocessors:
input_statement = preprocessor(self, input_statement)
statement, response = self.generate_response(input_statement, conversation_id)
previous_statement = self.storage.get_latest_response(conversation_id)
if not self.read_only:
self.learn_response(statement, previous_statement)
self.storage.add_to_conversation(conversation_id, statement, response)
return self.output.process_response(response, conversation_id)