summaryrefslogtreecommitdiffstats
path: root/g4f/Provider/ChatgptAi.py
diff options
context:
space:
mode:
Diffstat (limited to 'g4f/Provider/ChatgptAi.py')
-rw-r--r--g4f/Provider/ChatgptAi.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/g4f/Provider/ChatgptAi.py b/g4f/Provider/ChatgptAi.py
index 13c591cb..7613ccf1 100644
--- a/g4f/Provider/ChatgptAi.py
+++ b/g4f/Provider/ChatgptAi.py
@@ -1,6 +1,10 @@
-import re, requests
+from __future__ import annotations
-from ..typing import Any, CreateResult
+import re
+
+import requests
+
+from ..typing import Any, CreateResult
from .base_provider import BaseProvider
@@ -15,10 +19,8 @@ class ChatgptAi(BaseProvider):
messages: list[dict[str, str]],
stream: bool, **kwargs: Any) -> CreateResult:
- chat = ""
- for message in messages:
- chat += "%s: %s\n" % (message["role"], message["content"])
- chat += "assistant: "
+ chat = "\n".join(f"{message['role']}: {message['content']}" for message in messages)
+ chat += "\nassistant: "
response = requests.get("https://chatgpt.ai/")
nonce, post_id, _, bot_id = re.findall(