diff options
author | MIDORIBIN <aquarion123@gmail.com> | 2023-07-28 12:07:17 +0200 |
---|---|---|
committer | MIDORIBIN <aquarion123@gmail.com> | 2023-08-14 04:46:32 +0200 |
commit | f6ef3cb2237d8c336e915ef77ddbe6f37934c4fd (patch) | |
tree | c8bc44917ea03909cf586140f984ff0814bc30ea /g4f/.v1/gpt4free/italygpt2/__init__.py | |
parent | ~ | small fixes & new pypi version | v-0.0.1.9 (diff) | |
download | gpt4free-f6ef3cb2237d8c336e915ef77ddbe6f37934c4fd.tar gpt4free-f6ef3cb2237d8c336e915ef77ddbe6f37934c4fd.tar.gz gpt4free-f6ef3cb2237d8c336e915ef77ddbe6f37934c4fd.tar.bz2 gpt4free-f6ef3cb2237d8c336e915ef77ddbe6f37934c4fd.tar.lz gpt4free-f6ef3cb2237d8c336e915ef77ddbe6f37934c4fd.tar.xz gpt4free-f6ef3cb2237d8c336e915ef77ddbe6f37934c4fd.tar.zst gpt4free-f6ef3cb2237d8c336e915ef77ddbe6f37934c4fd.zip |
Diffstat (limited to 'g4f/.v1/gpt4free/italygpt2/__init__.py')
-rw-r--r-- | g4f/.v1/gpt4free/italygpt2/__init__.py | 70 |
1 files changed, 0 insertions, 70 deletions
diff --git a/g4f/.v1/gpt4free/italygpt2/__init__.py b/g4f/.v1/gpt4free/italygpt2/__init__.py deleted file mode 100644 index 1eb191c0..00000000 --- a/g4f/.v1/gpt4free/italygpt2/__init__.py +++ /dev/null @@ -1,70 +0,0 @@ -import re -import requests -import hashlib -from fake_useragent import UserAgent -class Account: - @staticmethod - def create(): - r=requests.get("https://italygpt.it/",headers=Account._header) - f=r.text - tid=re.search('<input type=\"hidden\" name=\"next_id\" id=\"next_id\" value=\"(\w+)\">',f).group(1) - if len(tid)==0: - raise RuntimeError("NetWorkError:failed to get id.") - else: - Account._tid=tid - Account._raw="[]" - return Account - def next(next_id:str)->str: - Account._tid=next_id - return Account._tid - def get()->str: - return Account._tid - _header={ - "Host": "italygpt.it", - "Referer":"https://italygpt.it/", - "User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36",#UserAgent().random, - "Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8", - "Accept-Language":"zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2", - "Upgrade-Insecure-Requests":"1", - "Sec-Fetch-Dest":"document", - "Sec-Fetch-Mode":"navigate", - "Sec-Fetch-Site":"none", - "Sec-Fetch-User":"?1", - "Connection":"keep-alive", - "Alt-Used":"italygpt.it", - "Pragma":"no-cache", - "Cache-Control":"no-cache", - "TE": "trailers" - } - def settraw(raws:str): - Account._raw=raws - return Account._raw - def gettraw(): - return Account._raw - -class Completion: - @staticmethod - def create( - account_data, - prompt: str, - message=False - ): - param={ - "prompt":prompt.replace(" ","+"), - "creative":"off", - "internet":"false", - "detailed":"off", - "current_id":"0", - "code":"", - "gpt4":"false", - "raw_messages":account_data.gettraw(), - "hash":hashlib.sha256(account_data.get().encode()).hexdigest() - } - if(message): - param["raw_messages"]=str(message) - r = requests.get("https://italygpt.it/question",headers=account_data._header,params=param,stream=True) - account_data.next(r.headers["Next_id"]) - account_data.settraw(r.headers["Raw_messages"]) - for chunk in r.iter_content(chunk_size=None): - r.raise_for_status() - yield chunk.decode()
\ No newline at end of file |