webscout 6.3__py3-none-any.whl → 6.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.

Files changed (85) hide show
  1. webscout/AIauto.py +191 -176
  2. webscout/AIbase.py +0 -197
  3. webscout/AIutel.py +488 -1130
  4. webscout/Bing_search.py +250 -153
  5. webscout/DWEBS.py +151 -19
  6. webscout/Extra/__init__.py +2 -1
  7. webscout/Extra/autocoder/__init__.py +9 -0
  8. webscout/Extra/autocoder/autocoder_utiles.py +121 -0
  9. webscout/Extra/autocoder/rawdog.py +681 -0
  10. webscout/Extra/autollama.py +246 -195
  11. webscout/Extra/gguf.py +441 -416
  12. webscout/LLM.py +206 -43
  13. webscout/Litlogger/__init__.py +681 -0
  14. webscout/Provider/DARKAI.py +1 -1
  15. webscout/Provider/EDITEE.py +1 -1
  16. webscout/Provider/NinjaChat.py +1 -1
  17. webscout/Provider/PI.py +221 -207
  18. webscout/Provider/Perplexity.py +598 -598
  19. webscout/Provider/RoboCoders.py +206 -0
  20. webscout/Provider/TTI/AiForce/__init__.py +22 -0
  21. webscout/Provider/TTI/AiForce/async_aiforce.py +257 -0
  22. webscout/Provider/TTI/AiForce/sync_aiforce.py +242 -0
  23. webscout/Provider/TTI/Nexra/__init__.py +22 -0
  24. webscout/Provider/TTI/Nexra/async_nexra.py +286 -0
  25. webscout/Provider/TTI/Nexra/sync_nexra.py +258 -0
  26. webscout/Provider/TTI/PollinationsAI/__init__.py +23 -0
  27. webscout/Provider/TTI/PollinationsAI/async_pollinations.py +330 -0
  28. webscout/Provider/TTI/PollinationsAI/sync_pollinations.py +285 -0
  29. webscout/Provider/TTI/__init__.py +2 -4
  30. webscout/Provider/TTI/artbit/__init__.py +22 -0
  31. webscout/Provider/TTI/artbit/async_artbit.py +184 -0
  32. webscout/Provider/TTI/artbit/sync_artbit.py +176 -0
  33. webscout/Provider/TTI/blackbox/__init__.py +4 -0
  34. webscout/Provider/TTI/blackbox/async_blackbox.py +212 -0
  35. webscout/Provider/TTI/{blackboximage.py → blackbox/sync_blackbox.py} +199 -153
  36. webscout/Provider/TTI/deepinfra/__init__.py +4 -0
  37. webscout/Provider/TTI/deepinfra/async_deepinfra.py +227 -0
  38. webscout/Provider/TTI/deepinfra/sync_deepinfra.py +199 -0
  39. webscout/Provider/TTI/huggingface/__init__.py +22 -0
  40. webscout/Provider/TTI/huggingface/async_huggingface.py +199 -0
  41. webscout/Provider/TTI/huggingface/sync_huggingface.py +195 -0
  42. webscout/Provider/TTI/imgninza/__init__.py +4 -0
  43. webscout/Provider/TTI/imgninza/async_ninza.py +214 -0
  44. webscout/Provider/TTI/{imgninza.py → imgninza/sync_ninza.py} +209 -136
  45. webscout/Provider/TTI/talkai/__init__.py +4 -0
  46. webscout/Provider/TTI/talkai/async_talkai.py +229 -0
  47. webscout/Provider/TTI/talkai/sync_talkai.py +207 -0
  48. webscout/Provider/__init__.py +146 -139
  49. webscout/Provider/askmyai.py +2 -2
  50. webscout/Provider/cerebras.py +227 -219
  51. webscout/Provider/llama3mitril.py +0 -1
  52. webscout/Provider/mhystical.py +176 -0
  53. webscout/Provider/perplexitylabs.py +265 -0
  54. webscout/Provider/twitterclone.py +251 -245
  55. webscout/Provider/typegpt.py +359 -0
  56. webscout/__init__.py +28 -23
  57. webscout/__main__.py +5 -5
  58. webscout/cli.py +252 -280
  59. webscout/conversation.py +227 -0
  60. webscout/exceptions.py +161 -29
  61. webscout/litagent/__init__.py +172 -0
  62. webscout/litprinter/__init__.py +831 -0
  63. webscout/optimizers.py +270 -0
  64. webscout/prompt_manager.py +279 -0
  65. webscout/swiftcli/__init__.py +810 -0
  66. webscout/transcriber.py +479 -551
  67. webscout/update_checker.py +125 -0
  68. webscout/version.py +1 -1
  69. {webscout-6.3.dist-info → webscout-6.4.dist-info}/METADATA +26 -45
  70. {webscout-6.3.dist-info → webscout-6.4.dist-info}/RECORD +75 -45
  71. webscout/Provider/TTI/AIuncensoredimage.py +0 -103
  72. webscout/Provider/TTI/Nexra.py +0 -120
  73. webscout/Provider/TTI/PollinationsAI.py +0 -138
  74. webscout/Provider/TTI/WebSimAI.py +0 -142
  75. webscout/Provider/TTI/aiforce.py +0 -160
  76. webscout/Provider/TTI/artbit.py +0 -141
  77. webscout/Provider/TTI/deepinfra.py +0 -148
  78. webscout/Provider/TTI/huggingface.py +0 -155
  79. webscout/Provider/TTI/talkai.py +0 -116
  80. webscout/models.py +0 -23
  81. /webscout/{g4f.py → gpt4free.py} +0 -0
  82. {webscout-6.3.dist-info → webscout-6.4.dist-info}/LICENSE.md +0 -0
  83. {webscout-6.3.dist-info → webscout-6.4.dist-info}/WHEEL +0 -0
  84. {webscout-6.3.dist-info → webscout-6.4.dist-info}/entry_points.txt +0 -0
  85. {webscout-6.3.dist-info → webscout-6.4.dist-info}/top_level.txt +0 -0
