minor fixes

pull/753/head
abc 12 months ago
parent 76c7be3172
commit e946729736

@ -5,6 +5,7 @@ url = None
model = None model = None
supports_stream = False supports_stream = False
needs_auth = False needs_auth = False
working = False
def _create_completion(model: str, messages: list, stream: bool, **kwargs): def _create_completion(model: str, messages: list, stream: bool, **kwargs):
return return

@ -6,6 +6,8 @@ url = "https://www.aitianhu.com/api/chat-process"
model = ['gpt-3.5-turbo'] model = ['gpt-3.5-turbo']
supports_stream = False supports_stream = False
needs_auth = False needs_auth = False
working = True
def _create_completion(model: str, messages: list, stream: bool, **kwargs): def _create_completion(model: str, messages: list, stream: bool, **kwargs):
base = '' base = ''

@ -6,6 +6,7 @@ url = "https://chat.acytoo.com/api/completions"
model = ['gpt-3.5-turbo'] model = ['gpt-3.5-turbo']
supports_stream = False supports_stream = False
needs_auth = False needs_auth = False
working = False
def _create_completion(model: str, messages: list, stream: bool, **kwargs): def _create_completion(model: str, messages: list, stream: bool, **kwargs):
base = '' base = ''

@ -6,6 +6,7 @@ url = "https://aiservice.vercel.app/api/chat/answer"
model = ['gpt-3.5-turbo'] model = ['gpt-3.5-turbo']
supports_stream = False supports_stream = False
needs_auth = False needs_auth = False
working = True
def _create_completion(model: str, messages: list, stream: bool, **kwargs): 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'] model = ['gpt-3.5-turbo']
supports_stream = False supports_stream = False
needs_auth = False needs_auth = False
working = True
def _create_completion(model: str, messages: list, stream: bool, **kwargs): def _create_completion(model: str, messages: list, stream: bool, **kwargs):
base = '' base = ''

@ -13,6 +13,8 @@ url: str = 'https://ai.ls'
model: str = 'gpt-3.5-turbo' model: str = 'gpt-3.5-turbo'
supports_stream = True supports_stream = True
needs_auth = False needs_auth = False
working = True
class Utils: class Utils:
def hash(json_data: Dict[str, str]) -> sha256: def hash(json_data: Dict[str, str]) -> sha256:

