[Custom API] ChatGPT - chat with your friend Nightbot!

Hiya, thanks for trying it out! Replying to whisper is not an option. As explained in the first post, if you want shorter responses you can specify it in your message, for example: “explain pi in 100 characters”.

how can i add it on my twitch channel everyone seems to know how to do it but i don’t can you guys help me?

Hey everyone, and more specifically @drmadness112!

EDIT: the API has been updated, and the following message is no longer up-to-date, you don’t need to add the extra string to “fix” the command, so feel free to disregard this message, leaving it up for posterity/context.

If you want to make ChatGPT (attempt to) shorten its answers without having to write it in every time, so it doesn’t cut the message with ellipsis, you can edit the command as such:

!editcom !xgpt $(urlfetch https://xgpt.gerhard.dev/api/command?q=$(querystring)%20answer%20in%20150%20characters%20or%20less)

It adds the following string to your request for every command call: “answer in 150 characters or less.”
I limited to 150 characters because I noticed that it seems to cuts the message at around 165 characters.
:warning: It works fairly well, but there are still mishaps sometimes.

Hey @1denik!

xgerhard already gave an example on how to do it in their introduction post:

Simply copy/paste the !commands add ... in your chat (it’ll only work if you already added Nightbot to your chat).

If you rather add the command through the dashboard, give the command a name, for example !xgpt, and copy/paste that bit in the Message field:

1 Like

I have really been hammering on this and outside of a few cannot reach external server errors it has been a blast. I am wondering if it is possible to make a call to xgpt from another script. I was hoping to have it recognize an input from the sending action…

[This Code I Have]
$(user), You drew $(eval responses=[The Fool!,The Magician!,The High Priestess!,The Empress!,The Emperor!,The Hierophant!,The Lovers!,The Chariot!,Justice!,Strength!,The Hermit!,Wheel of Fortune!,The Hanged Man!,Death!,Temperance!,The Devil!,The Tower!,The Star!,The Moon!,The Sun!,Judgement!,The World!];responses[Math.floor(Math.random()*responses.length)])

User:!tarot
Nightbot $(user) you chose ‘INSERT-CARD-NAME-HERE’
[Alias Call Here]
This is where I am confused how to pass of the results of command a to another command called from the !alias

[This is the code I am looking to Create]
Ex: !xgpt What is the meaning of INSERT-CARD-NAME-HERE in Tarot?
(Getting the input from !tarot results)

Nightbot: xgtp: INSERT-CARD-NAME-HERE in Tarot means Blah Blah Blah

What I am imagining is creating an in between command at the End of the Tarot command and then handing that off to xgtp? I am just lost at where to start.

Thanks for any help - JTS

Hey @Jeffrey_TheSeer!

An alias overrides the output of the first command, so what you’re trying to do is not possible.
And using an AI to pull the meaning of the cards could be a bit excessive, what makes me say that is that you already made a similar topic that has a better/simpler/easier solution in my opinion.

1 Like

Thank you for this Emily! Could I adjust that 150 value to 350, or whatever my own character limit is? And I’d do what you did and dial it back just before that limit as well.

Thanks

Yeah you can adjust to your preference. Character limit is 400, minus the username and conversation ID, so 350 should work.

EDIT: the API has been updated, and the following message is no longer up-to-date, you don’t need to add the extra string to “fix” the command, so feel free to disregard this message, leaving it up for posterity/context.

From my experience, the output is cut short with ellipsis at 165 characters, regardless of the platform limit, I’m really not sure why.
But if you want to increase it to 350, I highlighted the number you’d need to edit:

1 Like

Thanks for testing this! I now send an extra message with every request: “answer in X characters or less”.
So this extra part should not be needed anymore, but everyone can choose their own character limits ofcourse.

I put an X, since I dont have the exact number yet, I’m playing around with this number and a max_tokens value I can send to the ChatGPT API, which is their sort of way of counting words/characters. Trying to find the sweet spot between not reaching timeout limits for Nightbot, and also not sending cut off responses.
So please try it out, and let me know your findings. If responses are cut off frequently or commands are timing out I can adjust these numbers.

2 Likes

First of all congratulations on the api and thank you very much.

Since a few hours nightbot always responds “ChatGPT took to long to respond. Please try again in a bit. ResidentSleeper”

Hiya, saw you posted this messages a couple hours ago, I updated the api (see message above) after that which should hopefully fix most of these timeout messages.

It’s been working perfectly for a few hours. It does not show the error of “Error Connecting To Remote Server” or “ChatGPT took to long to respond. Please try again in a bit. ResidentSleeper”
Thank you!

1 Like

Thanks a lot, appreciate it!
The new version seems to be working great!

Gonna try this out tonite. Blessings to you.

Is there a way for him to respond only in Portuguese?

Hiya, I’ve noticed when I asked a qeustion in a foreign language the bot usually responds in that same language. Or you can ask the bot to reply in a specific language by specifying that in your question… " answer in portuguese".

1 Like

Hi! I started using this about 2 days ago and it was working perfectly fine but as of yesterday, the only response I now get is “Nightbot: Error, unexpected response…”

I have the same problem

@zTechy1 @sumyark thanks for the ping, that should be fixed!

3 Likes