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