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,284 @@
1
+ import requests
2
+ import json
3
+ import time
4
+ import uuid
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
+ # --- DeepInfra Client ---
33
+
34
+ class Completions(BaseCompletions):
35
+ def __init__(self, client: 'DeepInfra'):
36
+ self._client = client
37
+
38
+ def create(
39
+ self,
40
+ *,
41
+ model: str,
42
+ messages: List[Dict[str, str]],
43
+ max_tokens: Optional[int] = 2049,
44
+ stream: bool = False,
45
+ temperature: Optional[float] = None,
46
+ top_p: Optional[float] = None,
47
+ **kwargs: Any
48
+ ) -> Union[ChatCompletion, Generator[ChatCompletionChunk, None, None]]:
49
+ """
50
+ Creates a model response for the given chat conversation.
51
+ Mimics openai.chat.completions.create
52
+ """
53
+ payload = {
54
+ "model": model,
55
+ "messages": messages,
56
+ "max_tokens": max_tokens,
57
+ "stream": stream,
58
+ }
59
+ if temperature is not None:
60
+ payload["temperature"] = temperature
61
+ if top_p is not None:
62
+ payload["top_p"] = top_p
63
+
64
+ payload.update(kwargs)
65
+
66
+ request_id = f"chatcmpl-{uuid.uuid4()}"
67
+ created_time = int(time.time())
68
+
69
+ if stream:
70
+ return self._create_stream(request_id, created_time, model, payload)
71
+ else:
72
+ return self._create_non_stream(request_id, created_time, model, payload)
73
+
74
+ def _create_stream(
75
+ self, request_id: str, created_time: int, model: str, payload: Dict[str, Any]
76
+ ) -> Generator[ChatCompletionChunk, None, None]:
77
+ try:
78
+ response = self._client.session.post(
79
+ self._client.base_url,
80
+ headers=self._client.headers,
81
+ json=payload,
82
+ stream=True,
83
+ timeout=self._client.timeout
84
+ )
85
+ response.raise_for_status()
86
+
87
+ # Track token usage across chunks
88
+ prompt_tokens = 0
89
+ completion_tokens = 0
90
+ total_tokens = 0
91
+
92
+ for line in response.iter_lines():
93
+ if line:
94
+ decoded_line = line.decode('utf-8').strip()
95
+
96
+ if decoded_line.startswith("data: "):
97
+ json_str = decoded_line[6:]
98
+ if json_str == "[DONE]":
99
+ # Format the final [DONE] marker in OpenAI format
100
+ # print("data: [DONE]")
101
+ break
102
+
103
+ try:
104
+ data = json.loads(json_str)
105
+ choice_data = data.get('choices', [{}])[0]
106
+ delta_data = choice_data.get('delta', {})
107
+ finish_reason = choice_data.get('finish_reason')
108
+
109
+ # Update token counts if available
110
+ usage_data = data.get('usage', {})
111
+ if usage_data:
112
+ prompt_tokens = usage_data.get('prompt_tokens', prompt_tokens)
113
+ completion_tokens = usage_data.get('completion_tokens', completion_tokens)
114
+ total_tokens = usage_data.get('total_tokens', total_tokens)
115
+
116
+ # Create the delta object
117
+ delta = ChoiceDelta(
118
+ content=delta_data.get('content'),
119
+ role=delta_data.get('role'),
120
+ tool_calls=delta_data.get('tool_calls')
121
+ )
122
+
123
+ # Create the choice object
124
+ choice = Choice(
125
+ index=choice_data.get('index', 0),
126
+ delta=delta,
127
+ finish_reason=finish_reason,
128
+ logprobs=choice_data.get('logprobs')
129
+ )
130
+
131
+ # Create the chunk object
132
+ chunk = ChatCompletionChunk(
133
+ id=request_id,
134
+ choices=[choice],
135
+ created=created_time,
136
+ model=model,
137
+ system_fingerprint=data.get('system_fingerprint')
138
+ )
139
+
140
+ # Convert to dict for proper formatting
141
+ chunk_dict = chunk.to_dict()
142
+
143
+ # Add usage information to match OpenAI format
144
+ # Even if we don't have real token counts, include estimated usage
145
+ # This matches the format in the examples
146
+ usage_dict = {
147
+ "prompt_tokens": prompt_tokens or 10,
148
+ "completion_tokens": completion_tokens or (len(delta_data.get('content', '')) if delta_data.get('content') else 0),
149
+ "total_tokens": total_tokens or (10 + (len(delta_data.get('content', '')) if delta_data.get('content') else 0)),
150
+ "estimated_cost": None
151
+ }
152
+
153
+ # Update completion_tokens and total_tokens as we receive more content
154
+ if delta_data.get('content'):
155
+ completion_tokens += 1
156
+ total_tokens = prompt_tokens + completion_tokens
157
+ usage_dict["completion_tokens"] = completion_tokens
158
+ usage_dict["total_tokens"] = total_tokens
159
+
160
+ chunk_dict["usage"] = usage_dict
161
+
162
+ # Format the response in OpenAI format exactly as requested
163
+ # We need to print the raw string and also yield the chunk object
164
+ # This ensures both the console output and the returned object are correct
165
+ # print(f"data: {json.dumps(chunk_dict)}")
166
+
167
+ # Return the chunk object for internal processing
168
+ yield chunk
169
+ except json.JSONDecodeError:
170
+ print(f"Warning: Could not decode JSON line: {json_str}")
171
+ continue
172
+ except requests.exceptions.RequestException as e:
173
+ print(f"Error during DeepInfra stream request: {e}")
174
+ raise IOError(f"DeepInfra request failed: {e}") from e
175
+ except Exception as e:
176
+ print(f"Error processing DeepInfra stream: {e}")
177
+ raise
178
+
179
+ def _create_non_stream(
180
+ self, request_id: str, created_time: int, model: str, payload: Dict[str, Any]
181
+ ) -> ChatCompletion:
182
+ try:
183
+ response = self._client.session.post(
184
+ self._client.base_url,
185
+ headers=self._client.headers,
186
+ json=payload,
187
+ timeout=self._client.timeout
188
+ )
189
+ response.raise_for_status()
190
+ data = response.json()
191
+
192
+ choices_data = data.get('choices', [])
193
+ usage_data = data.get('usage', {})
194
+
195
+ choices = []
196
+ for choice_d in choices_data:
197
+ message_d = choice_d.get('message', {})
198
+ message = ChatCompletionMessage(
199
+ role=message_d.get('role', 'assistant'),
200
+ content=message_d.get('content', '')
201
+ )
202
+ choice = Choice(
203
+ index=choice_d.get('index', 0),
204
+ message=message,
205
+ finish_reason=choice_d.get('finish_reason', 'stop')
206
+ )
207
+ choices.append(choice)
208
+
209
+ usage = CompletionUsage(
210
+ prompt_tokens=usage_data.get('prompt_tokens', 0),
211
+ completion_tokens=usage_data.get('completion_tokens', 0),
212
+ total_tokens=usage_data.get('total_tokens', 0)
213
+ )
214
+
215
+ completion = ChatCompletion(
216
+ id=request_id,
217
+ choices=choices,
218
+ created=created_time,
219
+ model=data.get('model', model),
220
+ usage=usage,
221
+ )
222
+ return completion
223
+
224
+ except requests.exceptions.RequestException as e:
225
+ print(f"Error during DeepInfra non-stream request: {e}")
226
+ raise IOError(f"DeepInfra request failed: {e}") from e
227
+ except Exception as e:
228
+ print(f"Error processing DeepInfra response: {e}")
229
+ raise
230
+
231
+ class Chat(BaseChat):
232
+ def __init__(self, client: 'DeepInfra'):
233
+ self.completions = Completions(client)
234
+
235
+ class DeepInfra(OpenAICompatibleProvider):
236
+ AVAILABLE_MODELS = [
237
+ "deepseek-ai/DeepSeek-V3",
238
+ "google/gemma-2-27b-it",
239
+ "google/gemma-2-9b-it",
240
+ "meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8",
241
+ "meta-llama/Llama-4-Scout-17B-16E-Instruct",
242
+ "meta-llama/Llama-3.3-70B-Instruct",
243
+ "meta-llama/Llama-3.3-70B-Instruct-Turbo",
244
+ "meta-llama/Meta-Llama-3.1-8B-Instruct",
245
+ "meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo",
246
+ "microsoft/phi-4",
247
+ "microsoft/Phi-4-multimodal-instruct",
248
+ "microsoft/WizardLM-2-8x22B",
249
+ "mistralai/Mistral-Small-24B-Instruct-2501",
250
+ "nvidia/Llama-3.1-Nemotron-70B-Instruct",
251
+ "Qwen/QwQ-32B",
252
+ "Qwen/Qwen2.5-72B-Instruct",
253
+ "Qwen/Qwen2.5-Coder-32B-Instruct",
254
+ ]
255
+
256
+ def __init__(self, timeout: Optional[int] = None, browser: str = "chrome"):
257
+ self.timeout = timeout
258
+ self.base_url = "https://api.deepinfra.com/v1/openai/chat/completions"
259
+ self.session = requests.Session()
260
+
261
+ agent = LitAgent()
262
+ fingerprint = agent.generate_fingerprint(browser)
263
+
264
+ self.headers = {
265
+ "Accept": fingerprint["accept"],
266
+ "Accept-Encoding": "gzip, deflate, br, zstd",
267
+ "Accept-Language": fingerprint["accept_language"],
268
+ "Content-Type": "application/json",
269
+ "Cache-Control": "no-cache",
270
+ "Connection": "keep-alive",
271
+ "Origin": "https://deepinfra.com",
272
+ "Pragma": "no-cache",
273
+ "Referer": "https://deepinfra.com/",
274
+ "Sec-Fetch-Dest": "empty",
275
+ "Sec-Fetch-Mode": "cors",
276
+ "Sec-Fetch-Site": "same-site",
277
+ "X-Deepinfra-Source": "web-embed",
278
+ "Sec-CH-UA": fingerprint["sec_ch_ua"] or '"Not)A;Brand";v="99", "Microsoft Edge";v="127", "Chromium";v="127"',
279
+ "Sec-CH-UA-Mobile": "?0",
280
+ "Sec-CH-UA-Platform": f'"{fingerprint["platform"]}"',
281
+ "User-Agent": fingerprint["user_agent"],
282
+ }
283
+ self.session.headers.update(self.headers)
284
+ self.chat = Chat(self)