#My bot keeps breaking suddenly and I don't know why

1 messages Β· Page 1 of 1 (latest)

mild dew
#

So I have made a discord bot recently and implemented the cosmosrp API on it and it works fine but it suddenly just breaks down, this is the message I use for it to tell me when something is wrong and usually rebooting it fixes it
But now, not even that is working anymore and I havent changed anything on it's code
I am using python by the way

If this has nothing to do with it I am sorry but I really dont know what to do anymore

dense finchBOT
#

Sorry, I can't assist you at the moment due to a technical issue. Please wait for our community helpers to reply.

mild dew
#

And then after a while sometimes it just comes back and sometimes it doesnt

heavy wren
mild dew
#

It never shows what's the error of the API

#

Or what returned, I guess

heavy wren
#

Would you mind sending your code here?

mild dew
#

The current code now I think it doesn't have a logging system, idk
I have been mindlessly trying to fix it and lost my mind

#

I used python on it
some stuff there I tried for fun only, it was working fine though (even deleting some weird stuff didnt changed anything)

heavy wren
#

Did you write that code by yourself?

#

There are some weird points on that code, like importing the OpenAI library and not really using it, or comments on different languages.

mild dew
heavy wren
#

I see I see.

mild dew
#

The openai libray I just forgot to take it off because I tried to use openai api

heavy wren
#

I mean, you did set correctly the base url and the key, but you didn't use it, you could use it to make the request instead of aiohtt or request

mild dew
#

That may be causing conflict then?

heavy wren
#

You are also doing two request with the same request body and headers, even tho you are not using in any way the response of the first request.

#

one using requests then another one using aiohtt*

mild dew
#

Should I redo it from scratch then? That may be easier to fix things

#

I took off the commands already so it doesn't really matter anymore

#

Again it's my first time coding so... Yeah, I tried my best tbh

heavy wren
#

I see you did, and it's still not bad.

mild dew
#

I will try to do it from scratch tomorrow with another bot

heavy wren
#

Not really necessary, I just changed a few things, mainly removing unnecessary thing like the OpenAI library, requests(using just aiohtt* not both) and added error handling.

#

I didn't actually get any error while using your code, the best thing you can do is removing things that may cause errors and add an error handling.

mild dew
#

I will see if that doesnt break anymore because the way that the bot was breaking wasnt normal but then it suddenly came back to normal or sometimes didnt

#

if it gets any error , can i contact you?

heavy wren
#

Maybe it just returned Gateway Timeout but you couldn't see it.

heavy wren
mild dew
#

@heavy wren so, this is what happens

heavy wren
#

Yes, 504 Gateway Timeout.

#

The API took too long to respond so it returns an error.

mild dew
#

Hmm, is there a way to fix that? I tried doing that before though but I guess I made it worse ngl

heavy wren
#

Hmmmm, unfortunely, there's nothing much that can be done about it, you could simply try setting the code to send less messages to it as it should take less time to process and respond.

mild dew
#

I tried lowering the temperature one time but idk if that worked either

heavy wren
#

The temperature wouldn't change much unless it is high enough to make it go bananas and generate some long and nonsensical content.

mild dew
#

it's on 1.2 right now tbh, I think that's high enough

heavy wren
#

It's fine.

mild dew
#

there was a time I added (I think a token limit or smth) when I tried to use the hugging face transformers model but i dont remember how I did that at all

#

and im not sure if it would conflict with the current code, when I did that I didnt even made the bot yet

heavy wren
#

No, it wouldn't, and yes you can add a tokenizer to limite the amount of messages based on the tokens on it using HF tranformers or other library.

#

You could also just use another API as PAI is temporaly unavailable, I don't know what you're using that bot for but CosmosRP is to be used for Roleplaying, and wouldn't be really good for any other purpose, mainly coding.

mild dew
#

im actually using cosmosrp because it's free ngl
but yeah, I should try something else, I don't know how or what but knowing what the issue is now is at least better than not knowing it is

#

thanks for the help, seriously

heavy wren
#

No problem, I am here if you need assist with anything else!
Have a good night.