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.
- webscout/AIauto.py +191 -176
- webscout/AIbase.py +0 -197
- webscout/AIutel.py +488 -1130
- webscout/Bing_search.py +250 -153
- webscout/DWEBS.py +151 -19
- webscout/Extra/__init__.py +2 -1
- webscout/Extra/autocoder/__init__.py +9 -0
- webscout/Extra/autocoder/autocoder_utiles.py +121 -0
- webscout/Extra/autocoder/rawdog.py +681 -0
- webscout/Extra/autollama.py +246 -195
- webscout/Extra/gguf.py +441 -416
- 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 +221 -207
- webscout/Provider/Perplexity.py +598 -598
- 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/__init__.py +146 -139
- webscout/Provider/askmyai.py +2 -2
- webscout/Provider/cerebras.py +227 -219
- webscout/Provider/llama3mitril.py +0 -1
- webscout/Provider/mhystical.py +176 -0
- webscout/Provider/perplexitylabs.py +265 -0
- webscout/Provider/twitterclone.py +251 -245
- webscout/Provider/typegpt.py +359 -0
- webscout/__init__.py +28 -23
- 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 +831 -0
- webscout/optimizers.py +270 -0
- webscout/prompt_manager.py +279 -0
- webscout/swiftcli/__init__.py +810 -0
- webscout/transcriber.py +479 -551
- webscout/update_checker.py +125 -0
- webscout/version.py +1 -1
- {webscout-6.3.dist-info → webscout-6.4.dist-info}/METADATA +26 -45
- {webscout-6.3.dist-info → webscout-6.4.dist-info}/RECORD +75 -45
- 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/models.py +0 -23
- /webscout/{g4f.py → gpt4free.py} +0 -0
- {webscout-6.3.dist-info → webscout-6.4.dist-info}/LICENSE.md +0 -0
- {webscout-6.3.dist-info → webscout-6.4.dist-info}/WHEEL +0 -0
- {webscout-6.3.dist-info → webscout-6.4.dist-info}/entry_points.txt +0 -0
- {webscout-6.3.dist-info → webscout-6.4.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,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
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
self.
|
|
39
|
-
self.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
'Accept': '
|
|
43
|
-
'
|
|
44
|
-
'
|
|
45
|
-
'
|
|
46
|
-
'
|
|
47
|
-
'
|
|
48
|
-
'
|
|
49
|
-
'Sec-CH-UA': '"
|
|
50
|
-
'Sec-
|
|
51
|
-
'Sec-
|
|
52
|
-
'Sec-Fetch-
|
|
53
|
-
'
|
|
54
|
-
'
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
self.
|
|
64
|
-
self.
|
|
65
|
-
self.
|
|
66
|
-
self.
|
|
67
|
-
self.
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
method
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
)
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
self.
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
)
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
if
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
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)
|