webscout 8.0__py3-none-any.whl → 8.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 (80) hide show
  1. inferno/__init__.py +6 -0
  2. inferno/__main__.py +9 -0
  3. inferno/cli.py +6 -0
  4. webscout/Local/__init__.py +6 -0
  5. webscout/Local/__main__.py +9 -0
  6. webscout/Local/api.py +576 -0
  7. webscout/Local/cli.py +338 -0
  8. webscout/Local/config.py +75 -0
  9. webscout/Local/llm.py +188 -0
  10. webscout/Local/model_manager.py +205 -0
  11. webscout/Local/server.py +187 -0
  12. webscout/Local/utils.py +93 -0
  13. webscout/Provider/AISEARCH/DeepFind.py +1 -1
  14. webscout/Provider/AISEARCH/ISou.py +1 -1
  15. webscout/Provider/AISEARCH/Perplexity.py +359 -0
  16. webscout/Provider/AISEARCH/__init__.py +3 -1
  17. webscout/Provider/AISEARCH/felo_search.py +1 -1
  18. webscout/Provider/AISEARCH/genspark_search.py +1 -1
  19. webscout/Provider/AISEARCH/hika_search.py +1 -1
  20. webscout/Provider/AISEARCH/iask_search.py +436 -0
  21. webscout/Provider/AISEARCH/scira_search.py +9 -5
  22. webscout/Provider/AISEARCH/webpilotai_search.py +1 -1
  23. webscout/Provider/ExaAI.py +1 -1
  24. webscout/Provider/ExaChat.py +18 -8
  25. webscout/Provider/GithubChat.py +5 -1
  26. webscout/Provider/Glider.py +4 -2
  27. webscout/Provider/Jadve.py +2 -2
  28. webscout/Provider/OPENAI/__init__.py +24 -0
  29. webscout/Provider/OPENAI/base.py +46 -0
  30. webscout/Provider/OPENAI/c4ai.py +347 -0
  31. webscout/Provider/OPENAI/chatgpt.py +549 -0
  32. webscout/Provider/OPENAI/chatgptclone.py +460 -0
  33. webscout/Provider/OPENAI/deepinfra.py +284 -0
  34. webscout/Provider/OPENAI/exaai.py +419 -0
  35. webscout/Provider/OPENAI/exachat.py +433 -0
  36. webscout/Provider/OPENAI/freeaichat.py +355 -0
  37. webscout/Provider/OPENAI/glider.py +316 -0
  38. webscout/Provider/OPENAI/heckai.py +337 -0
  39. webscout/Provider/OPENAI/llmchatco.py +327 -0
  40. webscout/Provider/OPENAI/netwrck.py +348 -0
  41. webscout/Provider/OPENAI/opkfc.py +488 -0
  42. webscout/Provider/OPENAI/scirachat.py +463 -0
  43. webscout/Provider/OPENAI/sonus.py +294 -0
  44. webscout/Provider/OPENAI/standardinput.py +425 -0
  45. webscout/Provider/OPENAI/textpollinations.py +285 -0
  46. webscout/Provider/OPENAI/toolbaz.py +405 -0
  47. webscout/Provider/OPENAI/typegpt.py +361 -0
  48. webscout/Provider/OPENAI/uncovrAI.py +455 -0
  49. webscout/Provider/OPENAI/utils.py +211 -0
  50. webscout/Provider/OPENAI/venice.py +428 -0
  51. webscout/Provider/OPENAI/wisecat.py +381 -0
  52. webscout/Provider/OPENAI/writecream.py +158 -0
  53. webscout/Provider/OPENAI/x0gpt.py +389 -0
  54. webscout/Provider/OPENAI/yep.py +329 -0
  55. webscout/Provider/StandardInput.py +278 -0
  56. webscout/Provider/TextPollinationsAI.py +27 -28
  57. webscout/Provider/Venice.py +1 -1
  58. webscout/Provider/Writecream.py +211 -0
  59. webscout/Provider/WritingMate.py +197 -0
  60. webscout/Provider/Youchat.py +30 -26
  61. webscout/Provider/__init__.py +14 -6
  62. webscout/Provider/koala.py +2 -2
  63. webscout/Provider/llmchatco.py +5 -0
  64. webscout/Provider/scira_chat.py +18 -12
  65. webscout/Provider/scnet.py +187 -0
  66. webscout/Provider/toolbaz.py +320 -0
  67. webscout/Provider/typegpt.py +3 -184
  68. webscout/Provider/uncovr.py +3 -3
  69. webscout/conversation.py +32 -32
  70. webscout/prompt_manager.py +2 -1
  71. webscout/version.py +1 -1
  72. webscout-8.2.dist-info/METADATA +734 -0
  73. {webscout-8.0.dist-info → webscout-8.2.dist-info}/RECORD +77 -32
  74. webscout-8.2.dist-info/entry_points.txt +5 -0
  75. {webscout-8.0.dist-info → webscout-8.2.dist-info}/top_level.txt +1 -0
  76. webscout/Provider/flowith.py +0 -207
  77. webscout-8.0.dist-info/METADATA +0 -995
  78. webscout-8.0.dist-info/entry_points.txt +0 -3
  79. {webscout-8.0.dist-info → webscout-8.2.dist-info}/LICENSE.md +0 -0
  80. {webscout-8.0.dist-info → webscout-8.2.dist-info}/WHEEL +0 -0
