返回提交历史
Added
g4f/Provider/Providers/AiService.py
+40
-0
Added
g4f/Provider/Providers/BingHuan.py
+27
-0
Renamed
g4f/Provider/Providers/Wewordle.py
+4
-28
Renamed
g4f/Provider/Providers/helpers/binghuan.py
+0
-0
Modified
g4f/Provider/__init__.py
+3
-0
Deleted
testing/aiservice/AiService.py
+0
-62
Deleted
testing/aiservice/README.md
+0
-2
Deleted
testing/aiservice/testing.py
+0
-30
Deleted
testing/binghuan/BingHuan.py
+0
-49
Deleted
testing/binghuan/README.md
+0
-7
Deleted
testing/binghuan/testing.py
+0
-31
Deleted
testing/wewordle/README.md
+0
-1
Deleted
testing/wewordle/testing.py
+0
-30
XFEstudio/gpt4free
refactor/move provider from testing folder
6fb45515
代码差异
13 个文件
+74
-240
@@ -0,0 +1,40 @@
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
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
"accept": "*/*",
19
"content-type": "text/plain;charset=UTF-8",
20
"sec-fetch-dest": "empty",
21
"sec-fetch-mode": "cors",
22
"sec-fetch-site": "same-origin",
23
"Referer": "https://aiservice.vercel.app/chat",
24
}
25
data = {
26
"input": base
27
}
28
response = requests.post(url, headers=headers, json=data)
29
if response.status_code == 200:
30
_json = response.json()
31
yield _json['data']
32
else:
33
print(f"Error Occurred::{response.status_code}")
34
return None
35
36
37
38
params = f'g4f.Providers.{os.path.basename(__file__)[:-3]} supports: ' + \
39
'(%s)' % ', '.join(
40
[f"{name}: {get_type_hints(_create_completion)[name].__name__}" for name in _create_completion.__code__.co_varnames[:_create_completion.__code__.co_argcount]])
@@ -0,0 +1,27 @@
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
11
def _create_completion(model: str, messages: list, stream: bool, **kwargs):
12
path = os.path.dirname(os.path.realpath(__file__))
13
config = json.dumps({
14
'messages': messages,
15
'model': model}, separators=(',', ':'))
16
cmd = ['python', f'{path}/helpers/binghuan.py', config]
17
18
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
19
20
for line in iter(p.stdout.readline, b''):
21
yield line.decode('cp1252')
22
23
24
25
params = f'g4f.Providers.{os.path.basename(__file__)[:-3]} supports: ' + \
26
'(%s)' % ', '.join(
27
[f"{name}: {get_type_hints(_create_completion)[name].__name__}" for name in _create_completion.__code__.co_varnames[:_create_completion.__code__.co_argcount]])
@@ -4,7 +4,7 @@ import json
4
4
import random
5
5
import time
6
6
import string
7
# from ...typing import sha256, Dict, get_type_hints
7
from ...typing import sha256, Dict, get_type_hints
8
8
9
9
url = "https://wewordle.org/gptapi/v1/android/turbo"
10
10
model = ['gpt-3.5-turbo']
@@ -68,30 +68,6 @@ def _create_completion(model: str, messages: list, stream: bool, **kwargs):
68
68
print(f"Error Occurred::{response.status_code}")
69
69
return None
70
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]])
74
75
76
# Temporary For ChatCompletion Class
77
class ChatCompletion:
78
@staticmethod
79
def create(model: str, messages: list, provider: None or str, stream: bool = False, auth: str = False, **kwargs):
80
kwargs['auth'] = auth
81
82
if provider and needs_auth and not auth:
83
print(
84
f'ValueError: {provider} requires authentication (use auth="cookie or token or jwt ..." param)', file=sys.stderr)
85
sys.exit(1)
86
87
try:
88
89
90
return (_create_completion(model, messages, stream, **kwargs)
91
if stream else ''.join(_create_completion(model, messages, stream, **kwargs)))
92
except TypeError as e:
93
print(e)
94
arg: str = str(e).split("'")[1]
95
print(
96
f"ValueError: {provider} does not support '{arg}' argument", file=sys.stderr)
97
sys.exit(1)
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]])
此文件没有可显示的逐行差异。
@@ -19,6 +19,9 @@ from .Providers import (
19
19
EasyChat,
20
20
Acytoo,
21
21
DFEHub,
22
AiService,
23
BingHuan,
24
Wewordle
22
25
)
23
26
24
27
Palm = Bard
@@ -1,62 +0,0 @@
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
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
"accept": "*/*",
19
"content-type": "text/plain;charset=UTF-8",
20
"sec-fetch-dest": "empty",
21
"sec-fetch-mode": "cors",
22
"sec-fetch-site": "same-origin",
23
"Referer": "https://aiservice.vercel.app/chat",
24
}
25
data = {
26
"input": base
27
}
28
response = requests.post(url, headers=headers, json=data)
29
if response.status_code == 200:
30
_json = response.json()
31
yield _json['data']
32
else:
33
print(f"Error Occurred::{response.status_code}")
34
return None
35
36
37
38
# params = f'g4f.Providers.{os.path.basename(__file__)[:-3]} supports: ' + \
39
# '(%s)' % ', '.join(
40
# [f"{name}: {get_type_hints(_create_completion)[name].__name__}" for name in _create_completion.__code__.co_varnames[:_create_completion.__code__.co_argcount]])
41
42
43
# Temporary For ChatCompletion Class
44
class ChatCompletion:
45
@staticmethod
46
def create(model: str, messages: list, provider: None or str, stream: bool = False, auth: str = False, **kwargs):
47
kwargs['auth'] = auth
48
49
if provider and needs_auth and not auth:
50
print(
51
f'ValueError: {provider} requires authentication (use auth="cookie or token or jwt ..." param)', file=sys.stderr)
52
sys.exit(1)
53
54
try:
55
return (_create_completion(model, messages, stream, **kwargs)
56
if stream else ''.join(_create_completion(model, messages, stream, **kwargs)))
57
except TypeError as e:
58
print(e)
59
arg: str = str(e).split("'")[1]
60
print(
61
f"ValueError: {provider} does not support '{arg}' argument", file=sys.stderr)
62
sys.exit(1)
@@ -1,2 +0,0 @@
1
https://github.com/xtekky/gpt4free/issues/40#issuecomment-1629152431
2
probably gpt-3.5
@@ -1,30 +0,0 @@
1
from AiService import ChatCompletion
2
3
# Test 1
4
response = ChatCompletion.create(model="gpt-3.5-turbo",
5
provider="AiService",
6
stream=False,
7
messages=[{'role': 'user', 'content': 'who are you?'}])
8
9
print(response)
10
11
# Test 2
12
response = ChatCompletion.create(model="gpt-3.5-turbo",
13
provider="AiService",
14
stream=False,
15
messages=[{'role': 'user', 'content': 'what you can do?'}])
16
17
print(response)
18
19
20
# Test 3
21
response = ChatCompletion.create(model="gpt-3.5-turbo",
22
provider="AiService",
23
stream=False,
24
messages=[
25
{'role': 'user', 'content': 'now your name is Bob'},
26
{'role': 'assistant', 'content': 'Hello Im Bob, you asistant'},
27
{'role': 'user', 'content': 'what your name again?'},
28
])
29
30
print(response)
@@ -1,49 +0,0 @@
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
11
def _create_completion(model: str, messages: list, stream: bool, **kwargs):
12
path = os.path.dirname(os.path.realpath(__file__))
13
config = json.dumps({
14
'messages': messages,
15
'model': model}, separators=(',', ':'))
16
cmd = ['python', f'{path}/helpers/binghuan.py', config]
17
18
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
19
20
for line in iter(p.stdout.readline, b''):
21
yield line.decode('cp1252')
22
23
24
25
# params = f'g4f.Providers.{os.path.basename(__file__)[:-3]} supports: ' + \
26
# '(%s)' % ', '.join(
27
# [f"{name}: {get_type_hints(_create_completion)[name].__name__}" for name in _create_completion.__code__.co_varnames[:_create_completion.__code__.co_argcount]])
28
29
30
# Temporary For ChatCompletion Class
31
class ChatCompletion:
32
@staticmethod
33
def create(model: str, messages: list, provider: None or str, stream: bool = False, auth: str = False, **kwargs):
34
kwargs['auth'] = auth
35
36
if provider and needs_auth and not auth:
37
print(
38
f'ValueError: {provider} requires authentication (use auth="cookie or token or jwt ..." param)', file=sys.stderr)
39
sys.exit(1)
40
41
try:
42
return (_create_completion(model, messages, stream, **kwargs)
43
if stream else ''.join(_create_completion(model, messages, stream, **kwargs)))
44
except TypeError as e:
45
print(e)
46
arg: str = str(e).split("'")[1]
47
print(
48
f"ValueError: {provider} does not support '{arg}' argument", file=sys.stderr)
49
sys.exit(1)
@@ -1,7 +0,0 @@
1
https://github.com/xtekky/gpt4free/issues/40#issuecomment-1630946450
2
flow chat process is realy like real Bing (create conversation,listern to websocket and more)
3
so i just use code Bing Provider from https://gitler.moe/g4f/gpt4free/ version and replace API endpoint and some conversationstyles and work fine
4
5
but bing dont realy support multi/continues conversation (using prompt template from original Provider : def convert(messages) : https://github.com/xtekky/gpt4free/blob/e594500c4e7a8443e9b3f4af755c72f42dae83f0/g4f/Provider/Providers/Bing.py#L322)
6
7
also i have problem with emoji encoding idk how to fix that
@@ -1,31 +0,0 @@
1
from BingHuan import ChatCompletion
2
3
# Test 1
4
response = ChatCompletion.create(model="gpt-3.5-turbo",
5
provider="BingHuan",
6
stream=False,
7
messages=[{'role': 'user', 'content': 'who are you?'}])
8
9
print(response)
10
11
# Test 2
12
# this prompt will return emoji in end of response
13
response = ChatCompletion.create(model="gpt-3.5-turbo",
14
provider="BingHuan",
15
stream=False,
16
messages=[{'role': 'user', 'content': 'what you can do?'}])
17
18
print(response)
19
20
21
# Test 3
22
response = ChatCompletion.create(model="gpt-4",
23
provider="BingHuan",
24
stream=False,
25
messages=[
26
{'role': 'user', 'content': 'now your name is Bob'},
27
{'role': 'assistant', 'content': 'Hello Im Bob, you asistant'},
28
{'role': 'user', 'content': 'what your name again?'},
29
])
30
31
print(response)
@@ -1 +0,0 @@
1
original from website https://chat-gpt.com/chat https://github.com/xtekky/gpt4free/issues/40#issuecomment-1629152431, i got api https://wewordle.org/gptapi/v1/web/turbo but it got limit so i try to try reverse they android app and i got api https://wewordle.org/gptapi/v1/android/turbo and just randomize user id to bypass limit