mirror of
https://github.com/xtekky/gpt4free.git
synced 2024-11-09 22:28:52 +03:00
set encoding and temperature
This commit is contained in:
parent
2341e884d0
commit
5c2809a22f
@ -19,11 +19,12 @@ class Acytoo(BaseProvider):
|
||||
**kwargs: Any,
|
||||
) -> CreateResult:
|
||||
headers = _create_header()
|
||||
payload = _create_payload(messages)
|
||||
payload = _create_payload(messages, kwargs.get('temperature', 0.5))
|
||||
|
||||
url = "https://chat.acytoo.com/api/completions"
|
||||
response = requests.post(url=url, headers=headers, json=payload)
|
||||
response.raise_for_status()
|
||||
response.encoding = "utf-8"
|
||||
yield response.text
|
||||
|
||||
|
||||
@ -34,7 +35,7 @@ def _create_header():
|
||||
}
|
||||
|
||||
|
||||
def _create_payload(messages: list[dict[str, str]]):
|
||||
def _create_payload(messages: list[dict[str, str]], temperature):
|
||||
payload_messages = [
|
||||
message | {"createdAt": int(time.time()) * 1000} for message in messages
|
||||
]
|
||||
@ -42,6 +43,6 @@ def _create_payload(messages: list[dict[str, str]]):
|
||||
"key": "",
|
||||
"model": "gpt-3.5-turbo",
|
||||
"messages": payload_messages,
|
||||
"temperature": 1,
|
||||
"temperature": temperature,
|
||||
"password": "",
|
||||
}
|
||||
|
@ -40,9 +40,9 @@ class Aichat(BaseProvider):
|
||||
|
||||
json_data = {
|
||||
"message": base,
|
||||
"temperature": 1,
|
||||
"temperature": kwargs.get('temperature', 0.5),
|
||||
"presence_penalty": 0,
|
||||
"top_p": 1,
|
||||
"top_p": kwargs.get('top_p', 1),
|
||||
"frequency_penalty": 0,
|
||||
}
|
||||
|
||||
@ -52,4 +52,6 @@ class Aichat(BaseProvider):
|
||||
json=json_data,
|
||||
)
|
||||
response.raise_for_status()
|
||||
if not response.json()['response']:
|
||||
raise Exception("Error Response: " + response.json())
|
||||
yield response.json()["message"]
|
||||
|
@ -75,6 +75,8 @@ class H2o(BaseProvider):
|
||||
headers=headers,
|
||||
json=data,
|
||||
)
|
||||
response.raise_for_status()
|
||||
response.encoding = "utf-8"
|
||||
generated_text = response.text.replace("\n", "").split("data:")
|
||||
generated_text = json.loads(generated_text[-1])
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user