webscout 8.3.5__py3-none-any.whl → 8.3.7__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 (159) hide show
  1. webscout/AIutel.py +2 -0
  2. webscout/Bard.py +12 -6
  3. webscout/DWEBS.py +66 -57
  4. webscout/Provider/{UNFINISHED → AISEARCH}/PERPLEXED_search.py +34 -74
  5. webscout/Provider/AISEARCH/__init__.py +18 -11
  6. webscout/Provider/AISEARCH/scira_search.py +3 -1
  7. webscout/Provider/Aitopia.py +2 -3
  8. webscout/Provider/Andi.py +3 -3
  9. webscout/Provider/ChatGPTClone.py +1 -1
  10. webscout/Provider/ChatSandbox.py +1 -0
  11. webscout/Provider/Cloudflare.py +1 -1
  12. webscout/Provider/Cohere.py +1 -0
  13. webscout/Provider/Deepinfra.py +13 -10
  14. webscout/Provider/ExaAI.py +1 -1
  15. webscout/Provider/ExaChat.py +1 -80
  16. webscout/Provider/Flowith.py +6 -1
  17. webscout/Provider/Gemini.py +7 -5
  18. webscout/Provider/GeminiProxy.py +1 -0
  19. webscout/Provider/GithubChat.py +4 -1
  20. webscout/Provider/Groq.py +1 -1
  21. webscout/Provider/HeckAI.py +8 -4
  22. webscout/Provider/Jadve.py +23 -38
  23. webscout/Provider/K2Think.py +308 -0
  24. webscout/Provider/Koboldai.py +8 -186
  25. webscout/Provider/LambdaChat.py +2 -4
  26. webscout/Provider/Nemotron.py +3 -4
  27. webscout/Provider/Netwrck.py +6 -8
  28. webscout/Provider/OLLAMA.py +1 -0
  29. webscout/Provider/OPENAI/Cloudflare.py +6 -7
  30. webscout/Provider/OPENAI/FalconH1.py +2 -7
  31. webscout/Provider/OPENAI/FreeGemini.py +6 -8
  32. webscout/Provider/OPENAI/{monochat.py → K2Think.py} +180 -77
  33. webscout/Provider/OPENAI/NEMOTRON.py +3 -6
  34. webscout/Provider/OPENAI/PI.py +5 -4
  35. webscout/Provider/OPENAI/Qwen3.py +2 -3
  36. webscout/Provider/OPENAI/README.md +2 -1
  37. webscout/Provider/OPENAI/TogetherAI.py +52 -57
  38. webscout/Provider/OPENAI/TwoAI.py +3 -4
  39. webscout/Provider/OPENAI/__init__.py +17 -56
  40. webscout/Provider/OPENAI/ai4chat.py +313 -303
  41. webscout/Provider/OPENAI/base.py +9 -29
  42. webscout/Provider/OPENAI/chatgpt.py +7 -2
  43. webscout/Provider/OPENAI/chatgptclone.py +4 -7
  44. webscout/Provider/OPENAI/chatsandbox.py +84 -59
  45. webscout/Provider/OPENAI/deepinfra.py +12 -6
  46. webscout/Provider/OPENAI/e2b.py +60 -8
  47. webscout/Provider/OPENAI/flowith.py +4 -3
  48. webscout/Provider/OPENAI/generate_api_key.py +48 -0
  49. webscout/Provider/OPENAI/heckai.py +4 -1
  50. webscout/Provider/OPENAI/netwrck.py +9 -12
  51. webscout/Provider/OPENAI/refact.py +274 -0
  52. webscout/Provider/OPENAI/scirachat.py +6 -0
  53. webscout/Provider/OPENAI/textpollinations.py +3 -14
  54. webscout/Provider/OPENAI/toolbaz.py +14 -10
  55. webscout/Provider/OpenGPT.py +1 -1
  56. webscout/Provider/Openai.py +150 -402
  57. webscout/Provider/PI.py +1 -0
  58. webscout/Provider/Perplexitylabs.py +1 -2
  59. webscout/Provider/QwenLM.py +107 -89
  60. webscout/Provider/STT/__init__.py +17 -2
  61. webscout/Provider/{Llama3.py → Sambanova.py} +9 -10
  62. webscout/Provider/StandardInput.py +1 -1
  63. webscout/Provider/TTI/__init__.py +18 -12
  64. webscout/Provider/TTI/bing.py +14 -2
  65. webscout/Provider/TTI/together.py +10 -9
  66. webscout/Provider/TTS/README.md +0 -1
  67. webscout/Provider/TTS/__init__.py +18 -11
  68. webscout/Provider/TTS/base.py +479 -159
  69. webscout/Provider/TTS/deepgram.py +409 -156
  70. webscout/Provider/TTS/elevenlabs.py +425 -111
  71. webscout/Provider/TTS/freetts.py +317 -140
  72. webscout/Provider/TTS/gesserit.py +192 -128
  73. webscout/Provider/TTS/murfai.py +248 -113
  74. webscout/Provider/TTS/openai_fm.py +347 -129
  75. webscout/Provider/TTS/speechma.py +620 -586
  76. webscout/Provider/TeachAnything.py +1 -0
  77. webscout/Provider/TextPollinationsAI.py +5 -15
  78. webscout/Provider/TogetherAI.py +136 -142
  79. webscout/Provider/TwoAI.py +53 -309
  80. webscout/Provider/TypliAI.py +2 -1
  81. webscout/Provider/{GizAI.py → UNFINISHED/GizAI.py} +1 -1
  82. webscout/Provider/UNFINISHED/VercelAIGateway.py +339 -0
  83. webscout/Provider/Venice.py +2 -1
  84. webscout/Provider/VercelAI.py +1 -0
  85. webscout/Provider/WiseCat.py +2 -1
  86. webscout/Provider/WrDoChat.py +2 -1
  87. webscout/Provider/__init__.py +18 -174
  88. webscout/Provider/ai4chat.py +1 -1
  89. webscout/Provider/akashgpt.py +7 -10
  90. webscout/Provider/cerebras.py +194 -38
  91. webscout/Provider/chatglm.py +170 -83
  92. webscout/Provider/cleeai.py +1 -2
  93. webscout/Provider/deepseek_assistant.py +1 -1
  94. webscout/Provider/elmo.py +1 -1
  95. webscout/Provider/geminiapi.py +1 -1
  96. webscout/Provider/granite.py +1 -1
  97. webscout/Provider/hermes.py +1 -3
  98. webscout/Provider/julius.py +1 -0
  99. webscout/Provider/learnfastai.py +1 -1
  100. webscout/Provider/llama3mitril.py +1 -1
  101. webscout/Provider/llmchat.py +1 -1
  102. webscout/Provider/llmchatco.py +1 -1
  103. webscout/Provider/meta.py +3 -3
  104. webscout/Provider/oivscode.py +2 -2
  105. webscout/Provider/scira_chat.py +51 -124
  106. webscout/Provider/searchchat.py +1 -0
  107. webscout/Provider/sonus.py +1 -1
  108. webscout/Provider/toolbaz.py +15 -11
  109. webscout/Provider/turboseek.py +31 -22
  110. webscout/Provider/typefully.py +2 -1
  111. webscout/Provider/x0gpt.py +1 -0
  112. webscout/Provider/yep.py +2 -1
  113. webscout/conversation.py +22 -20
  114. webscout/sanitize.py +14 -10
  115. webscout/scout/README.md +20 -23
  116. webscout/scout/core/crawler.py +125 -38
  117. webscout/scout/core/scout.py +26 -5
  118. webscout/tempid.py +6 -0
  119. webscout/version.py +1 -1
  120. webscout/webscout_search.py +13 -6
  121. webscout/webscout_search_async.py +10 -8
  122. webscout/yep_search.py +13 -5
  123. {webscout-8.3.5.dist-info → webscout-8.3.7.dist-info}/METADATA +3 -1
  124. {webscout-8.3.5.dist-info → webscout-8.3.7.dist-info}/RECORD +132 -155
  125. webscout/Provider/AllenAI.py +0 -440
  126. webscout/Provider/Blackboxai.py +0 -793
  127. webscout/Provider/FreeGemini.py +0 -250
  128. webscout/Provider/Glider.py +0 -225
  129. webscout/Provider/Hunyuan.py +0 -283
  130. webscout/Provider/MCPCore.py +0 -322
  131. webscout/Provider/MiniMax.py +0 -207
  132. webscout/Provider/OPENAI/BLACKBOXAI.py +0 -1045
  133. webscout/Provider/OPENAI/MiniMax.py +0 -298
  134. webscout/Provider/OPENAI/autoproxy.py +0 -1067
  135. webscout/Provider/OPENAI/c4ai.py +0 -394
  136. webscout/Provider/OPENAI/copilot.py +0 -305
  137. webscout/Provider/OPENAI/glider.py +0 -330
  138. webscout/Provider/OPENAI/mcpcore.py +0 -431
  139. webscout/Provider/OPENAI/multichat.py +0 -378
  140. webscout/Provider/Reka.py +0 -214
  141. webscout/Provider/TTS/sthir.py +0 -94
  142. webscout/Provider/UNFINISHED/fetch_together_models.py +0 -90
  143. webscout/Provider/asksteve.py +0 -220
  144. webscout/Provider/copilot.py +0 -422
  145. webscout/Provider/freeaichat.py +0 -294
  146. webscout/Provider/koala.py +0 -182
  147. webscout/Provider/lmarena.py +0 -198
  148. webscout/Provider/monochat.py +0 -275
  149. webscout/Provider/multichat.py +0 -375
  150. webscout/Provider/scnet.py +0 -244
  151. webscout/Provider/talkai.py +0 -194
  152. /webscout/Provider/{Marcus.py → UNFINISHED/Marcus.py} +0 -0
  153. /webscout/Provider/{Qodo.py → UNFINISHED/Qodo.py} +0 -0
  154. /webscout/Provider/{XenAI.py → UNFINISHED/XenAI.py} +0 -0
  155. /webscout/Provider/{samurai.py → UNFINISHED/samurai.py} +0 -0
  156. {webscout-8.3.5.dist-info → webscout-8.3.7.dist-info}/WHEEL +0 -0
  157. {webscout-8.3.5.dist-info → webscout-8.3.7.dist-info}/entry_points.txt +0 -0
  158. {webscout-8.3.5.dist-info → webscout-8.3.7.dist-info}/licenses/LICENSE.md +0 -0
  159. {webscout-8.3.5.dist-info → webscout-8.3.7.dist-info}/top_level.txt +0 -0
