diff options
author | Heiner Lohaus <heiner.lohaus@netformic.com> | 2023-08-22 23:27:34 +0200 |
---|---|---|
committer | Heiner Lohaus <heiner.lohaus@netformic.com> | 2023-08-22 23:27:34 +0200 |
commit | 98d3304108de3e55c18f2af8a66a501541ec658b (patch) | |
tree | a2d80ab0c39ec93ebb97967a9f5a32f0c662c99e /g4f | |
parent | ~ | Merge pull request #829 (diff) | |
download | gpt4free-98d3304108de3e55c18f2af8a66a501541ec658b.tar gpt4free-98d3304108de3e55c18f2af8a66a501541ec658b.tar.gz gpt4free-98d3304108de3e55c18f2af8a66a501541ec658b.tar.bz2 gpt4free-98d3304108de3e55c18f2af8a66a501541ec658b.tar.lz gpt4free-98d3304108de3e55c18f2af8a66a501541ec658b.tar.xz gpt4free-98d3304108de3e55c18f2af8a66a501541ec658b.tar.zst gpt4free-98d3304108de3e55c18f2af8a66a501541ec658b.zip |
Diffstat (limited to '')
-rw-r--r-- | g4f/Provider/DfeHub.py | 1 | ||||
-rw-r--r-- | g4f/Provider/FastGpt.py | 2 | ||||
-rw-r--r-- | g4f/Provider/H2o.py | 8 | ||||
-rw-r--r-- | g4f/Provider/V50.py | 5 | ||||
-rw-r--r-- | g4f/Provider/Wewordle.py | 7 | ||||
-rw-r--r-- | g4f/Provider/You.py | 15 |
6 files changed, 18 insertions, 20 deletions
diff --git a/g4f/Provider/DfeHub.py b/g4f/Provider/DfeHub.py index 4093d0e4..5a7b22e1 100644 --- a/g4f/Provider/DfeHub.py +++ b/g4f/Provider/DfeHub.py @@ -50,6 +50,7 @@ class DfeHub(BaseProvider): "https://chat.dfehub.com/api/openai/v1/chat/completions", headers=headers, json=json_data, + timeout=3 ) for chunk in response.iter_lines(): diff --git a/g4f/Provider/FastGpt.py b/g4f/Provider/FastGpt.py index 950abab1..3c5a4420 100644 --- a/g4f/Provider/FastGpt.py +++ b/g4f/Provider/FastGpt.py @@ -6,7 +6,7 @@ from ..typing import Any, CreateResult class FastGpt(ABC): url: str = 'https://chat9.fastgpt.me/' - working = True + working = False needs_auth = False supports_stream = True supports_gpt_35_turbo = True diff --git a/g4f/Provider/H2o.py b/g4f/Provider/H2o.py index f9b799bb..305a0bbf 100644 --- a/g4f/Provider/H2o.py +++ b/g4f/Provider/H2o.py @@ -11,6 +11,7 @@ class H2o(BaseProvider): url = "https://gpt-gm.h2o.ai" working = True supports_stream = True + model = "h2oai/h2ogpt-gm-oasst1-en-2048-falcon-40b-v1" @staticmethod def create_completion( @@ -47,8 +48,9 @@ class H2o(BaseProvider): "https://gpt-gm.h2o.ai/conversation", headers=headers, json=data, - ) - conversation_id = response.json()["conversationId"] + ).json() + if "conversationId" not in response: + return data = { "inputs": conversation, @@ -71,7 +73,7 @@ class H2o(BaseProvider): } response = session.post( - f"https://gpt-gm.h2o.ai/conversation/{conversation_id}", + f"https://gpt-gm.h2o.ai/conversation/{response['conversationId']}", headers=headers, json=data, ) diff --git a/g4f/Provider/V50.py b/g4f/Provider/V50.py index 125dd7c5..765f73bd 100644 --- a/g4f/Provider/V50.py +++ b/g4f/Provider/V50.py @@ -8,7 +8,7 @@ class V50(BaseProvider): supports_gpt_35_turbo = True supports_stream = False needs_auth = False - working = True + working = False @staticmethod def create_completion( @@ -46,7 +46,8 @@ class V50(BaseProvider): } response = requests.post("https://p5.v50.ltd/api/chat-process", json=payload, headers=headers, proxies=kwargs['proxy'] if 'proxy' in kwargs else {}) - yield response.text + if "https://fk1.v50.ltd" not in response.text: + yield response.text @classmethod @property diff --git a/g4f/Provider/Wewordle.py b/g4f/Provider/Wewordle.py index f7f47ee0..cef209c9 100644 --- a/g4f/Provider/Wewordle.py +++ b/g4f/Provider/Wewordle.py @@ -21,11 +21,6 @@ class Wewordle(BaseProvider): stream: bool, **kwargs: Any, ) -> CreateResult: - base = "" - - for message in messages: - base += "%s: %s\n" % (message["role"], message["content"]) - base += "assistant:" # randomize user id and app id _user_id = "".join( random.choices(f"{string.ascii_lowercase}{string.digits}", k=16) @@ -45,7 +40,7 @@ class Wewordle(BaseProvider): } data: dict[str, Any] = { "user": _user_id, - "messages": [{"role": "user", "content": base}], + "messages": messages, "subscriber": { "originalPurchaseDate": None, "originalApplicationVersion": None, diff --git a/g4f/Provider/You.py b/g4f/Provider/You.py index 0d8114a8..cbd741ba 100644 --- a/g4f/Provider/You.py +++ b/g4f/Provider/You.py @@ -1,5 +1,6 @@ import re import urllib.parse +import json from curl_cffi import requests @@ -28,7 +29,11 @@ class You(BaseProvider): impersonate="chrome107", ) response.raise_for_status() - yield _parse_output(response.text) + start = 'data: {"youChatToken": ' + for line in response.content.splitlines(): + line = line.decode('utf-8') + if line.startswith(start): + yield json.loads(line[len(start): -1]) def _create_url_param(messages: list[dict[str, str]]): @@ -50,10 +55,4 @@ def _create_header(): return { "accept": "text/event-stream", "referer": "https://you.com/search?fromSearchBar=true&tbm=youchat", - } - - -def _parse_output(output: str) -> str: - regex = r"^data:\s{\"youChatToken\": \"(.*)\"}$" - tokens = [token for token in re.findall(regex, output, re.MULTILINE)] - return "".join(tokens) + }
\ No newline at end of file |