返回提交历史
Modified
g4f/Provider/Acytoo.py
+4
-3
Modified
g4f/Provider/Aichat.py
+4
-2
Modified
g4f/Provider/H2o.py
+2
-0
XFEstudio/gpt4free
set encoding and temperature
5c2809a2
代码差异
3 个文件
+10
-5
@@ -19,11 +19,12 @@ class Acytoo(BaseProvider):
19
19
**kwargs: Any,
20
20
) -> CreateResult:
21
21
headers = _create_header()
22
payload = _create_payload(messages)
22
payload = _create_payload(messages, kwargs.get('temperature', 0.5))
23
23
24
24
url = "https://chat.acytoo.com/api/completions"
25
25
response = requests.post(url=url, headers=headers, json=payload)
26
26
response.raise_for_status()
27
response.encoding = "utf-8"
27
28
yield response.text
28
29
29
30
@@ -34,7 +35,7 @@ def _create_header():
34
35
}
35
36
36
37
37
def _create_payload(messages: list[dict[str, str]]):
38
def _create_payload(messages: list[dict[str, str]], temperature):
38
39
payload_messages = [
39
40
message | {"createdAt": int(time.time()) * 1000} for message in messages
40
41
]
@@ -42,6 +43,6 @@ def _create_payload(messages: list[dict[str, str]]):
42
43
"key": "",
43
44
"model": "gpt-3.5-turbo",
44
45
"messages": payload_messages,
45
"temperature": 1,
46
"temperature": temperature,
46
47
"password": "",
47
48
}
@@ -40,9 +40,9 @@ class Aichat(BaseProvider):
40
40
41
41
json_data = {
42
42
"message": base,
43
"temperature": 1,
43
"temperature": kwargs.get('temperature', 0.5),
44
44
"presence_penalty": 0,
45
"top_p": 1,
45
"top_p": kwargs.get('top_p', 1),
46
46
"frequency_penalty": 0,
47
47
}
48
48
@@ -52,4 +52,6 @@ class Aichat(BaseProvider):
52
52
json=json_data,
53
53
)
54
54
response.raise_for_status()
55
if not response.json()['response']:
56
raise Exception("Error Response: " + response.json())
55
57
yield response.json()["message"]
@@ -75,6 +75,8 @@ class H2o(BaseProvider):
75
75
headers=headers,
76
76
json=data,
77
77
)
78
response.raise_for_status()
79
response.encoding = "utf-8"
78
80
generated_text = response.text.replace("\n", "").split("data:")
79
81
generated_text = json.loads(generated_text[-1])
80
82