webscout 6.3__py3-none-any.whl → 6.5__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 +191 -176
- webscout/AIbase.py +0 -197
- webscout/AIutel.py +441 -1130
- webscout/DWEBS.py +189 -35
- webscout/{YTdownloader.py → Extra/YTToolkit/YTdownloader.py} +990 -1103
- webscout/Extra/YTToolkit/__init__.py +3 -0
- webscout/{transcriber.py → Extra/YTToolkit/transcriber.py} +479 -551
- webscout/Extra/YTToolkit/ytapi/__init__.py +6 -0
- webscout/Extra/YTToolkit/ytapi/channel.py +307 -0
- webscout/Extra/YTToolkit/ytapi/errors.py +13 -0
- webscout/Extra/YTToolkit/ytapi/extras.py +45 -0
- webscout/Extra/YTToolkit/ytapi/https.py +88 -0
- webscout/Extra/YTToolkit/ytapi/patterns.py +61 -0
- webscout/Extra/YTToolkit/ytapi/playlist.py +59 -0
- webscout/Extra/YTToolkit/ytapi/pool.py +8 -0
- webscout/Extra/YTToolkit/ytapi/query.py +37 -0
- webscout/Extra/YTToolkit/ytapi/stream.py +60 -0
- webscout/Extra/YTToolkit/ytapi/utils.py +62 -0
- webscout/Extra/YTToolkit/ytapi/video.py +102 -0
- webscout/Extra/__init__.py +3 -1
- webscout/Extra/autocoder/__init__.py +9 -0
- webscout/Extra/autocoder/autocoder_utiles.py +121 -0
- webscout/Extra/autocoder/rawdog.py +680 -0
- webscout/Extra/autollama.py +246 -195
- webscout/Extra/gguf.py +81 -56
- webscout/Extra/markdownlite/__init__.py +862 -0
- webscout/Extra/weather_ascii.py +2 -2
- webscout/LLM.py +206 -43
- webscout/Litlogger/__init__.py +681 -0
- webscout/Provider/DARKAI.py +1 -1
- webscout/Provider/EDITEE.py +1 -1
- webscout/Provider/NinjaChat.py +1 -1
- webscout/Provider/PI.py +120 -35
- webscout/Provider/Perplexity.py +590 -598
- webscout/Provider/Reka.py +0 -1
- webscout/Provider/RoboCoders.py +206 -0
- webscout/Provider/TTI/AiForce/__init__.py +22 -0
- webscout/Provider/TTI/AiForce/async_aiforce.py +257 -0
- webscout/Provider/TTI/AiForce/sync_aiforce.py +242 -0
- webscout/Provider/TTI/Nexra/__init__.py +22 -0
- webscout/Provider/TTI/Nexra/async_nexra.py +286 -0
- webscout/Provider/TTI/Nexra/sync_nexra.py +258 -0
- webscout/Provider/TTI/PollinationsAI/__init__.py +23 -0
- webscout/Provider/TTI/PollinationsAI/async_pollinations.py +330 -0
- webscout/Provider/TTI/PollinationsAI/sync_pollinations.py +285 -0
- webscout/Provider/TTI/__init__.py +2 -4
- webscout/Provider/TTI/artbit/__init__.py +22 -0
- webscout/Provider/TTI/artbit/async_artbit.py +184 -0
- webscout/Provider/TTI/artbit/sync_artbit.py +176 -0
- webscout/Provider/TTI/blackbox/__init__.py +4 -0
- webscout/Provider/TTI/blackbox/async_blackbox.py +212 -0
- webscout/Provider/TTI/{blackboximage.py → blackbox/sync_blackbox.py} +199 -153
- webscout/Provider/TTI/deepinfra/__init__.py +4 -0
- webscout/Provider/TTI/deepinfra/async_deepinfra.py +227 -0
- webscout/Provider/TTI/deepinfra/sync_deepinfra.py +199 -0
- webscout/Provider/TTI/huggingface/__init__.py +22 -0
- webscout/Provider/TTI/huggingface/async_huggingface.py +199 -0
- webscout/Provider/TTI/huggingface/sync_huggingface.py +195 -0
- webscout/Provider/TTI/imgninza/__init__.py +4 -0
- webscout/Provider/TTI/imgninza/async_ninza.py +214 -0
- webscout/Provider/TTI/{imgninza.py → imgninza/sync_ninza.py} +209 -136
- webscout/Provider/TTI/talkai/__init__.py +4 -0
- webscout/Provider/TTI/talkai/async_talkai.py +229 -0
- webscout/Provider/TTI/talkai/sync_talkai.py +207 -0
- webscout/Provider/TTS/__init__.py +5 -1
- webscout/Provider/TTS/deepgram.py +183 -0
- webscout/Provider/TTS/elevenlabs.py +137 -0
- webscout/Provider/TTS/gesserit.py +151 -0
- webscout/Provider/TTS/murfai.py +139 -0
- webscout/Provider/TTS/parler.py +134 -107
- webscout/Provider/TTS/streamElements.py +360 -275
- webscout/Provider/TTS/utils.py +280 -0
- webscout/Provider/TTS/voicepod.py +116 -116
- webscout/Provider/__init__.py +8 -1
- webscout/Provider/askmyai.py +2 -2
- webscout/Provider/cerebras.py +227 -219
- webscout/Provider/llama3mitril.py +0 -1
- webscout/Provider/meta.py +794 -779
- webscout/Provider/mhystical.py +176 -0
- webscout/Provider/perplexitylabs.py +265 -0
- webscout/Provider/twitterclone.py +251 -245
- webscout/Provider/typegpt.py +358 -0
- webscout/__init__.py +9 -8
- webscout/__main__.py +5 -5
- webscout/cli.py +252 -280
- webscout/conversation.py +227 -0
- webscout/exceptions.py +161 -29
- webscout/litagent/__init__.py +172 -0
- webscout/litprinter/__init__.py +832 -0
- webscout/optimizers.py +270 -0
- webscout/prompt_manager.py +279 -0
- webscout/scout/__init__.py +11 -0
- webscout/scout/core.py +884 -0
- webscout/scout/element.py +459 -0
- webscout/scout/parsers/__init__.py +69 -0
- webscout/scout/parsers/html5lib_parser.py +172 -0
- webscout/scout/parsers/html_parser.py +236 -0
- webscout/scout/parsers/lxml_parser.py +178 -0
- webscout/scout/utils.py +38 -0
- webscout/swiftcli/__init__.py +810 -0
- webscout/update_checker.py +125 -0
- webscout/version.py +1 -1
- webscout/zeroart/__init__.py +55 -0
- webscout/zeroart/base.py +61 -0
- webscout/zeroart/effects.py +99 -0
- webscout/zeroart/fonts.py +816 -0
- webscout/zerodir/__init__.py +225 -0
- {webscout-6.3.dist-info → webscout-6.5.dist-info}/METADATA +37 -112
- webscout-6.5.dist-info/RECORD +179 -0
- webscout/Agents/Onlinesearcher.py +0 -182
- webscout/Agents/__init__.py +0 -2
- webscout/Agents/functioncall.py +0 -248
- webscout/Bing_search.py +0 -154
- webscout/Provider/TTI/AIuncensoredimage.py +0 -103
- webscout/Provider/TTI/Nexra.py +0 -120
- webscout/Provider/TTI/PollinationsAI.py +0 -138
- webscout/Provider/TTI/WebSimAI.py +0 -142
- webscout/Provider/TTI/aiforce.py +0 -160
- webscout/Provider/TTI/artbit.py +0 -141
- webscout/Provider/TTI/deepinfra.py +0 -148
- webscout/Provider/TTI/huggingface.py +0 -155
- webscout/Provider/TTI/talkai.py +0 -116
- webscout/g4f.py +0 -666
- webscout/models.py +0 -23
- webscout/requestsHTMLfix.py +0 -775
- webscout/webai.py +0 -2590
- webscout-6.3.dist-info/RECORD +0 -124
- {webscout-6.3.dist-info → webscout-6.5.dist-info}/LICENSE.md +0 -0
- {webscout-6.3.dist-info → webscout-6.5.dist-info}/WHEEL +0 -0
- {webscout-6.3.dist-info → webscout-6.5.dist-info}/entry_points.txt +0 -0
- {webscout-6.3.dist-info → webscout-6.5.dist-info}/top_level.txt +0 -0
webscout/Provider/NinjaChat.py
CHANGED
|
@@ -35,7 +35,7 @@ class NinjaChat(Provider):
|
|
|
35
35
|
proxies: dict = {},
|
|
36
36
|
history_offset: int = 10250,
|
|
37
37
|
act: str = None,
|
|
38
|
-
model: str = "
|
|
38
|
+
model: str = "llama", # Default model
|
|
39
39
|
system_message: str = "You are a helpful AI assistant.", # Default system message
|
|
40
40
|
):
|
|
41
41
|
"""Initializes the NinjaChat API client."""
|
webscout/Provider/PI.py
CHANGED
|
@@ -1,16 +1,29 @@
|
|
|
1
1
|
import cloudscraper
|
|
2
2
|
import json
|
|
3
|
-
|
|
3
|
+
import re
|
|
4
|
+
import threading
|
|
4
5
|
import requests
|
|
5
6
|
from webscout.AIutel import Optimizers
|
|
6
7
|
from webscout.AIutel import Conversation
|
|
7
8
|
from webscout.AIutel import AwesomePrompts
|
|
8
9
|
from webscout.AIbase import Provider
|
|
10
|
+
from typing import Dict
|
|
9
11
|
|
|
10
12
|
class PiAI(Provider):
|
|
13
|
+
"""PiAI class for interacting with the Pi.ai chat API, extending the Provider class.
|
|
14
|
+
|
|
15
|
+
This class provides methods for sending messages to the Pi.ai chat API and receiving responses,
|
|
16
|
+
enabling conversational interactions. It supports various configurations such as conversation mode,
|
|
17
|
+
token limits, and history management.
|
|
18
|
+
|
|
19
|
+
Attributes:
|
|
20
|
+
scraper (cloudscraper.CloudScraper): The scraper instance for handling HTTP requests.
|
|
21
|
+
url (str): The API endpoint for the Pi.ai chat service.
|
|
22
|
+
AVAILABLE_VOICES (Dict[str, int]): A dictionary mapping voice names to their corresponding IDs.
|
|
23
|
+
headers (Dict[str, str]): The headers to be used in HTTP requests to the API.
|
|
24
|
+
"""
|
|
11
25
|
def __init__(
|
|
12
26
|
self,
|
|
13
|
-
conversation_id: str,
|
|
14
27
|
is_conversation: bool = True,
|
|
15
28
|
max_tokens: int = 600,
|
|
16
29
|
timeout: int = 30,
|
|
@@ -21,23 +34,29 @@ class PiAI(Provider):
|
|
|
21
34
|
history_offset: int = 10250,
|
|
22
35
|
act: str = None,
|
|
23
36
|
):
|
|
24
|
-
"""
|
|
37
|
+
"""Initializes the PiAI class for interacting with the Pi.ai chat API.
|
|
25
38
|
|
|
26
39
|
Args:
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
act (str|int, optional): Awesome prompt key or index. (Used as intro). Defaults to None.
|
|
40
|
+
is_conversation (bool, optional): Flag for enabling conversational mode. Defaults to True.
|
|
41
|
+
max_tokens (int, optional): Maximum number of tokens to generate in the response. Defaults to 600.
|
|
42
|
+
timeout (int, optional): Timeout duration for HTTP requests in seconds. Defaults to 30.
|
|
43
|
+
intro (str, optional): Introductory prompt for the conversation. Defaults to None.
|
|
44
|
+
filepath (str, optional): Path to a file for storing conversation history. Defaults to None.
|
|
45
|
+
update_file (bool, optional): Indicates whether to update the file with new prompts and responses. Defaults to True.
|
|
46
|
+
proxies (dict, optional): Dictionary of HTTP request proxies. Defaults to an empty dictionary.
|
|
47
|
+
history_offset (int, optional): Number of last messages to retain in conversation history. Defaults to 10250.
|
|
48
|
+
act (str|int, optional): Key or index for selecting an awesome prompt to use as an intro. Defaults to None.
|
|
37
49
|
"""
|
|
38
|
-
self.conversation_id = conversation_id
|
|
39
50
|
self.scraper = cloudscraper.create_scraper()
|
|
40
51
|
self.url = 'https://pi.ai/api/chat'
|
|
52
|
+
self.AVAILABLE_VOICES: Dict[str, str] = {
|
|
53
|
+
"William": 1,
|
|
54
|
+
"Samantha": 2,
|
|
55
|
+
"Peter": 3,
|
|
56
|
+
"Amy": 4,
|
|
57
|
+
"Alice": 5,
|
|
58
|
+
"Harry": 6
|
|
59
|
+
}
|
|
41
60
|
self.headers = {
|
|
42
61
|
'Accept': 'text/event-stream',
|
|
43
62
|
'Accept-Encoding': 'gzip, deflate, br, zstd',
|
|
@@ -56,9 +75,9 @@ class PiAI(Provider):
|
|
|
56
75
|
'X-Api-Version': '3'
|
|
57
76
|
}
|
|
58
77
|
self.cookies = {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
78
|
+
'__Host-session': 'Ca5SoyAMJEaaB79jj1T69',
|
|
79
|
+
'__cf_bm': 'g07oaL0jcstNfKDyZv7_YFjN0jnuBZjbMiXOWhy7V7A-1723536536-1.0.1.1-xwukd03L7oIAUqPG.OHbFNatDdHGZ28mRGsbsqfjBlpuy.b8w6UZIk8F3knMhhtNzwo4JQhBVdtYOlG0MvAw8A'
|
|
80
|
+
}
|
|
62
81
|
|
|
63
82
|
self.session = requests.Session()
|
|
64
83
|
self.is_conversation = is_conversation
|
|
@@ -66,6 +85,7 @@ class PiAI(Provider):
|
|
|
66
85
|
self.stream_chunk_size = 64
|
|
67
86
|
self.timeout = timeout
|
|
68
87
|
self.last_response = {}
|
|
88
|
+
self.conversation_id = None
|
|
69
89
|
|
|
70
90
|
self.__available_optimizers = (
|
|
71
91
|
method
|
|
@@ -85,28 +105,50 @@ class PiAI(Provider):
|
|
|
85
105
|
)
|
|
86
106
|
self.conversation.history_offset = history_offset
|
|
87
107
|
self.session.proxies = proxies
|
|
108
|
+
# Initialize conversation ID
|
|
109
|
+
if self.is_conversation:
|
|
110
|
+
self.start_conversation()
|
|
111
|
+
|
|
112
|
+
def start_conversation(self) -> str:
|
|
113
|
+
response = self.scraper.post(
|
|
114
|
+
"https://pi.ai/api/chat/start",
|
|
115
|
+
headers=self.headers,
|
|
116
|
+
cookies=self.cookies,
|
|
117
|
+
json={},
|
|
118
|
+
timeout=self.timeout
|
|
119
|
+
)
|
|
120
|
+
data = response.json()
|
|
121
|
+
self.conversation_id = data['conversations'][0]['sid']
|
|
122
|
+
return self.conversation_id
|
|
88
123
|
|
|
89
124
|
def ask(
|
|
90
125
|
self,
|
|
91
126
|
prompt: str,
|
|
127
|
+
voice_name:str,
|
|
92
128
|
stream: bool = False,
|
|
93
129
|
raw: bool = False,
|
|
94
130
|
optimizer: str = None,
|
|
95
131
|
conversationally: bool = False,
|
|
132
|
+
verbose:bool = None,
|
|
133
|
+
output_file:str = None
|
|
96
134
|
) -> dict:
|
|
97
|
-
"""
|
|
135
|
+
"""Interact with the AI by sending a prompt and receiving a response.
|
|
98
136
|
|
|
99
137
|
Args:
|
|
100
|
-
prompt (str):
|
|
138
|
+
prompt (str): The prompt to be sent to the AI.
|
|
139
|
+
voice_name (str): The name of the voice to use for audio responses.
|
|
101
140
|
stream (bool, optional): Flag for streaming response. Defaults to False.
|
|
102
|
-
raw (bool, optional):
|
|
103
|
-
optimizer (str, optional):
|
|
104
|
-
conversationally (bool, optional):
|
|
141
|
+
raw (bool, optional): If True, returns the raw response as received. Defaults to False.
|
|
142
|
+
optimizer (str, optional): Name of the prompt optimizer to use - `[code, shell_command]`. Defaults to None.
|
|
143
|
+
conversationally (bool, optional): If True, chat conversationally when using optimizer. Defaults to False.
|
|
144
|
+
verbose (bool, optional): If True, provides detailed output. Defaults to None.
|
|
145
|
+
output_file (str, optional): File path to save the output. Defaults to None.
|
|
146
|
+
|
|
105
147
|
Returns:
|
|
106
|
-
|
|
148
|
+
dict: A dictionary containing the AI's response.
|
|
107
149
|
```json
|
|
108
150
|
{
|
|
109
|
-
"text"
|
|
151
|
+
"text": "How may I assist you today?"
|
|
110
152
|
}
|
|
111
153
|
```
|
|
112
154
|
"""
|
|
@@ -128,7 +170,12 @@ class PiAI(Provider):
|
|
|
128
170
|
|
|
129
171
|
def for_stream():
|
|
130
172
|
response = self.scraper.post(self.url, headers=self.headers, cookies=self.cookies, json=data, stream=True, timeout=self.timeout)
|
|
131
|
-
|
|
173
|
+
output_str = response.content.decode('utf-8')
|
|
174
|
+
sids = re.findall(r'"sid":"(.*?)"', output_str)
|
|
175
|
+
second_sid = sids[1] if len(sids) >= 2 else None
|
|
176
|
+
#Start the audio download in a separate thread
|
|
177
|
+
threading.Thread(target=self.download_audio_threaded, args=(voice_name, second_sid, verbose, output_file)).start()
|
|
178
|
+
|
|
132
179
|
streaming_text = ""
|
|
133
180
|
for line in response.iter_lines(decode_unicode=True):
|
|
134
181
|
if line.startswith("data: "):
|
|
@@ -156,23 +203,35 @@ class PiAI(Provider):
|
|
|
156
203
|
def chat(
|
|
157
204
|
self,
|
|
158
205
|
prompt: str,
|
|
206
|
+
voice_name: str = "Alice",
|
|
159
207
|
stream: bool = False,
|
|
160
208
|
optimizer: str = None,
|
|
161
209
|
conversationally: bool = False,
|
|
210
|
+
verbose:bool = True,
|
|
211
|
+
output_file:str = "PiAi.mp3"
|
|
162
212
|
) -> str:
|
|
163
|
-
"""
|
|
213
|
+
"""Generates a response based on the provided prompt.
|
|
214
|
+
|
|
164
215
|
Args:
|
|
165
|
-
prompt (str):
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
216
|
+
prompt (str): The input prompt to be sent for generating a response.
|
|
217
|
+
voice_name (str, optional): The name of the voice to use for the response. Defaults to "Alice".
|
|
218
|
+
stream (bool, optional): Flag for streaming the response. Defaults to False.
|
|
219
|
+
optimizer (str, optional): The name of the prompt optimizer to use - `[code, shell_command]`. Defaults to None.
|
|
220
|
+
conversationally (bool, optional): Indicates whether to chat conversationally when using the optimizer. Defaults to False.
|
|
221
|
+
verbose (bool, optional): Flag to indicate if verbose output is desired. Defaults to True.
|
|
222
|
+
output_file (str, optional): The file path where the audio will be saved. Defaults to "PiAi.mp3".
|
|
223
|
+
|
|
169
224
|
Returns:
|
|
170
|
-
str:
|
|
225
|
+
str: The generated response.
|
|
171
226
|
"""
|
|
172
|
-
|
|
227
|
+
assert (
|
|
228
|
+
voice_name in self.AVAILABLE_VOICES
|
|
229
|
+
), f"Voice '{voice_name}' not one of [{', '.join(self.AVAILABLE_VOICES.keys())}]"
|
|
173
230
|
def for_stream():
|
|
174
231
|
for response in self.ask(
|
|
175
|
-
prompt, True, optimizer=optimizer, conversationally=conversationally
|
|
232
|
+
prompt, voice_name, True, optimizer=optimizer, conversationally=conversationally,
|
|
233
|
+
verbose=verbose,
|
|
234
|
+
output_file=output_file
|
|
176
235
|
):
|
|
177
236
|
yield self.get_message(response).encode('utf-8').decode('utf-8')
|
|
178
237
|
|
|
@@ -180,9 +239,12 @@ class PiAI(Provider):
|
|
|
180
239
|
return self.get_message(
|
|
181
240
|
self.ask(
|
|
182
241
|
prompt,
|
|
242
|
+
voice_name,
|
|
183
243
|
False,
|
|
184
244
|
optimizer=optimizer,
|
|
185
245
|
conversationally=conversationally,
|
|
246
|
+
verbose=verbose,
|
|
247
|
+
output_file=output_file
|
|
186
248
|
)
|
|
187
249
|
).encode('utf-8').decode('utf-8')
|
|
188
250
|
|
|
@@ -200,9 +262,32 @@ class PiAI(Provider):
|
|
|
200
262
|
assert isinstance(response, dict), "Response should be of dict data-type only"
|
|
201
263
|
return response["text"]
|
|
202
264
|
|
|
265
|
+
def download_audio_threaded(self, voice_name: str, second_sid: str, verbose:bool, output_file:str) -> None:
|
|
266
|
+
"""Downloads audio in a separate thread.
|
|
267
|
+
|
|
268
|
+
Args:
|
|
269
|
+
voice_name (str): The name of the desired voice.
|
|
270
|
+
second_sid (str): The message SID for the audio request.
|
|
271
|
+
verbose (bool): Flag to indicate if verbose output is desired.
|
|
272
|
+
output_file (str): The file path where the audio will be saved.
|
|
273
|
+
"""
|
|
274
|
+
params = {
|
|
275
|
+
'mode': 'eager',
|
|
276
|
+
'voice': f'voice{self.AVAILABLE_VOICES[voice_name]}',
|
|
277
|
+
'messageSid': second_sid,
|
|
278
|
+
}
|
|
279
|
+
try:
|
|
280
|
+
audio_response = self.scraper.get('https://pi.ai/api/chat/voice', params=params, cookies=self.cookies, headers=self.headers, timeout=self.timeout)
|
|
281
|
+
audio_response.raise_for_status() # Raise an exception for bad status codes
|
|
282
|
+
with open(output_file, "wb") as file:
|
|
283
|
+
file.write(audio_response.content)
|
|
284
|
+
if verbose:print("\nAudio file downloaded successfully.")
|
|
285
|
+
except requests.exceptions.RequestException as e:
|
|
286
|
+
if verbose:print(f"\nFailed to download audio file. Error: {e}")
|
|
287
|
+
|
|
203
288
|
if __name__ == '__main__':
|
|
204
289
|
from rich import print
|
|
205
|
-
ai = PiAI(
|
|
206
|
-
response = ai.chat(input(">>> "))
|
|
290
|
+
ai = PiAI()
|
|
291
|
+
response = ai.chat(input(">>> "), stream=True, verbose=False)
|
|
207
292
|
for chunk in response:
|
|
208
293
|
print(chunk, end="", flush=True)
|