summaryrefslogtreecommitdiffstats
path: root/g4f/Provider/deprecated/OpenAssistant.py
diff options
context:
space:
mode:
authorkqlio67 <kqlio67@users.noreply.github.com>2024-09-24 12:23:53 +0200
committerkqlio67 <kqlio67@users.noreply.github.com>2024-09-24 12:23:53 +0200
commitf8e403a745c5caff31d7edb854dcba40eba3166d (patch)
treea75c6030a8054c56201fa2d41306a51b9052545c /g4f/Provider/deprecated/OpenAssistant.py
parentAdded gpt-4o provider (diff)
downloadgpt4free-f8e403a745c5caff31d7edb854dcba40eba3166d.tar
gpt4free-f8e403a745c5caff31d7edb854dcba40eba3166d.tar.gz
gpt4free-f8e403a745c5caff31d7edb854dcba40eba3166d.tar.bz2
gpt4free-f8e403a745c5caff31d7edb854dcba40eba3166d.tar.lz
gpt4free-f8e403a745c5caff31d7edb854dcba40eba3166d.tar.xz
gpt4free-f8e403a745c5caff31d7edb854dcba40eba3166d.tar.zst
gpt4free-f8e403a745c5caff31d7edb854dcba40eba3166d.zip
Diffstat (limited to 'g4f/Provider/deprecated/OpenAssistant.py')
-rw-r--r--g4f/Provider/deprecated/OpenAssistant.py88
1 files changed, 0 insertions, 88 deletions
diff --git a/g4f/Provider/deprecated/OpenAssistant.py b/g4f/Provider/deprecated/OpenAssistant.py
deleted file mode 100644
index 80cae3c2..00000000
--- a/g4f/Provider/deprecated/OpenAssistant.py
+++ /dev/null
@@ -1,88 +0,0 @@
-from __future__ import annotations
-
-import json
-
-from aiohttp import ClientSession
-
-from ...typing import AsyncResult, Messages
-from ..base_provider import AsyncGeneratorProvider
-from ..helper import format_prompt, get_cookies
-
-class OpenAssistant(AsyncGeneratorProvider):
- url = "https://open-assistant.io/chat"
- needs_auth = True
- working = False
- model = "OA_SFT_Llama_30B_6"
-
- @classmethod
- async def create_async_generator(
- cls,
- model: str,
- messages: Messages,
- proxy: str = None,
- cookies: dict = None,
- **kwargs
- ) -> AsyncResult:
- if not cookies:
- cookies = get_cookies("open-assistant.io")
-
- headers = {
- 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36',
- }
- async with ClientSession(
- cookies=cookies,
- headers=headers
- ) as session:
- async with session.post("https://open-assistant.io/api/chat", proxy=proxy) as response:
- chat_id = (await response.json())["id"]
-
- data = {
- "chat_id": chat_id,
- "content": f"<s>[INST]\n{format_prompt(messages)}\n[/INST]",
- "parent_id": None
- }
- async with session.post("https://open-assistant.io/api/chat/prompter_message", proxy=proxy, json=data) as response:
- parent_id = (await response.json())["id"]
-
- data = {
- "chat_id": chat_id,
- "parent_id": parent_id,
- "model_config_name": model if model else cls.model,
- "sampling_parameters":{
- "top_k": 50,
- "top_p": None,
- "typical_p": None,
- "temperature": 0.35,
- "repetition_penalty": 1.1111111111111112,
- "max_new_tokens": 1024,
- **kwargs
- },
- "plugins":[]
- }
- async with session.post("https://open-assistant.io/api/chat/assistant_message", proxy=proxy, json=data) as response:
- data = await response.json()
- if "id" in data:
- message_id = data["id"]
- elif "message" in data:
- raise RuntimeError(data["message"])
- else:
- response.raise_for_status()
-
- params = {
- 'chat_id': chat_id,
- 'message_id': message_id,
- }
- async with session.post("https://open-assistant.io/api/chat/events", proxy=proxy, params=params) as response:
- start = "data: "
- async for line in response.content:
- line = line.decode("utf-8")
- if line and line.startswith(start):
- line = json.loads(line[len(start):])
- if line["event_type"] == "token":
- yield line["text"]
-
- params = {
- 'chat_id': chat_id,
- }
- async with session.delete("https://open-assistant.io/api/chat", proxy=proxy, params=params) as response:
- response.raise_for_status()