Merge branch 'main' into main

This commit is contained in:
t.me/xtekky 2023-05-04 19:13:58 +01:00 committed by GitHub
commit e865fcbc5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 44 additions and 258 deletions

4
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,4 @@
{
"editor.tabCompletion": "on",
"diffEditor.codeLens": true
}

View File

@ -51,6 +51,13 @@ Just API's from some language model sites.
<td><a href="https://github.com/xtekky/gpt4free/issues"><img alt="Issues" src="https://img.shields.io/github/issues/xtekky/gpt4free?style=flat-square&labelColor=343b41"/></a></td>
<td><a href="https://github.com/xtekky/gpt4free/pulls"><img alt="Pull Requests" src="https://img.shields.io/github/issues-pr/xtekky/gpt4free?style=flat-square&labelColor=343b41"/></a></td>
</tr>
<tr>
<td><a href="https://github.com/xiangsx/gpt4free-ts"><b>gpt4free-ts</b></a></td>
<td><a href="https://github.com/xiangsx/gpt4free-ts/stargazers"><img alt="Stars" src="https://img.shields.io/github/stars/xiangsx/gpt4free-ts?style=flat-square&labelColor=343b41"/></a></td>
<td><a href="https://github.com/xiangsx/gpt4free-ts/network/members"><img alt="Forks" src="https://img.shields.io/github/forks/xiangsx/gpt4free-ts?style=flat-square&labelColor=343b41"/></a></td>
<td><a href="https://github.com/xiangsx/gpt4free-ts/issues"><img alt="Issues" src="https://img.shields.io/github/issues/xiangsx/gpt4free-ts?style=flat-square&labelColor=343b41"/></a></td>
<td><a href="https://github.com/xiangsx/gpt4free-ts/pulls"><img alt="Pull Requests" src="https://img.shields.io/github/issues-pr/xiangsx/gpt4free-ts?style=flat-square&labelColor=343b41"/></a></td>
</tr>
<tr>
<td><a href="https://github.com/xtekky/chatgpt-clone"><b>ChatGPT-Clone</b></a></td>
<td><a href="https://github.com/xtekky/chatgpt-clone/stargazers"><img alt="Stars" src="https://img.shields.io/github/stars/xtekky/chatgpt-clone?style=flat-square&labelColor=343b41"/></a></td>

View File

@ -1,49 +1,27 @@
import os
import pickle
from json import loads
from xtempmail import Email
from re import findall
from typing import Optional, Generator
from faker import Faker
from time import time, sleep
from typing import Generator, Optional
from uuid import uuid4
from fake_useragent import UserAgent
from pymailtm import MailTm, Message
from requests import post
from tls_client import Session
from .typing import ForeFrontResponse
class Account:
COOKIES_FILE_NAME = 'cookies.pickle'
@staticmethod
def login(proxy: Optional[str] = None, logging: bool = False) -> str:
if not os.path.isfile(Account.COOKIES_FILE_NAME):
return Account.create(proxy, logging)
with open(Account.COOKIES_FILE_NAME, 'rb') as f:
cookies = pickle.load(f)
proxies = {'http': 'http://' + proxy, 'https': 'http://' + proxy} if proxy else False
client = Session(client_identifier='chrome110')
client.proxies = proxies
client.cookies.update(cookies)
if Account.is_cookie_enabled(client):
response = client.get('https://clerk.forefront.ai/v1/client?_clerk_js_version=4.38.4')
return response.json()['response']['sessions'][0]['last_active_token']['jwt']
else:
return Account.create(proxy, logging)
@staticmethod
def create(proxy: Optional[str] = None, logging: bool = False, save_cookies: bool = False) -> str:
def create(proxy: Optional[str] = None, logging: bool = False):
proxies = {'http': 'http://' + proxy, 'https': 'http://' + proxy} if proxy else False
faker = Faker()
name = (faker.name().replace(' ', '_')).lower()
start = time()
mail_client = MailTm().get_account()
mail_address = mail_client.address
mail_client = Email(name=name)
mail_address = mail_client.email
client = Session(client_identifier='chrome110')
client.proxies = proxies
@ -66,7 +44,10 @@ class Account:
response = client.post(
f'https://clerk.forefront.ai/v1/client/sign_ups/{trace_token}/prepare_verification?_clerk_js_version=4.38.4',
data={'strategy': 'email_link', 'redirect_url': 'https://accounts.forefront.ai/sign-up/verify'},
data={
'strategy': 'email_link',
'redirect_url': 'https://accounts.forefront.ai/sign-up/verify'
},
)
if logging:
@ -74,31 +55,23 @@ class Account:
if 'sign_up_attempt' not in response.text:
return 'Failed to create account!'
while True:
sleep(1)
new_message: Message = mail_client.wait_for_message()
if logging:
print(new_message.data['id'])
verification_url = findall(r'https:\/\/clerk\.forefront\.ai\/v1\/verify\?token=\w.+', new_message.text)[0]
verification_url = None
new_message = mail_client.get_new_message(5)
for msg in new_message:
verification_url = findall(r'https:\/\/clerk\.forefront\.ai\/v1\/verify\?token=\w.+', msg.text)[0]
if verification_url:
break
if verification_url is None or not verification_url:
raise RuntimeError('Error while obtaining verfication URL!')
if logging:
print(verification_url)
response = client.get(verification_url)
response = client.get('https://clerk.forefront.ai/v1/client?_clerk_js_version=4.38.4')
token = response.json()['response']['sessions'][0]['last_active_token']['jwt']
if save_cookies:
with open(Account.COOKIES_FILE_NAME, 'wb') as f:
pickle.dump(client.cookies, f)
with open('accounts.txt', 'a') as f:
f.write(f'{mail_address}:{token}\n')
@ -107,11 +80,6 @@ class Account:
return token
@staticmethod
def is_cookie_enabled(client: Session) -> bool:
response = client.get('https://chat.forefront.ai/')
return 'window.startClerk' in response.text
class StreamingCompletion:
@staticmethod
@ -122,14 +90,14 @@ class StreamingCompletion:
action_type='new',
default_persona='607e41fe-95be-497e-8e97-010a59b2e2c0', # default
model='gpt-4',
proxy=None,
proxy=None
) -> Generator[ForeFrontResponse, None, None]:
if not token:
raise Exception('Token is required!')
if not chat_id:
chat_id = str(uuid4())
proxies = {'http': 'http://' + proxy, 'https': 'http://' + proxy} if proxy else None
proxies = { 'http': 'http://' + proxy, 'https': 'http://' + proxy } if proxy else None
headers = {
'authority': 'chat-server.tenant-forefront-default.knative.chi.coreweave.com',
@ -197,7 +165,7 @@ class Completion:
action_type='new',
default_persona='607e41fe-95be-497e-8e97-010a59b2e2c0', # default
model='gpt-4',
proxy=None,
proxy=None
) -> ForeFrontResponse:
text = ''
final_response = None
@ -208,7 +176,7 @@ class Completion:
action_type=action_type,
default_persona=default_persona,
model=model,
proxy=proxy,
proxy=proxy
):
if response:
final_response = response
@ -220,3 +188,4 @@ class Completion:
raise Exception('Unable to get the response, Please try again')
return final_response

