webscout 8.3__py3-none-any.whl → 8.3.2__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 (120) hide show
  1. webscout/AIauto.py +4 -4
  2. webscout/AIbase.py +61 -1
  3. webscout/AIutel.py +46 -53
  4. webscout/Bing_search.py +418 -0
  5. webscout/Extra/YTToolkit/ytapi/patterns.py +45 -45
  6. webscout/Extra/YTToolkit/ytapi/stream.py +1 -1
  7. webscout/Extra/YTToolkit/ytapi/video.py +10 -10
  8. webscout/Extra/autocoder/autocoder_utiles.py +1 -1
  9. webscout/Extra/gguf.py +706 -177
  10. webscout/Litlogger/formats.py +9 -0
  11. webscout/Litlogger/handlers.py +18 -0
  12. webscout/Litlogger/logger.py +43 -1
  13. webscout/Provider/AISEARCH/genspark_search.py +7 -7
  14. webscout/Provider/AISEARCH/scira_search.py +3 -2
  15. webscout/Provider/GeminiProxy.py +140 -0
  16. webscout/Provider/LambdaChat.py +7 -1
  17. webscout/Provider/MCPCore.py +78 -75
  18. webscout/Provider/OPENAI/BLACKBOXAI.py +1046 -1017
  19. webscout/Provider/OPENAI/GeminiProxy.py +328 -0
  20. webscout/Provider/OPENAI/Qwen3.py +303 -303
  21. webscout/Provider/OPENAI/README.md +5 -0
  22. webscout/Provider/OPENAI/README_AUTOPROXY.md +238 -0
  23. webscout/Provider/OPENAI/TogetherAI.py +355 -0
  24. webscout/Provider/OPENAI/__init__.py +16 -1
  25. webscout/Provider/OPENAI/autoproxy.py +332 -0
  26. webscout/Provider/OPENAI/base.py +101 -14
  27. webscout/Provider/OPENAI/chatgpt.py +15 -2
  28. webscout/Provider/OPENAI/chatgptclone.py +14 -3
  29. webscout/Provider/OPENAI/deepinfra.py +339 -328
  30. webscout/Provider/OPENAI/e2b.py +295 -74
  31. webscout/Provider/OPENAI/mcpcore.py +109 -70
  32. webscout/Provider/OPENAI/opkfc.py +18 -6
  33. webscout/Provider/OPENAI/scirachat.py +59 -50
  34. webscout/Provider/OPENAI/toolbaz.py +2 -10
  35. webscout/Provider/OPENAI/writecream.py +166 -166
  36. webscout/Provider/OPENAI/x0gpt.py +367 -367
  37. webscout/Provider/OPENAI/xenai.py +514 -0
  38. webscout/Provider/OPENAI/yep.py +389 -383
  39. webscout/Provider/STT/__init__.py +3 -0
  40. webscout/Provider/STT/base.py +281 -0
  41. webscout/Provider/STT/elevenlabs.py +265 -0
  42. webscout/Provider/TTI/__init__.py +4 -1
  43. webscout/Provider/TTI/aiarta.py +399 -365
  44. webscout/Provider/TTI/base.py +74 -2
  45. webscout/Provider/TTI/bing.py +231 -0
  46. webscout/Provider/TTI/fastflux.py +63 -30
  47. webscout/Provider/TTI/gpt1image.py +149 -0
  48. webscout/Provider/TTI/imagen.py +196 -0
  49. webscout/Provider/TTI/magicstudio.py +60 -29
  50. webscout/Provider/TTI/piclumen.py +43 -32
  51. webscout/Provider/TTI/pixelmuse.py +232 -225
  52. webscout/Provider/TTI/pollinations.py +43 -32
  53. webscout/Provider/TTI/together.py +287 -0
  54. webscout/Provider/TTI/utils.py +2 -1
  55. webscout/Provider/TTS/README.md +1 -0
  56. webscout/Provider/TTS/__init__.py +2 -1
  57. webscout/Provider/TTS/freetts.py +140 -0
  58. webscout/Provider/TTS/speechma.py +45 -39
  59. webscout/Provider/TogetherAI.py +366 -0
  60. webscout/Provider/UNFINISHED/ChutesAI.py +314 -0
  61. webscout/Provider/UNFINISHED/fetch_together_models.py +95 -0
  62. webscout/Provider/XenAI.py +324 -0
  63. webscout/Provider/__init__.py +8 -0
  64. webscout/Provider/deepseek_assistant.py +378 -0
  65. webscout/Provider/scira_chat.py +3 -2
  66. webscout/Provider/toolbaz.py +0 -1
  67. webscout/auth/__init__.py +44 -0
  68. webscout/auth/api_key_manager.py +189 -0
  69. webscout/auth/auth_system.py +100 -0
  70. webscout/auth/config.py +76 -0
  71. webscout/auth/database.py +400 -0
  72. webscout/auth/exceptions.py +67 -0
  73. webscout/auth/middleware.py +248 -0
  74. webscout/auth/models.py +130 -0
  75. webscout/auth/providers.py +257 -0
  76. webscout/auth/rate_limiter.py +254 -0
  77. webscout/auth/request_models.py +127 -0
  78. webscout/auth/request_processing.py +226 -0
  79. webscout/auth/routes.py +526 -0
  80. webscout/auth/schemas.py +103 -0
  81. webscout/auth/server.py +312 -0
  82. webscout/auth/static/favicon.svg +11 -0
  83. webscout/auth/swagger_ui.py +203 -0
  84. webscout/auth/templates/components/authentication.html +237 -0
  85. webscout/auth/templates/components/base.html +103 -0
  86. webscout/auth/templates/components/endpoints.html +750 -0
  87. webscout/auth/templates/components/examples.html +491 -0
  88. webscout/auth/templates/components/footer.html +75 -0
  89. webscout/auth/templates/components/header.html +27 -0
  90. webscout/auth/templates/components/models.html +286 -0
  91. webscout/auth/templates/components/navigation.html +70 -0
  92. webscout/auth/templates/static/api.js +455 -0
  93. webscout/auth/templates/static/icons.js +168 -0
  94. webscout/auth/templates/static/main.js +784 -0
  95. webscout/auth/templates/static/particles.js +201 -0
  96. webscout/auth/templates/static/styles.css +3353 -0
  97. webscout/auth/templates/static/ui.js +374 -0
  98. webscout/auth/templates/swagger_ui.html +170 -0
  99. webscout/client.py +49 -3
  100. webscout/litagent/Readme.md +12 -3
  101. webscout/litagent/agent.py +99 -62
  102. webscout/scout/core/scout.py +104 -26
  103. webscout/scout/element.py +139 -18
  104. webscout/swiftcli/core/cli.py +14 -3
  105. webscout/swiftcli/decorators/output.py +59 -9
  106. webscout/update_checker.py +31 -49
  107. webscout/version.py +1 -1
  108. webscout/webscout_search.py +4 -12
  109. webscout/webscout_search_async.py +3 -10
  110. webscout/yep_search.py +2 -11
  111. {webscout-8.3.dist-info → webscout-8.3.2.dist-info}/METADATA +41 -11
  112. {webscout-8.3.dist-info → webscout-8.3.2.dist-info}/RECORD +116 -68
  113. {webscout-8.3.dist-info → webscout-8.3.2.dist-info}/entry_points.txt +1 -1
  114. webscout/Provider/HF_space/__init__.py +0 -0
  115. webscout/Provider/HF_space/qwen_qwen2.py +0 -206
  116. webscout/Provider/OPENAI/api.py +0 -1035
  117. webscout/Provider/TTI/artbit.py +0 -0
  118. {webscout-8.3.dist-info → webscout-8.3.2.dist-info}/WHEEL +0 -0
  119. {webscout-8.3.dist-info → webscout-8.3.2.dist-info}/licenses/LICENSE.md +0 -0
  120. {webscout-8.3.dist-info → webscout-8.3.2.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,314 @@
1
+ import requests
2
+ import json
3
+ import time
4
+ import uuid
5
+ from typing import List, Dict, Optional, Union, Generator, Any
6
+ import re
7
+ import random
8
+ import string
9
+ from rich import print
10
+ from webscout.litagent.agent import LitAgent
11
+ import cloudscraper
12
+ # Import base classes and utility structures
13
+ from webscout.Provider.OPENAI.base import OpenAICompatibleProvider, BaseChat, BaseCompletions
14
+ from webscout.Provider.OPENAI.utils import (
15
+ ChatCompletionChunk, ChatCompletion, Choice, ChoiceDelta,
16
+ ChatCompletionMessage, CompletionUsage
17
+ )
18
+
19
+ # --- ChutesAI API Key Auto-Generator ---
20
+ def generate_chutesai_api_key():
21
+ url = "https://chutes.ai/auth/start?/create"
22
+ def generate_username(length=8):
23
+ return ''.join(random.choices(string.ascii_letters, k=length))
24
+ username = generate_username()
25
+ agent = LitAgent()
26
+ fingerprint = agent.generate_fingerprint("chrome")
27
+ headers = {
28
+ "Content-Type": "application/x-www-form-urlencoded",
29
+ "Accept": "application/json",
30
+ "User-Agent": fingerprint["user_agent"],
31
+ "Accept-Encoding": "gzip, deflate, br, zstd",
32
+ "Accept-Language": fingerprint["accept_language"],
33
+ "DNT": "1",
34
+ "Origin": "https://chutes.ai",
35
+ "Referer": "https://chutes.ai/auth/start",
36
+ "Sec-Ch-Ua": fingerprint["sec_ch_ua"],
37
+ "Sec-Ch-Ua-Mobile": "?0",
38
+ "Sec-Ch-Ua-Platform": fingerprint["platform"],
39
+ "X-Sveltekit-Action": "true"
40
+ }
41
+ data = {
42
+ "username": username,
43
+ "coldkey": "hotkey",
44
+ "__superform_id": "xpsmbd"
45
+ }
46
+ scraper = cloudscraper.create_scraper()
47
+ response = scraper.post(url, headers=headers, data=data)
48
+ print(f"[bold green]Status:[/] {response.status_code}")
49
+
50
+ # Ensure response is decoded as UTF-8
51
+ response.encoding = 'utf-8'
52
+
53
+ try:
54
+ resp_json = response.json()
55
+ except Exception:
56
+ try:
57
+ # Try to decode the response text with UTF-8 explicitly
58
+ decoded_text = response.content.decode('utf-8', errors='replace')
59
+ print(decoded_text)
60
+ except Exception:
61
+ print("Failed to decode response content")
62
+ return None
63
+ print(resp_json)
64
+ # Extract the api_key using regex from the 'data' field
65
+ if 'data' in resp_json:
66
+ api_key_match = re.search(r'(cpk_[a-zA-Z0-9.]+)', resp_json['data'])
67
+ if api_key_match:
68
+ api_key = api_key_match.group(1)
69
+ print(f"[bold yellow]Auto-generated ChutesAI API Key:[/] {api_key}")
70
+ return api_key
71
+ else:
72
+ print("[red]API key not found in response data.")
73
+ return None
74
+
75
+ # --- ChutesAI Client ---
76
+
77
+ class Completions(BaseCompletions):
78
+ def __init__(self, client: 'ChutesAI'):
79
+ self._client = client
80
+
81
+ def create(
82
+ self,
83
+ *,
84
+ model: str,
85
+ messages: List[Dict[str, str]],
86
+ max_tokens: Optional[int] = 1024,
87
+ stream: bool = False,
88
+ temperature: Optional[float] = None,
89
+ top_p: Optional[float] = None,
90
+ **kwargs: Any
91
+ ) -> Union[ChatCompletion, Generator[ChatCompletionChunk, None, None]]:
92
+ """
93
+ Creates a model response for the given chat conversation.
94
+ Mimics openai.chat.completions.create
95
+ """
96
+ payload = {
97
+ "model": model,
98
+ "messages": messages,
99
+ "max_tokens": max_tokens,
100
+ "stream": stream,
101
+ }
102
+ if temperature is not None:
103
+ payload["temperature"] = temperature
104
+ if top_p is not None:
105
+ payload["top_p"] = top_p
106
+ payload.update(kwargs)
107
+
108
+ request_id = f"chatcmpl-{uuid.uuid4()}"
109
+ created_time = int(time.time())
110
+
111
+ if stream:
112
+ return self._create_stream(request_id, created_time, model, payload)
113
+ else:
114
+ return self._create_non_stream(request_id, created_time, model, payload)
115
+
116
+ def _create_stream(
117
+ self, request_id: str, created_time: int, model: str, payload: Dict[str, Any]
118
+ ) -> Generator[ChatCompletionChunk, None, None]:
119
+ try:
120
+ response = self._client.scraper.post(
121
+ self._client.base_url,
122
+ headers=self._client.headers,
123
+ json=payload,
124
+ stream=True,
125
+ timeout=self._client.timeout
126
+ )
127
+ response.raise_for_status()
128
+
129
+ prompt_tokens = 0
130
+ completion_tokens = 0
131
+ total_tokens = 0
132
+
133
+ for line in response.iter_lines():
134
+ if line:
135
+ decoded_line = line.decode('utf-8', errors='replace').strip()
136
+ if decoded_line.startswith("data: "):
137
+ json_str = decoded_line[6:]
138
+ if json_str == "[DONE]":
139
+ break
140
+ try:
141
+ data = json.loads(json_str)
142
+ choice_data = data.get('choices', [{}])[0]
143
+ delta_data = choice_data.get('delta', {})
144
+ finish_reason = choice_data.get('finish_reason')
145
+
146
+ usage_data = data.get('usage', {})
147
+ if usage_data:
148
+ prompt_tokens = usage_data.get('prompt_tokens', prompt_tokens)
149
+ completion_tokens = usage_data.get('completion_tokens', completion_tokens)
150
+ total_tokens = usage_data.get('total_tokens', total_tokens)
151
+
152
+ delta = ChoiceDelta(
153
+ content=delta_data.get('content'),
154
+ role=delta_data.get('role'),
155
+ tool_calls=delta_data.get('tool_calls')
156
+ )
157
+ choice = Choice(
158
+ index=choice_data.get('index', 0),
159
+ delta=delta,
160
+ finish_reason=finish_reason,
161
+ logprobs=choice_data.get('logprobs')
162
+ )
163
+ chunk = ChatCompletionChunk(
164
+ id=request_id,
165
+ choices=[choice],
166
+ created=created_time,
167
+ model=model,
168
+ system_fingerprint=data.get('system_fingerprint')
169
+ )
170
+ if hasattr(chunk, "model_dump"):
171
+ chunk_dict = chunk.model_dump(exclude_none=True)
172
+ else:
173
+ chunk_dict = chunk.dict(exclude_none=True)
174
+ usage_dict = {
175
+ "prompt_tokens": prompt_tokens or 10,
176
+ "completion_tokens": completion_tokens or (len(delta_data.get('content', '')) if delta_data.get('content') else 0),
177
+ "total_tokens": total_tokens or (10 + (len(delta_data.get('content', '')) if delta_data.get('content') else 0)),
178
+ "estimated_cost": None
179
+ }
180
+ if delta_data.get('content'):
181
+ completion_tokens += 1
182
+ total_tokens = prompt_tokens + completion_tokens
183
+ usage_dict["completion_tokens"] = completion_tokens
184
+ usage_dict["total_tokens"] = total_tokens
185
+ chunk_dict["usage"] = usage_dict
186
+ yield chunk
187
+ except json.JSONDecodeError:
188
+ print(f"Warning: Could not decode JSON line: {json_str}")
189
+ continue
190
+ except requests.exceptions.RequestException as e:
191
+ print(f"Error during ChutesAI stream request: {e}")
192
+ raise IOError(f"ChutesAI request failed: {e}") from e
193
+ except Exception as e:
194
+ print(f"Error processing ChutesAI stream: {e}")
195
+ raise
196
+
197
+ def _create_non_stream(
198
+ self, request_id: str, created_time: int, model: str, payload: Dict[str, Any]
199
+ ) -> ChatCompletion:
200
+ try:
201
+ response = self._client.scraper.post(
202
+ self._client.base_url,
203
+ headers=self._client.headers,
204
+ json=payload,
205
+ timeout=self._client.timeout
206
+ )
207
+ response.raise_for_status()
208
+ data = response.json()
209
+ choices_data = data.get('choices', [])
210
+ usage_data = data.get('usage', {})
211
+ choices = []
212
+ for choice_d in choices_data:
213
+ message_d = choice_d.get('message', {})
214
+ message = ChatCompletionMessage(
215
+ role=message_d.get('role', 'assistant'),
216
+ content=message_d.get('content', '')
217
+ )
218
+ choice = Choice(
219
+ index=choice_d.get('index', 0),
220
+ message=message,
221
+ finish_reason=choice_d.get('finish_reason', 'stop')
222
+ )
223
+ choices.append(choice)
224
+ usage = CompletionUsage(
225
+ prompt_tokens=usage_data.get('prompt_tokens', 0),
226
+ completion_tokens=usage_data.get('completion_tokens', 0),
227
+ total_tokens=usage_data.get('total_tokens', 0)
228
+ )
229
+ completion = ChatCompletion(
230
+ id=request_id,
231
+ choices=choices,
232
+ created=created_time,
233
+ model=data.get('model', model),
234
+ usage=usage,
235
+ )
236
+ return completion
237
+ except requests.exceptions.RequestException as e:
238
+ print(f"Error during ChutesAI non-stream request: {e}")
239
+ raise IOError(f"ChutesAI request failed: {e}") from e
240
+ except Exception as e:
241
+ print(f"Error processing ChutesAI response: {e}")
242
+ raise
243
+
244
+ class Chat(BaseChat):
245
+ def __init__(self, client: 'ChutesAI'):
246
+ self.completions = Completions(client)
247
+
248
+ class ChutesAI(OpenAICompatibleProvider):
249
+ AVAILABLE_MODELS = [
250
+ "deepseek-ai/DeepSeek-V3-0324",
251
+ "deepseek-ai/DeepSeek-R1",
252
+ "NousResearch/DeepHermes-3-Mistral-24B-Preview",
253
+ "chutesai/Llama-4-Maverick-17B-128E-Instruct-FP8",
254
+ ]
255
+ def __init__(self, api_key: str = None,):
256
+ self.timeout = None # Infinite timeout
257
+ self.base_url = "https://llm.chutes.ai/v1/chat/completions"
258
+
259
+ # Always generate a new API key, ignore any provided key
260
+ print("[yellow]Generating new ChutesAI API key...[/]")
261
+ self.api_key = generate_chutesai_api_key()
262
+
263
+ if not self.api_key:
264
+ print("[red]Failed to generate API key. Retrying...[/]")
265
+ # Retry once more
266
+ self.api_key = generate_chutesai_api_key()
267
+
268
+ if not self.api_key:
269
+ raise ValueError("Failed to generate ChutesAI API key after multiple attempts.")
270
+
271
+ print(f"[green]Successfully generated API key: {self.api_key[:20]}...[/]")
272
+
273
+ self.scraper = cloudscraper.create_scraper()
274
+ self.headers = {
275
+ "Authorization": f"Bearer {self.api_key}",
276
+ "Content-Type": "application/json"
277
+ }
278
+ self.scraper.headers.update(self.headers)
279
+ self.chat = Chat(self)
280
+
281
+ @property
282
+ def models(self):
283
+ class _ModelList:
284
+ def list(inner_self):
285
+ return type(self).AVAILABLE_MODELS
286
+ return _ModelList()
287
+
288
+ if __name__ == "__main__":
289
+ try:
290
+ # Example usage - always use generated API key
291
+ client = ChutesAI()
292
+
293
+ messages = [
294
+ {"role": "system", "content": "You are a helpful assistant."},
295
+ {"role": "user", "content": "What is the capital of France?"}
296
+ ]
297
+
298
+ print("[cyan]Making API request...[/]")
299
+ response = client.chat.completions.create(
300
+ model="deepseek-ai/DeepSeek-V3-0324",
301
+ messages=messages,
302
+ max_tokens=50,
303
+ stream=True
304
+ )
305
+ for chunk in response:
306
+ if hasattr(chunk, "model_dump"):
307
+ chunk_dict = chunk.model_dump(exclude_none=True)
308
+ else:
309
+ chunk_dict = chunk.dict(exclude_none=True)
310
+ print(f"[green]Response Chunk:[/] {chunk_dict}")
311
+
312
+ except Exception as e:
313
+ print(f"[red]Error: {e}[/]")
314
+ print("[yellow]If the issue persists, the ChutesAI service might be down or the API key generation method needs updating.[/]")
@@ -0,0 +1,95 @@
1
+ import requests
2
+ import json
3
+
4
+ def fetch_together_models():
5
+ """Fetch models from Together.xyz API"""
6
+ api_key = "56c8eeff9971269d7a7e625ff88e8a83a34a556003a5c87c289ebe9a3d8a3d2c"
7
+ endpoint = "https://api.together.xyz/v1/models"
8
+
9
+ headers = {
10
+ "Authorization": f"Bearer {api_key}",
11
+ "Accept": "application/json"
12
+ }
13
+
14
+ try:
15
+ response = requests.get(endpoint, headers=headers, timeout=30)
16
+ response.raise_for_status()
17
+
18
+ models_data = response.json()
19
+
20
+ # Extract and categorize models
21
+ chat_models = []
22
+ image_models = []
23
+ language_models = []
24
+ all_models = []
25
+
26
+ print(f"Total models found: {len(models_data)}")
27
+ print("\n" + "="*80)
28
+
29
+ for model in models_data:
30
+ if isinstance(model, dict):
31
+ model_id = model.get("id", "")
32
+ model_type = model.get("type", "").lower()
33
+ context_length = model.get("context_length", 0)
34
+
35
+ if not model_id:
36
+ continue
37
+
38
+ all_models.append(model_id)
39
+
40
+ # Categorize by type
41
+ if model_type == "chat":
42
+ chat_models.append(model_id)
43
+ elif model_type == "image":
44
+ image_models.append(model_id)
45
+ elif model_type == "language":
46
+ language_models.append(model_id)
47
+
48
+ # Print model details
49
+ print(f"Model: {model_id}")
50
+ print(f" Type: {model_type}")
51
+ print(f" Context Length: {context_length}")
52
+ if model.get("config"):
53
+ config = model["config"]
54
+ if config.get("stop"):
55
+ print(f" Stop Tokens: {config['stop']}")
56
+ print("-" * 40)
57
+
58
+ print(f"\nSUMMARY:")
59
+ print(f"Chat Models: {len(chat_models)}")
60
+ print(f"Image Models: {len(image_models)}")
61
+ print(f"Language Models: {len(language_models)}")
62
+ print(f"Total Models: {len(all_models)}")
63
+
64
+ # Generate Python list for code
65
+ print("\n" + "="*80)
66
+ print("AVAILABLE_MODELS = [")
67
+ for model in sorted(all_models):
68
+ print(f' "{model}",')
69
+ print("]")
70
+
71
+ return {
72
+ "all_models": all_models,
73
+ "chat_models": chat_models,
74
+ "image_models": image_models,
75
+ "language_models": language_models,
76
+ "raw_data": models_data
77
+ }
78
+
79
+ except requests.exceptions.RequestException as e:
80
+ print(f"Error fetching models: {e}")
81
+ return None
82
+ except json.JSONDecodeError as e:
83
+ print(f"Error parsing JSON response: {e}")
84
+ return None
85
+
86
+ if __name__ == "__main__":
87
+ result = fetch_together_models()
88
+
89
+ if result:
90
+ print(f"\nšŸ“Š Successfully fetched {len(result['all_models'])} models from Together.xyz")
91
+
92
+ # Save to file
93
+ with open("together_models.json", "w") as f:
94
+ json.dump(result, f, indent=2)
95
+ print("āœ… Results saved to together_models.json")