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.

Files changed (131) hide show
  1. webscout/AIauto.py +191 -176
  2. webscout/AIbase.py +0 -197
  3. webscout/AIutel.py +441 -1130
  4. webscout/DWEBS.py +189 -35
  5. webscout/{YTdownloader.py → Extra/YTToolkit/YTdownloader.py} +990 -1103
  6. webscout/Extra/YTToolkit/__init__.py +3 -0
  7. webscout/{transcriber.py → Extra/YTToolkit/transcriber.py} +479 -551
  8. webscout/Extra/YTToolkit/ytapi/__init__.py +6 -0
  9. webscout/Extra/YTToolkit/ytapi/channel.py +307 -0
  10. webscout/Extra/YTToolkit/ytapi/errors.py +13 -0
  11. webscout/Extra/YTToolkit/ytapi/extras.py +45 -0
  12. webscout/Extra/YTToolkit/ytapi/https.py +88 -0
  13. webscout/Extra/YTToolkit/ytapi/patterns.py +61 -0
  14. webscout/Extra/YTToolkit/ytapi/playlist.py +59 -0
  15. webscout/Extra/YTToolkit/ytapi/pool.py +8 -0
  16. webscout/Extra/YTToolkit/ytapi/query.py +37 -0
  17. webscout/Extra/YTToolkit/ytapi/stream.py +60 -0
  18. webscout/Extra/YTToolkit/ytapi/utils.py +62 -0
  19. webscout/Extra/YTToolkit/ytapi/video.py +102 -0
  20. webscout/Extra/__init__.py +3 -1
  21. webscout/Extra/autocoder/__init__.py +9 -0
  22. webscout/Extra/autocoder/autocoder_utiles.py +121 -0
  23. webscout/Extra/autocoder/rawdog.py +680 -0
  24. webscout/Extra/autollama.py +246 -195
  25. webscout/Extra/gguf.py +81 -56
  26. webscout/Extra/markdownlite/__init__.py +862 -0
  27. webscout/Extra/weather_ascii.py +2 -2
  28. webscout/LLM.py +206 -43
  29. webscout/Litlogger/__init__.py +681 -0
  30. webscout/Provider/DARKAI.py +1 -1
  31. webscout/Provider/EDITEE.py +1 -1
  32. webscout/Provider/NinjaChat.py +1 -1
  33. webscout/Provider/PI.py +120 -35
  34. webscout/Provider/Perplexity.py +590 -598
  35. webscout/Provider/Reka.py +0 -1
  36. webscout/Provider/RoboCoders.py +206 -0
  37. webscout/Provider/TTI/AiForce/__init__.py +22 -0
  38. webscout/Provider/TTI/AiForce/async_aiforce.py +257 -0
  39. webscout/Provider/TTI/AiForce/sync_aiforce.py +242 -0
  40. webscout/Provider/TTI/Nexra/__init__.py +22 -0
  41. webscout/Provider/TTI/Nexra/async_nexra.py +286 -0
  42. webscout/Provider/TTI/Nexra/sync_nexra.py +258 -0
  43. webscout/Provider/TTI/PollinationsAI/__init__.py +23 -0
  44. webscout/Provider/TTI/PollinationsAI/async_pollinations.py +330 -0
  45. webscout/Provider/TTI/PollinationsAI/sync_pollinations.py +285 -0
  46. webscout/Provider/TTI/__init__.py +2 -4
  47. webscout/Provider/TTI/artbit/__init__.py +22 -0
  48. webscout/Provider/TTI/artbit/async_artbit.py +184 -0
  49. webscout/Provider/TTI/artbit/sync_artbit.py +176 -0
  50. webscout/Provider/TTI/blackbox/__init__.py +4 -0
  51. webscout/Provider/TTI/blackbox/async_blackbox.py +212 -0
  52. webscout/Provider/TTI/{blackboximage.py → blackbox/sync_blackbox.py} +199 -153
  53. webscout/Provider/TTI/deepinfra/__init__.py +4 -0
  54. webscout/Provider/TTI/deepinfra/async_deepinfra.py +227 -0
  55. webscout/Provider/TTI/deepinfra/sync_deepinfra.py +199 -0
  56. webscout/Provider/TTI/huggingface/__init__.py +22 -0
  57. webscout/Provider/TTI/huggingface/async_huggingface.py +199 -0
  58. webscout/Provider/TTI/huggingface/sync_huggingface.py +195 -0
  59. webscout/Provider/TTI/imgninza/__init__.py +4 -0
  60. webscout/Provider/TTI/imgninza/async_ninza.py +214 -0
  61. webscout/Provider/TTI/{imgninza.py → imgninza/sync_ninza.py} +209 -136
  62. webscout/Provider/TTI/talkai/__init__.py +4 -0
  63. webscout/Provider/TTI/talkai/async_talkai.py +229 -0
  64. webscout/Provider/TTI/talkai/sync_talkai.py +207 -0
  65. webscout/Provider/TTS/__init__.py +5 -1
  66. webscout/Provider/TTS/deepgram.py +183 -0
  67. webscout/Provider/TTS/elevenlabs.py +137 -0
  68. webscout/Provider/TTS/gesserit.py +151 -0
  69. webscout/Provider/TTS/murfai.py +139 -0
  70. webscout/Provider/TTS/parler.py +134 -107
  71. webscout/Provider/TTS/streamElements.py +360 -275
  72. webscout/Provider/TTS/utils.py +280 -0
  73. webscout/Provider/TTS/voicepod.py +116 -116
  74. webscout/Provider/__init__.py +8 -1
  75. webscout/Provider/askmyai.py +2 -2
  76. webscout/Provider/cerebras.py +227 -219
  77. webscout/Provider/llama3mitril.py +0 -1
  78. webscout/Provider/meta.py +794 -779
  79. webscout/Provider/mhystical.py +176 -0
  80. webscout/Provider/perplexitylabs.py +265 -0
  81. webscout/Provider/twitterclone.py +251 -245
  82. webscout/Provider/typegpt.py +358 -0
  83. webscout/__init__.py +9 -8
  84. webscout/__main__.py +5 -5
  85. webscout/cli.py +252 -280
  86. webscout/conversation.py +227 -0
  87. webscout/exceptions.py +161 -29
  88. webscout/litagent/__init__.py +172 -0
  89. webscout/litprinter/__init__.py +832 -0
  90. webscout/optimizers.py +270 -0
  91. webscout/prompt_manager.py +279 -0
  92. webscout/scout/__init__.py +11 -0
  93. webscout/scout/core.py +884 -0
  94. webscout/scout/element.py +459 -0
  95. webscout/scout/parsers/__init__.py +69 -0
  96. webscout/scout/parsers/html5lib_parser.py +172 -0
  97. webscout/scout/parsers/html_parser.py +236 -0
  98. webscout/scout/parsers/lxml_parser.py +178 -0
  99. webscout/scout/utils.py +38 -0
  100. webscout/swiftcli/__init__.py +810 -0
  101. webscout/update_checker.py +125 -0
  102. webscout/version.py +1 -1
  103. webscout/zeroart/__init__.py +55 -0
  104. webscout/zeroart/base.py +61 -0
  105. webscout/zeroart/effects.py +99 -0
  106. webscout/zeroart/fonts.py +816 -0
  107. webscout/zerodir/__init__.py +225 -0
  108. {webscout-6.3.dist-info → webscout-6.5.dist-info}/METADATA +37 -112
  109. webscout-6.5.dist-info/RECORD +179 -0
  110. webscout/Agents/Onlinesearcher.py +0 -182
  111. webscout/Agents/__init__.py +0 -2
  112. webscout/Agents/functioncall.py +0 -248
  113. webscout/Bing_search.py +0 -154
  114. webscout/Provider/TTI/AIuncensoredimage.py +0 -103
  115. webscout/Provider/TTI/Nexra.py +0 -120
  116. webscout/Provider/TTI/PollinationsAI.py +0 -138
  117. webscout/Provider/TTI/WebSimAI.py +0 -142
  118. webscout/Provider/TTI/aiforce.py +0 -160
  119. webscout/Provider/TTI/artbit.py +0 -141
  120. webscout/Provider/TTI/deepinfra.py +0 -148
  121. webscout/Provider/TTI/huggingface.py +0 -155
  122. webscout/Provider/TTI/talkai.py +0 -116
  123. webscout/g4f.py +0 -666
  124. webscout/models.py +0 -23
  125. webscout/requestsHTMLfix.py +0 -775
  126. webscout/webai.py +0 -2590
  127. webscout-6.3.dist-info/RECORD +0 -124
  128. {webscout-6.3.dist-info → webscout-6.5.dist-info}/LICENSE.md +0 -0
  129. {webscout-6.3.dist-info → webscout-6.5.dist-info}/WHEEL +0 -0
  130. {webscout-6.3.dist-info → webscout-6.5.dist-info}/entry_points.txt +0 -0
  131. {webscout-6.3.dist-info → webscout-6.5.dist-info}/top_level.txt +0 -0