@@ -0,0 +1,428 @@
1
+ import time
2
+ import uuid
3
+ import requests
4
+ import json
5
+ from typing import List, Dict, Optional, Union, Generator, Any
6
+
7
+ # Import base classes and utility structures
8
+ from .base import OpenAICompatibleProvider, BaseChat, BaseCompletions
9
+ from .utils import (
10
+ ChatCompletionChunk, ChatCompletion, Choice, ChoiceDelta,
11
+ ChatCompletionMessage, CompletionUsage
12
+ )
13
+
14
+ # Attempt to import LitAgent, fallback if not available
15
+ try:
16
+ from webscout.litagent import LitAgent
17
+ except ImportError:
18
+ # Define a dummy LitAgent if webscout is not installed or accessible
19
+ class LitAgent:
20
+ def generate_fingerprint(self, browser: str = "chrome") -> Dict[str, Any]:
21
+ # Return minimal default headers if LitAgent is unavailable
22
+ print("Warning: LitAgent not found. Using default minimal headers.")
23
+ return {
24
+ "accept": "*/*",
25
+ "accept_language": "en-US,en;q=0.9",
26
+ "platform": "Windows",
27
+ "sec_ch_ua": '"Not/A)Brand";v="99", "Google Chrome";v="127", "Chromium";v="127"',
28
+ "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",
29
+ "browser_type": browser,
30
+ }
31
+
32
+ def random(self) -> str:
33
+ return "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36"
34
+
35
+ # --- Venice Client ---
36
+
37
+ class Completions(BaseCompletions):
38
+ def __init__(self, client: 'Venice'):
39
+ self._client = client
40
+
41
+ def create(
42
+ self,
43
+ *,
44
+ model: str,
45
+ messages: List[Dict[str, str]],
46
+ max_tokens: Optional[int] = 2049,
47
+ stream: bool = False,
48
+ temperature: Optional[float] = 0.8,
49
+ top_p: Optional[float] = 0.9,
50
+ **kwargs: Any
51
+ ) -> Union[ChatCompletion, Generator[ChatCompletionChunk, None, None]]:
52
+ """
53
+ Creates a model response for the given chat conversation.
54
+ Mimics openai.chat.completions.create
55
+ """
56
+ # Extract system message if present for systemPrompt parameter
57
+ system_prompt = self._client.system_prompt
58
+ for msg in messages:
59
+ if msg["role"] == "system":
60
+ system_prompt = msg["content"]
61
+ break
62
+
63
+ # Prepare the payload for Venice API
64
+ payload = {
65
+ "requestId": str(uuid.uuid4())[:7],
66
+ "modelId": self._client.convert_model_name(model),
67
+ "prompt": messages,
68
+ "systemPrompt": system_prompt,
69
+ "conversationType": "text",
70
+ "temperature": temperature if temperature is not None else self._client.temperature,
71
+ "webEnabled": True,
72
+ "topP": top_p if top_p is not None else self._client.top_p,
73
+ "includeVeniceSystemPrompt": False,
74
+ "isCharacter": False,
75
+ "clientProcessingTime": 2000
76
+ }
77
+
78
+ # Add optional parameters if provided
79
+ if max_tokens is not None and max_tokens > 0:
80
+ payload["max_tokens"] = max_tokens
81
+
82
+ # Add any additional parameters
83
+ for key, value in kwargs.items():
84
+ if key not in payload:
85
+ payload[key] = value
86
+
87
+ request_id = f"chatcmpl-{uuid.uuid4()}"
88
+ created_time = int(time.time())
89
+
90
+ if stream:
91
+ return self._create_stream(request_id, created_time, model, payload)
92
+ else:
93
+ return self._create_non_stream(request_id, created_time, model, payload)
94
+
95
+ def _create_stream(
96
+ self, request_id: str, created_time: int, model: str, payload: Dict[str, Any]
97
+ ) -> Generator[ChatCompletionChunk, None, None]:
98
+ try:
99
+ response = self._client.session.post(
100
+ self._client.api_endpoint,
101
+ json=payload,
102
+ stream=True,
103
+ timeout=self._client.timeout
104
+ )
105
+
106
+ # Handle non-200 responses
107
+ if response.status_code != 200:
108
+ raise IOError(
109
+ f"Failed to generate response - ({response.status_code}, {response.reason}) - {response.text}"
110
+ )
111
+
112
+ # Track token usage across chunks
113
+ prompt_tokens = 0
114
+ completion_tokens = 0
115
+ total_tokens = 0
116
+
117
+ # Estimate prompt tokens based on message length
118
+ prompt_tokens = 0
119
+ for msg in payload.get("prompt", []):
120
+ prompt_tokens += len(msg.get("content", "").split())
121
+ prompt_tokens += len(payload.get("systemPrompt", "").split())
122
+
123
+ for line in response.iter_lines():
124
+ if not line:
125
+ continue
126
+
127
+ try:
128
+ # Decode bytes to string
129
+ line_data = line.decode('utf-8').strip()
130
+ if '"kind":"content"' in line_data:
131
+ data = json.loads(line_data)
132
+ if 'content' in data:
133
+ content = data['content']
134
+
135
+ # Format the content (replace escaped newlines)
136
+ content = self._client.format_text(content)
137
+
138
+ # Update token counts
139
+ completion_tokens += 1
140
+ total_tokens = prompt_tokens + completion_tokens
141
+
142
+ # Create the delta object
143
+ delta = ChoiceDelta(
144
+ content=content,
145
+ role="assistant",
146
+ tool_calls=None
147
+ )
148
+
149
+ # Create the choice object
150
+ choice = Choice(
151
+ index=0,
152
+ delta=delta,
153
+ finish_reason=None,
154
+ logprobs=None
155
+ )
156
+
157
+ # Create the chunk object
158
+ chunk = ChatCompletionChunk(
159
+ id=request_id,
160
+ choices=[choice],
161
+ created=created_time,
162
+ model=model,
163
+ system_fingerprint=None
164
+ )
165
+
166
+ # Convert to dict for proper formatting
167
+ chunk_dict = chunk.to_dict()
168
+
169
+ # Add usage information to match OpenAI format
170
+ usage_dict = {
171
+ "prompt_tokens": prompt_tokens,
172
+ "completion_tokens": completion_tokens,
173
+ "total_tokens": total_tokens,
174
+ "estimated_cost": None
175
+ }
176
+
177
+ chunk_dict["usage"] = usage_dict
178
+
179
+ # Return the chunk object for internal processing
180
+ yield chunk
181
+ except json.JSONDecodeError:
182
+ continue
183
+ except UnicodeDecodeError:
184
+ continue
185
+
186
+ # Final chunk with finish_reason="stop"
187
+ delta = ChoiceDelta(
188
+ content=None,
189
+ role=None,
190
+ tool_calls=None
191
+ )
192
+
193
+ choice = Choice(
194
+ index=0,
195
+ delta=delta,
196
+ finish_reason="stop",
197
+ logprobs=None
198
+ )
199
+
200
+ chunk = ChatCompletionChunk(
201
+ id=request_id,
202
+ choices=[choice],
203
+ created=created_time,
204
+ model=model,
205
+ system_fingerprint=None
206
+ )
207
+
208
+ chunk_dict = chunk.to_dict()
209
+ chunk_dict["usage"] = {
210
+ "prompt_tokens": prompt_tokens,
211
+ "completion_tokens": completion_tokens,
212
+ "total_tokens": total_tokens,
213
+ "estimated_cost": None
214
+ }
215
+
216
+ yield chunk
217
+
218
+ except Exception as e:
219
+ print(f"Error during Venice stream request: {e}")
220
+ raise IOError(f"Venice request failed: {e}") from e
221
+
222
+ def _create_non_stream(
223
+ self, request_id: str, created_time: int, model: str, payload: Dict[str, Any]
224
+ ) -> ChatCompletion:
225
+ try:
226
+ # For non-streaming, we still use streaming internally to collect the full response
227
+ response = self._client.session.post(
228
+ self._client.api_endpoint,
229
+ json=payload,
230
+ stream=True,
231
+ timeout=self._client.timeout
232
+ )
233
+
234
+ # Handle non-200 responses
235
+ if response.status_code != 200:
236
+ raise IOError(
237
+ f"Failed to generate response - ({response.status_code}, {response.reason}) - {response.text}"
238
+ )
239
+
240
+ # Collect the full response
241
+ full_text = ""
242
+ for line in response.iter_lines():
243
+ if not line:
244
+ continue
245
+
246
+ try:
247
+ # Decode bytes to string
248
+ line_data = line.decode('utf-8').strip()
249
+ if '"kind":"content"' in line_data:
250
+ data = json.loads(line_data)
251
+ if 'content' in data:
252
+ content = data['content']
253
+ full_text += content
254
+ except json.JSONDecodeError:
255
+ continue
256
+ except UnicodeDecodeError:
257
+ continue
258
+
259
+ # Format the text (replace escaped newlines)
260
+ full_text = self._client.format_text(full_text)
261
+
262
+ # Estimate token counts
263
+ prompt_tokens = 0
264
+ for msg in payload.get("prompt", []):
265
+ prompt_tokens += len(msg.get("content", "").split())
266
+ prompt_tokens += len(payload.get("systemPrompt", "").split())
267
+ completion_tokens = len(full_text.split())
268
+ total_tokens = prompt_tokens + completion_tokens
269
+
270
+ # Create the message object
271
+ message = ChatCompletionMessage(
272
+ role="assistant",
273
+ content=full_text
274
+ )
275
+
276
+ # Create the choice object
277
+ choice = Choice(
278
+ index=0,
279
+ message=message,
280
+ finish_reason="stop"
281
+ )
282
+
283
+ # Create the usage object
284
+ usage = CompletionUsage(
285
+ prompt_tokens=prompt_tokens,
286
+ completion_tokens=completion_tokens,
287
+ total_tokens=total_tokens
288
+ )
289
+
290
+ # Create the completion object
291
+ completion = ChatCompletion(
292
+ id=request_id,
293
+ choices=[choice],
294
+ created=created_time,
295
+ model=model,
296
+ usage=usage,
297
+ )
298
+
299
+ return completion
300
+
301
+ except Exception as e:
302
+ print(f"Error during Venice non-stream request: {e}")
303
+ raise IOError(f"Venice request failed: {e}") from e
304
+
305
+ class Chat(BaseChat):
306
+ def __init__(self, client: 'Venice'):
307
+ self.completions = Completions(client)
308
+
309
+ class Venice(OpenAICompatibleProvider):
310
+ """
311
+ OpenAI-compatible client for Venice AI API.
312
+
313
+ Usage:
314
+ client = Venice()
315
+ response = client.chat.completions.create(
316
+ model="mistral-31-24b",
317
+ messages=[{"role": "user", "content": "Hello!"}]
318
+ )
319
+ """
320
+
321
+ AVAILABLE_MODELS = [
322
+ "mistral-31-24b",
323
+ "llama-3.2-3b-akash",
324
+ "qwen2dot5-coder-32b",
325
+ "deepseek-coder-v2-lite",
326
+ ]
327
+
328
+ # No model mapping needed as we use the model names directly
329
+
330
+ def __init__(
331
+ self,
332
+ timeout: Optional[int] = None,
333
+ browser: str = "chrome"
334
+ ):
335
+ """
336
+ Initialize the Venice client.
337
+
338
+ Args:
339
+ timeout: Request timeout in seconds (None for no timeout)
340
+ browser: Browser to emulate in user agent
341
+ """
342
+ self.timeout = timeout
343
+ self.temperature = 0.8 # Default temperature
344
+ self.top_p = 0.9 # Default top_p
345
+ self.system_prompt = "You are a helpful AI assistant." # Default system prompt
346
+ self.api_endpoint = "https://venice.ai/api/inference/chat"
347
+ self.session = requests.Session()
348
+
349
+ # Initialize LitAgent for user agent generation
350
+ agent = LitAgent()
351
+ self.fingerprint = agent.generate_fingerprint(browser)
352
+
353
+ # Headers for the request
354
+ self.headers = {
355
+ "User-Agent": self.fingerprint["user_agent"],
356
+ "accept": self.fingerprint["accept"],
357
+ "accept-language": self.fingerprint["accept_language"],
358
+ "content-type": "application/json",
359
+ "origin": "https://venice.ai",
360
+ "referer": "https://venice.ai/chat/",
361
+ "sec-ch-ua": self.fingerprint["sec_ch_ua"] or '"Google Chrome";v="133", "Chromium";v="133", "Not?A_Brand";v="24"',
362
+ "sec-ch-ua-mobile": "?0",
363
+ "sec-ch-ua-platform": f'"{self.fingerprint["platform"]}"',
364
+ "sec-fetch-dest": "empty",
365
+ "sec-fetch-mode": "cors",
366
+ "sec-fetch-site": "same-origin"
367
+ }
368
+
369
+ self.session.headers.update(self.headers)
370
+
371
+ # Initialize the chat interface
372
+ self.chat = Chat(self)
373
+
374
+ def format_text(self, text: str) -> str:
375
+ """
376
+ Format text by replacing escaped newlines with actual newlines.
377
+
378
+ Args:
379
+ text: Text to format
380
+
381
+ Returns:
382
+ Formatted text
383
+ """
384
+ # Use a more comprehensive approach to handle all escape sequences
385
+ try:
386
+ # First handle double backslashes to avoid issues
387
+ text = text.replace('\\\\', '\\')
388
+
389
+ # Handle common escape sequences
390
+ text = text.replace('\\n', '\n')
391
+ text = text.replace('\\r', '\r')
392
+ text = text.replace('\\t', '\t')
393
+ text = text.replace('\\"', '"')
394
+ text = text.replace("\\'", "'")
395
+
396
+ # Handle any remaining escape sequences using JSON decoding
397
+ # This is a fallback in case there are other escape sequences
398
+ try:
399
+ # Add quotes to make it a valid JSON string
400
+ json_str = f'"{text}"'
401
+ # Use json module to decode all escape sequences
402
+ decoded = json.loads(json_str)
403
+ return decoded
404
+ except json.JSONDecodeError:
405
+ # If JSON decoding fails, return the text with the replacements we've already done
406
+ return text
407
+ except Exception as e:
408
+ # If any error occurs, return the original text
409
+ print(f"Warning: Error formatting text: {e}")
410
+ return text
411
+
412
+ def convert_model_name(self, model: str) -> str:
413
+ """
414
+ Convert model names to ones supported by Venice.
415
+
416
+ Args:
417
+ model: Model name to convert
418
+
419
+ Returns:
420
+ Venice model name
421
+ """
422
+ # If the model is already a valid Venice model, return it
423
+ if model in self.AVAILABLE_MODELS:
424
+ return model
425
+
426
+ # Default to the most capable model
427
+ print(f"Warning: Unknown model '{model}'. Using 'mistral-31-24b' instead.")
428
+ return "mistral-31-24b"