Nipun1212 / Claude_api

Claude_api is a Python package that provides a convenient way to interact with Claude 2 from Anthropic.
https://pypi.org/project/claude2/1.0.1/
MIT License
112 stars 5 forks source link

Bad Request #8

Open Walkercito opened 9 months ago

Walkercito commented 9 months ago

The library is no longer working, at least not to me. Correct me if I'm wrong.

I've created a ChatBot for my and a group of closer friends, but a few days back it suddenly stopped working prompting this error: 400 Bad Request (error code: 50006): Cannot send an empty message. It is a Discord bot, so I'm going to leave here the code that was working until a few days as I mentioned.

class GenerateResponse(commands.Cog):
    def __init__(self, bot):
        self.bot = bot
        self.cookie = settings.COOKIE
        self.claude = Claude(self.cookie)

    @commands.Cog.listener()
    async def on_message(self, message: discord.Message):
        if message.author == self.bot.user:
            return

        if "claude" in message.content.lower():
            prompt = message.content 

            async with message.channel.typing():
                try:
                    response = self.generate_response(prompt)
                    await message.channel.send(response)

                except Exception as e:
                    await message.channel.send(f"Ocurrió un error al generar la respuesta: {e}")

    def generate_response(self, prompt):
        try:
            response = self.claude.get_answer(prompt)
            return response
        except Exception as e:
            return f"Ocurrió un error: {e}"

    @commands.command()
    async def new(self, ctx):
        self.claude.create_new_conversation()
        await ctx.send('Listo')

async def setup(bot):
    await bot.add_cog(GenerateResponse(bot))

This is the Cog Class that is called when a new response is generated. After this, I tried the example code to see if it was a problem of mine and it print nothing but an empty line, and also in the Claude Chat no message is send.

Nipun1212 commented 9 months ago

hi I got exam going on I'll fix it after that, claude updated their api a while ago and hence it's causing the issues

Walkercito commented 9 months ago

Thanks, and no worries man, we can wait 👾

Walkercito commented 6 months ago

Nothing yet? :/