From 901595b10f08972ee3ac5fc08c346dbb561a7d62 Mon Sep 17 00:00:00 2001 From: msi-JunXiang Date: Sun, 3 Sep 2023 16:26:26 +0800 Subject: type hints Use `from __future__ import annotations avoid `dict` and `list` cause "TypeErro: 'type' object is not subscriptable". Refer to the following Stack Overflow discussions for more information: 1. https://stackoverflow.com/questions/75202610/typeerror-type-object-is-not-subscriptable-python 2. https://stackoverflow.com/questions/59101121/type-hint-for-a-dict-gives-typeerror-type-object-is-not-subscriptable --- g4f/Provider/OpenaiChat.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'g4f/Provider/OpenaiChat.py') diff --git a/g4f/Provider/OpenaiChat.py b/g4f/Provider/OpenaiChat.py index 9ca0cd58..f2d1ed6f 100644 --- a/g4f/Provider/OpenaiChat.py +++ b/g4f/Provider/OpenaiChat.py @@ -1,14 +1,18 @@ +from __future__ import annotations + has_module = True try: from revChatGPT.V1 import AsyncChatbot except ImportError: has_module = False -from .base_provider import AsyncGeneratorProvider, get_cookies, format_prompt -from ..typing import AsyncGenerator -from httpx import AsyncClient import json +from httpx import AsyncClient + +from ..typing import AsyncGenerator +from .base_provider import AsyncGeneratorProvider, format_prompt, get_cookies + class OpenaiChat(AsyncGeneratorProvider): url = "https://chat.openai.com" -- cgit v1.2.3