From 40be10af6734023fa1d519522433257a4c3b7064 Mon Sep 17 00:00:00 2001 From: kokofixcomputers Date: Mon, 1 Jul 2024 10:35:37 -0700 Subject: [PATCH 1/3] Fix change sharing resulting in 403 --- src/hugchat/hugchat.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hugchat/hugchat.py b/src/hugchat/hugchat.py index 354aa56..2ca09c2 100644 --- a/src/hugchat/hugchat.py +++ b/src/hugchat/hugchat.py @@ -355,7 +355,7 @@ def set_share_conversations(self, val: bool = True): r = self.session.post( self.hf_base_url + "/chat/settings", - headers={"Referer": "https://huggingface.co/chat"}, + headers={"Referer": "https://huggingface.co/chat", "Origin":"https://huggingface.co"}, cookies=self.get_cookies(), allow_redirects=True, files=settings, From 467c2bea15053ff288e2252d6888d059ed6efc5e Mon Sep 17 00:00:00 2001 From: kokofixcomputers Date: Mon, 1 Jul 2024 10:51:15 -0700 Subject: [PATCH 2/3] Update setup.py --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 0beae23..a00a6b2 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ setup( name="hugchat", - version="0.4.8", + version="0.4.9", description="A huggingchat python api.", long_description=open("README.md", "rt", encoding="utf-8").read(), long_description_content_type="text/markdown", From 2afbb8c4cf82c8154e651147e6daa3760c8e80d1 Mon Sep 17 00:00:00 2001 From: kokofixcomputers Date: Mon, 1 Jul 2024 11:09:43 -0700 Subject: [PATCH 3/3] add conversation id invalid --- src/hugchat/hugchat.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/hugchat/hugchat.py b/src/hugchat/hugchat.py index 2ca09c2..e487e9e 100644 --- a/src/hugchat/hugchat.py +++ b/src/hugchat/hugchat.py @@ -741,6 +741,8 @@ def _stream_query( "Model is overloaded, please try again later or switch to another model." ) logging.debug(resp.headers) + if "Conversation not found" in str(res): + raise exceptions.InvalidConversationIDError("Conversation id invalid") raise exceptions.ChatError(f"Failed to parse response: {res}") if break_flag: break