Skip to content
This repository has been archived by the owner on Aug 10, 2023. It is now read-only.

Unreliable conversation_id #7

Closed
angelfor3v3r opened this issue Dec 4, 2022 · 12 comments
Closed

Unreliable conversation_id #7

angelfor3v3r opened this issue Dec 4, 2022 · 12 comments
Labels
enhancement New feature or request

Comments

@angelfor3v3r
Copy link

I was wondering if you've had luck using "conversation_id" to continue a conversation. It seems like when I first start a conversation (without passing "conversation_id") and then reusing it for future replies, I always get a response like so:

bot  | {"detail":"Too many requests, please slow down"}
bot  | Error: Response is not a text/event-stream

Am I using it wrong? I'm basically just caching off the "conversation_id" after I get my first response and passing it to the ChatBot constructor.

@acheong08
Copy link
Owner

{"detail":"Too many requests, please slow down"}

This is a sign of rate limiting. There was a limit of 48 requests per minute I think. It might have been reduced.

@angelfor3v3r
Copy link
Author

That's why I'm confused. It never seems to stop rate limiting me and my first response always goes through fine. It just gives me "too many requests" only after I start passing a "conversation_id". I've waited over 10 minutes and I still get the same error. As soon as I take out the "conversation_id" parameter, I can generate replies without issue.

@acheong08
Copy link
Owner

Replicated. If you try to put a conversation_id manually, it fails. It might be that it compares the parent_id to the conversation_id on the server side. Try setting the correct parent_id as well as conversation_id

@angelfor3v3r
Copy link
Author

Yeah, I'm not rate limited anymore but it seems like it forgets it's previous replies for me (i.e, I ask it to write code and to modify it's last response and it doesn't understand).

I'm caching off "conversation_id" and "parent_id", then reusing both values on the next invocation of "get_chat_response".

@acheong08
Copy link
Owner

Does it work if you run it from the command line?

 $ python3 -m revChatGPT     

    ChatGPT - A command-line interface to OpenAI's ChatGPT (https://chat.openai.com/chat)
    Repo: github.com/acheong08/ChatGPT
    
Type '!exit' to exit
Press enter twice to submit your question.

You: Hello



Chatbot: Hello! I'm Assistant, a large language model trained by OpenAI. I'm here to help you with any questions you may have. What can I help you with today?


0
You: What is an egg



Chatbot: An egg is a reproductive body produced by female birds, reptiles, insects, and other animals. It consists of a protective outer layer called the shell, a nutrient-rich white or yellowish substance called the albumen, and a central yolk that contains the egg's genetic material. Some eggs are also fertilized by a male, in which case the egg contains a developing embryo. Eggs are a common ingredient in many types of food, and they are also a good source of protein and other nutrients.


0
You: continue



Chatbot: Sure! Is there anything specific you would like me to continue talking about regarding eggs? For example, I can talk more about the different types of eggs, how they are used in cooking, or their nutritional value. Let me know if there's anything specific you're interested in.


0
You: 

@angelfor3v3r
Copy link
Author

angelfor3v3r commented Dec 4, 2022

Yes, It does. I must be doing something very wrong in my code. I'm basically doing something like so:

chatbot = Chatbot(self.chatbot_cfg, conversation_id=saved_convo_id)

if parent_id:
    chatbot.parent_id = saved_parent_id

resp = chatbot.get_chat_response("prompt")

Both my "saved_convo_id" and "saved_parent_id" are the same ones from the original reply, but the replies I get seem to forget I've been talking to it.

@acheong08
Copy link
Owner

        self.parent_id = response["message"]["id"]
        self.conversation_id = response["conversation_id"]
        message = response["message"]["content"]["parts"][0]
        return {'message':message, 'conversation_id':self.conversation_id, 'parent_id':self.parent_id}

The get_chat_response function returns the conversation_id and parent_id. Make sure you're taking it from there.

@angelfor3v3r
Copy link
Author

angelfor3v3r commented Dec 4, 2022

I was. I'm trying a different approach now where I just cache off the entire "Chatbot" class instead. So far it seems to work better and I don't get rate limited, I need to test more though. Thanks for all the help so far!

@acheong08 acheong08 added the help wanted Extra attention is needed label Dec 5, 2022
@acheong08 acheong08 changed the title How does "conversation_id" work? Unreliable conversation_id Dec 5, 2022
@Pab450
Copy link

Pab450 commented Dec 5, 2022

I was. I'm trying a different approach now where I just cache off the entire "Chatbot" class instead. So far it seems to work better and I don't get rate limited, I need to test more though. Thanks for all the help so far!

Hey can you show me an example? I get the same problem and I don't quite understand how you managed to solve it?

@angelfor3v3r
Copy link
Author

My solution is pretty awful. Im just saing off the entire ChatBot class instance for each “user” in a dict. I then manually refresh tokens and such.

@acheong08
Copy link
Owner

I will do some testing with setting the parent_id and conversation_id later today

@acheong08 acheong08 added enhancement New feature or request and removed help wanted Extra attention is needed labels Dec 6, 2022
@acheong08
Copy link
Owner

acheong08 commented Dec 6, 2022

@angelfor3v3r @Pab450

from revChatGPT.revChatGPT import Chatbot
import json
# Get config
config = open("config.json", "r").read()
config = json.loads(config)
# Create a chatbot object
chatbot = Chatbot(config)

chatbot.refresh_session()

# Get a response
response = chatbot.get_chat_response("What is an egg?", output="text")

conversation = response['conversation_id']
parent_id = response['parent_id']
message = response['message']
print(message)

del chatbot

chatbot = Chatbot(config)
chatbot.conversation_id = conversation
chatbot.parent_id = parent_id
response = chatbot.get_chat_response("continue", output="text")
message = response['message']
print(message)
 $ python3 GPT.py
Logging in...
An egg is a fertilized or unfertilized reproductive cell produced by birds, reptiles, and some amphibians. In birds and reptiles, the egg contains a developing embryo, which is fed by a yolk. The egg is surrounded by a hard shell that protects the embryo and helps to regulate its temperature. In some species, the egg is also covered in a protective outer layer called the chorion. Eggs are a source of nutrition for many animals and are also used as a food by humans.
Eggs are an important food for many animals, including birds and reptiles, which use them to provide nourishment to their young. For humans, eggs are a rich source of protein, vitamins, and minerals, and are often used in cooking. They can be prepared in a variety of ways, including boiling, frying, and scrambling. Eggs are also used in many processed foods, such as baked goods and pasta. Some people also use eggs as a source of food for their pets, such as birds and reptiles.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants