[Python] Why doesn't the Chatterbot reply with a response?

Discussão em 'Python' iniciado por Stack, Fevereiro 7, 2025.

  1. Stack

    Stack Membro Participativo

    Why is the result of the request to Chatterbot not output in the response variable?

    from chatterbot import ChatBot
    from chatterbot.trainers import ChatterBotCorpusTrainer
    import disnake as discord
    from disnake import ApplicationCommandInteraction
    from disnake.ext import commands


    class KICog(commands.Cog):
    def __init__(self, bot):
    self.client = bot

    @commands.slash_command(
    name="ki",
    description="Interagiert mit dem Chaosgaming Chat-Bot",
    options=[
    discord.Option(
    type=discord.OptionType.string,
    name="sprache",
    description="Sprache der Interaktion mit dem Bot",
    required=True
    ),
    discord.Option(
    type=discord.OptionType.string,
    name="prompt",
    description="Prompt zur Verarbeitung in der Chaosgaming KI",
    required=True
    )
    ]
    )
    async def ki(self, interaction: ApplicationCommandInteraction, sprache=None, prompt=None):
    print("Sprache:" + sprache)
    print("Prompt:" + prompt)
    bot = ChatBot('Chaosgaming-KI')
    # Erstelle einen Trainer und trainiere den Chatbot mit den vordefinierten Corpusdaten
    trainer = ChatterBotCorpusTrainer(bot)

    trainer.train(
    "chatterbot.corpus.english") # Passe die Sprache an, wenn du eine andere Sprache verwenden möchtest
    response = bot.get_response(prompt)
    print(response)
    await interaction.send(response, ephemeral=True)


    def setup(bot):
    bot.add_cog(KICog(bot))

    Continue reading...

Compartilhe esta Página