starsaround commited on
Commit
50ee399
1 Parent(s): 80250d2

Upload 201 files

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. g4f/.v1/requirements.txt +6 -2
  2. g4f/Provider/Provider.py +1 -0
  3. g4f/Provider/Providers/AItianhu.py +38 -0
  4. g4f/Provider/Providers/Acytoo.py +42 -0
  5. g4f/Provider/Providers/AiService.py +41 -0
  6. g4f/Provider/Providers/Aichat.py +1 -0
  7. g4f/Provider/Providers/Ails.py +4 -2
  8. g4f/Provider/Providers/Bard.py +2 -0
  9. g4f/Provider/Providers/Bing.py +1 -0
  10. g4f/Provider/Providers/BingHuan.py +28 -0
  11. g4f/Provider/Providers/ChatgptAi.py +3 -2
  12. g4f/Provider/Providers/ChatgptLogin.py +2 -2
  13. g4f/Provider/Providers/DeepAi.py +2 -0
  14. g4f/Provider/Providers/DfeHub.py +56 -0
  15. g4f/Provider/Providers/EasyChat.py +52 -0
  16. g4f/Provider/Providers/Forefront.py +2 -0
  17. g4f/Provider/Providers/GetGpt.py +2 -0
  18. g4f/Provider/Providers/H2o.py +61 -73
  19. g4f/Provider/Providers/Liaobots.py +1 -0
  20. g4f/Provider/Providers/Lockchat.py +4 -3
  21. g4f/Provider/Providers/Theb.py +2 -1
  22. g4f/Provider/Providers/Vercel.py +8 -110
  23. g4f/Provider/Providers/Wewordle.py +73 -0
  24. g4f/Provider/Providers/You.py +1 -0
  25. g4f/Provider/Providers/Yqcloud.py +1 -0
  26. g4f/Provider/Providers/__init__.py +0 -0
  27. g4f/Provider/Providers/__pycache__/AItianhu.cpython-311.pyc +0 -0
  28. g4f/Provider/Providers/__pycache__/Acytoo.cpython-311.pyc +0 -0
  29. g4f/Provider/Providers/__pycache__/AiService.cpython-311.pyc +0 -0
  30. g4f/Provider/Providers/__pycache__/Aichat.cpython-311.pyc +0 -0
  31. g4f/Provider/Providers/__pycache__/Aichat.cpython-38.pyc +0 -0
  32. g4f/Provider/Providers/__pycache__/Ails.cpython-311.pyc +0 -0
  33. g4f/Provider/Providers/__pycache__/Ails.cpython-38.pyc +0 -0
  34. g4f/Provider/Providers/__pycache__/Bard.cpython-311.pyc +0 -0
  35. g4f/Provider/Providers/__pycache__/Bard.cpython-38.pyc +0 -0
  36. g4f/Provider/Providers/__pycache__/Bing.cpython-311.pyc +0 -0
  37. g4f/Provider/Providers/__pycache__/Bing.cpython-38.pyc +0 -0
  38. g4f/Provider/Providers/__pycache__/BingHuan.cpython-311.pyc +0 -0
  39. g4f/Provider/Providers/__pycache__/ChatgptAi.cpython-311.pyc +0 -0
  40. g4f/Provider/Providers/__pycache__/ChatgptLogin.cpython-311.pyc +0 -0
  41. g4f/Provider/Providers/__pycache__/DeepAi.cpython-311.pyc +0 -0
  42. g4f/Provider/Providers/__pycache__/DfeHub.cpython-311.pyc +0 -0
  43. g4f/Provider/Providers/__pycache__/EasyChat.cpython-311.pyc +0 -0
  44. g4f/Provider/Providers/__pycache__/Forefront.cpython-311.pyc +0 -0
  45. g4f/Provider/Providers/__pycache__/GetGpt.cpython-311.pyc +0 -0
  46. g4f/Provider/Providers/__pycache__/H2o.cpython-311.pyc +0 -0
  47. g4f/Provider/Providers/__pycache__/Liaobots.cpython-311.pyc +0 -0
  48. g4f/Provider/Providers/__pycache__/Lockchat.cpython-311.pyc +0 -0
  49. g4f/Provider/Providers/__pycache__/Theb.cpython-311.pyc +0 -0
  50. g4f/Provider/Providers/__pycache__/Theb.cpython-38.pyc +0 -0
g4f/.v1/requirements.txt CHANGED
@@ -5,11 +5,13 @@ pypasser
5
  names
6
  colorama
7
  curl_cffi
 
 
 
8
  streamlit
9
  selenium
10
  fake-useragent
11
  twocaptcha
12
- https://github.com/AI-Yash/st-chat/archive/refs/pull/24/head.zip
13
  pydantic
14
  pymailtm
15
  Levenshtein
@@ -18,4 +20,6 @@ mailgw_temporary_email
18
  pycryptodome
19
  random-password-generator
20
  numpy>=1.22.2 # not directly required, pinned by Snyk to avoid a vulnerability
21
- tornado>=6.3.2 # not directly required, pinned by Snyk to avoid a vulnerability
 
 
 
5
  names
6
  colorama
7
  curl_cffi
8
+ aiohttp
9
+ flask
10
+ flask_cors
11
  streamlit
12
  selenium
13
  fake-useragent
14
  twocaptcha
 
15
  pydantic
16
  pymailtm
17
  Levenshtein
 
20
  pycryptodome
21
  random-password-generator
22
  numpy>=1.22.2 # not directly required, pinned by Snyk to avoid a vulnerability
23
+ tornado>=6.3.2 # not directly required, pinned by Snyk to avoid a vulnerability
24
+ PyExecJS
25
+ browser_cookie3
g4f/Provider/Provider.py CHANGED
@@ -5,6 +5,7 @@ url = None
5
  model = None
6
  supports_stream = False
7
  needs_auth = False
 
8
 
9
  def _create_completion(model: str, messages: list, stream: bool, **kwargs):
10
  return
 
5
  model = None
6
  supports_stream = False
7
  needs_auth = False
8
+ working = False
9
 
10
  def _create_completion(model: str, messages: list, stream: bool, **kwargs):
11
  return
