webscout 8.3.4__py3-none-any.whl → 8.3.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.
- webscout/AIutel.py +52 -1016
- webscout/Provider/AISEARCH/__init__.py +11 -10
- webscout/Provider/AISEARCH/felo_search.py +7 -3
- webscout/Provider/AISEARCH/scira_search.py +2 -0
- webscout/Provider/AISEARCH/stellar_search.py +53 -8
- webscout/Provider/Deepinfra.py +7 -1
- webscout/Provider/OPENAI/TogetherAI.py +57 -48
- webscout/Provider/OPENAI/TwoAI.py +94 -1
- webscout/Provider/OPENAI/__init__.py +0 -2
- webscout/Provider/OPENAI/deepinfra.py +6 -0
- webscout/Provider/OPENAI/scirachat.py +4 -0
- webscout/Provider/OPENAI/textpollinations.py +11 -7
- webscout/Provider/OPENAI/venice.py +1 -0
- webscout/Provider/Perplexitylabs.py +163 -147
- webscout/Provider/Qodo.py +30 -6
- webscout/Provider/TTI/__init__.py +1 -0
- webscout/Provider/TTI/together.py +7 -6
- webscout/Provider/TTI/venice.py +368 -0
- webscout/Provider/TextPollinationsAI.py +11 -7
- webscout/Provider/TogetherAI.py +57 -44
- webscout/Provider/TwoAI.py +96 -2
- webscout/Provider/TypliAI.py +33 -27
- webscout/Provider/UNFINISHED/PERPLEXED_search.py +254 -0
- webscout/Provider/UNFINISHED/fetch_together_models.py +6 -11
- webscout/Provider/Venice.py +1 -0
- webscout/Provider/WiseCat.py +18 -20
- webscout/Provider/__init__.py +0 -6
- webscout/Provider/scira_chat.py +4 -0
- webscout/Provider/toolbaz.py +5 -10
- webscout/Provider/typefully.py +1 -11
- webscout/__init__.py +3 -15
- webscout/auth/__init__.py +19 -4
- webscout/auth/api_key_manager.py +189 -189
- webscout/auth/auth_system.py +25 -40
- webscout/auth/config.py +105 -6
- webscout/auth/database.py +377 -22
- webscout/auth/models.py +185 -130
- webscout/auth/request_processing.py +175 -11
- webscout/auth/routes.py +99 -2
- webscout/auth/server.py +9 -2
- webscout/auth/simple_logger.py +236 -0
- webscout/sanitize.py +1074 -0
- webscout/version.py +1 -1
- {webscout-8.3.4.dist-info → webscout-8.3.5.dist-info}/METADATA +9 -149
- {webscout-8.3.4.dist-info → webscout-8.3.5.dist-info}/RECORD +49 -51
- webscout/Provider/OPENAI/README_AUTOPROXY.md +0 -238
- webscout/Provider/OPENAI/typegpt.py +0 -368
- webscout/Provider/OPENAI/uncovrAI.py +0 -477
- webscout/Provider/WritingMate.py +0 -273
- webscout/Provider/typegpt.py +0 -284
- webscout/Provider/uncovr.py +0 -333
- {webscout-8.3.4.dist-info → webscout-8.3.5.dist-info}/WHEEL +0 -0
- {webscout-8.3.4.dist-info → webscout-8.3.5.dist-info}/entry_points.txt +0 -0
- {webscout-8.3.4.dist-info → webscout-8.3.5.dist-info}/licenses/LICENSE.md +0 -0
- {webscout-8.3.4.dist-info → webscout-8.3.5.dist-info}/top_level.txt +0 -0
webscout/Provider/uncovr.py
DELETED
|
@@ -1,333 +0,0 @@
|
|
|
1
|
-
from curl_cffi.requests import Session
|
|
2
|
-
from curl_cffi import CurlError
|
|
3
|
-
import json
|
|
4
|
-
import uuid
|
|
5
|
-
import re
|
|
6
|
-
from typing import Any, Dict, Optional, Generator, Union
|
|
7
|
-
from webscout.AIutel import Optimizers
|
|
8
|
-
from webscout.AIutel import Conversation, sanitize_stream # Import sanitize_stream
|
|
9
|
-
from webscout.AIutel import AwesomePrompts
|
|
10
|
-
from webscout.AIbase import Provider
|
|
11
|
-
from webscout import exceptions
|
|
12
|
-
from webscout.litagent import LitAgent
|
|
13
|
-
|
|
14
|
-
class UncovrAI(Provider):
|
|
15
|
-
"""
|
|
16
|
-
A class to interact with the Uncovr AI chat API.
|
|
17
|
-
"""
|
|
18
|
-
|
|
19
|
-
AVAILABLE_MODELS = [
|
|
20
|
-
"default",
|
|
21
|
-
"gpt-4o-mini",
|
|
22
|
-
"gemini-2-flash",
|
|
23
|
-
"gemini-2-flash-lite",
|
|
24
|
-
"groq-llama-3-1-8b",
|
|
25
|
-
"o3-mini",
|
|
26
|
-
"deepseek-r1-distill-qwen-32b",
|
|
27
|
-
# The following models are not available in the free plan:
|
|
28
|
-
# "claude-3-7-sonnet",
|
|
29
|
-
# "gpt-4o",
|
|
30
|
-
# "claude-3-5-sonnet-v2",
|
|
31
|
-
# "deepseek-r1-distill-llama-70b",
|
|
32
|
-
# "gemini-2-flash-lite-preview",
|
|
33
|
-
# "qwen-qwq-32b"
|
|
34
|
-
]
|
|
35
|
-
|
|
36
|
-
def __init__(
|
|
37
|
-
self,
|
|
38
|
-
is_conversation: bool = True,
|
|
39
|
-
max_tokens: int = 2049,
|
|
40
|
-
timeout: int = 30,
|
|
41
|
-
intro: str = None,
|
|
42
|
-
filepath: str = None,
|
|
43
|
-
update_file: bool = True,
|
|
44
|
-
proxies: dict = {},
|
|
45
|
-
history_offset: int = 10250,
|
|
46
|
-
act: str = None,
|
|
47
|
-
model: str = "default",
|
|
48
|
-
chat_id: str = None,
|
|
49
|
-
user_id: str = None,
|
|
50
|
-
browser: str = "chrome"
|
|
51
|
-
):
|
|
52
|
-
"""Initializes the Uncovr AI API client."""
|
|
53
|
-
if model not in self.AVAILABLE_MODELS:
|
|
54
|
-
raise ValueError(f"Invalid model: {model}. Choose from: {self.AVAILABLE_MODELS}")
|
|
55
|
-
|
|
56
|
-
self.url = "https://uncovr.app/api/workflows/chat"
|
|
57
|
-
|
|
58
|
-
# Initialize LitAgent for user agent generation
|
|
59
|
-
self.agent = LitAgent()
|
|
60
|
-
# Use fingerprinting to create a consistent browser identity
|
|
61
|
-
self.fingerprint = self.agent.generate_fingerprint(browser)
|
|
62
|
-
|
|
63
|
-
# Use the fingerprint for headers
|
|
64
|
-
self.headers = {
|
|
65
|
-
"Accept": self.fingerprint["accept"],
|
|
66
|
-
"Accept-Encoding": "gzip, deflate, br, zstd",
|
|
67
|
-
"Accept-Language": self.fingerprint["accept_language"],
|
|
68
|
-
"Content-Type": "application/json",
|
|
69
|
-
"Origin": "https://uncovr.app",
|
|
70
|
-
"Referer": "https://uncovr.app/",
|
|
71
|
-
"Sec-CH-UA": self.fingerprint["sec_ch_ua"] or '"Not)A;Brand";v="99", "Microsoft Edge";v="127", "Chromium";v="127"',
|
|
72
|
-
"Sec-CH-UA-Mobile": "?0",
|
|
73
|
-
"Sec-CH-UA-Platform": f'"{self.fingerprint["platform"]}"',
|
|
74
|
-
"User-Agent": self.fingerprint["user_agent"],
|
|
75
|
-
"Sec-Fetch-Dest": "empty",
|
|
76
|
-
"Sec-Fetch-Mode": "cors",
|
|
77
|
-
"Sec-Fetch-Site": "same-origin"
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
# Initialize curl_cffi Session
|
|
81
|
-
self.session = Session()
|
|
82
|
-
# Update curl_cffi session headers and proxies
|
|
83
|
-
self.session.headers.update(self.headers)
|
|
84
|
-
self.session.proxies.update(proxies)
|
|
85
|
-
|
|
86
|
-
self.is_conversation = is_conversation
|
|
87
|
-
self.max_tokens_to_sample = max_tokens
|
|
88
|
-
self.timeout = timeout
|
|
89
|
-
self.last_response = {}
|
|
90
|
-
self.model = model
|
|
91
|
-
self.chat_id = chat_id or str(uuid.uuid4())
|
|
92
|
-
self.user_id = user_id or f"user_{str(uuid.uuid4())[:8].upper()}"
|
|
93
|
-
|
|
94
|
-
self.__available_optimizers = (
|
|
95
|
-
method
|
|
96
|
-
for method in dir(Optimizers)
|
|
97
|
-
if callable(getattr(Optimizers, method)) and not method.startswith("__")
|
|
98
|
-
)
|
|
99
|
-
Conversation.intro = (
|
|
100
|
-
AwesomePrompts().get_act(
|
|
101
|
-
act, raise_not_found=True, default=None, case_insensitive=True
|
|
102
|
-
)
|
|
103
|
-
if act
|
|
104
|
-
else intro or Conversation.intro
|
|
105
|
-
)
|
|
106
|
-
|
|
107
|
-
self.conversation = Conversation(
|
|
108
|
-
is_conversation, self.max_tokens_to_sample, filepath, update_file
|
|
109
|
-
)
|
|
110
|
-
self.conversation.history_offset = history_offset
|
|
111
|
-
|
|
112
|
-
@staticmethod
|
|
113
|
-
def _uncovr_extractor(chunk: Union[str, Dict[str, Any]]) -> Optional[str]:
|
|
114
|
-
"""Extracts content from the UncovrAI stream format '0:"..."'."""
|
|
115
|
-
if isinstance(chunk, str):
|
|
116
|
-
match = re.match(r'^0:\s*"?(.*?)"?$', chunk) # Match 0: maybe optional quotes
|
|
117
|
-
if match:
|
|
118
|
-
# Decode potential unicode escapes like \u00e9 and handle escaped quotes/backslashes
|
|
119
|
-
content = match.group(1).encode().decode('unicode_escape')
|
|
120
|
-
return content.replace('\\\\', '\\').replace('\\"', '"')
|
|
121
|
-
return None
|
|
122
|
-
|
|
123
|
-
def refresh_identity(self, browser: str = None):
|
|
124
|
-
"""
|
|
125
|
-
Refreshes the browser identity fingerprint.
|
|
126
|
-
|
|
127
|
-
Args:
|
|
128
|
-
browser: Specific browser to use for the new fingerprint
|
|
129
|
-
"""
|
|
130
|
-
browser = browser or self.fingerprint.get("browser_type", "chrome")
|
|
131
|
-
self.fingerprint = self.agent.generate_fingerprint(browser)
|
|
132
|
-
|
|
133
|
-
# Update headers with new fingerprint
|
|
134
|
-
self.headers.update({
|
|
135
|
-
"Accept": self.fingerprint["accept"],
|
|
136
|
-
"Accept-Language": self.fingerprint["accept_language"],
|
|
137
|
-
"Sec-CH-UA": self.fingerprint["sec_ch_ua"] or self.headers["Sec-CH-UA"],
|
|
138
|
-
"Sec-CH-UA-Platform": f'"{self.fingerprint["platform"]}"',
|
|
139
|
-
"User-Agent": self.fingerprint["user_agent"],
|
|
140
|
-
})
|
|
141
|
-
|
|
142
|
-
# Update session headers
|
|
143
|
-
for header, value in self.headers.items():
|
|
144
|
-
self.session.headers[header] = value
|
|
145
|
-
|
|
146
|
-
return self.fingerprint
|
|
147
|
-
|
|
148
|
-
def ask(
|
|
149
|
-
self,
|
|
150
|
-
prompt: str,
|
|
151
|
-
stream: bool = False,
|
|
152
|
-
raw: bool = False,
|
|
153
|
-
optimizer: str = None,
|
|
154
|
-
conversationally: bool = False,
|
|
155
|
-
temperature: int = 32,
|
|
156
|
-
creativity: str = "medium",
|
|
157
|
-
selected_focus: list = ["web"],
|
|
158
|
-
selected_tools: list = ["quick-cards"]
|
|
159
|
-
) -> Union[Dict[str, Any], Generator]:
|
|
160
|
-
conversation_prompt = self.conversation.gen_complete_prompt(prompt)
|
|
161
|
-
if optimizer:
|
|
162
|
-
if optimizer in self.__available_optimizers:
|
|
163
|
-
conversation_prompt = getattr(Optimizers, optimizer)(
|
|
164
|
-
conversation_prompt if conversationally else prompt
|
|
165
|
-
)
|
|
166
|
-
else:
|
|
167
|
-
raise Exception(f"Optimizer is not one of {self.__available_optimizers}")
|
|
168
|
-
payload = {
|
|
169
|
-
"content": conversation_prompt,
|
|
170
|
-
"chatId": self.chat_id,
|
|
171
|
-
"userMessageId": str(uuid.uuid4()),
|
|
172
|
-
"ai_config": {
|
|
173
|
-
"selectedFocus": selected_focus,
|
|
174
|
-
"selectedTools": selected_tools,
|
|
175
|
-
"agentId": "chat",
|
|
176
|
-
"modelId": self.model,
|
|
177
|
-
"temperature": temperature,
|
|
178
|
-
"creativity": creativity
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
def for_stream():
|
|
182
|
-
try:
|
|
183
|
-
response = self.session.post(
|
|
184
|
-
self.url,
|
|
185
|
-
json=payload,
|
|
186
|
-
stream=True,
|
|
187
|
-
timeout=self.timeout,
|
|
188
|
-
impersonate=self.fingerprint.get("browser_type", "chrome110")
|
|
189
|
-
)
|
|
190
|
-
if response.status_code != 200:
|
|
191
|
-
if response.status_code in [403, 429]:
|
|
192
|
-
self.refresh_identity()
|
|
193
|
-
retry_response = self.session.post(
|
|
194
|
-
self.url,
|
|
195
|
-
json=payload,
|
|
196
|
-
stream=True,
|
|
197
|
-
timeout=self.timeout,
|
|
198
|
-
impersonate=self.fingerprint.get("browser_type", "chrome110")
|
|
199
|
-
)
|
|
200
|
-
if not retry_response.ok:
|
|
201
|
-
raise exceptions.FailedToGenerateResponseError(
|
|
202
|
-
f"Failed to generate response after identity refresh - ({retry_response.status_code}, {retry_response.reason}) - {retry_response.text}"
|
|
203
|
-
)
|
|
204
|
-
response = retry_response
|
|
205
|
-
else:
|
|
206
|
-
raise exceptions.FailedToGenerateResponseError(
|
|
207
|
-
f"Request failed with status code {response.status_code} - {response.text}"
|
|
208
|
-
)
|
|
209
|
-
streaming_text = ""
|
|
210
|
-
processed_stream = sanitize_stream(
|
|
211
|
-
data=response.iter_content(chunk_size=None),
|
|
212
|
-
intro_value=None,
|
|
213
|
-
to_json=False,
|
|
214
|
-
content_extractor=self._uncovr_extractor,
|
|
215
|
-
yield_raw_on_error=True,
|
|
216
|
-
raw=raw
|
|
217
|
-
)
|
|
218
|
-
for content_chunk in processed_stream:
|
|
219
|
-
# Always yield as string, even in raw mode
|
|
220
|
-
if isinstance(content_chunk, bytes):
|
|
221
|
-
content_chunk = content_chunk.decode('utf-8', errors='ignore')
|
|
222
|
-
if content_chunk is None:
|
|
223
|
-
continue # Ignore non-content lines
|
|
224
|
-
if raw:
|
|
225
|
-
yield content_chunk
|
|
226
|
-
else:
|
|
227
|
-
if content_chunk and isinstance(content_chunk, str):
|
|
228
|
-
streaming_text += content_chunk
|
|
229
|
-
yield dict(text=content_chunk)
|
|
230
|
-
self.last_response = {"text": streaming_text}
|
|
231
|
-
self.conversation.update_chat_history(prompt, streaming_text)
|
|
232
|
-
except CurlError as e:
|
|
233
|
-
raise exceptions.FailedToGenerateResponseError(f"Request failed (CurlError): {e}")
|
|
234
|
-
except Exception as e:
|
|
235
|
-
raise exceptions.FailedToGenerateResponseError(f"An unexpected error occurred ({type(e).__name__}): {e}")
|
|
236
|
-
def for_non_stream():
|
|
237
|
-
try:
|
|
238
|
-
response = self.session.post(
|
|
239
|
-
self.url,
|
|
240
|
-
json=payload,
|
|
241
|
-
timeout=self.timeout,
|
|
242
|
-
impersonate=self.fingerprint.get("browser_type", "chrome110")
|
|
243
|
-
)
|
|
244
|
-
if response.status_code != 200:
|
|
245
|
-
if response.status_code in [403, 429]:
|
|
246
|
-
self.refresh_identity()
|
|
247
|
-
response = self.session.post(
|
|
248
|
-
self.url,
|
|
249
|
-
json=payload,
|
|
250
|
-
timeout=self.timeout,
|
|
251
|
-
impersonate=self.fingerprint.get("browser_type", "chrome110")
|
|
252
|
-
)
|
|
253
|
-
if not response.ok:
|
|
254
|
-
raise exceptions.FailedToGenerateResponseError(
|
|
255
|
-
f"Failed to generate response after identity refresh - ({response.status_code}, {response.reason}) - {response.text}"
|
|
256
|
-
)
|
|
257
|
-
else:
|
|
258
|
-
raise exceptions.FailedToGenerateResponseError(
|
|
259
|
-
f"Request failed with status code {response.status_code} - {response.text}"
|
|
260
|
-
)
|
|
261
|
-
response_text = response.text
|
|
262
|
-
processed_stream = sanitize_stream(
|
|
263
|
-
data=response_text.splitlines(),
|
|
264
|
-
intro_value=None,
|
|
265
|
-
to_json=False,
|
|
266
|
-
content_extractor=self._uncovr_extractor,
|
|
267
|
-
yield_raw_on_error=True,
|
|
268
|
-
raw=raw
|
|
269
|
-
)
|
|
270
|
-
full_response = ""
|
|
271
|
-
for content in processed_stream:
|
|
272
|
-
if isinstance(content, bytes):
|
|
273
|
-
content = content.decode('utf-8', errors='ignore')
|
|
274
|
-
if content is None:
|
|
275
|
-
continue # Ignore non-content lines
|
|
276
|
-
if raw:
|
|
277
|
-
full_response += content
|
|
278
|
-
elif content and isinstance(content, str):
|
|
279
|
-
full_response += content
|
|
280
|
-
self.last_response = {"text": full_response}
|
|
281
|
-
self.conversation.update_chat_history(prompt, full_response)
|
|
282
|
-
return {"text": full_response} if not raw else full_response
|
|
283
|
-
except CurlError as e:
|
|
284
|
-
raise exceptions.FailedToGenerateResponseError(f"Request failed (CurlError): {e}")
|
|
285
|
-
except Exception as e:
|
|
286
|
-
raise exceptions.FailedToGenerateResponseError(f"Request failed ({type(e).__name__}): {e}")
|
|
287
|
-
return for_stream() if stream else for_non_stream()
|
|
288
|
-
|
|
289
|
-
def chat(
|
|
290
|
-
self,
|
|
291
|
-
prompt: str,
|
|
292
|
-
stream: bool = False,
|
|
293
|
-
optimizer: str = None,
|
|
294
|
-
conversationally: bool = False,
|
|
295
|
-
temperature: int = 32,
|
|
296
|
-
creativity: str = "medium",
|
|
297
|
-
selected_focus: list = ["web"],
|
|
298
|
-
selected_tools: list = [],
|
|
299
|
-
raw: bool = False, # Added raw parameter
|
|
300
|
-
) -> Union[str, Generator[str, None, None]]:
|
|
301
|
-
def for_stream():
|
|
302
|
-
for response in self.ask(
|
|
303
|
-
prompt, True, raw=raw, optimizer=optimizer, conversationally=conversationally,
|
|
304
|
-
temperature=temperature, creativity=creativity,
|
|
305
|
-
selected_focus=selected_focus, selected_tools=selected_tools
|
|
306
|
-
):
|
|
307
|
-
if raw:
|
|
308
|
-
yield response
|
|
309
|
-
else:
|
|
310
|
-
yield self.get_message(response)
|
|
311
|
-
def for_non_stream():
|
|
312
|
-
result = self.ask(
|
|
313
|
-
prompt, False, raw=raw, optimizer=optimizer, conversationally=conversationally,
|
|
314
|
-
temperature=temperature, creativity=creativity,
|
|
315
|
-
selected_focus=selected_focus, selected_tools=selected_tools
|
|
316
|
-
)
|
|
317
|
-
if raw:
|
|
318
|
-
return result
|
|
319
|
-
else:
|
|
320
|
-
return self.get_message(result)
|
|
321
|
-
return for_stream() if stream else for_non_stream()
|
|
322
|
-
|
|
323
|
-
def get_message(self, response: dict) -> str:
|
|
324
|
-
assert isinstance(response, dict), "Response should be of dict data-type only"
|
|
325
|
-
# Formatting handled by extractor
|
|
326
|
-
text = response.get("text", "")
|
|
327
|
-
return text.replace('\\n', '\n').replace('\\n\\n', '\n\n') # Keep newline replacement
|
|
328
|
-
|
|
329
|
-
if __name__ == "__main__":
|
|
330
|
-
ai = UncovrAI()
|
|
331
|
-
response = ai.chat("who is pm of india?", raw=False, stream=True)
|
|
332
|
-
for chunk in response:
|
|
333
|
-
print(chunk, end='', flush=True)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|