Skip to content

Commit bf115f2

Browse files
committed
Добавлены новые провайдеры
1 parent ec35226 commit bf115f2

File tree

4 files changed

+111
-3
lines changed

4 files changed

+111
-3
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import os, uuid, requests
2+
from ...typing import sha256, Dict, get_type_hints
3+
4+
url = 'https://chatgpt.valethealth.com'
5+
model = ['gpt-4-32k', 'gpt-4']
6+
supports_stream = True
7+
needs_auth = False
8+
working = True
9+
10+
models = {
11+
'gpt-4': {
12+
"id":"gpt-4",
13+
"name":"GPT-4",
14+
"maxLength":24000,
15+
"tokenLimit":8000
16+
},
17+
'gpt-4-32k': {
18+
"id":"gpt-3.5-turbo",
19+
"name":"GPT-3.5-16k",
20+
"maxLength":4800,
21+
"tokenLimit":16000
22+
},
23+
}
24+
25+
def _create_completion(model: str, messages: list, stream: bool, **kwargs):
26+
27+
print(kwargs)
28+
29+
headers = {
30+
'authority': 'chatgpt.valethealth.com',
31+
'content-type': 'application/json',
32+
'origin': 'https://chatgpt.valethealth.com',
33+
'referer': 'https://chatgpt.valethealth.com/zh',
34+
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36',
35+
}
36+
37+
json_data = {
38+
'conversationId': str(uuid.uuid4()),
39+
'model': models[model],
40+
'messages': messages,
41+
'key': '',
42+
'prompt': "You are ChatGPT, a large language model trained by OpenAI. Follow the user's instructions carefully. Respond using markdown.",
43+
}
44+
45+
response = requests.post('https://chatgpt.valethealth.com/api/chat',
46+
headers=headers, json=json_data, stream=True)
47+
48+
for token in response.iter_content(chunk_size=2046):
49+
yield (token.decode('utf-8'))
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/i207.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import os, uuid, requests
2+
from ...typing import sha256, Dict, get_type_hints
3+
4+
url = 'gpt3.i207m.top'
5+
model = ['gpt-4-32k', 'gpt-4']
6+
supports_stream = True
7+
needs_auth = False
8+
working = True
9+
10+
models = {
11+
'gpt-4': {
12+
"id":"gpt-4",
13+
"name":"GPT-4",
14+
"maxLength":24000,
15+
"tokenLimit":8000
16+
},
17+
'gpt-4-32k': {
18+
"id":"gpt-4-32k",
19+
"name":"GPT-4-32k",
20+
"maxLength":96000,
21+
"tokenLimit":32000
22+
},
23+
}
24+
25+
def _create_completion(model: str, messages: list, stream: bool, **kwargs):
26+
27+
print(kwargs)
28+
29+
headers = {
30+
'authority': 'gpt3.i207m.top',
31+
'content-type': 'application/json',
32+
'origin': 'https://gpt3.i207m.top',
33+
'referer': 'https://gpt3.i207m.top/zh',
34+
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36',
35+
}
36+
37+
json_data = {
38+
'conversationId': str(uuid.uuid4()),
39+
'model': models[model],
40+
'messages': messages,
41+
'key': '',
42+
'prompt': "You are ChatGPT, a large language model trained by OpenAI. Follow the user's instructions carefully. Respond using markdown.",
43+
}
44+
45+
response = requests.post('https://gpt3.i207m.top/api/chat',
46+
headers=headers, json=json_data, stream=True)
47+
48+
for token in response.iter_content(chunk_size=2046):
49+
yield (token.decode('utf-8'))
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/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from .Providers import (
33
AItianhu,
44
Ails,
5+
Valethealth,
56
You,
67
Yqcloud,
78
Bard,
@@ -41,7 +42,9 @@
4142
CoffeCat,
4243
GptBz,
4344
Qidinam,
44-
Unifyai
45+
Unifyai,
46+
Valethealth,
47+
i207
4548

4649
)
4750

test.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
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.Acytoo, messages=[
10+
response = g4f.ChatCompletion.create(model='gpt-4', provider=g4f.Provider.i207, messages=[
1111
{"role": "user", "content": "hello"}], stream=False)
1212

1313

@@ -16,4 +16,5 @@
1616
for message in response:
1717
print(message)
1818
else:
19-
print(response)
19+
print(response)
20+

0 commit comments

Comments
 (0)