summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorabc <98614666+xtekky@users.noreply.github.com>2023-08-14 01:02:01 +0200
committerabc <98614666+xtekky@users.noreply.github.com>2023-08-14 01:02:01 +0200
commitd53fc931a3cb059851eae7f4ffc1f515d4091998 (patch)
treea7f36371063e34abe98679ee358ce3479271ae01
parentMerge pull request #801 from johnd0e/fix-ails (diff)
downloadgpt4free-d53fc931a3cb059851eae7f4ffc1f515d4091998.tar
gpt4free-d53fc931a3cb059851eae7f4ffc1f515d4091998.tar.gz
gpt4free-d53fc931a3cb059851eae7f4ffc1f515d4091998.tar.bz2
gpt4free-d53fc931a3cb059851eae7f4ffc1f515d4091998.tar.lz
gpt4free-d53fc931a3cb059851eae7f4ffc1f515d4091998.tar.xz
gpt4free-d53fc931a3cb059851eae7f4ffc1f515d4091998.tar.zst
gpt4free-d53fc931a3cb059851eae7f4ffc1f515d4091998.zip
Diffstat (limited to '')
-rw-r--r--.gitignore1
-rw-r--r--g4f/Provider/Providers/Vercel.py110
-rw-r--r--g4f/__init__.py2
-rw-r--r--g4f/models.py5
-rw-r--r--setup.py2
5 files changed, 115 insertions, 5 deletions
diff --git a/.gitignore b/.gitignore
index 03f73c6d..cb63eefd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -35,6 +35,7 @@ dist/
*.egg-info
build
test.py
+update.py
# Emacs crap
*~ \ No newline at end of file
diff --git a/g4f/Provider/Providers/Vercel.py b/g4f/Provider/Providers/Vercel.py
index 03d9be17..f9331bfc 100644
--- a/g4f/Provider/Providers/Vercel.py
+++ b/g4f/Provider/Providers/Vercel.py
@@ -42,6 +42,116 @@ vercel_models = {'anthropic:claude-instant-v1': {'id': 'anthropic:claude-instant
'id': 'huggingface:bigcode/santacoder', 'provider': 'huggingface', 'providerHumanName': 'HuggingFace', 'makerHumanName': 'BigCode', 'instructions': 'The model was trained on GitHub code. As such it is not an instruction model and commands like "Write a function that computes the square root." do not work well. You should phrase commands like they occur in source code such as comments (e.g. # the following function computes the sqrt) or write a function signature and docstring and let the model complete the function body.', 'parameters': {'temperature': {'value': 0.5, 'range': [0.1, 1]}, 'maximumLength': {'value': 200, 'range': [50, 1024]}, 'topP': {'value': 0.95, 'range': [0.01, 0.99]}, 'topK': {'value': 4, 'range': [1, 500]}, 'repetitionPenalty': {'value': 1.03, 'range': [0.1, 2]}}, 'name': 'santacoder'}, 'cohere:command-medium-nightly': {'id': 'cohere:command-medium-nightly', 'provider': 'cohere', 'providerHumanName': 'Cohere', 'makerHumanName': 'Cohere', 'name': 'command-medium-nightly', 'parameters': {'temperature': {'value': 0.9, 'range': [0, 2]}, 'maximumLength': {'value': 200, 'range': [50, 1024]}, 'topP': {'value': 1, 'range': [0, 1]}, 'topK': {'value': 0, 'range': [0, 500]}, 'presencePenalty': {'value': 0, 'range': [0, 1]}, 'frequencyPenalty': {'value': 0, 'range': [0, 1]}, 'stopSequences': {'value': [], 'range': []}}}, 'cohere:command-xlarge-nightly': {'id': 'cohere:command-xlarge-nightly', 'provider': 'cohere', 'providerHumanName': 'Cohere', 'makerHumanName': 'Cohere', 'name': 'command-xlarge-nightly', 'parameters': {'temperature': {'value': 0.9, 'range': [0, 2]}, 'maximumLength': {'value': 200, 'range': [50, 1024]}, 'topP': {'value': 1, 'range': [0, 1]}, 'topK': {'value': 0, 'range': [0, 500]}, 'presencePenalty': {'value': 0, 'range': [0, 1]}, 'frequencyPenalty': {'value': 0, 'range': [0, 1]}, 'stopSequences': {'value': [], 'range': []}}}, 'openai:gpt-4': {'id': 'openai:gpt-4', 'provider': 'openai', 'providerHumanName': 'OpenAI', 'makerHumanName': 'OpenAI', 'name': 'gpt-4', 'minBillingTier': 'pro', 'parameters': {'temperature': {'value': 0.7, 'range': [0.1, 1]}, 'maximumLength': {'value': 200, 'range': [50, 1024]}, 'topP': {'value': 1, 'range': [0.1, 1]}, 'presencePenalty': {'value': 0, 'range': [0, 1]}, 'frequencyPenalty': {'value': 0, 'range': [0, 1]}, 'stopSequences': {'value': [], 'range': []}}}, 'openai:code-cushman-001': {'id': 'openai:code-cushman-001', 'provider': 'openai', 'providerHumanName': 'OpenAI', 'makerHumanName': 'OpenAI', 'parameters': {'temperature': {'value': 0.5, 'range': [0.1, 1]}, 'maximumLength': {'value': 200, 'range': [50, 1024]}, 'topP': {'value': 1, 'range': [0.1, 1]}, 'presencePenalty': {'value': 0, 'range': [0, 1]}, 'frequencyPenalty': {'value': 0, 'range': [0, 1]}, 'stopSequences': {'value': [], 'range': []}}, 'name': 'code-cushman-001'}, 'openai:code-davinci-002': {'id': 'openai:code-davinci-002', 'provider': 'openai', 'providerHumanName': 'OpenAI', 'makerHumanName': 'OpenAI', 'parameters': {'temperature': {'value': 0.5, 'range': [0.1, 1]}, 'maximumLength': {'value': 200, 'range': [50, 1024]}, 'topP': {'value': 1, 'range': [0.1, 1]}, 'presencePenalty': {'value': 0, 'range': [0, 1]}, 'frequencyPenalty': {'value': 0, 'range': [0, 1]}, 'stopSequences': {'value': [], 'range': []}}, 'name': 'code-davinci-002'}, 'openai:gpt-3.5-turbo': {'id': 'openai:gpt-3.5-turbo', 'provider': 'openai', 'providerHumanName': 'OpenAI', 'makerHumanName': 'OpenAI', 'parameters': {'temperature': {'value': 0.7, 'range': [0, 1]}, 'maximumLength': {'value': 200, 'range': [50, 1024]}, 'topP': {'value': 1, 'range': [0.1, 1]}, 'topK': {'value': 1, 'range': [1, 500]}, 'presencePenalty': {'value': 1, 'range': [0, 1]}, 'frequencyPenalty': {'value': 1, 'range': [0, 1]}, 'stopSequences': {'value': [], 'range': []}}, 'name': 'gpt-3.5-turbo'}, 'openai:text-ada-001': {'id': 'openai:text-ada-001', 'provider': 'openai', 'providerHumanName': 'OpenAI', 'makerHumanName': 'OpenAI', 'name': 'text-ada-001', 'parameters': {'temperature': {'value': 0.5, 'range': [0.1, 1]}, 'maximumLength': {'value': 200, 'range': [50, 1024]}, 'topP': {'value': 1, 'range': [0.1, 1]}, 'presencePenalty': {'value': 0, 'range': [0, 1]}, 'frequencyPenalty': {'value': 0, 'range': [0, 1]}, 'stopSequences': {'value': [], 'range': []}}}, 'openai:text-babbage-001': {'id': 'openai:text-babbage-001', 'provider': 'openai', 'providerHumanName': 'OpenAI', 'makerHumanName': 'OpenAI', 'name': 'text-babbage-001', 'parameters': {'temperature': {'value': 0.5, 'range': [0.1, 1]}, 'maximumLength': {'value': 200, 'range': [50, 1024]}, 'topP': {'value': 1, 'range': [0.1, 1]}, 'presencePenalty': {'value': 0, 'range': [0, 1]}, 'frequencyPenalty': {'value': 0, 'range': [0, 1]}, 'stopSequences': {'value': [], 'range': []}}}, 'openai:text-curie-001': {'id': 'openai:text-curie-001', 'provider': 'openai', 'providerHumanName': 'OpenAI', 'makerHumanName': 'OpenAI', 'name': 'text-curie-001', 'parameters': {'temperature': {'value': 0.5, 'range': [0.1, 1]}, 'maximumLength': {'value': 200, 'range': [50, 1024]}, 'topP': {'value': 1, 'range': [0.1, 1]}, 'presencePenalty': {'value': 0, 'range': [0, 1]}, 'frequencyPenalty': {'value': 0, 'range': [0, 1]}, 'stopSequences': {'value': [], 'range': []}}}, 'openai:text-davinci-002': {'id': 'openai:text-davinci-002', 'provider': 'openai', 'providerHumanName': 'OpenAI', 'makerHumanName': 'OpenAI', 'name': 'text-davinci-002', 'parameters': {'temperature': {'value': 0.5, 'range': [0.1, 1]}, 'maximumLength': {'value': 200, 'range': [50, 1024]}, 'topP': {'value': 1, 'range': [0.1, 1]}, 'presencePenalty': {'value': 0, 'range': [0, 1]}, 'frequencyPenalty': {'value': 0, 'range': [0, 1]}, 'stopSequences': {'value': [], 'range': []}}}, 'openai:text-davinci-003': {'id': 'openai:text-davinci-003', 'provider': 'openai', 'providerHumanName': 'OpenAI', 'makerHumanName': 'OpenAI', 'name': 'text-davinci-003', 'parameters': {'temperature': {'value': 0.5, 'range': [0.1, 1]}, 'maximumLength': {'value': 200, 'range': [50, 1024]}, 'topP': {'value': 1, 'range': [0.1, 1]}, 'presencePenalty': {'value': 0, 'range': [0, 1]}, 'frequencyPenalty': {'value': 0, 'range': [0, 1]}, 'stopSequences': {'value': [], 'range': []}}}}
+# import requests
+# import execjs
+# import ubox
+# import json
+# import re
+
+
+# html = requests.get('https://sdk.vercel.ai/').text
+# paths_regex = r'static\/chunks.+?\.js'
+# separator_regex = r'"\]\)<\/script><script>self\.__next_f\.push\(\[.,"'
+
+# paths = re.findall(paths_regex, html)
+# for i in range(len(paths)):
+# paths[i] = re.sub(separator_regex, "", paths[i])
+# paths = list(set(paths))
+# print(paths)
+
+# scripts = []
+# threads = []
+
+# print(f"Downloading and parsing scripts...")
+# def download_thread(path):
+# script_url = f"{self.base_url}/_next/{path}"
+# script = self.session.get(script_url).text
+# scripts.append(script)
+
+# for path in paths:
+# thread = threading.Thread(target=download_thread, args=(path,), daemon=True)
+# thread.start()
+# threads.append(thread)
+
+# for thread in threads:
+# thread.join()
+
+# for script in scripts:
+# models_regex = r'let .="\\n\\nHuman:\",r=(.+?),.='
+# matches = re.findall(models_regex, script)
+
+# if matches:
+# models_str = matches[0]
+# stop_sequences_regex = r'(?<=stopSequences:{value:\[)\D(?<!\])'
+# models_str = re.sub(stop_sequences_regex, re.escape('"\\n\\nHuman:"'), models_str)
+
+# context = quickjs.Context()
+# json_str = context.eval(f"({models_str})").json()
+# #return json.loads(json_str)
+
+# quit()
+# headers = {
+# 'authority': 'sdk.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',
+# 'origin': 'https://sdk.vercel.ai',
+# 'referer': 'https://sdk.vercel.ai/',
+# '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'
+# }
+
+# response = requests.get('https://sdk.vercel.ai/openai.jpeg', headers=headers)
+
+# data = (json.loads(ubox.b64dec(response.text)))
+
+# script = 'globalThis={data: "sentinel"};a=()=>{return (%s)(%s)}' % (data['c'], data['a'])
+
+# token_data = execjs.compile(script).call('a')
+# print(token_data)
+
+# token = {
+# 'r': token_data,
+# 't': data["t"]
+# }
+
+# botToken = ubox.b64enc(json.dumps(token, separators=(',', ':')))
+# print(botToken)
+
+# import requests
+
+# headers['custom-encoding'] = botToken
+
+# json_data = {
+# 'messages': [
+# {
+# 'role': 'user',
+# 'content': 'hello',
+# },
+# ],
+# 'playgroundId': ubox.uuid4(),
+# 'chatIndex': 0,
+# 'model': 'openai:gpt-3.5-turbo',
+# 'temperature': 0.7,
+# 'maxTokens': 500,
+# 'topK': 1,
+# 'topP': 1,
+# 'frequencyPenalty': 1,
+# 'presencePenalty': 1,
+# 'stopSequences': []
+# }
+
+# response = requests.post('https://sdk.vercel.ai/api/generate',
+# headers=headers, json=json_data, stream=True)
+
+# for token in response.iter_content(chunk_size=2046):
+# print(token)
+
def _create_completion(model: str, messages: list, stream: bool, **kwargs):
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'
diff --git a/g4f/__init__.py b/g4f/__init__.py
index e5d3d4bf..d04d2c78 100644
--- a/g4f/__init__.py
+++ b/g4f/__init__.py
@@ -6,7 +6,7 @@ logging = False
class ChatCompletion:
@staticmethod
- def create(model: models.Model | str, messages: list, provider: Provider.Provider = None, stream: bool = False, auth: str = False, **kwargs):
+ def create(model: models.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'
diff --git a/g4f/models.py b/g4f/models.py
index 3a049614..27336244 100644
--- a/g4f/models.py
+++ b/g4f/models.py
@@ -7,13 +7,12 @@ from dataclasses import dataclass
class Model:
name: str
base_provider: str
- best_provider: ModuleType | None
-
+ best_provider: ModuleType or None
gpt_35_turbo = Model(
name="gpt-3.5-turbo",
base_provider="openai",
- best_provider=Provider.Forefront,
+ best_provider=Provider.GetGpt,
)
gpt_4 = Model(
diff --git a/setup.py b/setup.py
index 2843d869..f7f1e247 100644
--- a/setup.py
+++ b/setup.py
@@ -10,7 +10,7 @@ with codecs.open(os.path.join(here, "README.md"), encoding="utf-8") as fh:
with open('requirements.txt') as f:
required = f.read().splitlines()
-VERSION = '0.0.1.4'
+VERSION = '0.0.1.9'
DESCRIPTION = 'The official gpt4free repository | various collection of powerful language models'
# Setting up