ChatGPT
ChatGPT copied to clipboard
Not a JSON response
When my conversation becomes more and more, I often receive Not a JSON response
I need to reset the entire conversation reset_chat to receive the next response
Do you have any idea what could be causing this problem?
Please post your code when opening an issue, Including detailed steps to reproduce the problem
I'm having this error, and reset_chat doesn't help either. And for me, this error happens EVERY time I request something from ChatGPT. :/
Nevermind, I figured out the problem: the authorization token was expired. Using a new token fixed it!
I think I know where the problem is, I put refresh_session in the wrong place
I think I know where the problem is, I put
refresh_sessionin the wrong place
So where should I put refresh_session?
here is my code.
import sys
from config import config
from revChatGPT.revChatGPT import Chatbot
chatbot = Chatbot(config, conversation_id=None)
def resetChat():
chatbot.reset_chat() # Forgets conversation
def getresult(prompt):
chatbot.refresh_session() # Uses the session_token to get a new bearer token
resp = chatbot.get_chat_response(prompt, output="text") # Sends a request to the API and returns the response by OpenAI
print("getresult", resp['message'])
return resp['message']
if __name__ == '__main__':
getresult(sys.argv[1])
Is refresh_session misplaced?
It is in the right place
That's correct
I am experiencing the same issue again, and this is the code that I use for handling the returned message
from asyncChatGPT.asyncChatGPT import Chatbot
.
.
async def handle_response(prompt) -> str:
chatbot.refresh_session()
response = await chatbot.get_chat_response(prompt, output="text")
responseMessage = response['message']
return responseMessage
As the number of messages in the conversation increases, around 10 to 20, it will keep throwing errors Not a JSON response until I reset the chatbot
It seems the API limits the max length of the conversation. That is an OpenAI issue
Need more investigation
Gonna add better error handlers to show the actual response if not JSON
I think better error handlers have been added