@@ -1,245 +1,251 @@
1
- import requests
2
- import json
3
- from webscout.AIutel import Optimizers, Conversation, AwesomePrompts
4
- from webscout.AIbase import Provider
5
- from webscout import exceptions
6
-
7
- class AIUncensored(Provider):
8
- """
9
- A class to interact with the AIUncensored.info API.
10
- """
11
-
12
- def __init__(
13
- self,
14
- is_conversation: bool = True,
15
- max_tokens: int = 600,
16
- timeout: int = 30,
17
- intro: str = None,
18
- filepath: str = None,
19
- update_file: bool = True,
20
- proxies: dict = {},
21
- history_offset: int = 10250,
22
- act: str = None,
23
- system_prompt: str = "You are a helpful AI assistant.",
24
- ):
25
- """
26
- Initializes the AIUncensored.info API with given parameters.
27
-
28
- Args:
29
- is_conversation (bool, optional): Flag for chatting conversationally. Defaults to True.
30
- max_tokens (int, optional): Maximum number of tokens to be generated upon completion. Defaults to 600.
31
- timeout (int, optional): Http request timeout. Defaults to 30.
32
- intro (str, optional): Conversation introductory prompt. Defaults to None.
33
- filepath (str, optional): Path to file containing conversation history. Defaults to None.
34
- update_file (bool, optional): Add new prompts and responses to the file. Defaults to True.
35
- proxies (dict, optional): Http request proxies. Defaults to {}.
36
- history_offset (int, optional): Limit conversation history to this number of last texts. Defaults to 10250.
37
- act (str|int, optional): Awesome prompt key or index. (Used as intro). Defaults to None.
38
- system_prompt (str, optional): System prompt for AIUncensored.
39
- Defaults to "You are a helpful AI assistant.".
40
- """
41
- self.session = requests.Session()
42
- self.is_conversation = is_conversation
43
- self.max_tokens_to_sample = max_tokens
44
- self.api_endpoint = ['https://twitterclone-i0wr.onrender.com/api/chat', 'https://twitterclone-4e8t.onrender.com/api/chat', 'https://twitterclone-8wd1.onrender.com/api/chat']
45
- self.endpoint_index = 0
46
- self.stream_chunk_size = 64
47
- self.timeout = timeout
48
- self.last_response = {}
49
- self.system_prompt = system_prompt
50
- self.headers = {
51
- "authority": "twitterclone-i0wr.onrender.com",
52
- "accept": "*/*",
53
- "accept-encoding": "gzip, deflate, br, zstd",
54
- "accept-language": "en-US,en;q=0.9,en-IN;q=0.8",
55
- "content-type": "application/json",
56
- "dnt": "1",
57
- "origin": "https://www.aiuncensored.info",
58
- "priority": "u=1, i",
59
- "referer": "https://www.aiuncensored.info/",
60
- "sec-ch-ua": '"Chromium";v="128", "Not;A=Brand";v="24", "Microsoft Edge";v="128"',
61
- "sec-ch-ua-mobile": "?0",
62
- "sec-ch-ua-platform": '"Windows"',
63
- "sec-fetch-dest": "empty",
64
- "sec-fetch-mode": "cors",
65
- "sec-fetch-site": "cross-site",
66
- "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36 Edg/128.0.0.0",
67
- }
68
-
69
- self.__available_optimizers = [
70
- method for method in dir(Optimizers)
71
- if callable(getattr(Optimizers, method)) and not method.startswith("__")
72
- ]
73
- self.session.headers.update(self.headers)
74
- Conversation.intro = (
75
- AwesomePrompts().get_act(
76
- act, raise_not_found=True, default=None, case_insensitive=True
77
- )
78
- if act
79
- else intro or Conversation.intro
80
- )
81
- self.conversation = Conversation(
82
- is_conversation, self.max_tokens_to_sample, filepath, update_file
83
- )
84
- self.conversation.history_offset = history_offset
85
- self.session.proxies = proxies
86
-
87
-
88
- def ask(
89
- self,
90
- prompt: str,
91
- stream: bool = False,
92
- raw: bool = False,
93
- optimizer: str = None,
94
- conversationally: bool = False,
95
- ):
96
- """
97
- Chat with AI
98
-
99
- Args:
100
- prompt (str): Prompt to be sent.
101
- 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.
105
-
106
- Returns:
107
- dict or generator:
108
- If stream is False, returns a dict:
109
- ```json
110
- {
111
- "text" : "How may I assist you today?"
112
- }
113
- ```
114
- If stream is True, yields dicts with incremental text.
115
- """
116
-
117
- conversation_prompt = self.conversation.gen_complete_prompt(prompt)
118
-
119
-
120
- if optimizer:
121
-
122
- if optimizer in self.__available_optimizers:
123
- try:
124
- conversation_prompt = getattr(Optimizers, optimizer)(
125
- conversation_prompt if conversationally else prompt
126
- )
127
-
128
- except Exception as e:
129
-
130
- raise
131
- else:
132
-
133
- raise Exception(
134
- f"Optimizer is not one of {self.__available_optimizers}"
135
- )
136
-
137
- payload = {
138
- "messages": [
139
- {
140
- "role": "system",
141
- "content": self.system_prompt
142
- },
143
- {
144
- "role": "user",
145
- "content": conversation_prompt
146
- }
147
- ]
148
- }
149
-
150
-
151
-
152
- def for_stream():
153
- full_content = ''
154
- with requests.post(self.api_endpoint[self.endpoint_index], headers=self.headers, json=payload, stream=True, timeout=self.timeout) as response:
155
-
156
- if response.status_code == 200:
157
- for line in response.iter_lines():
158
- decoded_line = line.decode('utf-8').strip()
159
- if decoded_line:
160
-
161
- if decoded_line == "data: [DONE]":
162
-
163
- break
164
- if decoded_line.startswith("data: "):
165
- data_str = decoded_line[len("data: "):]
166
- try:
167
- data_json = json.loads(data_str)
168
- content = data_json.get("data", "")
169
- if content:
170
- full_content += content
171
- yield content if raw else dict(text=content)
172
- except json.JSONDecodeError:
173
- raise Exception
174
- self.last_response.update(dict(text=full_content))
175
- self.conversation.update_chat_history(
176
- prompt, self.get_message(self.last_response)
177
- )
178
- self.endpoint_index = (self.endpoint_index + 1) % len(self.api_endpoint)
179
- def for_non_stream():
180
- full_content = ''
181
- for _ in for_stream():
182
- pass
183
- return self.last_response
184
-
185
- return for_stream() if stream else for_non_stream()
186
-
187
- def chat(
188
- self,
189
- prompt: str,
190
- stream: bool = False,
191
- optimizer: str = None,
192
- conversationally: bool = False,
193
- ):
194
- """
195
- Generate response `str`
196
- Args:
197
- prompt (str): Prompt to be sent.
198
- stream (bool, optional): Flag for streaming response. Defaults to False.
199
- optimizer (str, optional): Prompt optimizer name - `[code, shell_command]`. Defaults to None.
200
- conversationally (bool, optional): Chat conversationally when using optimizer. Defaults to False.
201
- Returns:
202
- str or generator:
203
- If stream is False, returns a string.
204
- If stream is True, yields incremental strings.
205
- """
206
-
207
- def for_stream():
208
-
209
- for response in self.ask(
210
- prompt, True, optimizer=optimizer, conversationally=conversationally
211
- ):
212
-
213
- yield self.get_message(response)
214
-
215
- def for_non_stream():
216
-
217
- response = self.ask(
218
- prompt,
219
- False,
220
- optimizer=optimizer,
221
- conversationally=conversationally,
222
- )
223
-
224
- return self.get_message(response)
225
-
226
- return for_stream() if stream else for_non_stream()
227
-
228
- def get_message(self, response: dict) -> str:
229
- """Retrieves message only from response
230
-
231
- Args:
232
- response (dict): Response generated by `self.ask`
233
-
234
- Returns:
235
- str: Message extracted
236
- """
237
- assert isinstance(response, dict), "Response should be of dict data-type only"
238
- return response["text"]
239
-
240
- if __name__ == "__main__":
241
- from rich import print
242
- ai = AIUncensored(timeout=5000)
243
- response = ai.chat("write a poem about AI", stream=True)
244
- for chunk in response:
245
- print(chunk, end="", flush=True)
1
+ import requests
2
+ import json
3
+ import random
4
+ from webscout.AIutel import Optimizers, Conversation, AwesomePrompts
5
+ from webscout.AIbase import Provider
6
+ from webscout import exceptions
7
+
8
+ class AIUncensored(Provider):
9
+ """
10
+ A class to interact with the AIUncensored.info API.
11
+ """
12
+
13
+ def __init__(
14
+ self,
15
+ is_conversation: bool = True,
16
+ max_tokens: int = 600,
17
+ timeout: int = 30,
18
+ intro: str = None,
19
+ filepath: str = None,
20
+ update_file: bool = True,
21
+ proxies: dict = {},
22
+ history_offset: int = 10250,
23
+ act: str = None,
24
+ system_prompt: str = "You are a helpful AI assistant.",
25
+ ):
26
+ """
27
+ Initializes the AIUncensored.info API with given parameters.
28
+
29
+ Args:
30
+ is_conversation (bool, optional): Flag for chatting conversationally. Defaults to True.
31
+ max_tokens (int, optional): Maximum number of tokens to be generated upon completion. Defaults to 600.
32
+ timeout (int, optional): Http request timeout. Defaults to 30.
33
+ intro (str, optional): Conversation introductory prompt. Defaults to None.
34
+ filepath (str, optional): Path to file containing conversation history. Defaults to None.
35
+ update_file (bool, optional): Add new prompts and responses to the file. Defaults to True.
36
+ proxies (dict, optional): Http request proxies. Defaults to {}.
37
+ history_offset (int, optional): Limit conversation history to this number of last texts. Defaults to 10250.
38
+ act (str|int, optional): Awesome prompt key or index. (Used as intro). Defaults to None.
39
+ system_prompt (str, optional): System prompt for AIUncensored.
40
+ Defaults to "You are a helpful AI assistant.".
41
+ """
42
+ self.session = requests.Session()
43
+ self.is_conversation = is_conversation
44
+ self.max_tokens_to_sample = max_tokens
45
+ self.api_endpoint = ['https://twitterclone-i0wr.onrender.com/api/chat', 'https://twitterclone-4e8t.onrender.com/api/chat', 'https://twitterclone-8wd1.onrender.com/api/chat']
46
+ self.endpoint_index = 0
47
+ self.stream_chunk_size = 64
48
+ self.timeout = timeout
49
+ self.last_response = {}
50
+ self.system_prompt = system_prompt
51
+ self.headers = {
52
+ "authority": "twitterclone-i0wr.onrender.com",
53
+ "accept": "*/*",
54
+ "accept-encoding": "gzip, deflate, br, zstd",
55
+ "accept-language": "en-US,en;q=0.9,en-IN;q=0.8",
56
+ "content-type": "application/json",
57
+ "dnt": "1",
58
+ "origin": "https://www.aiuncensored.info",
59
+ "priority": "u=1, i",
60
+ "referer": "https://www.aiuncensored.info/",
61
+ "sec-ch-ua": '"Chromium";v="128", "Not;A=Brand";v="24", "Microsoft Edge";v="128"',
62
+ "sec-ch-ua-mobile": "?0",
63
+ "sec-ch-ua-platform": '"Windows"',
64
+ "sec-fetch-dest": "empty",
65
+ "sec-fetch-mode": "cors",
66
+ "sec-fetch-site": "cross-site",
67
+ "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36 Edg/128.0.0.0",
68
+ }
69
+
70
+ self.__available_optimizers = [
71
+ method for method in dir(Optimizers)
72
+ if callable(getattr(Optimizers, method)) and not method.startswith("__")
73
+ ]
74
+ self.session.headers.update(self.headers)
75
+ Conversation.intro = (
76
+ AwesomePrompts().get_act(
77
+ act, raise_not_found=True, default=None, case_insensitive=True
78
+ )
79
+ if act
80
+ else intro or Conversation.intro
81
+ )
82
+ self.conversation = Conversation(
83
+ is_conversation, self.max_tokens_to_sample, filepath, update_file
84
+ )
85
+ self.conversation.history_offset = history_offset
86
+ self.session.proxies = proxies
87
+
88
+
89
+ def ask(
90
+ self,
91
+ prompt: str,
92
+ stream: bool = False,
93
+ raw: bool = False,
94
+ optimizer: str = None,
95
+ conversationally: bool = False,
96
+ ):
97
+ """
98
+ Chat with AI
99
+
100
+ Args:
101
+ prompt (str): Prompt to be sent.
102
+ stream (bool, optional): Flag for streaming response. Defaults to False.
103
+ raw (bool, optional): Stream back raw response as received. Defaults to False.
104
+ optimizer (str, optional): Prompt optimizer name - `[code, shell_command]`. Defaults to None.
105
+ conversationally (bool, optional): Chat conversationally when using optimizer. Defaults to False.
106
+
107
+ Returns:
108
+ dict or generator:
109
+ If stream is False, returns a dict:
110
+ ```json
111
+ {
112
+ "text" : "How may I assist you today?"
113
+ }
114
+ ```
115
+ If stream is True, yields dicts with incremental text.
116
+ """
117
+
118
+ conversation_prompt = self.conversation.gen_complete_prompt(prompt)
119
+
120
+
121
+ if optimizer:
122
+
123
+ if optimizer in self.__available_optimizers:
124
+ try:
125
+ conversation_prompt = getattr(Optimizers, optimizer)(
126
+ conversation_prompt if conversationally else prompt
127
+ )
128
+
129
+ except Exception as e:
130
+
131
+ raise
132
+ else:
133
+
134
+ raise Exception(
135
+ f"Optimizer is not one of {self.__available_optimizers}"
136
+ )
137
+
138
+ payload = {
139
+ "messages": [
140
+ {
141
+ "role": "system",
142
+ "content": self.system_prompt
143
+ },
144
+ {
145
+ "role": "user",
146
+ "content": conversation_prompt
147
+ }
148
+ ],
149
+ "cipher": "24040024"
150
+ }
151
+
152
+
153
+
154
+ def for_stream():
155
+ full_content = ''
156
+ with requests.post(self.api_endpoint[self.endpoint_index], headers=self.headers, json=payload, stream=True, timeout=self.timeout) as response:
157
+ if response.status_code == 200:
158
+ for line in response.iter_lines():
159
+ decoded_line = line.decode('utf-8').strip()
160
+ if decoded_line:
161
+
162
+ if decoded_line == "data: [DONE]":
163
+
164
+ break
165
+ if decoded_line.startswith("data: "):
166
+ data_str = decoded_line[len("data: "):]
167
+ try:
168
+ data_json = json.loads(data_str)
169
+ content = data_json.get("data", "")
170
+ if content:
171
+ full_content += content
172
+ yield content if raw else dict(text=content)
173
+ except json.JSONDecodeError:
174
+ raise Exception
175
+ self.last_response.update(dict(text=full_content))
176
+ self.conversation.update_chat_history(
177
+ prompt, self.get_message(self.last_response)
178
+ )
179
+ self.endpoint_index = (self.endpoint_index + 1) % len(self.api_endpoint)
180
+ def for_non_stream():
181
+ full_content = ''
182
+ for _ in for_stream():
183
+ pass
184
+ return self.last_response
185
+
186
+ return for_stream() if stream else for_non_stream()
187
+
188
+ def chat(
189
+ self,
190
+ prompt: str,
191
+ stream: bool = False,
192
+ optimizer: str = None,
193
+ conversationally: bool = False,
194
+ ):
195
+ """
196
+ Generate response `str`
197
+ Args:
198
+ prompt (str): Prompt to be sent.
199
+ stream (bool, optional): Flag for streaming response. Defaults to False.
200
+ optimizer (str, optional): Prompt optimizer name - `[code, shell_command]`. Defaults to None.
201
+ conversationally (bool, optional): Chat conversationally when using optimizer. Defaults to False.
202
+ Returns:
203
+ str or generator:
204
+ If stream is False, returns a string.
205
+ If stream is True, yields incremental strings.
206
+ """
207
+
208
+ def for_stream():
209
+
210
+ for response in self.ask(
211
+ prompt, True, optimizer=optimizer, conversationally=conversationally
212
+ ):
213
+
214
+ yield self.get_message(response)
215
+
216
+ def for_non_stream():
217
+
218
+ response = self.ask(
219
+ prompt,
220
+ False,
221
+ optimizer=optimizer,
222
+ conversationally=conversationally,
223
+ )
224
+
225
+ return self.get_message(response)
226
+
227
+ return for_stream() if stream else for_non_stream()
228
+
229
+ @staticmethod
230
+ def generate_cipher() -> str:
231
+ """Generate a cipher in format like '3221229284179118'"""
232
+ return ''.join([str(random.randint(0, 9)) for _ in range(16)])
233
+
234
+ def get_message(self, response: dict) -> str:
235
+ """Retrieves message only from response
236
+
237
+ Args:
238
+ response (dict): Response generated by `self.ask`
239
+
240
+ Returns:
241
+ str: Message extracted
242
+ """
243
+ assert isinstance(response, dict), "Response should be of dict data-type only"
244
+ return response["text"]
245
+
246
+ if __name__ == "__main__":
247
+ from rich import print
248
+ ai = AIUncensored(timeout=5000)
249
+ response = ai.chat("write a poem about AI", stream=True)
250
+ for chunk in response:
251
+ print(chunk, end="", flush=True)