mirror of
https://github.com/xtekky/gpt4free.git
synced 2024-09-12 08:29:30 -04:00
~| Merge pull request #834
fix Yqcloud and You prompter using only the last message
This commit is contained in:
commit
80f85e851e
@ -72,6 +72,8 @@ class Ails(BaseProvider):
|
||||
if b"content" in token:
|
||||
completion_chunk = json.loads(token.decode().replace("data: ", ""))
|
||||
token = completion_chunk["choices"][0]["delta"].get("content")
|
||||
if "ai.ls" in token.lower() or "ai.ci" in token.lower():
|
||||
raise Exception("Response Error: " + token)
|
||||
if token != None:
|
||||
yield token
|
||||
|
||||
|
@ -19,7 +19,7 @@ class You(BaseProvider):
|
||||
stream: bool,
|
||||
**kwargs: Any,
|
||||
) -> CreateResult:
|
||||
url_param = _create_url_param(messages)
|
||||
url_param = _create_url_param(messages, kwargs.get("history", []))
|
||||
headers = _create_header()
|
||||
url = f"https://you.com/api/streamingSearch?{url_param}"
|
||||
response = requests.get(
|
||||
@ -28,12 +28,15 @@ class You(BaseProvider):
|
||||
impersonate="chrome107",
|
||||
)
|
||||
response.raise_for_status()
|
||||
yield _parse_output(response.text)
|
||||
yield _parse_output(response.text).encode().decode("unicode_escape")
|
||||
|
||||
|
||||
def _create_url_param(messages: list[dict[str, str]]):
|
||||
prompt = messages.pop()["content"]
|
||||
chat = _convert_chat(messages)
|
||||
def _create_url_param(messages: list[dict[str, str]], history: list[dict[str, str]]):
|
||||
prompt = ""
|
||||
for message in messages:
|
||||
prompt += "%s: %s\n" % (message["role"], message["content"])
|
||||
prompt += "assistant:"
|
||||
chat = _convert_chat(history)
|
||||
param = {"q": prompt, "domain": "youchat", "chat": chat}
|
||||
return urllib.parse.urlencode(param)
|
||||
|
||||
|
@ -35,7 +35,10 @@ def _create_header():
|
||||
|
||||
|
||||
def _create_payload(messages: list[dict[str, str]]):
|
||||
prompt = messages[-1]["content"]
|
||||
prompt = ""
|
||||
for message in messages:
|
||||
prompt += "%s: %s\n" % (message["role"], message["content"])
|
||||
prompt += "assistant:"
|
||||
return {
|
||||
"prompt": prompt,
|
||||
"network": True,
|
||||
|
Loading…
Reference in New Issue
Block a user