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
webscout/Provider/PI.py CHANGED
@@ -1,208 +1,222 @@
1
- import cloudscraper
2
- import json
3
-
4
- import requests
5
- from webscout.AIutel import Optimizers
6
- from webscout.AIutel import Conversation
7
- from webscout.AIutel import AwesomePrompts
8
- from webscout.AIbase import Provider
9
-
10
- class PiAI(Provider):
11
- def __init__(
12
- self,
13
- conversation_id: str,
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
- ):
24
- """Instantiates PiAI
25
-
26
- 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.
37
- """
38
- self.conversation_id = conversation_id
39
- self.scraper = cloudscraper.create_scraper()
40
- self.url = 'https://pi.ai/api/chat'
41
- self.headers = {
42
- 'Accept': 'text/event-stream',
43
- 'Accept-Encoding': 'gzip, deflate, br, zstd',
44
- 'Accept-Language': 'en-US,en;q=0.9,en-IN;q=0.8',
45
- 'Content-Type': 'application/json',
46
- 'DNT': '1',
47
- 'Origin': 'https://pi.ai',
48
- 'Referer': 'https://pi.ai/talk',
49
- 'Sec-CH-UA': '"Not)A;Brand";v="99", "Microsoft Edge";v="127", "Chromium";v="127"',
50
- 'Sec-CH-UA-Mobile': '?0',
51
- 'Sec-CH-UA-Platform': '"Windows"',
52
- 'Sec-Fetch-Dest': 'empty',
53
- 'Sec-Fetch-Mode': 'cors',
54
- 'Sec-Fetch-Site': 'same-origin',
55
- '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',
56
- 'X-Api-Version': '3'
57
- }
58
- self.cookies = {
59
- '__Host-session': 'Ca5SoyAMJEaaB79jj1T69',
60
- '__cf_bm': 'g07oaL0jcstNfKDyZv7_YFjN0jnuBZjbMiXOWhy7V7A-1723536536-1.0.1.1-xwukd03L7oIAUqPG.OHbFNatDdHGZ28mRGsbsqfjBlpuy.b8w6UZIk8F3knMhhtNzwo4JQhBVdtYOlG0MvAw8A'
61
- }
62
-
63
- self.session = requests.Session()
64
- self.is_conversation = is_conversation
65
- self.max_tokens_to_sample = max_tokens
66
- self.stream_chunk_size = 64
67
- self.timeout = timeout
68
- self.last_response = {}
69
-
70
- self.__available_optimizers = (
71
- method
72
- for method in dir(Optimizers)
73
- if callable(getattr(Optimizers, method)) and not method.startswith("__")
74
- )
75
- self.session.headers.update(self.headers)
76
- Conversation.intro = (
77
- AwesomePrompts().get_act(
78
- act, raise_not_found=True, default=None, case_insensitive=True
79
- )
80
- if act
81
- else intro or Conversation.intro
82
- )
83
- self.conversation = Conversation(
84
- is_conversation, self.max_tokens_to_sample, filepath, update_file
85
- )
86
- self.conversation.history_offset = history_offset
87
- self.session.proxies = proxies
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
- ) -> dict:
97
- """Chat with AI
98
-
99
- Args:
100
- prompt (str): Prompt to be send.
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
- Returns:
106
- dict : {}
107
- ```json
108
- {
109
- "text" : "How may I assist you today?"
110
- }
111
- ```
112
- """
113
- conversation_prompt = self.conversation.gen_complete_prompt(prompt)
114
- if optimizer:
115
- if optimizer in self.__available_optimizers:
116
- conversation_prompt = getattr(Optimizers, optimizer)(
117
- conversation_prompt if conversationally else prompt
118
- )
119
- else:
120
- raise Exception(
121
- f"Optimizer is not one of {self.__available_optimizers}"
122
- )
123
-
124
- data = {
125
- 'text': conversation_prompt,
126
- 'conversation': self.conversation_id
127
- }
128
-
129
- def for_stream():
130
- response = self.scraper.post(self.url, headers=self.headers, cookies=self.cookies, json=data, stream=True, timeout=self.timeout)
131
-
132
- streaming_text = ""
133
- for line in response.iter_lines(decode_unicode=True):
134
- if line.startswith("data: "):
135
- json_data = line[6:]
136
- try:
137
- parsed_data = json.loads(json_data)
138
- if 'text' in parsed_data:
139
- streaming_text += parsed_data['text']
140
- resp = dict(text=streaming_text)
141
- self.last_response.update(resp)
142
- yield parsed_data if raw else resp
143
- except json.JSONDecodeError:
144
- continue
145
- self.conversation.update_chat_history(
146
- prompt, self.get_message(self.last_response)
147
- )
148
-
149
- def for_non_stream():
150
- for _ in for_stream():
151
- pass
152
- return self.last_response
153
-
154
- return for_stream() if stream else for_non_stream()
155
-
156
- def chat(
157
- self,
158
- prompt: str,
159
- stream: bool = False,
160
- optimizer: str = None,
161
- conversationally: bool = False,
162
- ) -> str:
163
- """Generate response `str`
164
- 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.
169
- Returns:
170
- str: Response generated
171
- """
172
-
173
- def for_stream():
174
- for response in self.ask(
175
- prompt, True, optimizer=optimizer, conversationally=conversationally
176
- ):
177
- yield self.get_message(response).encode('utf-8').decode('utf-8')
178
-
179
- def for_non_stream():
180
- return self.get_message(
181
- self.ask(
182
- prompt,
183
- False,
184
- optimizer=optimizer,
185
- conversationally=conversationally,
186
- )
187
- ).encode('utf-8').decode('utf-8')
188
-
189
- return for_stream() if stream else for_non_stream()
190
-
191
- def get_message(self, response: dict) -> str:
192
- """Retrieves message only from response
193
-
194
- Args:
195
- response (dict): Response generated by `self.ask`
196
-
197
- Returns:
198
- str: Message extracted
199
- """
200
- assert isinstance(response, dict), "Response should be of dict data-type only"
201
- return response["text"]
202
-
203
- if __name__ == '__main__':
204
- from rich import print
205
- ai = PiAI(conversation_id="6kti6HPbUKKWUAEpeD7vQ")
206
- response = ai.chat(input(">>> "))
207
- for chunk in response:
1
+ import cloudscraper
2
+ import json
3
+
4
+ import requests
5
+ from webscout.AIutel import Optimizers
6
+ from webscout.AIutel import Conversation
7
+ from webscout.AIutel import AwesomePrompts
8
+ from webscout.AIbase import Provider
9
+
10
+ class PiAI(Provider):
11
+ def __init__(
12
+ self,
13
+ is_conversation: bool = True,
14
+ max_tokens: int = 600,
15
+ timeout: int = 30,
16
+ intro: str = None,
17
+ filepath: str = None,
18
+ update_file: bool = True,
19
+ proxies: dict = {},
20
+ history_offset: int = 10250,
21
+ act: str = None,
22
+ ):
23
+ """Instantiates PiAI
24
+
25
+ Args:
26
+ conversation_id (str): The conversation ID for the Pi.ai chat.
27
+ is_conversation (bool, optional): Flag for chatting conversationally. Defaults to True.
28
+ max_tokens (int, optional): Maximum number of tokens to be generated upon completion. Defaults to 600.
29
+ timeout (int, optional): Http request timeout. Defaults to 30.
30
+ intro (str, optional): Conversation introductory prompt. Defaults to None.
31
+ filepath (str, optional): Path to file containing conversation history. Defaults to None.
32
+ update_file (bool, optional): Add new prompts and responses to the file. Defaults to True.
33
+ proxies (dict, optional): Http request proxies. Defaults to {}.
34
+ history_offset (int, optional): Limit conversation history to this number of last texts. Defaults to 10250.
35
+ act (str|int, optional): Awesome prompt key or index. (Used as intro). Defaults to None.
36
+ """
37
+ self.scraper = cloudscraper.create_scraper()
38
+ self.url = 'https://pi.ai/api/chat'
39
+ self.headers = {
40
+ 'Accept': 'text/event-stream',
41
+ 'Accept-Encoding': 'gzip, deflate, br, zstd',
42
+ 'Accept-Language': 'en-US,en;q=0.9,en-IN;q=0.8',
43
+ 'Content-Type': 'application/json',
44
+ 'DNT': '1',
45
+ 'Origin': 'https://pi.ai',
46
+ 'Referer': 'https://pi.ai/talk',
47
+ 'Sec-CH-UA': '"Not)A;Brand";v="99", "Microsoft Edge";v="127", "Chromium";v="127"',
48
+ 'Sec-CH-UA-Mobile': '?0',
49
+ 'Sec-CH-UA-Platform': '"Windows"',
50
+ 'Sec-Fetch-Dest': 'empty',
51
+ 'Sec-Fetch-Mode': 'cors',
52
+ 'Sec-Fetch-Site': 'same-origin',
53
+ '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',
54
+ 'X-Api-Version': '3'
55
+ }
56
+ self.cookies = {
57
+ '__Host-session': 'Ca5SoyAMJEaaB79jj1T69',
58
+ '__cf_bm': 'g07oaL0jcstNfKDyZv7_YFjN0jnuBZjbMiXOWhy7V7A-1723536536-1.0.1.1-xwukd03L7oIAUqPG.OHbFNatDdHGZ28mRGsbsqfjBlpuy.b8w6UZIk8F3knMhhtNzwo4JQhBVdtYOlG0MvAw8A'
59
+ }
60
+
61
+ self.session = requests.Session()
62
+ self.is_conversation = is_conversation
63
+ self.max_tokens_to_sample = max_tokens
64
+ self.stream_chunk_size = 64
65
+ self.timeout = timeout
66
+ self.last_response = {}
67
+ self.conversation_id = None
68
+
69
+ self.__available_optimizers = (
70
+ method
71
+ 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
+ # Initialize conversation ID
88
+ if self.is_conversation:
89
+ self.start_conversation()
90
+
91
+ def start_conversation(self) -> str:
92
+ response = self.scraper.post(
93
+ "https://pi.ai/api/chat/start",
94
+ headers=self.headers,
95
+ cookies=self.cookies,
96
+ json={},
97
+ timeout=self.timeout
98
+ )
99
+ data = response.json()
100
+ self.conversation_id = data['conversations'][0]['sid']
101
+ return self.conversation_id
102
+
103
+ def ask(
104
+ self,
105
+ prompt: str,
106
+ stream: bool = False,
107
+ raw: bool = False,
108
+ optimizer: str = None,
109
+ conversationally: bool = False,
110
+ ) -> dict:
111
+ """Chat with AI
112
+
113
+ Args:
114
+ prompt (str): Prompt to be send.
115
+ stream (bool, optional): Flag for streaming response. Defaults to False.
116
+ raw (bool, optional): Stream back raw response as received. Defaults to False.
117
+ optimizer (str, optional): Prompt optimizer name - `[code, shell_command]`. Defaults to None.
118
+ conversationally (bool, optional): Chat conversationally when using optimizer. Defaults to False.
119
+ Returns:
120
+ dict : {}
121
+ ```json
122
+ {
123
+ "text" : "How may I assist you today?"
124
+ }
125
+ ```
126
+ """
127
+ conversation_prompt = self.conversation.gen_complete_prompt(prompt)
128
+ if optimizer:
129
+ if optimizer in self.__available_optimizers:
130
+ conversation_prompt = getattr(Optimizers, optimizer)(
131
+ conversation_prompt if conversationally else prompt
132
+ )
133
+ else:
134
+ raise Exception(
135
+ f"Optimizer is not one of {self.__available_optimizers}"
136
+ )
137
+
138
+ data = {
139
+ 'text': conversation_prompt,
140
+ 'conversation': self.conversation_id
141
+ }
142
+
143
+ def for_stream():
144
+ response = self.scraper.post(self.url, headers=self.headers, cookies=self.cookies, json=data, stream=True, timeout=self.timeout)
145
+
146
+ streaming_text = ""
147
+ for line in response.iter_lines(decode_unicode=True):
148
+ if line.startswith("data: "):
149
+ json_data = line[6:]
150
+ try:
151
+ parsed_data = json.loads(json_data)
152
+ if 'text' in parsed_data:
153
+ streaming_text += parsed_data['text']
154
+ resp = dict(text=streaming_text)
155
+ self.last_response.update(resp)
156
+ yield parsed_data if raw else resp
157
+ except json.JSONDecodeError:
158
+ continue
159
+ self.conversation.update_chat_history(
160
+ prompt, self.get_message(self.last_response)
161
+ )
162
+
163
+ def for_non_stream():
164
+ for _ in for_stream():
165
+ pass
166
+ return self.last_response
167
+
168
+ return for_stream() if stream else for_non_stream()
169
+
170
+ def chat(
171
+ self,
172
+ prompt: str,
173
+ stream: bool = False,
174
+ optimizer: str = None,
175
+ conversationally: bool = False,
176
+ ) -> str:
177
+ """Generate response `str`
178
+ Args:
179
+ prompt (str): Prompt to be send.
180
+ stream (bool, optional): Flag for streaming response. Defaults to False.
181
+ optimizer (str, optional): Prompt optimizer name - `[code, shell_command]`. Defaults to None.
182
+ conversationally (bool, optional): Chat conversationally when using optimizer. Defaults to False.
183
+ Returns:
184
+ str: Response generated
185
+ """
186
+
187
+ def for_stream():
188
+ for response in self.ask(
189
+ prompt, True, optimizer=optimizer, conversationally=conversationally
190
+ ):
191
+ yield self.get_message(response).encode('utf-8').decode('utf-8')
192
+
193
+ def for_non_stream():
194
+ return self.get_message(
195
+ self.ask(
196
+ prompt,
197
+ False,
198
+ optimizer=optimizer,
199
+ conversationally=conversationally,
200
+ )
201
+ ).encode('utf-8').decode('utf-8')
202
+
203
+ return for_stream() if stream else for_non_stream()
204
+
205
+ def get_message(self, response: dict) -> str:
206
+ """Retrieves message only from response
207
+
208
+ Args:
209
+ response (dict): Response generated by `self.ask`
210
+
211
+ Returns:
212
+ str: Message extracted
213
+ """
214
+ assert isinstance(response, dict), "Response should be of dict data-type only"
215
+ return response["text"]
216
+
217
+ if __name__ == '__main__':
218
+ from rich import print
219
+ ai = PiAI()
220
+ response = ai.chat(input(">>> "), stream=True)
221
+ for chunk in response:
208
222
  print(chunk, end="", flush=True)