Integrating chatterbot to renpy project?

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
meektabbie1
Newbie
Posts: 3
Joined: Wed Mar 14, 2018 7:46 am
Contact:

Integrating chatterbot to renpy project?

#1 Post by meektabbie1 »

Hello! I have a question that may be silly but do you think it’s possible to integrate chatterbot (https://github.com/gunthercox/ChatterBot) with Renpy? I was interested to try after having a look at these: (viewtopic.php?t=19128), (viewtopic.php?f=51&t=35856).

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:
Image

Image

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]"
Bot code (file name is “chatbot.py”):

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)
I’ve set up the chatterbot files in the game directory as well, and while everything seems to register I can’t get the .logic files to work.

rayminator
Miko-Class Veteran
Posts: 793
Joined: Fri Feb 09, 2018 12:05 am
Location: Canada
Contact:

Re: Integrating chatterbot to renpy project?

#2 Post by rayminator »

I don't think that the chatterbox will work it in renpy it looks like it's a web-based script

this line uses mysql data base

Code: Select all

storage_adapter="chatterbot.storage.SQLStorageAdapter",

meektabbie1
Newbie
Posts: 3
Joined: Wed Mar 14, 2018 7:46 am
Contact:

Re: Integrating chatterbot to renpy project?

#3 Post by meektabbie1 »

Ah I see. I guess it's not possible then. Thanks for your reply though!

Post Reply

Who is online

Users browsing this forum: Google [Bot]