summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--g4f/Provider/Bing.py4
-rw-r--r--g4f/Provider/Chatxyz.py60
-rw-r--r--g4f/Provider/Phind.py7
-rw-r--r--g4f/Provider/__init__.py1
4 files changed, 67 insertions, 5 deletions
diff --git a/g4f/Provider/Bing.py b/g4f/Provider/Bing.py
index dccfc5b1..e03b413f 100644
--- a/g4f/Provider/Bing.py
+++ b/g4f/Provider/Bing.py
@@ -408,14 +408,14 @@ def create_message(conversation: Conversation, prompt: str, tone: str, context:
'traceId': os.urandom(16).hex(),
'isStartOfSession': True,
'requestId': request_id,
- 'message': Defaults.location | {
+ 'message': {**Defaults.location, **{
'author': 'user',
'inputMethod': 'Keyboard',
'text': prompt,
'messageType': 'Chat',
'requestId': request_id,
'messageId': request_id,
- },
+ }},
"scenario": "SERP",
'tone': tone,
'spokenTextMode': 'None',
diff --git a/g4f/Provider/Chatxyz.py b/g4f/Provider/Chatxyz.py
new file mode 100644
index 00000000..feb09be9
--- /dev/null
+++ b/g4f/Provider/Chatxyz.py
@@ -0,0 +1,60 @@
+from __future__ import annotations
+
+import json
+from aiohttp import ClientSession
+
+from ..typing import AsyncResult, Messages
+from .base_provider import AsyncGeneratorProvider
+
+class Chatxyz(AsyncGeneratorProvider):
+ url = "https://chat.3211000.xyz"
+ working = True
+ supports_gpt_35_turbo = True
+ supports_message_history = True
+
+ @classmethod
+ async def create_async_generator(
+ cls,
+ model: str,
+ messages: Messages,
+ proxy: str = None,
+ **kwargs
+ ) -> AsyncResult:
+ headers = {
+ 'Accept': 'text/event-stream',
+ 'Accept-Encoding': 'gzip, deflate, br',
+ 'Accept-Language': 'en-US,en;q=0.5',
+ 'Alt-Used': 'chat.3211000.xyz',
+ 'Content-Type': 'application/json',
+ 'Host': 'chat.3211000.xyz',
+ 'Origin': 'https://chat.3211000.xyz',
+ 'Referer': 'https://chat.3211000.xyz/',
+ 'Sec-Fetch-Dest': 'empty',
+ 'Sec-Fetch-Mode': 'cors',
+ 'Sec-Fetch-Site': 'same-origin',
+ 'TE': 'trailers',
+ 'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:121.0) Gecko/20100101 Firefox/121.0',
+ 'x-requested-with': 'XMLHttpRequest'
+ }
+ async with ClientSession(headers=headers) as session:
+ data = {
+ "messages": messages,
+ "stream": True,
+ "model": "gpt-3.5-turbo",
+ "temperature": 0.5,
+ "presence_penalty": 0,
+ "frequency_penalty": 0,
+ "top_p": 1,
+ **kwargs
+ }
+ async with session.post(f'{cls.url}/api/openai/v1/chat/completions', json=data, proxy=proxy) as response:
+ response.raise_for_status()
+ async for chunk in response.content:
+ line = chunk.decode()
+ if line.startswith("data: [DONE]"):
+ break
+ elif line.startswith("data: "):
+ line = json.loads(line[6:])
+ chunk = line["choices"][0]["delta"].get("content")
+ if(chunk):
+ yield chunk \ No newline at end of file
diff --git a/g4f/Provider/Phind.py b/g4f/Provider/Phind.py
index 9d2acc75..bb216989 100644
--- a/g4f/Provider/Phind.py
+++ b/g4f/Provider/Phind.py
@@ -56,14 +56,15 @@ class Phind(AsyncGeneratorProvider):
"customLinks": []
},
"context": "",
- "rewrittenQuestion": prompt
+ "rewrittenQuestion": prompt,
+ "challenge": 0.21132115912208504
}
async with session.post(f"{cls.url}/api/infer/followup/answer", headers=headers, json=data) as response:
new_line = False
async for line in response.iter_lines():
if line.startswith(b"data: "):
chunk = line[6:]
- if chunk.startswith(b"<PHIND_METADATA>"):
+ if chunk.startswith(b"<PHIND_METADATA>") or chunk.startswith(b"<PHIND_INDICATOR>"):
pass
elif chunk:
yield chunk.decode()
@@ -71,4 +72,4 @@ class Phind(AsyncGeneratorProvider):
yield "\n"
new_line = False
else:
- new_line = True \ No newline at end of file
+ new_line = True
diff --git a/g4f/Provider/__init__.py b/g4f/Provider/__init__.py
index 114b3d03..4670d331 100644
--- a/g4f/Provider/__init__.py
+++ b/g4f/Provider/__init__.py
@@ -25,6 +25,7 @@ from .ChatgptFree import ChatgptFree
from .ChatgptLogin import ChatgptLogin
from .ChatgptNext import ChatgptNext
from .ChatgptX import ChatgptX
+from .Chatxyz import Chatxyz
from .DeepInfra import DeepInfra
from .FakeGpt import FakeGpt
from .FreeGpt import FreeGpt