Skip to content

Commit 6a85ae4

Browse files
committed
Добавлены новые провайдеры
1 parent 9da807f commit 6a85ae4

File tree

5 files changed

+19
-20
lines changed

5 files changed

+19
-20
lines changed

g4f/Provider/Providers/AItianhu.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
from ...typing import sha256, Dict, get_type_hints
33
import json
44

5-
url = "https://2t2yo.aitianhu.fit/api/chat-process"
6-
model = ['gpt-3.5-turbo']
5+
url = "https://ixlc0.aitianhu.site/api/chat-process"
6+
model = ['gpt-4']
77
supports_stream = False
88
needs_auth = False
99
working = True
@@ -25,14 +25,12 @@ def _create_completion(model: str, messages: list, stream: bool, **kwargs):
2525
"temperature": 0.8,
2626
"top_p": 1
2727
}
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
28+
response = requests.post(url, headers=headers, json=data, verify=False)
29+
30+
for line in response.iter_lines():
31+
if b'content' in line:
32+
line_json = json.loads(line.decode('utf-8').split('data: ')[1])
33+
yield (line_json['choices'][0]['delta']['content'])
3634

3735
params = f'g4f.Providers.{os.path.basename(__file__)[:-3]} supports: ' + \
3836
'(%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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import json
44

55
url = "https://chat.acytoo.com/api/completions"
6-
model = ['gpt-3.5-turbo']
6+
model = ['gpt-3.5-turbo', 'gpt-3.5-turbo-16k', 'gpt-4-0613', 'gpt-4-32k']
77
supports_stream = False
88
needs_auth = False
99
working = True
@@ -19,7 +19,7 @@ def _create_completion(model: str, messages: list, stream: bool, **kwargs):
1919
}
2020
data = {
2121
"key": "",
22-
"model": "gpt-3.5-turbo",
22+
"model": model,
2323
"messages": [
2424
{
2525
"role": "user",

g4f/Provider/Providers/CoffeCat.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
url = "https://caffcat.com"
66
model = ['gpt-3.5-turbo', 'gpt-3.5-turbo-16k']
7-
supports_stream = True
7+
supports_stream = False
88
needs_auth = False
99
working = True
1010

@@ -32,7 +32,7 @@ def _create_completion(model: str, messages: list, stream: bool, **kwargs):
3232

3333
json_data = {
3434
'messages': messages,
35-
'stream': True,
35+
'stream': False,
3636
'model': model,
3737
'temperature': 0.5,
3838
'presence_penalty': 0,

g4f/models.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,14 @@ class gpt_4_standart:
102102
class gpt_4_0613:
103103
name: str = 'gpt-4-0613'
104104
base_provider: str = 'openai'
105-
best_provider: Provider.Provider = Provider.Chatty
106-
best_providers: list = [Provider.Chatty]
105+
best_provider: Provider.Provider = Provider.Acytoo
106+
best_providers: list = [Provider.Acytoo]
107107

108108
class gpt_4_32k:
109109
name: str = 'gpt-4-32k'
110110
base_provider: str = 'reversed'
111-
best_provider: Provider.Provider = Provider.Chatty
112-
best_providers: list = [Provider.Chatty]
111+
best_provider: Provider.Provider = Provider.Acytoo
112+
best_providers: list = [Provider.Acytoo]
113113

114114
class claude_2:
115115
name: str = 'claude-2'
@@ -198,6 +198,7 @@ class ModelUtils:
198198
'gpt-4': Model.gpt_4,
199199
'gpt-4-standart': Model.gpt_4_standart,
200200
'gpt-4-0613': Model.gpt_4_0613,
201+
'gpt-4-32k': Model.gpt_4_32k,
201202
'gpt-3.5-turbo-16k': Model.gpt_35_turbo_16k,
202203
'gpt-3.5-turbo-16k-0613': Model.gpt_35_turbo_16k_0613,
203204

test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
from g4f.typing import sha256, Dict, get_type_hints
55
import json
66

7-
#proxy = FreeProxy(country_id=['FL'], timeout=0.5, rand=True).get()
7+
proxy = FreeProxy(country_id=['FL'], timeout=0.5, rand=True).get()
88
stream = False
99
#print(proxy)
10-
response = g4f.ChatCompletion.create(model='gpt-3.5-turbo-16k', provider=g4f.Provider.EasyChat, messages=[
10+
response = g4f.ChatCompletion.create(model='gpt-3.5-turbo-16k', provider=g4f.Provider.AItianhu, messages=[
1111
{"role": "user", "content": "hello"}], stream=False)
1212

1313

0 commit comments

Comments
 (0)