@@ -1,422 +0,0 @@
1
- import os
2
- import json
3
- import base64
4
- import asyncio
5
- from urllib.parse import quote
6
- from typing import Optional, Dict, Any, List, Union, Generator
7
-
8
- from curl_cffi.requests import Session, CurlWsFlag
9
-
10
- from webscout.AIutel import Optimizers
11
- from webscout.AIutel import Conversation
12
- from webscout.AIutel import AwesomePrompts, sanitize_stream
13
- from webscout.AIbase import Provider, AsyncProvider
14
- from webscout import exceptions
15
- from webscout.litagent import LitAgent
16
-
17
- try:
18
- has_curl_cffi = True
19
- except ImportError:
20
- has_curl_cffi = False
21
-
22
- try:
23
- import nodriver
24
- has_nodriver = True
25
- except ImportError:
26
- has_nodriver = False
27
-
28
-
29
- class NoValidHarFileError(Exception):
30
- pass
31
-
32
-
33
- class CopilotConversation:
34
- conversation_id: str
35
-
36
- def __init__(self, conversation_id: str):
37
- self.conversation_id = conversation_id
38
-
39
-
40
- class Copilot(Provider):
41
- """
42
- A class to interact with the Microsoft Copilot API.
43
- """
44
-
45
- label = "Microsoft Copilot"
46
- url = "https://copilot.microsoft.com"
47
- websocket_url = "wss://copilot.microsoft.com/c/api/chat?api-version=2"
48
- conversation_url = f"{url}/c/api/conversations"
49
- AVAILABLE_MODELS = ["Copilot", "Think Deeper"]
50
- _access_token: str = None
51
- _cookies: dict = None
52
-
53
- def __init__(
54
- self,
55
- is_conversation: bool = True,
56
- max_tokens: int = 2000,
57
- timeout: int = 900,
58
- intro: str = None,
59
- filepath: str = None,
60
- update_file: bool = True,
61
- proxies: dict = {},
62
- history_offset: int = 10250,
63
- act: str = None,
64
- model: str = "Copilot"
65
- ):
66
- """Initializes the Copilot API client."""
67
- if model not in self.AVAILABLE_MODELS:
68
- raise ValueError(f"Invalid model: {model}. Choose from: {self.AVAILABLE_MODELS}")
69
-
70
- # Use LitAgent for user-agent
71
- self.headers = {
72
- 'User-Agent': LitAgent().random(),
73
- 'Accept-Language': 'en-US,en;q=0.9',
74
- 'Connection': 'keep-alive',
75
- 'Content-Type': 'application/json',
76
- 'Origin': self.url,
77
- 'Referer': f'{self.url}/',
78
- 'Sec-Fetch-Dest': 'empty',
79
- 'Sec-Fetch-Mode': 'cors',
80
- 'Sec-Fetch-Site': 'same-origin',
81
- }
82
-
83
- self.is_conversation = is_conversation
84
- self.max_tokens_to_sample = max_tokens
85
- self.timeout = timeout
86
- self.last_response = {}
87
- self.model = model
88
- self.proxies = proxies
89
-
90
- self.__available_optimizers = (
91
- method
92
- for method in dir(Optimizers)
93
- if callable(getattr(Optimizers, method)) and not method.startswith("__")
94
- )
95
- Conversation.intro = (
96
- AwesomePrompts().get_act(
97
- act, raise_not_found=True, default=None, case_insensitive=True
98
- )
99
- if act
100
- else intro or Conversation.intro
101
- )
102
-
103
- self.conversation = Conversation(
104
- is_conversation, self.max_tokens_to_sample, filepath, update_file
105
- )
106
- self.conversation.history_offset = history_offset
107
-
108
- def ask(
109
- self,
110
- prompt: str,
111
- stream: bool = True,
112
- raw: bool = False,
113
- optimizer: str = None,
114
- conversationally: bool = False,
115
- images=None,
116
- api_key: str = None,
117
- **kwargs
118
- ) -> Union[Dict[str, Any], Generator]:
119
- """
120
- Enhanced Copilot.ask with:
121
- - return_conversation support
122
- - multiple image upload
123
- - event dispatch for websocket events
124
- - suggested followups and metadata
125
- - improved error handling
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(f"Optimizer is not one of {self.__available_optimizers}")
135
-
136
- def handle_event(msg, state):
137
- event = msg.get("event")
138
- if event == "appendText":
139
- state["is_started"] = True
140
- content = msg.get("text")
141
- state["streaming_text"] += content
142
- resp = {"text": content}
143
- return resp if raw else resp
144
- elif event == "generatingImage":
145
- state["image_prompt"] = msg.get("prompt")
146
- elif event == "imageGenerated":
147
- return {"type": "image", "url": msg.get("url"), "prompt": state.get("image_prompt"), "preview": msg.get("thumbnailUrl")}
148
- elif event == "done":
149
- state["done"] = True
150
- elif event == "suggestedFollowups":
151
- return {"type": "suggested_followups", "suggestions": msg.get("suggestions")}
152
- elif event == "replaceText":
153
- content = msg.get("text")
154
- state["streaming_text"] += content
155
- resp = {"text": content}
156
- return resp if raw else resp
157
- elif event == "error":
158
- raise exceptions.FailedToGenerateResponseError(f"Error: {msg}")
159
- elif event not in ["received", "startMessage", "citation", "partCompleted"]:
160
- pass
161
- return None
162
-
163
- def for_stream():
164
- try:
165
- if not has_curl_cffi:
166
- raise Exception('Install or update "curl_cffi" package | pip install -U curl_cffi')
167
-
168
- websocket_url = self.websocket_url
169
- headers = None
170
-
171
- # Auth logic (token/cookies)
172
- if images is not None or api_key is not None:
173
- if api_key is not None:
174
- self._access_token = api_key
175
- if self._access_token is None:
176
- try:
177
- self._access_token, self._cookies = readHAR(self.url)
178
- except NoValidHarFileError as h:
179
- if has_nodriver:
180
- yield {"type": "login", "provider": self.label, "url": os.environ.get("webscout_login", "")}
181
- self._access_token, self._cookies = asyncio.run(get_access_token_and_cookies(self.url, self.proxies.get("https")))
182
- else:
183
- raise h
184
- websocket_url = f"{websocket_url}&accessToken={quote(self._access_token)}"
185
- headers = {"authorization": f"Bearer {self._access_token}"}
186
-
187
- with Session(
188
- timeout=self.timeout,
189
- proxy=self.proxies.get("https"),
190
- impersonate="chrome",
191
- headers=headers,
192
- cookies=self._cookies,
193
- ) as session:
194
- if self._access_token is not None:
195
- self._cookies = session.cookies.jar if hasattr(session.cookies, "jar") else session.cookies
196
-
197
- response = session.get(f"{self.url}/c/api/user")
198
- if response.status_code == 401:
199
- raise exceptions.AuthenticationError("Status 401: Invalid access token")
200
- if response.status_code != 200:
201
- raise exceptions.APIConnectionError(f"Status {response.status_code}: {response.text}")
202
- user = response.json().get('firstName')
203
- if user is None:
204
- self._access_token = None
205
-
206
- # Conversation management
207
- conversation = kwargs.get("conversation", None)
208
- if conversation is None:
209
- response = session.post(self.conversation_url)
210
- if response.status_code != 200:
211
- raise exceptions.APIConnectionError(f"Status {response.status_code}: {response.text}")
212
- conversation_id = response.json().get("id")
213
- conversation = CopilotConversation(conversation_id)
214
- if kwargs.get("return_conversation", False):
215
- yield conversation
216
- else:
217
- conversation_id = conversation.conversation_id
218
-
219
- # Multiple image upload
220
- uploaded_images = []
221
- if images is not None:
222
- for image_tuple in images:
223
- image = image_tuple[0] if isinstance(image_tuple, (tuple, list)) else image_tuple
224
- # Convert image to bytes if needed
225
- if isinstance(image, str):
226
- if image.startswith("data:"):
227
- header, encoded = image.split(",", 1)
228
- data = base64.b64decode(encoded)
229
- else:
230
- with open(image, "rb") as f:
231
- data = f.read()
232
- else:
233
- data = image
234
- # Get content type
235
- content_type = "image/jpeg"
236
- if data[:2] == b'\xff\xd8':
237
- content_type = "image/jpeg"
238
- elif data[:8] == b'\x89PNG\r\n\x1a\n':
239
- content_type = "image/png"
240
- elif data[:6] in (b'GIF87a', b'GIF89a'):
241
- content_type = "image/gif"
242
- elif data[:2] in (b'BM', b'BA'):
243
- content_type = "image/bmp"
244
- response = session.post(
245
- f"{self.url}/c/api/attachments",
246
- headers={"content-type": content_type},
247
- data=data
248
- )
249
- if response.status_code != 200:
250
- raise exceptions.APIConnectionError(f"Status {response.status_code}: {response.text}")
251
- uploaded_images.append({"type": "image", "url": response.json().get("url")})
252
-
253
- # WebSocket connection
254
- wss = session.ws_connect(websocket_url)
255
- wss.send(json.dumps({"event": "setOptions", "supportedCards": ["weather", "local", "image", "sports", "video", "ads", "finance"], "ads": {"supportedTypes": ["multimedia", "product", "tourActivity", "propertyPromotion", "text"]}}))
256
- wss.send(json.dumps({
257
- "event": "send",
258
- "conversationId": conversation_id,
259
- "content": [*uploaded_images, {
260
- "type": "text",
261
- "text": conversation_prompt,
262
- }],
263
- "mode": "reasoning" if "Think" in self.model else "chat"
264
- }).encode(), CurlWsFlag.TEXT)
265
-
266
- # Event-driven response loop
267
- state = {"is_started": False, "image_prompt": None, "done": False, "streaming_text": ""}
268
- last_msg = None
269
- try:
270
- while not state["done"]:
271
- try:
272
- msg = wss.recv()[0]
273
- msg = json.loads(msg)
274
- except Exception:
275
- break
276
- last_msg = msg
277
- result = handle_event(msg, state)
278
- if result is not None:
279
- yield result
280
- if not state["is_started"]:
281
- raise exceptions.FailedToGenerateResponseError(f"Invalid response: {last_msg}")
282
- self.conversation.update_chat_history(prompt, state["streaming_text"])
283
- self.last_response = {"text": state["streaming_text"]}
284
- finally:
285
- wss.close()
286
- except Exception as e:
287
- raise exceptions.FailedToGenerateResponseError(f"Error: {str(e)}")
288
-
289
- def for_non_stream():
290
- streaming_text = ""
291
- for response in for_stream():
292
- if isinstance(response, dict) and "text" in response:
293
- streaming_text += response["text"]
294
- self.last_response = {"text": streaming_text}
295
- return self.last_response
296
-
297
- return for_stream() if stream else for_non_stream()
298
-
299
- def chat(
300
- self,
301
- prompt: str,
302
- stream: bool = True,
303
- optimizer: str = None,
304
- conversationally: bool = False,
305
- images = None,
306
- api_key: str = None,
307
- **kwargs
308
- ) -> Union[str, Generator]:
309
- def for_stream():
310
- for response in self.ask(prompt, True, optimizer=optimizer,
311
- conversationally=conversationally,
312
- images=images, api_key=api_key, **kwargs):
313
- if isinstance(response, dict):
314
- if "text" in response:
315
- yield response["text"]
316
- elif "type" in response:
317
- if response["type"] == "image":
318
- yield f"\n![Image]({response['url']})\n"
319
- elif response["type"] == "suggested_followups":
320
- yield "\nSuggested follow-up questions:\n"
321
- for suggestion in response["suggestions"]:
322
- yield f"- {suggestion}\n"
323
-
324
- def for_non_stream():
325
- response = self.ask(prompt, False, optimizer=optimizer,
326
- conversationally=conversationally,
327
- images=images, api_key=api_key, **kwargs)
328
- return self.get_message(response)
329
-
330
- return for_stream() if stream else for_non_stream()
331
-
332
- def get_message(self, response: dict) -> str:
333
- assert isinstance(response, dict), "Response should be of dict data-type only"
334
- return response.get("text", "")
335
-
336
-
337
- async def get_access_token_and_cookies(url: str, proxy: str = None, target: str = "ChatAI"):
338
- browser, stop_browser = await get_nodriver(proxy=proxy, user_data_dir="copilot")
339
- try:
340
- page = await browser.get(url)
341
- access_token = None
342
- while access_token is None:
343
- access_token = await page.evaluate("""
344
- (() => {
345
- for (var i = 0; i < localStorage.length; i++) {
346
- try {
347
- item = JSON.parse(localStorage.getItem(localStorage.key(i)));
348
- if (item.credentialType == "AccessToken"
349
- && item.expiresOn > Math.floor(Date.now() / 1000)
350
- && item.target.includes("target")) {
351
- return item.secret;
352
- }
353
- } catch(e) {}
354
- }
355
- })()
356
- """.replace('"target"', json.dumps(target)))
357
- if access_token is None:
358
- await asyncio.sleep(1)
359
- cookies = {}
360
- for c in await page.send(nodriver.cdp.network.get_cookies([url])):
361
- cookies[c.name] = c.value
362
- await page.close()
363
- return access_token, cookies
364
- finally:
365
- stop_browser()
366
-
367
-
368
- def readHAR(url: str):
369
- api_key = None
370
- cookies = None
371
- har_files = []
372
- # Look for HAR files in common locations
373
- har_paths = [
374
- os.path.join(os.path.expanduser("~"), "Downloads"),
375
- os.path.join(os.path.expanduser("~"), "Desktop")
376
- ]
377
- for path in har_paths:
378
- if os.path.exists(path):
379
- for file in os.listdir(path):
380
- if file.endswith(".har"):
381
- har_files.append(os.path.join(path, file))
382
-
383
- for path in har_files:
384
- with open(path, 'rb') as file:
385
- try:
386
- harFile = json.loads(file.read())
387
- except json.JSONDecodeError:
388
- # Error: not a HAR file!
389
- continue
390
- for v in harFile['log']['entries']:
391
- if v['request']['url'].startswith(url):
392
- v_headers = {h['name'].lower(): h['value'] for h in v['request']['headers']}
393
- if "authorization" in v_headers:
394
- api_key = v_headers["authorization"].split(maxsplit=1).pop()
395
- if v['request']['cookies']:
396
- cookies = {c['name']: c['value'] for c in v['request']['cookies']}
397
- if api_key is None:
398
- raise NoValidHarFileError("No access token found in .har files")
399
-
400
- return api_key, cookies
401
-
402
-
403
- # def get_clarity() -> bytes:
404
- # body = base64.b64decode("H4sIAAAAAAAAA23RwU7DMAwG4HfJ2aqS2E5ibjxH1cMOnQYqYZvUTQPx7vyJRGGAemj01XWcP+9udg+j80MetDhSyrEISc5GrqrtZnmaTydHbrdUnSsWYT2u+8Obo0Ce/IQvaDBmjkwhUlKKIRNHmQgosqEArWPRDQMx90rxeUMPzB1j+UJvwNIxhTvsPcXyX1T+rizE4juK3mEEhpAUg/JvzW1/+U/tB1LATmhqotoiweMea50PLy2vui4LOY3XfD1dwnkor5fn/e18XBFgm6fHjSzZmCyV7d3aRByAEYextaTHEH3i5pgKGVP/s+DScE5PuLKIpW6FnCi1gY3Rbpqmj0/DI/+L7QEAAA==")
405
- # return body
406
-
407
-
408
- async def get_nodriver(proxy=None, user_data_dir=None):
409
- browser = await nodriver.Browser(
410
- headless=True,
411
- proxy=proxy,
412
- user_data_dir=user_data_dir
413
- )
414
- return browser, lambda: browser.close()
415
-
416
-
417
- if __name__ == "__main__":
418
- from rich import print
419
- ai = Copilot(timeout=900, model="Think Deeper")
420
- response = ai.chat(input("> "), stream=True)
421
- for chunk in response:
422
- print(chunk, end="", flush=True)