vsakkas / sydney.py

Python Client for Copilot (formerly named Bing Chat), also known as Sydney.
MIT License
239 stars 31 forks source link

Loading conversations: chat context/history #163

Closed Cyberes closed 2 months ago

Cyberes commented 2 months ago

Hi, thanks for the great project. Would it be possible to implement loading previous conversations? Currently, we can only start a new conversation and reset the current one.

My current solution is probably going to try pickling the sydney object and store it in a sqlite3 database. It would be cool to load conversations natively instead.

phamxtien commented 2 months ago

I add below code to sydney.py

async def save_conversation(self, filename) -> None:        
        with open(filename, "w") as f:
            f.write(
                json.dumps(
                    {
                        "conversation_signature": self.conversation_signature,
                        "encrypted_conversation_signature": self.encrypted_conversation_signature,
                        "conversation_id": self.conversation_id,
                        "client_id": self.client_id,
                        "invocation_id": self.invocation_id,
                        # "number_of_messages": self.number_of_messages,
                        # "max_messages": self.max_messages
                    }
                ),
            )

    async def load_conversation(self, filename) -> None:
        with open(filename) as f:
            conversation = json.load(f)
            self.conversation_signature = conversation["conversation_signature"]
            self.encrypted_conversation_signature = conversation["encrypted_conversation_signature"]
            self.conversation_id = conversation["conversation_id"]
            self.client_id = conversation["client_id"]
            self.invocation_id = conversation["invocation_id"]
            # self.number_of_messages = conversation["number_of_messages"]
            # self.max_messages = conversation["max_messages"]
Cyberes commented 2 months ago

I was wondering if I could just build the conversation myself like you did! Thanks my guy

Cyberes commented 2 months ago

Actually, this sort of works. But the AI seems to be stuck on the first response regardless of any subsequent queries I send it.

Cyberes commented 2 months ago

aw nvm lol

phamxtien commented 2 months ago

Tôi đã tự hỏi liệu tôi có thể tự xây dựng cuộc trò chuyện như bạn đã làm không! Cảm ơn chàng trai của tôi

Don't load_conversation on first query