diff options
author | hs_junxiang <jimmy871117@gmail.com> | 2023-09-04 07:34:31 +0200 |
---|---|---|
committer | hs_junxiang <jimmy871117@gmail.com> | 2023-09-04 07:41:22 +0200 |
commit | 17c9adf4852a0ca0d1a5cfa448478fa195a9c368 (patch) | |
tree | 070475a0003dde9f0815e7fe98f907f029f3c916 /g4f | |
parent | ~ | Merge pull request #872 (diff) | |
download | gpt4free-17c9adf4852a0ca0d1a5cfa448478fa195a9c368.tar gpt4free-17c9adf4852a0ca0d1a5cfa448478fa195a9c368.tar.gz gpt4free-17c9adf4852a0ca0d1a5cfa448478fa195a9c368.tar.bz2 gpt4free-17c9adf4852a0ca0d1a5cfa448478fa195a9c368.tar.lz gpt4free-17c9adf4852a0ca0d1a5cfa448478fa195a9c368.tar.xz gpt4free-17c9adf4852a0ca0d1a5cfa448478fa195a9c368.tar.zst gpt4free-17c9adf4852a0ca0d1a5cfa448478fa195a9c368.zip |
Diffstat (limited to '')
-rw-r--r-- | g4f/Provider/AItianhu.py | 6 | ||||
-rw-r--r-- | g4f/Provider/AiService.py | 6 | ||||
-rw-r--r-- | g4f/Provider/Aichat.py | 6 | ||||
-rw-r--r-- | g4f/Provider/Bing.py | 5 | ||||
-rw-r--r-- | g4f/Provider/ChatgptAi.py | 6 | ||||
-rw-r--r-- | g4f/Provider/Theb.py | 6 | ||||
-rw-r--r-- | g4f/Provider/V50.py | 8 |
7 files changed, 14 insertions, 29 deletions
diff --git a/g4f/Provider/AItianhu.py b/g4f/Provider/AItianhu.py index abf66cc1..28e66dcf 100644 --- a/g4f/Provider/AItianhu.py +++ b/g4f/Provider/AItianhu.py @@ -17,10 +17,8 @@ class AItianhu(BaseProvider): messages: list[dict[str, str]], stream: bool, **kwargs: Any) -> CreateResult: - base = "" - for message in messages: - base += "%s: %s\n" % (message["role"], message["content"]) - base += "assistant:" + base = "\n".join(f"{message['role']}: {message['content']}" for message in messages) + base += "\nassistant: " headers = { "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36" diff --git a/g4f/Provider/AiService.py b/g4f/Provider/AiService.py index 3453bfd9..3ce2f3df 100644 --- a/g4f/Provider/AiService.py +++ b/g4f/Provider/AiService.py @@ -16,10 +16,8 @@ class AiService(BaseProvider): stream: bool, **kwargs: Any, ) -> CreateResult: - base = "" - for message in messages: - base += "%s: %s\n" % (message["role"], message["content"]) - base += "assistant:" + base = "\n".join(f"{message['role']}: {message['content']}" for message in messages) + base += "\nassistant: " headers = { "accept": "*/*", diff --git a/g4f/Provider/Aichat.py b/g4f/Provider/Aichat.py index 62954e07..4c3f35b6 100644 --- a/g4f/Provider/Aichat.py +++ b/g4f/Provider/Aichat.py @@ -15,10 +15,8 @@ class Aichat(BaseProvider): messages: list[dict[str, str]], stream: bool, **kwargs: Any) -> CreateResult: - base = "" - for message in messages: - base += "%s: %s\n" % (message["role"], message["content"]) - base += "assistant:" + chat = "\n".join(f"{message['role']}: {message['content']}" for message in messages) + chat += "\nassistant: " headers = { "authority": "chat-gpt.org", diff --git a/g4f/Provider/Bing.py b/g4f/Provider/Bing.py index 48968e39..1642877d 100644 --- a/g4f/Provider/Bing.py +++ b/g4f/Provider/Bing.py @@ -40,10 +40,7 @@ class Bing(AsyncGeneratorProvider): return stream_generate(prompt, context, cookies_dict) def create_context(messages: list[dict[str, str]]): - context = "" - - for message in messages: - context += "[%s](#message)\n%s\n\n" % (message["role"], message["content"]) + context = "".join(f"[{message['role']}](#message)\n{message['content']}\n\n" for message in messages) return context diff --git a/g4f/Provider/ChatgptAi.py b/g4f/Provider/ChatgptAi.py index 13c591cb..97b62840 100644 --- a/g4f/Provider/ChatgptAi.py +++ b/g4f/Provider/ChatgptAi.py @@ -15,10 +15,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( diff --git a/g4f/Provider/Theb.py b/g4f/Provider/Theb.py index 9a47bb89..118de53b 100644 --- a/g4f/Provider/Theb.py +++ b/g4f/Provider/Theb.py @@ -17,10 +17,8 @@ class Theb(BaseProvider): messages: list[dict[str, str]], stream: bool, **kwargs: Any) -> CreateResult: - conversation = '' - for message in messages: - conversation += '%s: %s\n' % (message['role'], message['content']) - conversation += 'assistant: ' + conversation = "\n".join(f"{message['role']}: {message['content']}" for message in messages) + conversation += "\nassistant: " auth = kwargs.get("auth", { "bearer_token":"free", diff --git a/g4f/Provider/V50.py b/g4f/Provider/V50.py index 1dc7651d..ad3fd9e4 100644 --- a/g4f/Provider/V50.py +++ b/g4f/Provider/V50.py @@ -16,11 +16,9 @@ class V50(BaseProvider): messages: list[dict[str, str]], stream: bool, **kwargs: Any) -> CreateResult: - conversation = '' - for message in messages: - conversation += '%s: %s\n' % (message['role'], message['content']) - - conversation += 'assistant: ' + conversation = "\n".join(f"{message['role']}: {message['content']}" for message in messages) + conversation += "\nassistant: " + payload = { "prompt" : conversation, "options" : {}, |