@@ -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 = "perplexity", # Default model
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
- """Instantiates PiAI
37
+ """Initializes the PiAI class for interacting with the Pi.ai chat API.
25
38
 
26
39
  Args:
27
- conversation_id (str): The conversation ID for the Pi.ai chat.
28
- is_conversation (bool, optional): Flag for chatting conversationally. Defaults to True.
29
- max_tokens (int, optional): Maximum number of tokens to be generated upon completion. Defaults to 600.
30
- timeout (int, optional): Http request timeout. Defaults to 30.
31
- intro (str, optional): Conversation introductory prompt. Defaults to None.
32
- filepath (str, optional): Path to file containing conversation history. Defaults to None.
33
- update_file (bool, optional): Add new prompts and responses to the file. Defaults to True.
34
- proxies (dict, optional): Http request proxies. Defaults to {}.
35
- history_offset (int, optional): Limit conversation history to this number of last texts. Defaults to 10250.
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
- '__Host-session': 'Ca5SoyAMJEaaB79jj1T69',
60
- '__cf_bm': 'g07oaL0jcstNfKDyZv7_YFjN0jnuBZjbMiXOWhy7V7A-1723536536-1.0.1.1-xwukd03L7oIAUqPG.OHbFNatDdHGZ28mRGsbsqfjBlpuy.b8w6UZIk8F3knMhhtNzwo4JQhBVdtYOlG0MvAw8A'
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
- """Chat with AI
135
+ """Interact with the AI by sending a prompt and receiving a response.
98
136
 
99
137
  Args:
100
- prompt (str): Prompt to be send.
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): Stream back raw response as received. Defaults to False.
103
- optimizer (str, optional): Prompt optimizer name - `[code, shell_command]`. Defaults to None.
104
- conversationally (bool, optional): Chat conversationally when using optimizer. Defaults to False.
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
- dict : {}
148
+ dict: A dictionary containing the AI's response.
107
149
  ```json
108
150
  {
109
- "text" : "How may I assist you today?"
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
- """Generate response `str`
213
+ """Generates a response based on the provided prompt.
214
+
164
215
  Args:
165
- prompt (str): Prompt to be send.
166
- stream (bool, optional): Flag for streaming response. Defaults to False.
167
- optimizer (str, optional): Prompt optimizer name - `[code, shell_command]`. Defaults to None.
168
- conversationally (bool, optional): Chat conversationally when using optimizer. Defaults to False.
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: Response generated
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(conversation_id="6kti6HPbUKKWUAEpeD7vQ")
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)