View File

@ -1,18 +0,0 @@
### Example: `italygpt`
```python
# create an instance
from gpt4free import italygpt
italygpt = italygpt.Completion()
# initialize api
italygpt.init()
# get an answer
italygpt.create(prompt="What is the meaning of life?")
print(italygpt.answer) # html formatted
# keep the old conversation
italygpt.create(prompt="Are you a human?", messages=italygpt.messages)
print(italygpt.answer)
```

View File

@ -1,28 +0,0 @@
import requests, time, ast, json
from bs4 import BeautifulSoup
from hashlib import sha256
class Completion:
# answer is returned with html formatting
next_id = None
messages = []
answer = None
def init(self):
r = requests.get("https://italygpt.it")
soup = BeautifulSoup(r.text, "html.parser")
self.next_id = soup.find("input", {"name": "next_id"})["value"]
def create(self, prompt: str, messages: list = []):
try:
r = requests.get("https://italygpt.it/question", params={"hash": sha256(self.next_id.encode()).hexdigest(), "prompt": prompt, "raw_messages": json.dumps(messages)}).json()
except:
r = requests.get("https://italygpt.it/question", params={"hash": sha256(self.next_id.encode()).hexdigest(), "prompt": prompt, "raw_messages": json.dumps(messages)}).text
if "too many requests" in r.lower():
# rate limit is 17 requests per 1 minute
time.sleep(20)
return self.create(prompt, messages)
self.next_id = r["next_id"]
self.messages = ast.literal_eval(r["raw_messages"])
self.answer = r["response"]
return self

View File

@ -104,8 +104,8 @@ class Model:
def create(
token: str,
model: str = 'gpt-3.5-turbo', # claude-instant
system_prompt: str = 'You are ChatGPT a large language model developed by Openai. Answer as consisely as possible',
description: str = 'gpt-3.5 language model from openai, skidded by poe.com',
system_prompt: str = 'You are ChatGPT a large language model. Answer as consisely as possible',
description: str = 'gpt-3.5 language model',
handle: str = None,
) -> ModelResponse:
if not handle:

4
gpt4free/test.py Normal file
View File

@ -0,0 +1,4 @@
import forefront
token = forefront.Account.create()
response = forefront.Completion.create(token=token, prompt='Hello!')
print(response)

View File

@ -72,3 +72,5 @@ class Completion:
for message in Completion.create(prompt, proxy):
response_list.append(message)
return ''.join(response_list)
Completion.message_queue.put(response.decode(errors='replace'))

View File

@ -1,5 +1,5 @@
[tool.poetry]
name = "openai-rev"
name = "gpt4free"
version = "0.1.0"
description = ""
authors = []

View File

