返回提交历史
Modified
g4f/Provider/needs_auth/OpenaiChat.py
+2
-2
Modified
g4f/tools/files.py
+2
-2
XFEstudio/gpt4free
Fix issue with old conversations
2360cc33
代码差异
2 个文件
+4
-4
@@ -351,7 +351,7 @@ class OpenaiChat(AsyncAuthedProvider, ProviderModelMixin):
351
351
conversation = Conversation(conversation_id, str(uuid.uuid4()), getattr(auth_result, "cookies", {}).get("oai-did"))
352
352
else:
353
353
conversation = copy(conversation)
354
if getattr(auth_result, "cookies", {}).get("oai-did") != conversation.user_id:
354
if getattr(auth_result, "cookies", {}).get("oai-did") != getattr(conversation, "user_id", None):
355
355
conversation = Conversation(None, str(uuid.uuid4()))
356
356
if cls._api_key is None:
357
357
auto_continue = False
@@ -587,7 +587,7 @@ class OpenaiChat(AsyncAuthedProvider, ProviderModelMixin):
587
587
cookies: Cookies = None,
588
588
headers: dict = None,
589
589
**kwargs
590
) -> AsyncIterator[str]:
590
) -> AsyncIterator:
591
591
if cls._expires is not None and (cls._expires - 60*10) < time.time():
592
592
cls._headers = cls._api_key = None
593
593
if cls._headers is None or headers is not None:
@@ -353,7 +353,7 @@ async def get_filename(response: ClientResponse) -> str:
353
353
sha256_hash = hashlib.sha256(url.encode()).digest()
354
354
base32_encoded = base64.b32encode(sha256_hash).decode()
355
355
url_hash = base32_encoded[:24].lower()
356
return f"{parsed_url.netloc} {parsed_url.path[1:].replace('/', '_')} {url_hash}{extension}"
356
return f"{parsed_url.netloc}+{parsed_url.path[1:].replace('/', '_')}+{url_hash}{extension}"
357
357
358
358
return None
359
359
@@ -494,7 +494,7 @@ def read_and_download_urls(bucket_dir: Path, event_stream: bool = False) -> Iter
494
494
count += 1
495
495
yield f'data: {json.dumps({"action": "download", "count": count})}\n\n'
496
496
497
async def async_read_and_download_urls(bucket_dir: Path, event_stream: bool = False) -> Iterator[str]:
497
async def async_read_and_download_urls(bucket_dir: Path, event_stream: bool = False) -> AsyncIterator[str]:
498
498
urls = get_downloads_urls(bucket_dir)
499
499
if urls:
500
500
count = 0