diff options
author | kqlio67 <kqlio67@users.noreply.github.com> | 2024-09-25 10:44:23 +0200 |
---|---|---|
committer | kqlio67 <kqlio67@users.noreply.github.com> | 2024-09-25 10:44:23 +0200 |
commit | ec4e25073b5357a1213bfe00a93a21b5b6652bea (patch) | |
tree | c7cfa751ae9604d0bc05e42661492f934a2d333d /g4f/Provider/deprecated/Wuguokai.py | |
parent | feat(g4f/Provider/HuggingChat.): add Qwen2.5-72B model and alias (diff) | |
download | gpt4free-ec4e25073b5357a1213bfe00a93a21b5b6652bea.tar gpt4free-ec4e25073b5357a1213bfe00a93a21b5b6652bea.tar.gz gpt4free-ec4e25073b5357a1213bfe00a93a21b5b6652bea.tar.bz2 gpt4free-ec4e25073b5357a1213bfe00a93a21b5b6652bea.tar.lz gpt4free-ec4e25073b5357a1213bfe00a93a21b5b6652bea.tar.xz gpt4free-ec4e25073b5357a1213bfe00a93a21b5b6652bea.tar.zst gpt4free-ec4e25073b5357a1213bfe00a93a21b5b6652bea.zip |
Diffstat (limited to 'g4f/Provider/deprecated/Wuguokai.py')
-rw-r--r-- | g4f/Provider/deprecated/Wuguokai.py | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/g4f/Provider/deprecated/Wuguokai.py b/g4f/Provider/deprecated/Wuguokai.py new file mode 100644 index 00000000..f12d1bfe --- /dev/null +++ b/g4f/Provider/deprecated/Wuguokai.py @@ -0,0 +1,57 @@ +from __future__ import annotations + +import random + +import requests + +from ...typing import Any, CreateResult +from ..base_provider import AbstractProvider, format_prompt + + +class Wuguokai(AbstractProvider): + url = 'https://chat.wuguokai.xyz' + supports_gpt_35_turbo = True + working = False + + @staticmethod + def create_completion( + model: str, + messages: list[dict[str, str]], + stream: bool, + **kwargs: Any, + ) -> CreateResult: + headers = { + 'authority': 'ai-api.wuguokai.xyz', + 'accept': 'application/json, text/plain, */*', + 'accept-language': 'id-ID,id;q=0.9,en-US;q=0.8,en;q=0.7', + 'content-type': 'application/json', + 'origin': 'https://chat.wuguokai.xyz', + 'referer': 'https://chat.wuguokai.xyz/', + 'sec-ch-ua': '"Not.A/Brand";v="8", "Chromium";v="114", "Google Chrome";v="114"', + 'sec-ch-ua-mobile': '?0', + 'sec-ch-ua-platform': '"Windows"', + 'sec-fetch-dest': 'empty', + 'sec-fetch-mode': 'cors', + 'sec-fetch-site': 'same-site', + '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' + } + data ={ + "prompt": format_prompt(messages), + "options": {}, + "userId": f"#/chat/{random.randint(1,99999999)}", + "usingContext": True + } + response = requests.post( + "https://ai-api20.wuguokai.xyz/api/chat-process", + headers=headers, + timeout=3, + json=data, + proxies=kwargs.get('proxy', {}), + ) + _split = response.text.split("> 若回答失败请重试或多刷新几次界面后重试") + if response.status_code != 200: + raise Exception(f"Error: {response.status_code} {response.reason}") + if len(_split) > 1: + yield _split[1].strip() + else: + yield _split[0].strip()
\ No newline at end of file |