g4f/Provider/Providers/AItianhu.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os, requests
2
+ from ...typing import sha256, Dict, get_type_hints
3
+ import json
4
+
5
+ url = "https://www.aitianhu.com/api/chat-process"
6
+ model = ['gpt-3.5-turbo']
7
+ supports_stream = False
8
+ needs_auth = False
9
+ working = True
10
+
11
+
12
+ def _create_completion(model: str, messages: list, stream: bool, **kwargs):
13
+ base = ''
14
+ for message in messages:
15
+ base += '%s: %s\n' % (message['role'], message['content'])
16
+ base += 'assistant:'
17
+
18
+ headers = {
19
+ "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"
20
+ }
21
+ data = {
22
+ "prompt": base,
23
+ "options": {},
24
+ "systemMessage": "You are ChatGPT, a large language model trained by OpenAI. Follow the user's instructions carefully. Respond using markdown.",
25
+ "temperature": kwargs.get("temperature", 0.8),
26
+ "top_p": kwargs.get("top_p", 1)
27
+ }
28
+ response = requests.post(url, headers=headers, json=data)
29
+ if response.status_code == 200:
30
+ lines = response.text.strip().split('\n')
31
+ res = json.loads(lines[-1])
32
+ yield res['text']
33
+ else:
34
+ print(f"Error Occurred::{response.status_code}")
35
+ return None
36
+
37
+ params = f'g4f.Providers.{os.path.basename(__file__)[:-3]} supports: ' + \
38
+ '(%s)' % ', '.join([f"{name}: {get_type_hints(_create_completion)[name].__name__}" for name in _create_completion.__code__.co_varnames[:_create_completion.__code__.co_argcount]])
g4f/Provider/Providers/Acytoo.py ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os, requests
2
+ from ...typing import sha256, Dict, get_type_hints
3
+ import json
4
+
5
+ url = "https://chat.acytoo.com/api/completions"
6
+ model = ['gpt-3.5-turbo']
7
+ supports_stream = False
8
+ needs_auth = False
9
+ working = False
10
+
11
+ def _create_completion(model: str, messages: list, stream: bool, **kwargs):
12
+ base = ''
13
+ for message in messages:
14
+ base += '%s: %s\n' % (message['role'], message['content'])
15
+ base += 'assistant:'
16
+
17
+ headers = {
18
+ "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"
19
+ }
20
+ data = {
21
+ "key": "",
22
+ "model": "gpt-3.5-turbo",
23
+ "messages": [
24
+ {
25
+ "role": "user",
26
+ "content": base,
27
+ "createdAt": 1688518523500
28
+ }
29
+ ],
30
+ "temperature": 1,
31
+ "password": ""
32
+ }
33
+
34
+ response = requests.post(url, headers=headers, data=json.dumps(data))
35
+ if response.status_code == 200:
36
+ yield response.text
37
+ else:
38
+ print(f"Error Occurred::{response.status_code}")
39
+ return None
40
+
41
+ params = f'g4f.Providers.{os.path.basename(__file__)[:-3]} supports: ' + \
42
+ '(%s)' % ', '.join([f"{name}: {get_type_hints(_create_completion)[name].__name__}" for name in _create_completion.__code__.co_varnames[:_create_completion.__code__.co_argcount]])
g4f/Provider/Providers/AiService.py ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os,sys
2
+ import requests
3
+ from ...typing import get_type_hints
4
+
5
+ url = "https://aiservice.vercel.app/api/chat/answer"
6
+ model = ['gpt-3.5-turbo']
7
+ supports_stream = False
8
+ needs_auth = False
9
+ working = True
10
+
11
+
12
+ def _create_completion(model: str, messages: list, stream: bool, **kwargs):
13
+ base = ''
14
+ for message in messages:
15
+ base += '%s: %s\n' % (message['role'], message['content'])
16
+ base += 'assistant:'
17
+
18
+ headers = {
19
+ "accept": "*/*",
20
+ "content-type": "text/plain;charset=UTF-8",
21
+ "sec-fetch-dest": "empty",
22
+ "sec-fetch-mode": "cors",
23
+ "sec-fetch-site": "same-origin",
24
+ "Referer": "https://aiservice.vercel.app/chat",
25
+ }
26
+ data = {
27
+ "input": base
28
+ }
29
+ response = requests.post(url, headers=headers, json=data)
30
+ if response.status_code == 200:
31
+ _json = response.json()
32
+ yield _json['data']
33
+ else:
34
+ print(f"Error Occurred::{response.status_code}")
35
+ return None
36
+
37
+
38
+
39
+ params = f'g4f.Providers.{os.path.basename(__file__)[:-3]} supports: ' + \
40
+ '(%s)' % ', '.join(
41
+ [f"{name}: {get_type_hints(_create_completion)[name].__name__}" for name in _create_completion.__code__.co_varnames[:_create_completion.__code__.co_argcount]])
g4f/Provider/Providers/Aichat.py CHANGED
@@ -5,6 +5,7 @@ url = 'https://chat-gpt.org/chat'
5
  model = ['gpt-3.5-turbo']
6
  supports_stream = False
7
  needs_auth = False
 
8
 
9
  def _create_completion(model: str, messages: list, stream: bool, **kwargs):
10
  base = ''
 
5
  model = ['gpt-3.5-turbo']
6
  supports_stream = False
7
  needs_auth = False
8
+ working = True
9
 
10
  def _create_completion(model: str, messages: list, stream: bool, **kwargs):
11
  base = ''
g4f/Provider/Providers/Ails.py CHANGED
@@ -13,6 +13,8 @@ url: str = 'https://ai.ls'
13
  model: str = 'gpt-3.5-turbo'
14
  supports_stream = True
15
  needs_auth = False
 
 
16
 
17
  class Utils:
18
  def hash(json_data: Dict[str, str]) -> sha256:
