summaryrefslogtreecommitdiffstats
path: root/g4f/Provider
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--g4f/Provider/AItianhu.py2
-rw-r--r--g4f/Provider/Acytoo.py8
-rw-r--r--g4f/Provider/AiService.py2
-rw-r--r--g4f/Provider/DfeHub.py3
-rw-r--r--g4f/Provider/FastGpt.py2
-rw-r--r--g4f/Provider/H2o.py8
-rw-r--r--g4f/Provider/V50.py5
-rw-r--r--g4f/Provider/Wewordle.py15
-rw-r--r--g4f/Provider/You.py17
9 files changed, 30 insertions, 32 deletions
diff --git a/g4f/Provider/AItianhu.py b/g4f/Provider/AItianhu.py
index e8e5714a..9f5440bc 100644
--- a/g4f/Provider/AItianhu.py
+++ b/g4f/Provider/AItianhu.py
@@ -7,7 +7,7 @@ from .base_provider import BaseProvider
class AItianhu(BaseProvider):
- url = "https://www.aitianhu.com/api/chat-process"
+ url = "https://www.aitianhu.com/"
working = False
supports_gpt_35_turbo = True
diff --git a/g4f/Provider/Acytoo.py b/g4f/Provider/Acytoo.py
index 2edd9efd..975e914b 100644
--- a/g4f/Provider/Acytoo.py
+++ b/g4f/Provider/Acytoo.py
@@ -7,12 +7,13 @@ from .base_provider import BaseProvider
class Acytoo(BaseProvider):
- url = "https://chat.acytoo.com/api/completions"
+ url = "https://chat.acytoo.com/"
working = True
supports_gpt_35_turbo = True
- @staticmethod
+ @classmethod
def create_completion(
+ cls,
model: str,
messages: list[dict[str, str]],
stream: bool,
@@ -21,8 +22,7 @@ class Acytoo(BaseProvider):
headers = _create_header()
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 = requests.post("{cls.url}api/completions", headers=headers, json=payload)
response.raise_for_status()
response.encoding = "utf-8"
yield response.text
diff --git a/g4f/Provider/AiService.py b/g4f/Provider/AiService.py
index 2c0d5de2..3453bfd9 100644
--- a/g4f/Provider/AiService.py
+++ b/g4f/Provider/AiService.py
@@ -5,7 +5,7 @@ from .base_provider import BaseProvider
class AiService(BaseProvider):
- url = "https://aiservice.vercel.app/api/chat/answer"
+ url = "https://aiservice.vercel.app/"
working = False
supports_gpt_35_turbo = True
diff --git a/g4f/Provider/DfeHub.py b/g4f/Provider/DfeHub.py
index 4093d0e4..6f96ec7a 100644
--- a/g4f/Provider/DfeHub.py
+++ b/g4f/Provider/DfeHub.py
@@ -9,7 +9,7 @@ from .base_provider import BaseProvider
class DfeHub(BaseProvider):
- url = "https://chat.dfehub.com/api/chat"
+ url = "https://chat.dfehub.com/"
supports_stream = True
supports_gpt_35_turbo = True
@@ -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..8e106716 100644
--- a/g4f/Provider/Wewordle.py
+++ b/g4f/Provider/Wewordle.py
@@ -10,22 +10,18 @@ from .base_provider import BaseProvider
class Wewordle(BaseProvider):
- url = "https://wewordle.org/gptapi/v1/android/turbo"
+ url = "https://wewordle.org/"
working = True
supports_gpt_35_turbo = True
- @staticmethod
+ @classmethod
def create_completion(
+ cls,
model: str,
messages: list[dict[str, str]],
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 +41,7 @@ class Wewordle(BaseProvider):
}
data: dict[str, Any] = {
"user": _user_id,
- "messages": [{"role": "user", "content": base}],
+ "messages": messages,
"subscriber": {
"originalPurchaseDate": None,
"originalApplicationVersion": None,
@@ -67,8 +63,7 @@ class Wewordle(BaseProvider):
},
}
- url = "https://wewordle.org/gptapi/v1/android/turbo"
- response = requests.post(url, headers=headers, data=json.dumps(data))
+ response = requests.post(f"{cls.url}gptapi/v1/android/turbo", headers=headers, data=json.dumps(data))
response.raise_for_status()
_json = response.json()
if "message" in _json:
diff --git a/g4f/Provider/You.py b/g4f/Provider/You.py
index a8de7dec..7ea699a2 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,8 +29,12 @@ class You(BaseProvider):
impersonate="chrome107",
)
response.raise_for_status()
- yield _parse_output(response.text).encode().decode("unicode_escape")
-
+
+ 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]], history: list[dict[str, str]]):
prompt = ""
@@ -53,10 +58,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