summaryrefslogtreecommitdiffstats
path: root/g4f/Provider/selenium
diff options
context:
space:
mode:
authorkqlio67 <kqlio67@users.noreply.github.com>2024-11-06 16:25:09 +0100
committerkqlio67 <kqlio67@users.noreply.github.com>2024-11-06 16:25:09 +0100
commite98793d0a7af43878cf023fb045dd945a82507cf (patch)
tree205f2318755db4c7ad41a6d13e735c5d48e1450b /g4f/Provider/selenium
parentUpdate (g4f/Provider/DeepInfra.py g4f/Provider/__init__.py g4f/Provider/needs_auth/) (diff)
downloadgpt4free-e98793d0a7af43878cf023fb045dd945a82507cf.tar
gpt4free-e98793d0a7af43878cf023fb045dd945a82507cf.tar.gz
gpt4free-e98793d0a7af43878cf023fb045dd945a82507cf.tar.bz2
gpt4free-e98793d0a7af43878cf023fb045dd945a82507cf.tar.lz
gpt4free-e98793d0a7af43878cf023fb045dd945a82507cf.tar.xz
gpt4free-e98793d0a7af43878cf023fb045dd945a82507cf.tar.zst
gpt4free-e98793d0a7af43878cf023fb045dd945a82507cf.zip
Diffstat (limited to 'g4f/Provider/selenium')
-rw-r--r--g4f/Provider/selenium/MyShell.py76
-rw-r--r--g4f/Provider/selenium/__init__.py1
2 files changed, 0 insertions, 77 deletions
diff --git a/g4f/Provider/selenium/MyShell.py b/g4f/Provider/selenium/MyShell.py
deleted file mode 100644
index 02e182d4..00000000
--- a/g4f/Provider/selenium/MyShell.py
+++ /dev/null
@@ -1,76 +0,0 @@
-from __future__ import annotations
-
-import time, json
-
-from ...typing import CreateResult, Messages
-from ..base_provider import AbstractProvider
-from ..helper import format_prompt
-from ...webdriver import WebDriver, WebDriverSession, bypass_cloudflare
-
-class MyShell(AbstractProvider):
- url = "https://app.myshell.ai/chat"
- working = False
- supports_gpt_35_turbo = True
- supports_stream = True
-
- @classmethod
- def create_completion(
- cls,
- model: str,
- messages: Messages,
- stream: bool,
- proxy: str = None,
- timeout: int = 120,
- webdriver: WebDriver = None,
- **kwargs
- ) -> CreateResult:
- with WebDriverSession(webdriver, "", proxy=proxy) as driver:
- bypass_cloudflare(driver, cls.url, timeout)
-
- # Send request with message
- data = {
- "botId": "4738",
- "conversation_scenario": 3,
- "message": format_prompt(messages),
- "messageType": 1
- }
- script = """
-response = await fetch("https://api.myshell.ai/v1/bot/chat/send_message", {
- "headers": {
- "accept": "application/json",
- "content-type": "application/json",
- "myshell-service-name": "organics-api",
- "visitor-id": localStorage.getItem("mix_visitorId")
- },
- "body": '{body}',
- "method": "POST"
-})
-window._reader = response.body.pipeThrough(new TextDecoderStream()).getReader();
-"""
- driver.execute_script(script.replace("{body}", json.dumps(data)))
- script = """
-chunk = await window._reader.read();
-if (chunk.done) {
- return null;
-}
-content = '';
-chunk.value.split('\\n').forEach((line, index) => {
- if (line.startsWith('data: ')) {
- try {
- const data = JSON.parse(line.substring('data: '.length));
- if ('content' in data) {
- content += data['content'];
- }
- } catch(e) {}
- }
-});
-return content;
-"""
- while True:
- chunk = driver.execute_script(script)
- if chunk:
- yield chunk
- elif chunk != "":
- break
- else:
- time.sleep(0.1)
diff --git a/g4f/Provider/selenium/__init__.py b/g4f/Provider/selenium/__init__.py
index 3a59ea58..44adf5fb 100644
--- a/g4f/Provider/selenium/__init__.py
+++ b/g4f/Provider/selenium/__init__.py
@@ -1,4 +1,3 @@
-from .MyShell import MyShell
from .PerplexityAi import PerplexityAi
from .Phind import Phind
from .TalkAi import TalkAi