monra commited on
Commit
df737e5
1 Parent(s): b4c1592

New GPT-4 API provider: Dfehub

Browse files
client/html/index.html CHANGED
@@ -41,7 +41,7 @@
41
  <i class="fa-brands fa-github"></i>
42
  <span class="conversation-title">
43
  Author: @ramonvc<br />
44
- Version: 0.0.8-Alpha<br />
45
  </span>
46
  </a>
47
  </div>
@@ -75,7 +75,7 @@
75
  <option value="gpt-3.5-turbo-0613">GPT-3.5-0613</option>
76
  <option value="gpt-3.5-turbo-16k">GPT-3.5-turbo-16k</option>
77
  <option value="gpt-3.5-turbo-16k-0613" selected>GPT-3.5-turbo-16k-0613</option>
78
- <option value="gpt-4-0613" disabled>GPT-4 (offline)</option>
79
  </select>
80
  </div>
81
  <div class="field">
 
41
  <i class="fa-brands fa-github"></i>
42
  <span class="conversation-title">
43
  Author: @ramonvc<br />
44
+ Version: 0.0.9-Alpha<br />
45
  </span>
46
  </a>
47
  </div>
 
75
  <option value="gpt-3.5-turbo-0613">GPT-3.5-0613</option>
76
  <option value="gpt-3.5-turbo-16k">GPT-3.5-turbo-16k</option>
77
  <option value="gpt-3.5-turbo-16k-0613" selected>GPT-3.5-turbo-16k-0613</option>
78
+ <option value="gpt-4">GPT-4 (unstable)</option>
79
  </select>
80
  </div>
81
  <div class="field">
g4f/Provider/Providers/Dfehub.py ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import requests
3
+ from ...typing import sha256, Dict, get_type_hints
4
+
5
+ url = "https://chat.dfehub.com"
6
+ model = ['gpt-3.5-turbo', 'gpt-3.5-turbo-16k', 'gpt-4']
7
+ supports_stream = True
8
+ needs_auth = False
9
+
10
+
11
+ def _create_completion(model: str, messages: list, stream: bool, **kwargs):
12
+ headers = {
13
+ 'Authority': 'chat.dfehub.com',
14
+ 'Content-Type': 'application/json',
15
+ 'Method': 'POST',
16
+ 'Path': '/api/openai/v1/chat/completions',
17
+ 'Scheme': 'https',
18
+ 'Accept': 'text/event-stream',
19
+ 'Accept-Language': 'pt-BR,pt;q=0.9,en-US;q=0.8,en;q=0.7,zh-CN;q=0.6,zh;q=0.5',
20
+ 'Content-Type': 'application/json',
21
+ 'Origin': 'https://chat.dfehub.com',
22
+ 'Referer': 'https://chat.dfehub.com/',
23
+ 'Sec-Ch-Ua': '"Not.A/Brand";v="8", "Chromium";v="114", "Google Chrome";v="114"',
24
+ 'Sec-Ch-Ua-Mobile': '?0',
25
+ 'Sec-Ch-Ua-Platform': '"Windows"',
26
+ 'Sec-Fetch-Dest': 'empty',
27
+ 'Sec-Fetch-Mode': 'cors',
28
+ 'Sec-Fetch-Site': 'same-origin',
29
+ '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',
30
+ 'X-Requested-With': 'XMLHttpRequest',
31
+ }
32
+
33
+ data = {
34
+ 'model': model,
35
+ 'temperature': 0.7,
36
+ 'max_tokens': '8000',
37
+ 'presence_penalty': 0,
38
+ 'messages': messages,
39
+ }
40
+
41
+ response = requests.post(url + '/api/openai/v1/chat/completions',
42
+ headers=headers, json=data, stream=stream)
43
+
44
+ yield response.json()['choices'][0]['message']['content']
45
+
46
+
47
+ params = f'g4f.Providers.{os.path.basename(__file__)[:-3]} supports: ' + \
48
+ '(%s)' % ', '.join(
49
+ [f"{name}: {get_type_hints(_create_completion)[name].__name__}" for name in _create_completion.__code__.co_varnames[:_create_completion.__code__.co_argcount]])
g4f/Provider/__init__.py CHANGED
@@ -8,6 +8,7 @@ from .Providers import (
8
  ChatgptLogin,
9
  ChatgptLogin,
10
  DeepAi,
 
11
  Easychat,
12
  Ezcht,
13
  Fakeopen,
 
8
  ChatgptLogin,
9
  ChatgptLogin,
10
  DeepAi,
11
+ Dfehub,
12
  Easychat,
13
  Ezcht,
14
  Fakeopen,
g4f/models.py CHANGED
@@ -35,8 +35,7 @@ class Model:
35
  class gpt_4:
36
  name: str = 'gpt-4'
37
  base_provider: str = 'openai'
38
- best_provider: Provider.Provider = Provider.Lockchat
39
- best_providers: list = [Provider.Bing, Provider.Lockchat]
40
 
41
  class gpt_4_0613:
42
  name: str = 'gpt-4-0613'
 
35
  class gpt_4:
36
  name: str = 'gpt-4'
37
  base_provider: str = 'openai'
38
+ best_provider: Provider.Provider = Provider.Dfehub
 
39
 
40
  class gpt_4_0613:
41
  name: str = 'gpt-4-0613'