@@ -45,7 +47,7 @@ def _create_completion(model: str, messages: list, temperature: float = 0.6, str
45
  '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',
46
  'authorization': 'Bearer free',
47
  'client-id': str(uuid.uuid4()),
48
- 'client-v': '0.1.217',
49
  'content-type': 'application/json',
50
  'origin': 'https://ai.ls',
51
  'referer': 'https://ai.ls/',
@@ -73,7 +75,7 @@ def _create_completion(model: str, messages: list, temperature: float = 0.6, str
73
 
74
  json_data = json.dumps(separators=(',', ':'), obj={
75
  'model': 'gpt-3.5-turbo',
76
- 'temperature': 0.6,
77
  'stream': True,
78
  'messages': messages} | sig)
79
 
 
13
  model: str = 'gpt-3.5-turbo'
14
  supports_stream = True
15
  needs_auth = False
16
+ working = True
17
+
18
 
19
  class Utils:
20
  def hash(json_data: Dict[str, str]) -> sha256:
 
47
  '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',
48
  'authorization': 'Bearer free',
49
  'client-id': str(uuid.uuid4()),
50
+ 'client-v': '0.1.249',
51
  'content-type': 'application/json',
52
  'origin': 'https://ai.ls',
53
  'referer': 'https://ai.ls/',
 
75
 
76
  json_data = json.dumps(separators=(',', ':'), obj={
77
  'model': 'gpt-3.5-turbo',
78
+ 'temperature': temperature,
79
  'stream': True,
80
  'messages': messages} | sig)
81
 
g4f/Provider/Providers/Bard.py CHANGED
@@ -5,6 +5,8 @@ url = 'https://bard.google.com'
5
  model = ['Palm2']
6
  supports_stream = False
7
  needs_auth = True
 
 
8
 
9
  def _create_completion(model: str, messages: list, stream: bool, **kwargs):
10
  psid = {cookie.name: cookie.value for cookie in browser_cookie3.chrome(
 
5
  model = ['Palm2']
6
  supports_stream = False
7
  needs_auth = True
8
+ working = True
9
+
10
 
11
  def _create_completion(model: str, messages: list, stream: bool, **kwargs):
12
  psid = {cookie.name: cookie.value for cookie in browser_cookie3.chrome(
g4f/Provider/Providers/Bing.py CHANGED
@@ -16,6 +16,7 @@ url = 'https://bing.com/chat'
16
  model = ['gpt-4']
17
  supports_stream = True
18
  needs_auth = False
 
19
 
20
  ssl_context = ssl.create_default_context()
21
  ssl_context.load_verify_locations(certifi.where())
 
16
  model = ['gpt-4']
17
  supports_stream = True
18
  needs_auth = False
19
+ working = True
20
 
21
  ssl_context = ssl.create_default_context()
22
  ssl_context.load_verify_locations(certifi.where())
g4f/Provider/Providers/BingHuan.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os,sys
2
+ import json
3
+ import subprocess
4
+ from ...typing import sha256, Dict, get_type_hints
5
+
6
+ url = 'https://b.ai-huan.xyz'
7
+ model = ['gpt-3.5-turbo', 'gpt-4']
8
+ supports_stream = True
9
+ needs_auth = False
10
+ working = False
11
+
12
+
13
+ def _create_completion(model: str, messages: list, stream: bool, **kwargs):
14
+ path = os.path.dirname(os.path.realpath(__file__))
15
+ config = json.dumps({
16
+ 'messages': messages,
17
+ 'model': model}, separators=(',', ':'))
18
+ cmd = ['python', f'{path}/helpers/binghuan.py', config]
19
+
20
+ p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
21
+
22
+ for line in iter(p.stdout.readline, b''):
23
+ yield line.decode('cp1252')
24
+
25
+
26
+ params = f'g4f.Providers.{os.path.basename(__file__)[:-3]} supports: ' + \
27
+ '(%s)' % ', '.join(
28
+ [f"{name}: {get_type_hints(_create_completion)[name].__name__}" for name in _create_completion.__code__.co_varnames[:_create_completion.__code__.co_argcount]])
g4f/Provider/Providers/ChatgptAi.py CHANGED
@@ -6,6 +6,8 @@ url = 'https://chatgpt.ai/gpt-4/'
6
  model = ['gpt-4']
7
  supports_stream = False
8
  needs_auth = False
 
 
9
 
10
  def _create_completion(model: str, messages: list, stream: bool, **kwargs):
11
  chat = ''
@@ -13,8 +15,7 @@ def _create_completion(model: str, messages: list, stream: bool, **kwargs):
13
  chat += '%s: %s\n' % (message['role'], message['content'])
14
  chat += 'assistant: '
15
 
16
- response = requests.get('https://chatgpt.ai/gpt-4/')
17
-
18
  nonce, post_id, _, bot_id = re.findall(r'data-nonce="(.*)"\n data-post-id="(.*)"\n data-url="(.*)"\n data-bot-id="(.*)"\n data-width', response.text)[0]
19
 
20
  headers = {
 
6
  model = ['gpt-4']
7
  supports_stream = False
8
  needs_auth = False
9
+ working = True
10
+
11
 
12
  def _create_completion(model: str, messages: list, stream: bool, **kwargs):
13
  chat = ''
 
15
  chat += '%s: %s\n' % (message['role'], message['content'])
16
  chat += 'assistant: '
17
 
18
+ response = requests.get('https://chatgpt.ai/')
 
19
  nonce, post_id, _, bot_id = re.findall(r'data-nonce="(.*)"\n data-post-id="(.*)"\n data-url="(.*)"\n data-bot-id="(.*)"\n data-width', response.text)[0]
20
 
21
  headers = {
g4f/Provider/Providers/ChatgptLogin.py CHANGED
@@ -8,7 +8,7 @@ url = 'https://chatgptlogin.ac'
8
  model = ['gpt-3.5-turbo']
9
  supports_stream = False
10
  needs_auth = False
11
-
12
 
13
  def _create_completion(model: str, messages: list, stream: bool, **kwargs):
14
  def get_nonce():
@@ -75,7 +75,7 @@ def _create_completion(model: str, messages: list, stream: bool, **kwargs):
75
  'userName': '<div class="mwai-name-text">User:</div>',
76
  'aiName': '<div class="mwai-name-text">AI:</div>',
77
  'model': 'gpt-3.5-turbo',
78
- 'temperature': 0.8,
79
  'maxTokens': 1024,
80
  'maxResults': 1,
81
  'apiKey': '',
 
8
  model = ['gpt-3.5-turbo']
9
  supports_stream = False
10
  needs_auth = False
11
+ working = False
12
 
13
  def _create_completion(model: str, messages: list, stream: bool, **kwargs):
14
  def get_nonce():
 
75
  'userName': '<div class="mwai-name-text">User:</div>',
76
  'aiName': '<div class="mwai-name-text">AI:</div>',
77
  'model': 'gpt-3.5-turbo',
78
+ 'temperature': kwargs.get('temperature', 0.8),
79
  'maxTokens': 1024,
80
  'maxResults': 1,
81
  'apiKey': '',
g4f/Provider/Providers/DeepAi.py CHANGED
@@ -10,6 +10,8 @@ url = 'https://deepai.org'
10
  model = ['gpt-3.5-turbo']
11
  supports_stream = True
12
  needs_auth = False
 
 
13
 
14
  def _create_completion(model: str, messages: list, stream: bool, **kwargs):
15
  def md5(text: str) -> str:
 
10
  model = ['gpt-3.5-turbo']
11
  supports_stream = True
12
  needs_auth = False
13
+ working = True
14
+
15
 
16
  def _create_completion(model: str, messages: list, stream: bool, **kwargs):
17
  def md5(text: str) -> str:
g4f/Provider/Providers/DfeHub.py ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os, requests
2
+ from ...typing import sha256, Dict, get_type_hints
3
+ import json
4
+ import re
5
+ import time
6
+
7
+ url = "https://chat.dfehub.com/api/chat"
8
+ model = ['gpt-3.5-turbo']
9
+ supports_stream = True
10
+ needs_auth = False
11
+ working = True
12
+
13
+
14
+ def _create_completion(model: str, messages: list, stream: bool, **kwargs):
15
+ headers = {
16
+ 'authority': 'chat.dfehub.com',
17
+ 'accept': '*/*',
18
+ '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',
19
+ 'content-type': 'application/json',
20
+ 'origin': 'https://chat.dfehub.com',
21
+ 'referer': 'https://chat.dfehub.com/',
22
+ 'sec-ch-ua': '"Not.A/Brand";v="8", "Chromium";v="114", "Google Chrome";v="114"',
23
+ 'sec-ch-ua-mobile': '?0',
24
+ 'sec-ch-ua-platform': '"macOS"',
25
+ 'sec-fetch-dest': 'empty',
26
+ 'sec-fetch-mode': 'cors',
27
+ 'sec-fetch-site': 'same-origin',
28
+ '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',
29
+ 'x-requested-with': 'XMLHttpRequest',
30
+ }
31
+
32
+ json_data = {
33
+ 'messages': messages,
34
+ 'model': 'gpt-3.5-turbo',
35
+ 'temperature': kwargs.get('temperature', 0.5),
36
+ 'presence_penalty': kwargs.get('presence_penalty', 0),
37
+ 'frequency_penalty': kwargs.get('frequency_penalty', 0),
38
+ 'top_p': kwargs.get('top_p', 1),
39
+ "stream": True,
40
+ }
41
+ response = requests.post('https://chat.dfehub.com/api/openai/v1/chat/completions',
42
+ headers=headers, json=json_data)
43
+
44
+ for chunk in response.iter_lines():
45
+ if b'detail' in chunk:
46
+ delay = re.findall(r"\d+\.\d+", chunk.decode())
47
+ delay = float(delay[-1])
48
+ print(f"Provider.DfeHub::Rate Limit Reached::Waiting {delay} seconds")
49
+ time.sleep(delay)
50
+ yield from _create_completion(model, messages, stream, **kwargs)
51
+ if b'content' in chunk:
52
+ data = json.loads(chunk.decode().split('data: ')[1])
53
+ yield (data['choices'][0]['delta']['content'])
54
+
55
+ params = f'g4f.Providers.{os.path.basename(__file__)[:-3]} supports: ' + \
56
+ '(%s)' % ', '.join([f"{name}: {get_type_hints(_create_completion)[name].__name__}" for name in _create_completion.__code__.co_varnames[:_create_completion.__code__.co_argcount]])
g4f/Provider/Providers/EasyChat.py ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os, requests
2
+ from ...typing import sha256, Dict, get_type_hints
3
+ import json
4
+
5
+ url = "https://free.easychat.work"
6
+ model = ['gpt-3.5-turbo']
7
+ supports_stream = True
8
+ needs_auth = False
9
+ working = True
10
+
11
+
12
+ def _create_completion(model: str, messages: list, stream: bool, **kwargs):
13
+ headers = {
14
+ 'authority': 'free.easychat.work',
15
+ 'accept': 'text/event-stream',
16
+ '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',
17
+ 'content-type': 'application/json',
18
+ 'endpoint': '',
19
+ 'origin': 'https://free.easychat.work',
20
+ 'plugins': '0',
21
+ 'referer': 'https://free.easychat.work/',
22
+ 'sec-ch-ua': '"Not.A/Brand";v="8", "Chromium";v="114", "Google Chrome";v="114"',
23
+ 'sec-ch-ua-mobile': '?0',
24
+ 'sec-ch-ua-platform': '"macOS"',
25
+ 'sec-fetch-dest': 'empty',
26
+ 'sec-fetch-mode': 'cors',
27
+ 'sec-fetch-site': 'same-origin',
28
+ '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',
29
+ 'usesearch': 'false',
30
+ 'x-requested-with': 'XMLHttpRequest',
31
+ }
32
+
33
+ json_data = {
34
+ 'messages': messages,
35
+ 'stream': True,
36
+ 'model': model,
37
+ 'temperature': kwargs.get('temperature', 0.5),
38
+ 'presence_penalty': kwargs.get('presence_penalty', 0),
39
+ 'frequency_penalty': kwargs.get('frequency_penalty', 0),
40
+ 'top_p': kwargs.get('top_p', 1),
41
+ }
42
+
43
+ response = requests.post('https://free.easychat.work/api/openai/v1/chat/completions',
44
+ headers=headers, json=json_data)
45
+
46
+ for chunk in response.iter_lines():
47
+ if b'content' in chunk:
48
+ data = json.loads(chunk.decode().split('data: ')[1])
49
+ yield (data['choices'][0]['delta']['content'])
50
+
51
+ params = f'g4f.Providers.{os.path.basename(__file__)[:-3]} supports: ' + \
52
+ '(%s)' % ', '.join([f"{name}: {get_type_hints(_create_completion)[name].__name__}" for name in _create_completion.__code__.co_varnames[:_create_completion.__code__.co_argcount]])
g4f/Provider/Providers/Forefront.py CHANGED
@@ -7,6 +7,8 @@ url = 'https://forefront.com'
7
  model = ['gpt-3.5-turbo']
8
  supports_stream = True
9
  needs_auth = False
 
 
10
 
11
  def _create_completion(model: str, messages: list, stream: bool, **kwargs):
12
  json_data = {
 
7
  model = ['gpt-3.5-turbo']
8
  supports_stream = True
9
  needs_auth = False
10
+ working = False
11
+
12
 
13
  def _create_completion(model: str, messages: list, stream: bool, **kwargs):
14
  json_data = {
g4f/Provider/Providers/GetGpt.py CHANGED
@@ -9,6 +9,8 @@ url = 'https://chat.getgpt.world/'
9
  model = ['gpt-3.5-turbo']
10
  supports_stream = True
11
  needs_auth = False
 
 
12
 
13
  def _create_completion(model: str, messages: list, stream: bool, **kwargs):
14
  def encrypt(e):
 
9
  model = ['gpt-3.5-turbo']
10
  supports_stream = True
11
  needs_auth = False
12
+ working = True
13
+
14
 
15
  def _create_completion(model: str, messages: list, stream: bool, **kwargs):
16
  def encrypt(e):
g4f/Provider/Providers/H2o.py CHANGED
@@ -10,6 +10,7 @@ url = 'https://gpt-gm.h2o.ai'
10
  model = ['falcon-40b', 'falcon-7b', 'llama-13b']
11
  supports_stream = True
12
  needs_auth = False
 
13
 
14
  models = {
15
  'falcon-7b': 'h2oai/h2ogpt-gm-oasst1-en-2048-falcon-7b-v3',
@@ -18,89 +19,76 @@ models = {
18
  }
19
 
20
  def _create_completion(model: str, messages: list, stream: bool, **kwargs):
21
- conversation = 'instruction: this is a conversation beween, a user and an AI assistant, respond to the latest message, referring to the conversation if needed\n'
 
22
  for message in messages:
23
  conversation += '%s: %s\n' % (message['role'], message['content'])
24
- conversation += 'assistant:'
25
 
26
- client = Session()
27
- client.headers = {
28
- 'authority': 'gpt-gm.h2o.ai',
29
- 'origin': 'https://gpt-gm.h2o.ai',
30
- 'referer': 'https://gpt-gm.h2o.ai/',
31
- 'sec-ch-ua': '"Not.A/Brand";v="8", "Chromium";v="114", "Google Chrome";v="114"',
32
- 'sec-ch-ua-mobile': '?0',
33
- 'sec-ch-ua-platform': '"Windows"',
34
- 'sec-fetch-dest': 'document',
35
- 'sec-fetch-mode': 'navigate',
36
- 'sec-fetch-site': 'same-origin',
37
- 'sec-fetch-user': '?1',
38
- 'upgrade-insecure-requests': '1',
39
- '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',
40
- }
41
-
42
- client.get('https://gpt-gm.h2o.ai/')
43
- response = client.post('https://gpt-gm.h2o.ai/settings', data={
44
- 'ethicsModalAccepted': 'true',
45
- 'shareConversationsWithModelAuthors': 'true',
46
- 'ethicsModalAcceptedAt': '',
47
- 'activeModel': 'h2oai/h2ogpt-gm-oasst1-en-2048-falcon-40b-v1',
48
- 'searchEnabled': 'true',
49
- })
50
 
 
51
  headers = {
52
- 'authority': 'gpt-gm.h2o.ai',
53
- 'accept': '*/*',
54
- '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',
55
- 'origin': 'https://gpt-gm.h2o.ai',
56
- 'referer': 'https://gpt-gm.h2o.ai/',
57
- 'sec-ch-ua': '"Not.A/Brand";v="8", "Chromium";v="114", "Google Chrome";v="114"',
58
- 'sec-ch-ua-mobile': '?0',
59
- 'sec-ch-ua-platform': '"Windows"',
60
- 'sec-fetch-dest': 'empty',
61
- 'sec-fetch-mode': 'cors',
62
- 'sec-fetch-site': 'same-origin',
63
- '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',
64
  }
65
-
66
- json_data = {
67
- 'model': models[model]
 
 
 
68
  }
 
69
 
70
- response = client.post('https://gpt-gm.h2o.ai/conversation',
71
- headers=headers, json=json_data)
72
- conversationId = response.json()['conversationId']
73
-
74
-
75
- completion = client.post(f'https://gpt-gm.h2o.ai/conversation/{conversationId}', stream=True, json = {
76
- 'inputs': conversation,
77
- 'parameters': {
78
- 'temperature': kwargs.get('temperature', 0.4),
79
- 'truncate': kwargs.get('truncate', 2048),
80
- 'max_new_tokens': kwargs.get('max_new_tokens', 1024),
81
- 'do_sample': kwargs.get('do_sample', True),
82
- 'repetition_penalty': kwargs.get('repetition_penalty', 1.2),
83
- 'return_full_text': kwargs.get('return_full_text', False)
 
 
 
 
 
 
 
 
 
 
84
  },
85
- 'stream': True,
86
- 'options': {
87
- 'id': kwargs.get('id', str(uuid4())),
88
- 'response_id': kwargs.get('response_id', str(uuid4())),
89
- 'is_retry': False,
90
- 'use_cache': False,
91
- 'web_search_id': ''
92
  }
93
- })
 
 
 
 
 
 
94
 
95
- for line in completion.iter_lines():
96
- if b'data' in line:
97
- line = loads(line.decode('utf-8').replace('data:', ''))
98
- token = line['token']['text']
99
-
100
- if token == '<|endoftext|>':
101
- break
102
- else:
103
- yield (token)
104
-
105
  params = f'g4f.Providers.{os.path.basename(__file__)[:-3]} supports: ' + \
106
  '(%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
  model = ['falcon-40b', 'falcon-7b', 'llama-13b']
11
  supports_stream = True
12
  needs_auth = False
13
+ working = True
14
 
15
  models = {
16
  'falcon-7b': 'h2oai/h2ogpt-gm-oasst1-en-2048-falcon-7b-v3',
 
19
  }
20
 
21
  def _create_completion(model: str, messages: list, stream: bool, **kwargs):
22
+
23
+ conversation = ''
24
  for message in messages:
25
  conversation += '%s: %s\n' % (message['role'], message['content'])
 
26
 
27
+ conversation += 'assistant: '
28
+ session = requests.Session()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
 
30
+ response = session.get("https://gpt-gm.h2o.ai/")
31
  headers = {
32
+ "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/115.0",
33
+ "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8",
34
+ "Accept-Language": "ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3",
35
+ "Content-Type": "application/x-www-form-urlencoded",
36
+ "Upgrade-Insecure-Requests": "1",
37
+ "Sec-Fetch-Dest": "document",
38
+ "Sec-Fetch-Mode": "navigate",
39
+ "Sec-Fetch-Site": "same-origin",
40
+ "Sec-Fetch-User": "?1",
41
+ "Referer": "https://gpt-gm.h2o.ai/r/jGfKSwU"
 
 
42
  }
43
+ data = {
44
+ "ethicsModalAccepted": "true",
45
+ "shareConversationsWithModelAuthors": "true",
46
+ "ethicsModalAcceptedAt": "",
47
+ "activeModel": "h2oai/h2ogpt-gm-oasst1-en-2048-falcon-40b-v1",
48
+ "searchEnabled": "true"
49
  }
50
+ response = session.post("https://gpt-gm.h2o.ai/settings", headers=headers, data=data)
51
 
52
+ headers = {
53
+ "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/115.0",
54
+ "Accept": "*/*",
55
+ "Accept-Language": "ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3",
56
+ "Content-Type": "application/json",
57
+ "Sec-Fetch-Dest": "empty",
58
+ "Sec-Fetch-Mode": "cors",
59
+ "Sec-Fetch-Site": "same-origin",
60
+ "Referer": "https://gpt-gm.h2o.ai/"
61
+ }
62
+ data = {
63
+ "model": models[model]
64
+ }
65
+
66
+ conversation_id = session.post("https://gpt-gm.h2o.ai/conversation", headers=headers, json=data)
67
+ data = {
68
+ "inputs": conversation,
69
+ "parameters": {
70
+ "temperature": kwargs.get('temperature', 0.4),
71
+ "truncate": kwargs.get('truncate', 2048),
72
+ "max_new_tokens": kwargs.get('max_new_tokens', 1024),
73
+ "do_sample": kwargs.get('do_sample', True),
74
+ "repetition_penalty": kwargs.get('repetition_penalty', 1.2),
75
+ "return_full_text": kwargs.get('return_full_text', False)
76
  },
77
+ "stream": True,
78
+ "options": {
79
+ "id": kwargs.get('id', str(uuid4())),
80
+ "response_id": kwargs.get('response_id', str(uuid4())),
81
+ "is_retry": False,
82
+ "use_cache": False,
83
+ "web_search_id": ""
84
  }
85
+ }
86
+
87
+ response = session.post(f"https://gpt-gm.h2o.ai/conversation/{conversation_id.json()['conversationId']}", headers=headers, json=data)
88
+ generated_text = response.text.replace("\n", "").split("data:")
89
+ generated_text = json.loads(generated_text[-1])
90
+
91
+ return generated_text["generated_text"]
92
 
 
 
 
 
 
 
 
 
 
 
93
  params = f'g4f.Providers.{os.path.basename(__file__)[:-3]} supports: ' + \
94
  '(%s)' % ', '.join([f"{name}: {get_type_hints(_create_completion)[name].__name__}" for name in _create_completion.__code__.co_varnames[:_create_completion.__code__.co_argcount]])
g4f/Provider/Providers/Liaobots.py CHANGED
@@ -5,6 +5,7 @@ url = 'https://liaobots.com'
5
  model = ['gpt-3.5-turbo', 'gpt-4']
6
  supports_stream = True
7
  needs_auth = True
 
8
 
9
  models = {
10
  'gpt-4': {
 
5
  model = ['gpt-3.5-turbo', 'gpt-4']
6
  supports_stream = True
7
  needs_auth = True
8
+ working = False
9
 
10
  models = {
11
  'gpt-4': {
g4f/Provider/Providers/Lockchat.py CHANGED
@@ -2,15 +2,16 @@ import requests
2
  import os
3
  import json
4
  from ...typing import sha256, Dict, get_type_hints
5
- url = 'http://super.lockchat.app'
6
  model = ['gpt-4', 'gpt-3.5-turbo']
7
  supports_stream = True
8
  needs_auth = False
 
9
 
10
  def _create_completion(model: str, messages: list, stream: bool, temperature: float = 0.7, **kwargs):
11
 
12
  payload = {
13
- "temperature": 0.7,
14
  "messages": messages,
15
  "model": model,
16
  "stream": True,
@@ -18,7 +19,7 @@ def _create_completion(model: str, messages: list, stream: bool, temperature: fl
18
  headers = {
19
  "user-agent": "ChatX/39 CFNetwork/1408.0.4 Darwin/22.5.0",
20
  }
21
- response = requests.post("http://super.lockchat.app/v1/chat/completions?auth=FnMNPlwZEnGFqvEc9470Vw==",
22
  json=payload, headers=headers, stream=True)
23
  for token in response.iter_lines():
24
  if b'The model: `gpt-4` does not exist' in token:
 
2
  import os
3
  import json
4
  from ...typing import sha256, Dict, get_type_hints
5
+ url = 'http://supertest.lockchat.app'
6
  model = ['gpt-4', 'gpt-3.5-turbo']
7
  supports_stream = True
8
  needs_auth = False
9
+ working = False
10
 
11
  def _create_completion(model: str, messages: list, stream: bool, temperature: float = 0.7, **kwargs):
12
 
13
  payload = {
14
+ "temperature": temperature,
15
  "messages": messages,
16
  "model": model,
17
  "stream": True,
 
19
  headers = {
20
  "user-agent": "ChatX/39 CFNetwork/1408.0.4 Darwin/22.5.0",
21
  }
22
+ response = requests.post("http://supertest.lockchat.app/v1/chat/completions",
23
  json=payload, headers=headers, stream=True)
24
  for token in response.iter_lines():
25
  if b'The model: `gpt-4` does not exist' in token:
g4f/Provider/Providers/Theb.py CHANGED
@@ -9,6 +9,7 @@ url = 'https://theb.ai'
9
  model = ['gpt-3.5-turbo']
10
  supports_stream = True
11
  needs_auth = False
 
12
 
13
  def _create_completion(model: str, messages: list, stream: bool, **kwargs):
14
 
@@ -20,7 +21,7 @@ def _create_completion(model: str, messages: list, stream: bool, **kwargs):
20
  cmd = ['python3', f'{path}/helpers/theb.py', config]
21
 
22
  p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
23
-
24
  for line in iter(p.stdout.readline, b''):
25
  yield line.decode('utf-8')
26
 
 
9
  model = ['gpt-3.5-turbo']
10
  supports_stream = True
11
  needs_auth = False
12
+ working = False
13
 
14
  def _create_completion(model: str, messages: list, stream: bool, **kwargs):
15
 
 
21
  cmd = ['python3', f'{path}/helpers/theb.py', config]
22
 
23
  p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
24
+
25
  for line in iter(p.stdout.readline, b''):
26
  yield line.decode('utf-8')
27
 
g4f/Provider/Providers/Vercel.py CHANGED
@@ -11,6 +11,7 @@ from ...typing import sha256, Dict, get_type_hints
11
  url = 'https://play.vercel.ai'
12
  supports_stream = True
13
  needs_auth = False
 
14
 
15
  models = {
16
  'claude-instant-v1': 'anthropic:claude-instant-v1',
@@ -41,122 +42,19 @@ vercel_models = {'anthropic:claude-instant-v1': {'id': 'anthropic:claude-instant
41
  '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': []}}}}
42
 
43
 
44
- # based on https://github.com/ading2210/vercel-llm-api // modified
45
- class Client:
46
- def __init__(self):
47
- self.session = requests.Session()
48
- self.headers = {
49
- 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110 Safari/537.36',
50
- 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8',
51
- 'Accept-Encoding': 'gzip, deflate, br',
52
- 'Accept-Language': 'en-US,en;q=0.5',
53
- 'Te': 'trailers',
54
- 'Upgrade-Insecure-Requests': '1'
55
- }
56
- self.session.headers.update(self.headers)
57
-
58
- def get_token(self):
59
- b64 = self.session.get('https://sdk.vercel.ai/openai.jpeg').text
60
- data = json.loads(base64.b64decode(b64))
61
-
62
- code = 'const globalThis = {data: `sentinel`}; function token() {return (%s)(%s)}' % (
63
- data['c'], data['a'])
64
-
65
- token_string = json.dumps(separators=(',', ':'),
66
- obj={'r': execjs.compile(code).call('token'), 't': data['t']})
67
-
68
- return base64.b64encode(token_string.encode()).decode()
69
-
70
- def get_default_params(self, model_id):
71
- return {key: param['value'] for key, param in vercel_models[model_id]['parameters'].items()}
72
-
73
- def generate(self, model_id: str, prompt: str, params: dict = {}):
74
- if not ':' in model_id:
75
- model_id = models[model_id]
76
-
77
- defaults = self.get_default_params(model_id)
78
-
79
- payload = defaults | params | {
80
- 'prompt': prompt,
81
- 'model': model_id,
82
- }
83
-
84
- headers = self.headers | {
85
- 'Accept-Encoding': 'gzip, deflate, br',
86
- 'Custom-Encoding': self.get_token(),
87
- 'Host': 'sdk.vercel.ai',
88
- 'Origin': 'https://sdk.vercel.ai',
89
- 'Referrer': 'https://sdk.vercel.ai',
90
- 'Sec-Fetch-Dest': 'empty',
91
- 'Sec-Fetch-Mode': 'cors',
92
- 'Sec-Fetch-Site': 'same-origin',
93
- }
94
-
95
- chunks_queue = queue.Queue()
96
- error = None
97
- response = None
98
-
99
- def callback(data):
100
- chunks_queue.put(data.decode())
101
-
102
- def request_thread():
103
- nonlocal response, error
104
- for _ in range(3):
105
- try:
106
- response = self.session.post('https://sdk.vercel.ai/api/generate',
107
- json=payload, headers=headers, content_callback=callback)
108
- response.raise_for_status()
109
-
110
- except Exception as e:
111
- if _ == 2:
112
- error = e
113
-
114
- else:
115
- continue
116
-
117
- thread = threading.Thread(target=request_thread, daemon=True)
118
- thread.start()
119
-
120
- text = ''
121
- index = 0
122
- while True:
123
- try:
124
- chunk = chunks_queue.get(block=True, timeout=0.1)
125
-
126
- except queue.Empty:
127
- if error:
128
- raise error
129
-
130
- elif response:
131
- break
132
-
133
- else:
134
- continue
135
-
136
- text += chunk
137
- lines = text.split('\n')
138
-
139
- if len(lines) - 1 > index:
140
- new = lines[index:-1]
141
- for word in new:
142
- yield json.loads(word)
143
- index = len(lines) - 1
144
-
145
  def _create_completion(model: str, messages: list, stream: bool, **kwargs):
146
- yield 'Vercel is currently not working.'
147
  return
 
148
 
149
- 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'
150
-
151
- for message in messages:
152
- conversation += '%s: %s\n' % (message['role'], message['content'])
153
 
154
- conversation += 'assistant: '
155
 
156
- completion = Client().generate(model, conversation)
157
 
158
- for token in completion:
159
- yield token
160
 
161
  params = f'g4f.Providers.{os.path.basename(__file__)[:-3]} supports: ' + \
162
  '(%s)' % ', '.join([f"{name}: {get_type_hints(_create_completion)[name].__name__}" for name in _create_completion.__code__.co_varnames[:_create_completion.__code__.co_argcount]])
 
11
  url = 'https://play.vercel.ai'
12
  supports_stream = True
13
  needs_auth = False
14
+ working = False
15
 
16
  models = {
17
  'claude-instant-v1': 'anthropic:claude-instant-v1',
 
42
  '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': []}}}}
43
 
44
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
  def _create_completion(model: str, messages: list, stream: bool, **kwargs):
 
46
  return
47
+ # 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'
48
 
49
+ # for message in messages:
50
+ # conversation += '%s: %s\n' % (message['role'], message['content'])
 
 
51
 
52
+ # conversation += 'assistant: '
53
 
54
+ # completion = Client().generate(model, conversation)
55
 
56
+ # for token in completion:
57
+ # yield token
58
 
59
  params = f'g4f.Providers.{os.path.basename(__file__)[:-3]} supports: ' + \
60
  '(%s)' % ', '.join([f"{name}: {get_type_hints(_create_completion)[name].__name__}" for name in _create_completion.__code__.co_varnames[:_create_completion.__code__.co_argcount]])
g4f/Provider/Providers/Wewordle.py ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os,sys
2
+ import requests
3
+ import json
4
+ import random
5
+ import time
6
+ import string
7
+ from ...typing import sha256, Dict, get_type_hints
8
+
9
+ url = "https://wewordle.org/gptapi/v1/android/turbo"
10
+ model = ['gpt-3.5-turbo']
11
+ supports_stream = False
12
+ needs_auth = False
13
+ working = False
14
+
15
+ def _create_completion(model: str, messages: list, stream: bool, **kwargs):
16
+ base = ''
17
+ for message in messages:
18
+ base += '%s: %s\n' % (message['role'], message['content'])
19
+ base += 'assistant:'
20
+ # randomize user id and app id
21
+ _user_id = ''.join(random.choices(f'{string.ascii_lowercase}{string.digits}', k=16))
22
+ _app_id = ''.join(random.choices(f'{string.ascii_lowercase}{string.digits}', k=31))
23
+ # make current date with format utc
24
+ _request_date = time.strftime("%Y-%m-%dT%H:%M:%S.000Z", time.gmtime())
25
+ headers = {
26
+ 'accept': '*/*',
27
+ 'pragma': 'no-cache',
28
+ 'Content-Type': 'application/json',
29
+ 'Connection':'keep-alive'
30
+ # user agent android client
31
+ # 'User-Agent': 'Dalvik/2.1.0 (Linux; U; Android 10; SM-G975F Build/QP1A.190711.020)',
32
+
33
+ }
34
+ data = {
35
+ "user": _user_id,
36
+ "messages": [
37
+ {"role": "user", "content": base}
38
+ ],
39
+ "subscriber": {
40
+ "originalPurchaseDate": None,
41
+ "originalApplicationVersion": None,
42
+ "allPurchaseDatesMillis": {},
43
+ "entitlements": {
44
+ "active": {},
45
+ "all": {}
46
+ },
47
+ "allPurchaseDates": {},
48
+ "allExpirationDatesMillis": {},
49
+ "allExpirationDates": {},
50
+ "originalAppUserId": f"$RCAnonymousID:{_app_id}",
51
+ "latestExpirationDate": None,
52
+ "requestDate": _request_date,
53
+ "latestExpirationDateMillis": None,
54
+ "nonSubscriptionTransactions": [],
55
+ "originalPurchaseDateMillis": None,
56
+ "managementURL": None,
57
+ "allPurchasedProductIdentifiers": [],
58
+ "firstSeen": _request_date,
59
+ "activeSubscriptions": []
60
+ }
61
+ }
62
+ response = requests.post(url, headers=headers, data=json.dumps(data))
63
+ if response.status_code == 200:
64
+ _json = response.json()
65
+ if 'message' in _json:
66
+ yield _json['message']['content']
67
+ else:
68
+ print(f"Error Occurred::{response.status_code}")
69
+ return None
70
+
71
+ params = f'g4f.Providers.{os.path.basename(__file__)[:-3]} supports: ' + \
72
+ '(%s)' % ', '.join(
73
+ [f"{name}: {get_type_hints(_create_completion)[name].__name__}" for name in _create_completion.__code__.co_varnames[:_create_completion.__code__.co_argcount]])
g4f/Provider/Providers/You.py CHANGED
@@ -9,6 +9,7 @@ url = 'https://you.com'
9
  model = 'gpt-3.5-turbo'
10
  supports_stream = True
11
  needs_auth = False
 
12
 
13
  def _create_completion(model: str, messages: list, stream: bool, **kwargs):
14
 
 
9
  model = 'gpt-3.5-turbo'
10
  supports_stream = True
11
  needs_auth = False
12
+ working = False
13
 
14
  def _create_completion(model: str, messages: list, stream: bool, **kwargs):
15
 
g4f/Provider/Providers/Yqcloud.py CHANGED
@@ -9,6 +9,7 @@ model = [
9
  ]
10
  supports_stream = True
11
  needs_auth = False
 
12
 
13
  def _create_completion(model: str, messages: list, stream: bool, **kwargs):
14
 
 
9
  ]
10
  supports_stream = True
11
  needs_auth = False
12
+ working = False
13
 
14
  def _create_completion(model: str, messages: list, stream: bool, **kwargs):
15
 
g4f/Provider/Providers/__init__.py ADDED
File without changes
g4f/Provider/Providers/__pycache__/AItianhu.cpython-311.pyc ADDED
Binary file (2.81 kB). View file
 
g4f/Provider/Providers/__pycache__/Acytoo.cpython-311.pyc ADDED
Binary file (2.42 kB). View file
 
g4f/Provider/Providers/__pycache__/AiService.cpython-311.pyc ADDED
Binary file (2.32 kB). View file
 
g4f/Provider/Providers/__pycache__/Aichat.cpython-311.pyc CHANGED
Binary files a/g4f/Provider/Providers/__pycache__/Aichat.cpython-311.pyc and b/g4f/Provider/Providers/__pycache__/Aichat.cpython-311.pyc differ
 
g4f/Provider/Providers/__pycache__/Aichat.cpython-38.pyc ADDED
Binary file (1.72 kB). View file
 
g4f/Provider/Providers/__pycache__/Ails.cpython-311.pyc CHANGED
Binary files a/g4f/Provider/Providers/__pycache__/Ails.cpython-311.pyc and b/g4f/Provider/Providers/__pycache__/Ails.cpython-311.pyc differ
 
g4f/Provider/Providers/__pycache__/Ails.cpython-38.pyc ADDED
Binary file (3.42 kB). View file
 
g4f/Provider/Providers/__pycache__/Bard.cpython-311.pyc CHANGED
Binary files a/g4f/Provider/Providers/__pycache__/Bard.cpython-311.pyc and b/g4f/Provider/Providers/__pycache__/Bard.cpython-311.pyc differ
 
g4f/Provider/Providers/__pycache__/Bard.cpython-38.pyc ADDED
Binary file (2.86 kB). View file
 
g4f/Provider/Providers/__pycache__/Bing.cpython-311.pyc CHANGED
Binary files a/g4f/Provider/Providers/__pycache__/Bing.cpython-311.pyc and b/g4f/Provider/Providers/__pycache__/Bing.cpython-311.pyc differ
 
g4f/Provider/Providers/__pycache__/Bing.cpython-38.pyc ADDED
Binary file (8.12 kB). View file
 
g4f/Provider/Providers/__pycache__/BingHuan.cpython-311.pyc ADDED
Binary file (2.33 kB). View file
 
g4f/Provider/Providers/__pycache__/ChatgptAi.cpython-311.pyc ADDED
Binary file (3.11 kB). View file
 
g4f/Provider/Providers/__pycache__/ChatgptLogin.cpython-311.pyc CHANGED
Binary files a/g4f/Provider/Providers/__pycache__/ChatgptLogin.cpython-311.pyc and b/g4f/Provider/Providers/__pycache__/ChatgptLogin.cpython-311.pyc differ
 
g4f/Provider/Providers/__pycache__/DeepAi.cpython-311.pyc CHANGED
Binary files a/g4f/Provider/Providers/__pycache__/DeepAi.cpython-311.pyc and b/g4f/Provider/Providers/__pycache__/DeepAi.cpython-311.pyc differ
 
g4f/Provider/Providers/__pycache__/DfeHub.cpython-311.pyc ADDED
Binary file (3.81 kB). View file
 
g4f/Provider/Providers/__pycache__/EasyChat.cpython-311.pyc ADDED
Binary file (3.51 kB). View file
 
g4f/Provider/Providers/__pycache__/Forefront.cpython-311.pyc CHANGED
Binary files a/g4f/Provider/Providers/__pycache__/Forefront.cpython-311.pyc and b/g4f/Provider/Providers/__pycache__/Forefront.cpython-311.pyc differ
 
g4f/Provider/Providers/__pycache__/GetGpt.cpython-311.pyc CHANGED
Binary files a/g4f/Provider/Providers/__pycache__/GetGpt.cpython-311.pyc and b/g4f/Provider/Providers/__pycache__/GetGpt.cpython-311.pyc differ
 
g4f/Provider/Providers/__pycache__/H2o.cpython-311.pyc CHANGED
Binary files a/g4f/Provider/Providers/__pycache__/H2o.cpython-311.pyc and b/g4f/Provider/Providers/__pycache__/H2o.cpython-311.pyc differ
 
g4f/Provider/Providers/__pycache__/Liaobots.cpython-311.pyc CHANGED
Binary files a/g4f/Provider/Providers/__pycache__/Liaobots.cpython-311.pyc and b/g4f/Provider/Providers/__pycache__/Liaobots.cpython-311.pyc differ
 
g4f/Provider/Providers/__pycache__/Lockchat.cpython-311.pyc CHANGED
Binary files a/g4f/Provider/Providers/__pycache__/Lockchat.cpython-311.pyc and b/g4f/Provider/Providers/__pycache__/Lockchat.cpython-311.pyc differ
 
g4f/Provider/Providers/__pycache__/Theb.cpython-311.pyc CHANGED
Binary files a/g4f/Provider/Providers/__pycache__/Theb.cpython-311.pyc and b/g4f/Provider/Providers/__pycache__/Theb.cpython-311.pyc differ
 
g4f/Provider/Providers/__pycache__/Theb.cpython-38.pyc ADDED
Binary file (1.29 kB). View file