webscout 5.2__py3-none-any.whl → 5.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of webscout might be problematic. Click here for more details.
- webscout/AIauto.py +8 -12
- webscout/AIutel.py +10 -10
- webscout/Agents/Onlinesearcher.py +5 -5
- webscout/Agents/functioncall.py +123 -97
- webscout/DWEBS.py +99 -77
- webscout/Local/_version.py +2 -2
- webscout/Provider/Andi.py +1 -21
- webscout/Provider/BasedGPT.py +1 -21
- webscout/Provider/Blackboxai.py +1 -21
- webscout/Provider/Chatify.py +175 -0
- webscout/Provider/Cloudflare.py +1 -22
- webscout/Provider/Cohere.py +2 -23
- webscout/Provider/DARKAI.py +0 -1
- webscout/Provider/Deepinfra.py +2 -16
- webscout/Provider/EDITEE.py +3 -26
- webscout/Provider/Gemini.py +1 -24
- webscout/Provider/Groq.py +0 -2
- webscout/Provider/Koboldai.py +0 -21
- webscout/Provider/Llama.py +4 -21
- webscout/Provider/NetFly.py +21 -61
- webscout/Provider/OLLAMA.py +0 -17
- webscout/Provider/Openai.py +2 -22
- webscout/Provider/Perplexity.py +1 -2
- webscout/Provider/Phind.py +3 -508
- webscout/Provider/RUBIKSAI.py +11 -5
- webscout/Provider/Reka.py +4 -21
- webscout/Provider/TTS/streamElements.py +1 -22
- webscout/Provider/TTS/voicepod.py +11 -8
- webscout/Provider/ThinkAnyAI.py +17 -78
- webscout/Provider/Youchat.py +3 -20
- webscout/Provider/__init__.py +17 -8
- webscout/Provider/ai4chat.py +14 -8
- webscout/Provider/cerebras.py +199 -0
- webscout/Provider/{Berlin4h.py → cleeai.py} +68 -73
- webscout/Provider/{liaobots.py → elmo.py} +75 -106
- webscout/Provider/felo_search.py +29 -87
- webscout/Provider/geminiapi.py +198 -0
- webscout/Provider/genspark.py +222 -0
- webscout/Provider/julius.py +3 -20
- webscout/Provider/koala.py +1 -1
- webscout/Provider/lepton.py +194 -0
- webscout/Provider/turboseek.py +4 -21
- webscout/Provider/x0gpt.py +182 -0
- webscout/Provider/xdash.py +2 -22
- webscout/Provider/yep.py +391 -149
- webscout/YTdownloader.py +2 -3
- webscout/__init__.py +2 -2
- webscout/exceptions.py +2 -1
- webscout/transcriber.py +195 -140
- webscout/version.py +1 -1
- {webscout-5.2.dist-info → webscout-5.4.dist-info}/METADATA +47 -134
- webscout-5.4.dist-info/RECORD +98 -0
- webscout/voice.py +0 -34
- webscout-5.2.dist-info/RECORD +0 -93
- {webscout-5.2.dist-info → webscout-5.4.dist-info}/LICENSE.md +0 -0
- {webscout-5.2.dist-info → webscout-5.4.dist-info}/WHEEL +0 -0
- {webscout-5.2.dist-info → webscout-5.4.dist-info}/entry_points.txt +0 -0
- {webscout-5.2.dist-info → webscout-5.4.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
from typing import Any, Dict
|
|
2
|
+
from uuid import uuid4
|
|
3
|
+
import requests
|
|
4
|
+
|
|
5
|
+
import re
|
|
6
|
+
|
|
7
|
+
from webscout.AIutel import Optimizers
|
|
8
|
+
from webscout.AIutel import Conversation
|
|
9
|
+
from webscout.AIutel import AwesomePrompts
|
|
10
|
+
from webscout.AIbase import Provider
|
|
11
|
+
from webscout import exceptions
|
|
12
|
+
|
|
13
|
+
class X0GPT(Provider):
|
|
14
|
+
"""
|
|
15
|
+
A class to interact with the x0-gpt.devwtf.in API.
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
def __init__(
|
|
19
|
+
self,
|
|
20
|
+
is_conversation: bool = True,
|
|
21
|
+
max_tokens: int = 600,
|
|
22
|
+
timeout: int = 30,
|
|
23
|
+
intro: str = None,
|
|
24
|
+
filepath: str = None,
|
|
25
|
+
update_file: bool = True,
|
|
26
|
+
proxies: dict = {},
|
|
27
|
+
history_offset: int = 10250,
|
|
28
|
+
act: str = None,
|
|
29
|
+
):
|
|
30
|
+
"""
|
|
31
|
+
Initializes the X0GPT API with given parameters.
|
|
32
|
+
"""
|
|
33
|
+
self.session = requests.Session()
|
|
34
|
+
self.is_conversation = is_conversation
|
|
35
|
+
self.max_tokens_to_sample = max_tokens
|
|
36
|
+
self.api_endpoint = "https://x0-gpt.devwtf.in/api/stream/reply"
|
|
37
|
+
self.timeout = timeout
|
|
38
|
+
self.last_response = {}
|
|
39
|
+
self.headers = {
|
|
40
|
+
"authority": "x0-gpt.devwtf.in",
|
|
41
|
+
"method": "POST",
|
|
42
|
+
"path": "/api/stream/reply",
|
|
43
|
+
"scheme": "https",
|
|
44
|
+
"accept": "*/*",
|
|
45
|
+
"accept-encoding": "gzip, deflate, br, zstd",
|
|
46
|
+
"accept-language": "en-US,en;q=0.9,en-IN;q=0.8",
|
|
47
|
+
"content-length": "114",
|
|
48
|
+
"content-type": "application/json",
|
|
49
|
+
"dnt": "1",
|
|
50
|
+
"origin": "https://x0-gpt.devwtf.in",
|
|
51
|
+
"priority": "u=1, i",
|
|
52
|
+
"referer": "https://x0-gpt.devwtf.in/chat",
|
|
53
|
+
"sec-ch-ua": '"Not)A;Brand";v="99", "Microsoft Edge";v="127", "Chromium";v="127"',
|
|
54
|
+
"sec-ch-ua-mobile": "?0",
|
|
55
|
+
"sec-ch-ua-platform": '"Windows"',
|
|
56
|
+
"sec-fetch-dest": "empty",
|
|
57
|
+
"sec-fetch-mode": "cors",
|
|
58
|
+
"sec-fetch-site": "same-origin",
|
|
59
|
+
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36 Edg/127.0.0.0"
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
self.__available_optimizers = (
|
|
63
|
+
method
|
|
64
|
+
for method in dir(Optimizers)
|
|
65
|
+
if callable(getattr(Optimizers, method)) and not method.startswith("__")
|
|
66
|
+
)
|
|
67
|
+
self.session.headers.update(self.headers)
|
|
68
|
+
Conversation.intro = (
|
|
69
|
+
AwesomePrompts().get_act(
|
|
70
|
+
act, raise_not_found=True, default=None, case_insensitive=True
|
|
71
|
+
)
|
|
72
|
+
if act
|
|
73
|
+
else intro or Conversation.intro
|
|
74
|
+
)
|
|
75
|
+
self.conversation = Conversation(
|
|
76
|
+
is_conversation, self.max_tokens_to_sample, filepath, update_file
|
|
77
|
+
)
|
|
78
|
+
self.conversation.history_offset = history_offset
|
|
79
|
+
self.session.proxies = proxies
|
|
80
|
+
|
|
81
|
+
def ask(
|
|
82
|
+
self,
|
|
83
|
+
prompt: str,
|
|
84
|
+
stream: bool = False,
|
|
85
|
+
raw: bool = False,
|
|
86
|
+
optimizer: str = None,
|
|
87
|
+
conversationally: bool = False,
|
|
88
|
+
) -> Dict[str, Any]:
|
|
89
|
+
"""
|
|
90
|
+
Sends a prompt to the x0-gpt.devwtf.in API and returns the response.
|
|
91
|
+
"""
|
|
92
|
+
conversation_prompt = self.conversation.gen_complete_prompt(prompt)
|
|
93
|
+
if optimizer:
|
|
94
|
+
if optimizer in self.__available_optimizers:
|
|
95
|
+
conversation_prompt = getattr(Optimizers, optimizer)(
|
|
96
|
+
conversation_prompt if conversationally else prompt
|
|
97
|
+
)
|
|
98
|
+
else:
|
|
99
|
+
raise Exception(
|
|
100
|
+
f"Optimizer is not one of {self.__available_optimizers}"
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
payload = {
|
|
104
|
+
"messages": [
|
|
105
|
+
{
|
|
106
|
+
"role": "user",
|
|
107
|
+
"content": conversation_prompt
|
|
108
|
+
}
|
|
109
|
+
],
|
|
110
|
+
"chatId": uuid4().hex,
|
|
111
|
+
"namespace": None
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
def for_stream():
|
|
115
|
+
response = self.session.post(self.api_endpoint, headers=self.headers, json=payload, stream=True, timeout=self.timeout)
|
|
116
|
+
if not response.ok:
|
|
117
|
+
raise exceptions.FailedToGenerateResponseError(
|
|
118
|
+
f"Failed to generate response - ({response.status_code}, {response.reason}) - {response.text}"
|
|
119
|
+
)
|
|
120
|
+
streaming_response = ""
|
|
121
|
+
for line in response.iter_lines(decode_unicode=True, chunk_size=64):
|
|
122
|
+
if line:
|
|
123
|
+
match = re.search(r'0:"(.*?)"', line)
|
|
124
|
+
if match:
|
|
125
|
+
content = match.group(1)
|
|
126
|
+
streaming_response += content
|
|
127
|
+
yield content if raw else dict(text=streaming_response)
|
|
128
|
+
self.last_response.update(dict(text=streaming_response))
|
|
129
|
+
self.conversation.update_chat_history(
|
|
130
|
+
prompt, self.get_message(self.last_response)
|
|
131
|
+
)
|
|
132
|
+
|
|
133
|
+
def for_non_stream():
|
|
134
|
+
for _ in for_stream():
|
|
135
|
+
pass
|
|
136
|
+
return self.last_response
|
|
137
|
+
|
|
138
|
+
return for_stream() if stream else for_non_stream()
|
|
139
|
+
|
|
140
|
+
def chat(
|
|
141
|
+
self,
|
|
142
|
+
prompt: str,
|
|
143
|
+
stream: bool = False,
|
|
144
|
+
optimizer: str = None,
|
|
145
|
+
conversationally: bool = False,
|
|
146
|
+
) -> str:
|
|
147
|
+
"""
|
|
148
|
+
Generates a response from the X0GPT API.
|
|
149
|
+
"""
|
|
150
|
+
|
|
151
|
+
def for_stream():
|
|
152
|
+
for response in self.ask(
|
|
153
|
+
prompt, True, optimizer=optimizer, conversationally=conversationally
|
|
154
|
+
):
|
|
155
|
+
yield self.get_message(response).replace("\n", "\n\n")
|
|
156
|
+
|
|
157
|
+
def for_non_stream():
|
|
158
|
+
return self.get_message(
|
|
159
|
+
self.ask(
|
|
160
|
+
prompt,
|
|
161
|
+
False,
|
|
162
|
+
optimizer=optimizer,
|
|
163
|
+
conversationally=conversationally,
|
|
164
|
+
)
|
|
165
|
+
).replace("\n", "\n\n")
|
|
166
|
+
|
|
167
|
+
return for_stream() if stream else for_non_stream()
|
|
168
|
+
|
|
169
|
+
def get_message(self, response: dict) -> str:
|
|
170
|
+
"""
|
|
171
|
+
Extracts the message from the API response.
|
|
172
|
+
"""
|
|
173
|
+
assert isinstance(response, dict), "Response should be of dict data-type only"
|
|
174
|
+
formatted_text = response["text"].replace('\\n', '\n').replace('\\n\\n', '\n\n')
|
|
175
|
+
return formatted_text
|
|
176
|
+
|
|
177
|
+
if __name__ == "__main__":
|
|
178
|
+
from rich import print
|
|
179
|
+
ai = X0GPT()
|
|
180
|
+
response = ai.chat(input(">>> "))
|
|
181
|
+
for chunk in response:
|
|
182
|
+
print(chunk, end="", flush=True)
|
webscout/Provider/xdash.py
CHANGED
|
@@ -1,32 +1,11 @@
|
|
|
1
|
-
import time
|
|
2
1
|
import uuid
|
|
3
|
-
from selenium import webdriver
|
|
4
|
-
from selenium.webdriver.chrome.options import Options
|
|
5
|
-
from selenium.webdriver.common.by import By
|
|
6
|
-
from selenium.webdriver.support import expected_conditions as EC
|
|
7
|
-
from selenium.webdriver.support.ui import WebDriverWait
|
|
8
|
-
import click
|
|
9
2
|
import requests
|
|
10
|
-
from requests import get
|
|
11
|
-
from uuid import uuid4
|
|
12
|
-
from re import findall
|
|
13
|
-
from requests.exceptions import RequestException
|
|
14
|
-
from curl_cffi.requests import get, RequestsError
|
|
15
|
-
import g4f
|
|
16
|
-
from random import randint
|
|
17
|
-
from PIL import Image
|
|
18
|
-
import io
|
|
19
|
-
import re
|
|
20
|
-
import json
|
|
21
|
-
import yaml
|
|
22
3
|
from webscout.AIutel import Optimizers
|
|
23
4
|
from webscout.AIutel import Conversation
|
|
24
5
|
from webscout.AIutel import AwesomePrompts, sanitize_stream
|
|
25
6
|
from webscout.AIbase import Provider, AsyncProvider
|
|
26
7
|
from webscout import exceptions
|
|
27
8
|
from typing import Any, AsyncGenerator, Dict
|
|
28
|
-
import logging
|
|
29
|
-
import httpx
|
|
30
9
|
|
|
31
10
|
class XDASH(Provider):
|
|
32
11
|
def __init__(
|
|
@@ -199,4 +178,5 @@ if __name__ == '__main__':
|
|
|
199
178
|
from rich import print
|
|
200
179
|
ai = XDASH()
|
|
201
180
|
response = ai.chat(input(">>> "))
|
|
202
|
-
|
|
181
|
+
for chunk in response:
|
|
182
|
+
print(chunk, end="", flush=True)
|