mirror of https://github.com/xtekky/gpt4free.git
minor fixes
This commit is contained in:
parent
76c7be3172
commit
e946729736
|
@ -5,6 +5,7 @@ url = None
|
|||
model = None
|
||||
supports_stream = False
|
||||
needs_auth = False
|
||||
working = False
|
||||
|
||||
def _create_completion(model: str, messages: list, stream: bool, **kwargs):
|
||||
return
|
||||
|
|
|
@ -6,6 +6,8 @@ url = "https://www.aitianhu.com/api/chat-process"
|
|||
model = ['gpt-3.5-turbo']
|
||||
supports_stream = False
|
||||
needs_auth = False
|
||||
working = True
|
||||
|
||||
|
||||
def _create_completion(model: str, messages: list, stream: bool, **kwargs):
|
||||
base = ''
|
||||
|
|
|
@ -6,6 +6,7 @@ url = "https://chat.acytoo.com/api/completions"
|
|||
model = ['gpt-3.5-turbo']
|
||||
supports_stream = False
|
||||
needs_auth = False
|
||||
working = False
|
||||
|
||||
def _create_completion(model: str, messages: list, stream: bool, **kwargs):
|
||||
base = ''
|
||||
|
|
|
@ -6,6 +6,7 @@ url = "https://aiservice.vercel.app/api/chat/answer"
|
|||
model = ['gpt-3.5-turbo']
|
||||
supports_stream = False
|
||||
needs_auth = False
|
||||
working = True
|
||||
|
||||
|
||||
def _create_completion(model: str, messages: list, stream: bool, **kwargs):
|
||||
|
|
|
@ -5,6 +5,7 @@ url = 'https://chat-gpt.org/chat'
|
|||
model = ['gpt-3.5-turbo']
|
||||
supports_stream = False
|
||||
needs_auth = False
|
||||
working = True
|
||||
|
||||
def _create_completion(model: str, messages: list, stream: bool, **kwargs):
|
||||
base = ''
|
||||
|
|
|
@ -13,6 +13,8 @@ url: str = 'https://ai.ls'
|
|||
model: str = 'gpt-3.5-turbo'
|
||||
supports_stream = True
|
||||
needs_auth = False
|
||||
working = True
|
||||
|
||||
|
||||
class Utils:
|
||||
def hash(json_data: Dict[str, str]) -> sha256:
|
||||
|
|
|
@ -5,6 +5,8 @@ url = 'https://bard.google.com'
|
|||
model = ['Palm2']
|
||||
supports_stream = False
|
||||
needs_auth = True
|
||||
working = True
|
||||
|
||||
|
||||
def _create_completion(model: str, messages: list, stream: bool, **kwargs):
|
||||
psid = {cookie.name: cookie.value for cookie in browser_cookie3.chrome(
|
||||
|
|
|
@ -16,6 +16,7 @@ url = 'https://bing.com/chat'
|
|||
model = ['gpt-4']
|
||||
supports_stream = True
|
||||
needs_auth = False
|
||||
working = True
|
||||
|
||||
ssl_context = ssl.create_default_context()
|
||||
ssl_context.load_verify_locations(certifi.where())
|
||||
|
|
|
@ -7,6 +7,8 @@ url = 'https://b.ai-huan.xyz'
|
|||
model = ['gpt-3.5-turbo', 'gpt-4']
|
||||
supports_stream = True
|
||||
needs_auth = False
|
||||
working = False
|
||||
|
||||
|
||||
def _create_completion(model: str, messages: list, stream: bool, **kwargs):
|
||||
path = os.path.dirname(os.path.realpath(__file__))
|
||||
|
|
|
@ -6,6 +6,8 @@ url = 'https://chatgpt.ai/gpt-4/'
|
|||
model = ['gpt-4']
|
||||
supports_stream = False
|
||||
needs_auth = False
|
||||
working = True
|
||||
|
||||
|
||||
def _create_completion(model: str, messages: list, stream: bool, **kwargs):
|
||||
chat = ''
|
||||
|
|
|
@ -8,7 +8,7 @@ url = 'https://chatgptlogin.ac'
|
|||
model = ['gpt-3.5-turbo']
|
||||
supports_stream = False
|
||||
needs_auth = False
|
||||
|
||||
working = False
|
||||
|
||||
def _create_completion(model: str, messages: list, stream: bool, **kwargs):
|
||||
def get_nonce():
|
||||
|
|
|
@ -4,41 +4,45 @@ import json
|
|||
|
||||
url = "https://chat.dfehub.com/api/chat"
|
||||
model = ['gpt-3.5-turbo']
|
||||
supports_stream = False
|
||||
supports_stream = True
|
||||
needs_auth = False
|
||||
working = True
|
||||
|
||||
|
||||
def _create_completion(model: str, messages: list, stream: bool, **kwargs):
|
||||
base = ''
|
||||
for message in messages:
|
||||
base += '%s: %s\n' % (message['role'], message['content'])
|
||||
base += 'assistant:'
|
||||
|
||||
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"
|
||||
'authority': 'chat.dfehub.com',
|
||||
'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',
|
||||
'origin': 'https://chat.dfehub.com',
|
||||
'referer': 'https://chat.dfehub.com/',
|
||||
'sec-ch-ua': '"Not.A/Brand";v="8", "Chromium";v="114", "Google Chrome";v="114"',
|
||||
'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/114.0.0.0 Safari/537.36',
|
||||
'x-requested-with': 'XMLHttpRequest',
|
||||
}
|
||||
data = {
|
||||
"model": {
|
||||
"id": "gpt-3.5-turbo",
|
||||
"name": "GPT-3.5",
|
||||
"maxLength": 12000,
|
||||
"tokenLimit": 4000
|
||||
},
|
||||
"messages": [
|
||||
{
|
||||
"role": "user",
|
||||
"content": base
|
||||
}
|
||||
],
|
||||
"key": "",
|
||||
"prompt": "You are ChatGPT, a large language model trained by OpenAI. Follow the user's instructions carefully. Respond using markdown.",
|
||||
"temperature": 1
|
||||
|
||||
json_data = {
|
||||
'messages': messages,
|
||||
'model': 'gpt-3.5-turbo',
|
||||
'temperature': 0.5,
|
||||
'presence_penalty': 0,
|
||||
'frequency_penalty': 0,
|
||||
'top_p': 1,
|
||||
}
|
||||
response = requests.post(url, headers=headers, data=json.dumps(data))
|
||||
if response.status_code == 200:
|
||||
yield response.text
|
||||
else:
|
||||
print(f"Error Occurred::{response.status_code}")
|
||||
return None
|
||||
|
||||
response = requests.post('https://chat.dfehub.com/api/openai/v1/chat/completions',
|
||||
headers=headers, json=json_data)
|
||||
|
||||
for chunk in response.iter_lines():
|
||||
if b'content' in chunk:
|
||||
data = json.loads(chunk.decode().split('data: ')[1])
|
||||
yield (data['choices'][0]['delta']['content'])
|
||||
|
||||
params = f'g4f.Providers.{os.path.basename(__file__)[:-3]} supports: ' + \
|
||||
'(%s)' % ', '.join([f"{name}: {get_type_hints(_create_completion)[name].__name__}" for name in _create_completion.__code__.co_varnames[:_create_completion.__code__.co_argcount]])
|
|
@ -10,6 +10,8 @@ url = 'https://deepai.org'
|
|||
model = ['gpt-3.5-turbo']
|
||||
supports_stream = True
|
||||
needs_auth = False
|
||||
working = True
|
||||
|
||||
|
||||
def _create_completion(model: str, messages: list, stream: bool, **kwargs):
|
||||
def md5(text: str) -> str:
|
||||
|
|
|
@ -2,42 +2,51 @@ import os, requests
|
|||
from ...typing import sha256, Dict, get_type_hints
|
||||
import json
|
||||
|
||||
url = "https://free.easychat.work/api/openai/v1/chat/completions"
|
||||
url = "https://free.easychat.work"
|
||||
model = ['gpt-3.5-turbo']
|
||||
supports_stream = False
|
||||
supports_stream = True
|
||||
needs_auth = False
|
||||
working = True
|
||||
|
||||
|
||||
def _create_completion(model: str, messages: list, stream: bool, **kwargs):
|
||||
''' limited to 240 messages/hour'''
|
||||
base = ''
|
||||
for message in messages:
|
||||
base += '%s: %s\n' % (message['role'], message['content'])
|
||||
base += 'assistant:'
|
||||
|
||||
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",
|
||||
'authority': 'free.easychat.work',
|
||||
'accept': 'text/event-stream',
|
||||
'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',
|
||||
'endpoint': '',
|
||||
'origin': 'https://free.easychat.work',
|
||||
'plugins': '0',
|
||||
'referer': 'https://free.easychat.work/',
|
||||
'sec-ch-ua': '"Not.A/Brand";v="8", "Chromium";v="114", "Google Chrome";v="114"',
|
||||
'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/114.0.0.0 Safari/537.36',
|
||||
'usesearch': 'false',
|
||||
'x-requested-with': 'XMLHttpRequest',
|
||||
}
|
||||
|
||||
data = {
|
||||
"messages": [
|
||||
{"role": "system", "content": "You are ChatGPT, a large language model trained by OpenAI."},
|
||||
{"role": "user", "content": base}
|
||||
],
|
||||
"stream": False,
|
||||
"model": "gpt-3.5-turbo",
|
||||
"temperature": 0.5,
|
||||
"presence_penalty": 0,
|
||||
"frequency_penalty": 0,
|
||||
"top_p": 1
|
||||
json_data = {
|
||||
'messages': messages,
|
||||
'stream': True,
|
||||
'model': model,
|
||||
'temperature': 0.5,
|
||||
'presence_penalty': 0,
|
||||
'frequency_penalty': 0,
|
||||
'top_p': 1,
|
||||
}
|
||||
|
||||
response = requests.post(url, headers=headers, json=data)
|
||||
if response.status_code == 200:
|
||||
response = response.json()
|
||||
yield response['choices'][0]['message']['content']
|
||||
else:
|
||||
print(f"Error Occurred::{response.status_code}")
|
||||
return None
|
||||
response = requests.post('https://free.easychat.work/api/openai/v1/chat/completions',
|
||||
headers=headers, json=json_data)
|
||||
|
||||
for chunk in response.iter_lines():
|
||||
if b'content' in chunk:
|
||||
data = json.loads(chunk.decode().split('data: ')[1])
|
||||
yield (data['choices'][0]['delta']['content'])
|
||||
|
||||
params = f'g4f.Providers.{os.path.basename(__file__)[:-3]} supports: ' + \
|
||||
'(%s)' % ', '.join([f"{name}: {get_type_hints(_create_completion)[name].__name__}" for name in _create_completion.__code__.co_varnames[:_create_completion.__code__.co_argcount]])
|
|
@ -7,6 +7,8 @@ url = 'https://forefront.com'
|
|||
model = ['gpt-3.5-turbo']
|
||||
supports_stream = True
|
||||
needs_auth = False
|
||||
working = False
|
||||
|
||||
|
||||
def _create_completion(model: str, messages: list, stream: bool, **kwargs):
|
||||
json_data = {
|
||||
|
|
|
@ -9,6 +9,8 @@ url = 'https://chat.getgpt.world/'
|
|||
model = ['gpt-3.5-turbo']
|
||||
supports_stream = True
|
||||
needs_auth = False
|
||||
working = True
|
||||
|
||||
|
||||
def _create_completion(model: str, messages: list, stream: bool, **kwargs):
|
||||
def encrypt(e):
|
||||
|
|
|
@ -10,6 +10,7 @@ url = 'https://gpt-gm.h2o.ai'
|
|||
model = ['falcon-40b', 'falcon-7b', 'llama-13b']
|
||||
supports_stream = True
|
||||
needs_auth = False
|
||||
working = True
|
||||
|
||||
models = {
|
||||
'falcon-7b': 'h2oai/h2ogpt-gm-oasst1-en-2048-falcon-7b-v3',
|
||||
|
@ -18,6 +19,7 @@ models = {
|
|||
}
|
||||
|
||||
def _create_completion(model: str, messages: list, stream: bool, **kwargs):
|
||||
|
||||
conversation = ''
|
||||
for message in messages:
|
||||
conversation += '%s: %s\n' % (message['role'], message['content'])
|
||||
|
@ -47,8 +49,6 @@ def _create_completion(model: str, messages: list, stream: bool, **kwargs):
|
|||
}
|
||||
response = session.post("https://gpt-gm.h2o.ai/settings", headers=headers, data=data)
|
||||
|
||||
|
||||
|
||||
headers = {
|
||||
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/115.0",
|
||||
"Accept": "*/*",
|
||||
|
|
|
@ -5,6 +5,7 @@ url = 'https://liaobots.com'
|
|||
model = ['gpt-3.5-turbo', 'gpt-4']
|
||||
supports_stream = True
|
||||
needs_auth = True
|
||||
working = False
|
||||
|
||||
models = {
|
||||
'gpt-4': {
|
||||
|
|
|
@ -6,6 +6,7 @@ url = 'http://supertest.lockchat.app'
|
|||
model = ['gpt-4', 'gpt-3.5-turbo']
|
||||
supports_stream = True
|
||||
needs_auth = False
|
||||
working = False
|
||||
|
||||
def _create_completion(model: str, messages: list, stream: bool, temperature: float = 0.7, **kwargs):
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ url = 'https://theb.ai'
|
|||
model = ['gpt-3.5-turbo']
|
||||
supports_stream = True
|
||||
needs_auth = False
|
||||
working = False
|
||||
|
||||
def _create_completion(model: str, messages: list, stream: bool, **kwargs):
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ from ...typing import sha256, Dict, get_type_hints
|
|||
url = 'https://play.vercel.ai'
|
||||
supports_stream = True
|
||||
needs_auth = False
|
||||
working = False
|
||||
|
||||
models = {
|
||||
'claude-instant-v1': 'anthropic:claude-instant-v1',
|
||||
|
@ -143,8 +144,6 @@ class Client:
|
|||
index = len(lines) - 1
|
||||
|
||||
def _create_completion(model: str, messages: list, stream: bool, **kwargs):
|
||||
yield 'Vercel is currently not working.'
|
||||
return
|
||||
|
||||
conversation = 'This is a conversation between a human and a language model, respond to the last message accordingly, referring to the past history of messages if needed.\n'
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ url = "https://wewordle.org/gptapi/v1/android/turbo"
|
|||
model = ['gpt-3.5-turbo']
|
||||
supports_stream = False
|
||||
needs_auth = False
|
||||
|
||||
working = False
|
||||
|
||||
def _create_completion(model: str, messages: list, stream: bool, **kwargs):
|
||||
base = ''
|
||||
|
|
|
@ -9,6 +9,7 @@ url = 'https://you.com'
|
|||
model = 'gpt-3.5-turbo'
|
||||
supports_stream = True
|
||||
needs_auth = False
|
||||
working = False
|
||||
|
||||
def _create_completion(model: str, messages: list, stream: bool, **kwargs):
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ model = [
|
|||
]
|
||||
supports_stream = True
|
||||
needs_auth = False
|
||||
working = False
|
||||
|
||||
def _create_completion(model: str, messages: list, stream: bool, **kwargs):
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ from .Providers import (
|
|||
AItianhu,
|
||||
EasyChat,
|
||||
Acytoo,
|
||||
DFEHub,
|
||||
DfeHub,
|
||||
AiService,
|
||||
BingHuan,
|
||||
Wewordle,
|
||||
|
|
|
@ -2,11 +2,14 @@ import sys
|
|||
from . import Provider
|
||||
from g4f.models import Model, ModelUtils
|
||||
|
||||
logging = False
|
||||
|
||||
class ChatCompletion:
|
||||
@staticmethod
|
||||
def create(model: Model.model or str, messages: list, provider: Provider.Provider = None, stream: bool = False, auth: str = False, **kwargs):
|
||||
kwargs['auth'] = auth
|
||||
if provider and provider.working == False:
|
||||
return f'{provider.__name__} is not working'
|
||||
|
||||
if provider and provider.needs_auth and not auth:
|
||||
print(
|
||||
|
@ -27,7 +30,7 @@ class ChatCompletion:
|
|||
f"ValueError: {engine.__name__} does not support 'stream' argument", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
print(f'Using {engine.__name__} provider')
|
||||
if logging: print(f'Using {engine.__name__} provider')
|
||||
|
||||
return (engine._create_completion(model.name, messages, stream, **kwargs)
|
||||
if stream else ''.join(engine._create_completion(model.name, messages, stream, **kwargs)))
|
||||
|
|
|
@ -152,11 +152,42 @@ class Model:
|
|||
name: str = 'llama-13b'
|
||||
base_provider: str = 'huggingface'
|
||||
best_provider: Provider.Provider = Provider.H2o
|
||||
|
||||
class gpt_35_turbo_16k:
|
||||
name: str = 'gpt-3.5-turbo-16k'
|
||||
base_provider: str = 'openai'
|
||||
best_provider: Provider.Provider = Provider.EasyChat
|
||||
|
||||
class gpt_35_turbo_0613:
|
||||
name: str = 'gpt-3.5-turbo-0613'
|
||||
base_provider: str = 'openai'
|
||||
best_provider: Provider.Provider = Provider.EasyChat
|
||||
|
||||
class gpt_35_turbo_16k_0613:
|
||||
name: str = 'gpt-3.5-turbo-16k-0613'
|
||||
base_provider: str = 'openai'
|
||||
best_provider: Provider.Provider = Provider.EasyChat
|
||||
|
||||
class gpt_4_32k:
|
||||
name: str = 'gpt-4-32k'
|
||||
base_provider: str = 'openai'
|
||||
best_provider = None
|
||||
|
||||
class gpt_4_0613:
|
||||
name: str = 'gpt-4-0613'
|
||||
base_provider: str = 'openai'
|
||||
best_provider = None
|
||||
|
||||
class ModelUtils:
|
||||
convert: dict = {
|
||||
'gpt-3.5-turbo': Model.gpt_35_turbo,
|
||||
'gpt-3.6-turbo-16k': Model.gpt_35_turbo_16k,
|
||||
'gpt-3.5-turbo-0613': Model.gpt_35_turbo_0613,
|
||||
'gpt-3.5-turbo-16k-0613': Model.gpt_35_turbo_16k_0613,
|
||||
|
||||
'gpt-4': Model.gpt_4,
|
||||
'gpt-4-32k': Model.gpt_4_32k,
|
||||
'gpt-4-0613': Model.gpt_4_0613,
|
||||
|
||||
'claude-instant-v1-100k': Model.claude_instant_v1_100k,
|
||||
'claude-v1-100k': Model.claude_v1_100k,
|
||||
|
|
|
@ -2,7 +2,7 @@ import g4f
|
|||
|
||||
# Set with provider
|
||||
stream = False
|
||||
response = g4f.ChatCompletion.create(model='gpt-3.5-turbo', provider=g4f.Provider.ChatgptLogin, messages=[
|
||||
response = g4f.ChatCompletion.create(model='gpt-3.5-turbo', provider=g4f.Provider.Yqcloud, messages=[
|
||||
{"role": "user", "content": "hello"}], stream=stream)
|
||||
|
||||
if stream:
|
||||
|
|
Loading…
Reference in New Issue