Fix issue with old conversations

This commit is contained in:
Heiner Lohaus 2025-01-07 00:26:01 +01:00
parent 2e531d227c
commit 2360cc3330
2 changed files with 4 additions and 4 deletions

View file

@ -351,7 +351,7 @@ class OpenaiChat(AsyncAuthedProvider, ProviderModelMixin):
conversation = Conversation(conversation_id, str(uuid.uuid4()), getattr(auth_result, "cookies", {}).get("oai-did"))
else:
conversation = copy(conversation)
if getattr(auth_result, "cookies", {}).get("oai-did") != conversation.user_id:
if getattr(auth_result, "cookies", {}).get("oai-did") != getattr(conversation, "user_id", None):
conversation = Conversation(None, str(uuid.uuid4()))
if cls._api_key is None:
auto_continue = False
@ -587,7 +587,7 @@ class OpenaiChat(AsyncAuthedProvider, ProviderModelMixin):
cookies: Cookies = None,
headers: dict = None,
**kwargs
) -> AsyncIterator[str]:
) -> AsyncIterator:
if cls._expires is not None and (cls._expires - 60*10) < time.time():
cls._headers = cls._api_key = None
if cls._headers is None or headers is not None:

View file

@ -353,7 +353,7 @@ async def get_filename(response: ClientResponse) -> str:
sha256_hash = hashlib.sha256(url.encode()).digest()
base32_encoded = base64.b32encode(sha256_hash).decode()
url_hash = base32_encoded[:24].lower()
return f"{parsed_url.netloc} {parsed_url.path[1:].replace('/', '_')} {url_hash}{extension}"
return f"{parsed_url.netloc}+{parsed_url.path[1:].replace('/', '_')}+{url_hash}{extension}"
return None
@ -494,7 +494,7 @@ def read_and_download_urls(bucket_dir: Path, event_stream: bool = False) -> Iter
count += 1
yield f'data: {json.dumps({"action": "download", "count": count})}\n\n'
async def async_read_and_download_urls(bucket_dir: Path, event_stream: bool = False) -> Iterator[str]:
async def async_read_and_download_urls(bucket_dir: Path, event_stream: bool = False) -> AsyncIterator[str]:
urls = get_downloads_urls(bucket_dir)
if urls:
count = 0