@ -1,8 +0,0 @@
# asyncio.run(gptbz.test())
import requests
image = '/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAA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SYPOGnyEA7/ADdvmJnH8G3IHX5s4xxmtmiihdRVFZR9AoooqjI//9k='
response = requests.get('https://ocr.holey.cc/ncku?base64_str=%s' % image) # .split('base64,')[1])
print(response.content)

View File

@ -1,41 +0,0 @@
import requests
class Completion:
def create(prompt: str,
model: str = 'openai:gpt-3.5-turbo',
temperature: float = 0.7,
max_tokens: int = 200,
top_p: float = 1,
top_k: int = 1,
frequency_penalty: float = 1,
presence_penalty: float = 1,
stopSequences: list = []):
token = requests.get('https://play.vercel.ai/openai.jpeg', headers={
'authority': 'play.vercel.ai',
'accept-language': 'en,fr-FR;q=0.9,fr;q=0.8,es-ES;q=0.7,es;q=0.6,en-US;q=0.5,am;q=0.4,de;q=0.3',
'referer': 'https://play.vercel.ai/',
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36'}).text.replace('=','')
print(token)
headers = {
'authority': 'play.vercel.ai',
'custom-encoding': token,
'origin': 'https://play.vercel.ai',
'referer': 'https://play.vercel.ai/',
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36'
}
for chunk in requests.post('https://play.vercel.ai/api/generate', headers=headers, stream=True, json={
'prompt': prompt,
'model': model,
'temperature': temperature,
'maxTokens': max_tokens,
'topK': top_p,
'topP': top_k,
'frequencyPenalty': frequency_penalty,
'presencePenalty': presence_penalty,
'stopSequences': stopSequences}).iter_lines():
yield (chunk)

View File

@ -1,33 +0,0 @@
(async () => {
let response = await fetch("https://play.vercel.ai/openai.jpeg", {
"headers": {
"accept": "*/*",
"accept-language": "en,fr-FR;q=0.9,fr;q=0.8,es-ES;q=0.7,es;q=0.6,en-US;q=0.5,am;q=0.4,de;q=0.3",
"sec-ch-ua": "\"Chromium\";v=\"112\", \"Google Chrome\";v=\"112\", \"Not:A-Brand\";v=\"99\"",
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-platform": "\"macOS\"",
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
"sec-fetch-site": "same-origin"
},
"referrer": "https://play.vercel.ai/",
"referrerPolicy": "strict-origin-when-cross-origin",
"body": null,
"method": "GET",
"mode": "cors",
"credentials": "omit"
});
let data = JSON.parse(atob(await response.text()))
let ret = eval("(".concat(data.c, ")(data.a)"));
botPreventionToken = btoa(JSON.stringify({
r: ret,
t: data.t
}))
console.log(botPreventionToken);
})()

View File

@ -1,67 +0,0 @@
import requests
from base64 import b64decode, b64encode
from json import loads
from json import dumps
headers = {
'Accept': '*/*',
'Accept-Language': 'en-GB,en-US;q=0.9,en;q=0.8',
'Connection': 'keep-alive',
'Referer': 'https://play.vercel.ai/',
'Sec-Fetch-Dest': 'empty',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Site': 'same-origin',
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36',
'sec-ch-ua': '"Chromium";v="110", "Google Chrome";v="110", "Not:A-Brand";v="99"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"macOS"',
}
response = requests.get('https://play.vercel.ai/openai.jpeg', headers=headers)
token_data = loads(b64decode(response.text))
print(token_data)
raw_token = {
'a': token_data['a'] * .1 * .2,
't': token_data['t']
}
print(raw_token)
new_token = b64encode(dumps(raw_token, separators=(',', ':')).encode()).decode()
print(new_token)
import requests
headers = {
'authority': 'play.vercel.ai',
'accept': '*/*',
'accept-language': 'en,fr-FR;q=0.9,fr;q=0.8,es-ES;q=0.7,es;q=0.6,en-US;q=0.5,am;q=0.4,de;q=0.3',
'content-type': 'application/json',
'custom-encoding': new_token,
'origin': 'https://play.vercel.ai',
'referer': 'https://play.vercel.ai/',
'sec-ch-ua': '"Chromium";v="112", "Google Chrome";v="112", "Not:A-Brand";v="99"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"macOS"',
'sec-fetch-dest': 'empty',
'sec-fetch-mode': 'cors',
'sec-fetch-site': 'same-origin',
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36',
}
json_data = {
'prompt': 'hello\n',
'model': 'openai:gpt-3.5-turbo',
'temperature': 0.7,
'maxTokens': 200,
'topK': 1,
'topP': 1,
'frequencyPenalty': 1,
'presencePenalty': 1,
'stopSequences': [],
}
response = requests.post('https://play.vercel.ai/api/generate', headers=headers, json=json_data)
print(response.text)

View File

@ -1,5 +0,0 @@
import vercelai
for token in vercelai.Completion.create('summarize the gnu gpl 1.0'):
print(token, end='', flush=True)