@ -5,6 +5,8 @@ url = 'https://bard.google.com'
model = ['Palm2'] model = ['Palm2']
supports_stream = False supports_stream = False
needs_auth = True needs_auth = True
working = True
def _create_completion(model: str, messages: list, stream: bool, **kwargs): def _create_completion(model: str, messages: list, stream: bool, **kwargs):
psid = {cookie.name: cookie.value for cookie in browser_cookie3.chrome( psid = {cookie.name: cookie.value for cookie in browser_cookie3.chrome(

@ -16,6 +16,7 @@ url = 'https://bing.com/chat'
model = ['gpt-4'] model = ['gpt-4']
supports_stream = True supports_stream = True
needs_auth = False needs_auth = False
working = True
ssl_context = ssl.create_default_context() ssl_context = ssl.create_default_context()
ssl_context.load_verify_locations(certifi.where()) ssl_context.load_verify_locations(certifi.where())

@ -7,6 +7,8 @@ url = 'https://b.ai-huan.xyz'
model = ['gpt-3.5-turbo', 'gpt-4'] model = ['gpt-3.5-turbo', 'gpt-4']
supports_stream = True supports_stream = True
needs_auth = False needs_auth = False
working = False
def _create_completion(model: str, messages: list, stream: bool, **kwargs): def _create_completion(model: str, messages: list, stream: bool, **kwargs):
path = os.path.dirname(os.path.realpath(__file__)) path = os.path.dirname(os.path.realpath(__file__))

@ -6,6 +6,8 @@ url = 'https://chatgpt.ai/gpt-4/'
model = ['gpt-4'] model = ['gpt-4']
supports_stream = False supports_stream = False
needs_auth = False needs_auth = False
working = True
def _create_completion(model: str, messages: list, stream: bool, **kwargs): def _create_completion(model: str, messages: list, stream: bool, **kwargs):
chat = '' chat = ''

@ -8,7 +8,7 @@ url = 'https://chatgptlogin.ac'
model = ['gpt-3.5-turbo'] model = ['gpt-3.5-turbo']
supports_stream = False supports_stream = False
needs_auth = False needs_auth = False
working = False
def _create_completion(model: str, messages: list, stream: bool, **kwargs): def _create_completion(model: str, messages: list, stream: bool, **kwargs):
def get_nonce(): def get_nonce():

@ -4,41 +4,45 @@ import json
url = "https://chat.dfehub.com/api/chat" url = "https://chat.dfehub.com/api/chat"
model = ['gpt-3.5-turbo'] model = ['gpt-3.5-turbo']
supports_stream = False supports_stream = True
needs_auth = False 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:'
def _create_completion(model: str, messages: list, stream: bool, **kwargs):
headers = { 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": { json_data = {
"id": "gpt-3.5-turbo", 'messages': messages,
"name": "GPT-3.5", 'model': 'gpt-3.5-turbo',
"maxLength": 12000, 'temperature': 0.5,
"tokenLimit": 4000 'presence_penalty': 0,
}, 'frequency_penalty': 0,
"messages": [ 'top_p': 1,
{
"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
} }
response = requests.post(url, headers=headers, data=json.dumps(data))
if response.status_code == 200: response = requests.post('https://chat.dfehub.com/api/openai/v1/chat/completions',
yield response.text headers=headers, json=json_data)
else:
print(f"Error Occurred::{response.status_code}") for chunk in response.iter_lines():
return None 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: ' + \ 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]]) '(%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'] model = ['gpt-3.5-turbo']
supports_stream = True supports_stream = True
needs_auth = False needs_auth = False
working = True
def _create_completion(model: str, messages: list, stream: bool, **kwargs): def _create_completion(model: str, messages: list, stream: bool, **kwargs):
def md5(text: str) -> str: def md5(text: str) -> str:

@ -2,42 +2,51 @@ import os, requests
from ...typing import sha256, Dict, get_type_hints from ...typing import sha256, Dict, get_type_hints
import json import json
url = "https://free.easychat.work/api/openai/v1/chat/completions" url = "https://free.easychat.work"
model = ['gpt-3.5-turbo'] model = ['gpt-3.5-turbo']
supports_stream = False supports_stream = True
needs_auth = False needs_auth = False
working = True
def _create_completion(model: str, messages: list, stream: bool, **kwargs): 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 = { 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 = { json_data = {
"messages": [ 'messages': messages,
{"role": "system", "content": "You are ChatGPT, a large language model trained by OpenAI."}, 'stream': True,
{"role": "user", "content": base} 'model': model,
], 'temperature': 0.5,
"stream": False, 'presence_penalty': 0,
"model": "gpt-3.5-turbo", 'frequency_penalty': 0,
"temperature": 0.5, 'top_p': 1,
"presence_penalty": 0,
"frequency_penalty": 0,
"top_p": 1
} }
response = requests.post(url, headers=headers, json=data) response = requests.post('https://free.easychat.work/api/openai/v1/chat/completions',
if response.status_code == 200: headers=headers, json=json_data)
response = response.json()
yield response['choices'][0]['message']['content'] for chunk in response.iter_lines():
else: if b'content' in chunk:
print(f"Error Occurred::{response.status_code}") data = json.loads(chunk.decode().split('data: ')[1])
return None yield (data['choices'][0]['delta']['content'])
params = f'g4f.Providers.{os.path.basename(__file__)[:-3]} supports: ' + \ 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]]) '(%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'] model = ['gpt-3.5-turbo']
supports_stream = True supports_stream = True
needs_auth = False needs_auth = False
working = False
def _create_completion(model: str, messages: list, stream: bool, **kwargs): def _create_completion(model: str, messages: list, stream: bool, **kwargs):
json_data = { json_data = {

@ -9,6 +9,8 @@ url = 'https://chat.getgpt.world/'
model = ['gpt-3.5-turbo'] model = ['gpt-3.5-turbo']
supports_stream = True supports_stream = True
needs_auth = False needs_auth = False
working = True
def _create_completion(model: str, messages: list, stream: bool, **kwargs): def _create_completion(model: str, messages: list, stream: bool, **kwargs):
def encrypt(e): def encrypt(e):

@ -10,6 +10,7 @@ url = 'https://gpt-gm.h2o.ai'
model = ['falcon-40b', 'falcon-7b', 'llama-13b'] model = ['falcon-40b', 'falcon-7b', 'llama-13b']
supports_stream = True supports_stream = True
needs_auth = False needs_auth = False
working = True
models = { models = {
'falcon-7b': 'h2oai/h2ogpt-gm-oasst1-en-2048-falcon-7b-v3', '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): def _create_completion(model: str, messages: list, stream: bool, **kwargs):
conversation = '' conversation = ''
for message in messages: for message in messages:
conversation += '%s: %s\n' % (message['role'], message['content']) 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) response = session.post("https://gpt-gm.h2o.ai/settings", headers=headers, data=data)
headers = { headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/115.0", "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/115.0",
"Accept": "*/*", "Accept": "*/*",

@ -5,6 +5,7 @@ url = 'https://liaobots.com'
model = ['gpt-3.5-turbo', 'gpt-4'] model = ['gpt-3.5-turbo', 'gpt-4']
supports_stream = True supports_stream = True
needs_auth = True needs_auth = True
working = False
models = { models = {
'gpt-4': { 'gpt-4': {

@ -6,6 +6,7 @@ url = 'http://supertest.lockchat.app'
model = ['gpt-4', 'gpt-3.5-turbo'] model = ['gpt-4', 'gpt-3.5-turbo']
supports_stream = True supports_stream = True
needs_auth = False needs_auth = False
working = False
def _create_completion(model: str, messages: list, stream: bool, temperature: float = 0.7, **kwargs): 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'] model = ['gpt-3.5-turbo']
supports_stream = True supports_stream = True
needs_auth = False needs_auth = False
working = False
def _create_completion(model: str, messages: list, stream: bool, **kwargs): 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' url = 'https://play.vercel.ai'
supports_stream = True supports_stream = True
needs_auth = False needs_auth = False
working = False
models = { models = {
'claude-instant-v1': 'anthropic:claude-instant-v1', 'claude-instant-v1': 'anthropic:claude-instant-v1',
@ -143,8 +144,6 @@ class Client:
index = len(lines) - 1 index = len(lines) - 1
def _create_completion(model: str, messages: list, stream: bool, **kwargs): 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' 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'] model = ['gpt-3.5-turbo']
supports_stream = False supports_stream = False
needs_auth = False needs_auth = False
working = False
def _create_completion(model: str, messages: list, stream: bool, **kwargs): def _create_completion(model: str, messages: list, stream: bool, **kwargs):
base = '' base = ''

@ -9,6 +9,7 @@ url = 'https://you.com'
model = 'gpt-3.5-turbo' model = 'gpt-3.5-turbo'
supports_stream = True supports_stream = True
needs_auth = False needs_auth = False
working = False
def _create_completion(model: str, messages: list, stream: bool, **kwargs): def _create_completion(model: str, messages: list, stream: bool, **kwargs):

@ -9,6 +9,7 @@ model = [
] ]
supports_stream = True supports_stream = True
needs_auth = False needs_auth = False
working = False
def _create_completion(model: str, messages: list, stream: bool, **kwargs): def _create_completion(model: str, messages: list, stream: bool, **kwargs):

@ -18,7 +18,7 @@ from .Providers import (
AItianhu, AItianhu,
EasyChat, EasyChat,
Acytoo, Acytoo,
DFEHub, DfeHub,
AiService, AiService,
BingHuan, BingHuan,
Wewordle, Wewordle,

@ -2,11 +2,14 @@ import sys
from . import Provider from . import Provider
from g4f.models import Model, ModelUtils from g4f.models import Model, ModelUtils
logging = False
class ChatCompletion: class ChatCompletion:
@staticmethod @staticmethod
def create(model: Model.model or str, messages: list, provider: Provider.Provider = None, stream: bool = False, auth: str = False, **kwargs): def create(model: Model.model or str, messages: list, provider: Provider.Provider = None, stream: bool = False, auth: str = False, **kwargs):
kwargs['auth'] = auth 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: if provider and provider.needs_auth and not auth:
print( print(
@ -27,7 +30,7 @@ class ChatCompletion:
f"ValueError: {engine.__name__} does not support 'stream' argument", file=sys.stderr) f"ValueError: {engine.__name__} does not support 'stream' argument", file=sys.stderr)
sys.exit(1) 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) return (engine._create_completion(model.name, messages, stream, **kwargs)
if stream else ''.join(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' name: str = 'llama-13b'
base_provider: str = 'huggingface' base_provider: str = 'huggingface'
best_provider: Provider.Provider = Provider.H2o 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: class ModelUtils:
convert: dict = { convert: dict = {
'gpt-3.5-turbo': Model.gpt_35_turbo, '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': 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-instant-v1-100k': Model.claude_instant_v1_100k,
'claude-v1-100k': Model.claude_v1_100k, 'claude-v1-100k': Model.claude_v1_100k,

@ -2,7 +2,7 @@ import g4f
# Set with provider # Set with provider
stream = False 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) {"role": "user", "content": "hello"}], stream=stream)
if stream: if stream:

Loading…
Cancel
Save