webscout 7.5__py3-none-any.whl → 7.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 (132) hide show
  1. webscout/AIauto.py +5 -53
  2. webscout/AIutel.py +8 -318
  3. webscout/DWEBS.py +460 -489
  4. webscout/Extra/YTToolkit/YTdownloader.py +14 -53
  5. webscout/Extra/YTToolkit/transcriber.py +12 -13
  6. webscout/Extra/YTToolkit/ytapi/video.py +0 -1
  7. webscout/Extra/__init__.py +0 -1
  8. webscout/Extra/autocoder/__init__.py +9 -9
  9. webscout/Extra/autocoder/autocoder_utiles.py +193 -199
  10. webscout/Extra/autocoder/rawdog.py +789 -677
  11. webscout/Extra/gguf.py +682 -428
  12. webscout/Extra/weather.py +178 -156
  13. webscout/Extra/weather_ascii.py +70 -17
  14. webscout/Litlogger/core/logger.py +1 -2
  15. webscout/Litlogger/handlers/file.py +1 -1
  16. webscout/Litlogger/styles/formats.py +0 -2
  17. webscout/Litlogger/utils/detectors.py +0 -1
  18. webscout/Provider/AISEARCH/DeepFind.py +0 -1
  19. webscout/Provider/AISEARCH/ISou.py +1 -22
  20. webscout/Provider/AISEARCH/felo_search.py +0 -1
  21. webscout/Provider/AllenAI.py +28 -30
  22. webscout/Provider/C4ai.py +29 -11
  23. webscout/Provider/ChatGPTClone.py +226 -0
  24. webscout/Provider/ChatGPTGratis.py +24 -56
  25. webscout/Provider/DeepSeek.py +25 -17
  26. webscout/Provider/Deepinfra.py +115 -48
  27. webscout/Provider/Gemini.py +1 -1
  28. webscout/Provider/Glider.py +33 -12
  29. webscout/Provider/HF_space/qwen_qwen2.py +2 -2
  30. webscout/Provider/HeckAI.py +23 -7
  31. webscout/Provider/Hunyuan.py +272 -0
  32. webscout/Provider/Jadve.py +20 -5
  33. webscout/Provider/LambdaChat.py +391 -0
  34. webscout/Provider/Netwrck.py +42 -19
  35. webscout/Provider/OLLAMA.py +256 -32
  36. webscout/Provider/PI.py +4 -2
  37. webscout/Provider/Perplexitylabs.py +26 -6
  38. webscout/Provider/PizzaGPT.py +10 -51
  39. webscout/Provider/TTI/AiForce/async_aiforce.py +4 -37
  40. webscout/Provider/TTI/AiForce/sync_aiforce.py +41 -38
  41. webscout/Provider/TTI/FreeAIPlayground/__init__.py +9 -9
  42. webscout/Provider/TTI/FreeAIPlayground/async_freeaiplayground.py +179 -206
  43. webscout/Provider/TTI/FreeAIPlayground/sync_freeaiplayground.py +180 -192
  44. webscout/Provider/TTI/MagicStudio/__init__.py +2 -0
  45. webscout/Provider/TTI/MagicStudio/async_magicstudio.py +111 -0
  46. webscout/Provider/TTI/MagicStudio/sync_magicstudio.py +109 -0
  47. webscout/Provider/TTI/PollinationsAI/async_pollinations.py +5 -24
  48. webscout/Provider/TTI/PollinationsAI/sync_pollinations.py +2 -22
  49. webscout/Provider/TTI/__init__.py +2 -3
  50. webscout/Provider/TTI/aiarta/async_aiarta.py +14 -14
  51. webscout/Provider/TTI/aiarta/sync_aiarta.py +52 -21
  52. webscout/Provider/TTI/artbit/async_artbit.py +3 -32
  53. webscout/Provider/TTI/artbit/sync_artbit.py +3 -31
  54. webscout/Provider/TTI/fastflux/__init__.py +22 -0
  55. webscout/Provider/TTI/fastflux/async_fastflux.py +261 -0
  56. webscout/Provider/TTI/fastflux/sync_fastflux.py +252 -0
  57. webscout/Provider/TTI/piclumen/__init__.py +22 -22
  58. webscout/Provider/TTI/piclumen/sync_piclumen.py +232 -232
  59. webscout/Provider/TTS/__init__.py +2 -2
  60. webscout/Provider/TTS/deepgram.py +12 -39
  61. webscout/Provider/TTS/elevenlabs.py +14 -40
  62. webscout/Provider/TTS/gesserit.py +11 -35
  63. webscout/Provider/TTS/murfai.py +13 -39
  64. webscout/Provider/TTS/parler.py +17 -40
  65. webscout/Provider/TTS/speechma.py +180 -0
  66. webscout/Provider/TTS/streamElements.py +17 -44
  67. webscout/Provider/TextPollinationsAI.py +39 -59
  68. webscout/Provider/Venice.py +25 -8
  69. webscout/Provider/WebSim.py +227 -0
  70. webscout/Provider/WiseCat.py +27 -5
  71. webscout/Provider/Youchat.py +64 -37
  72. webscout/Provider/__init__.py +12 -7
  73. webscout/Provider/akashgpt.py +20 -5
  74. webscout/Provider/flowith.py +33 -7
  75. webscout/Provider/freeaichat.py +32 -45
  76. webscout/Provider/koala.py +20 -5
  77. webscout/Provider/labyrinth.py +239 -0
  78. webscout/Provider/learnfastai.py +28 -15
  79. webscout/Provider/llamatutor.py +1 -1
  80. webscout/Provider/llmchat.py +30 -8
  81. webscout/Provider/multichat.py +65 -9
  82. webscout/Provider/sonus.py +208 -0
  83. webscout/Provider/talkai.py +1 -0
  84. webscout/Provider/turboseek.py +3 -0
  85. webscout/Provider/tutorai.py +2 -0
  86. webscout/Provider/typegpt.py +155 -65
  87. webscout/Provider/uncovr.py +297 -0
  88. webscout/Provider/x0gpt.py +3 -1
  89. webscout/Provider/yep.py +102 -20
  90. webscout/__init__.py +3 -0
  91. webscout/cli.py +53 -40
  92. webscout/conversation.py +1 -10
  93. webscout/litagent/__init__.py +2 -2
  94. webscout/litagent/agent.py +356 -20
  95. webscout/litagent/constants.py +34 -5
  96. webscout/litprinter/__init__.py +0 -3
  97. webscout/models.py +181 -0
  98. webscout/optimizers.py +1 -1
  99. webscout/prompt_manager.py +2 -8
  100. webscout/scout/core/scout.py +1 -4
  101. webscout/scout/core/search_result.py +1 -1
  102. webscout/scout/core/text_utils.py +1 -1
  103. webscout/scout/core.py +2 -5
  104. webscout/scout/element.py +1 -1
  105. webscout/scout/parsers/html_parser.py +1 -1
  106. webscout/scout/utils.py +0 -1
  107. webscout/swiftcli/__init__.py +1 -3
  108. webscout/tempid.py +1 -1
  109. webscout/update_checker.py +1 -3
  110. webscout/version.py +1 -1
  111. webscout/webscout_search_async.py +1 -2
  112. webscout/yep_search.py +297 -297
  113. {webscout-7.5.dist-info → webscout-7.7.dist-info}/LICENSE.md +4 -4
  114. {webscout-7.5.dist-info → webscout-7.7.dist-info}/METADATA +127 -405
  115. {webscout-7.5.dist-info → webscout-7.7.dist-info}/RECORD +118 -117
  116. webscout/Extra/autollama.py +0 -231
  117. webscout/Provider/Amigo.py +0 -274
  118. webscout/Provider/Bing.py +0 -243
  119. webscout/Provider/DiscordRocks.py +0 -253
  120. webscout/Provider/TTI/blackbox/__init__.py +0 -4
  121. webscout/Provider/TTI/blackbox/async_blackbox.py +0 -212
  122. webscout/Provider/TTI/blackbox/sync_blackbox.py +0 -199
  123. webscout/Provider/TTI/deepinfra/__init__.py +0 -4
  124. webscout/Provider/TTI/deepinfra/async_deepinfra.py +0 -227
  125. webscout/Provider/TTI/deepinfra/sync_deepinfra.py +0 -199
  126. webscout/Provider/TTI/imgninza/__init__.py +0 -4
  127. webscout/Provider/TTI/imgninza/async_ninza.py +0 -214
  128. webscout/Provider/TTI/imgninza/sync_ninza.py +0 -209
  129. webscout/Provider/TTS/voicepod.py +0 -117
  130. {webscout-7.5.dist-info → webscout-7.7.dist-info}/WHEEL +0 -0
  131. {webscout-7.5.dist-info → webscout-7.7.dist-info}/entry_points.txt +0 -0
  132. {webscout-7.5.dist-info → webscout-7.7.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,297 @@
1
+ import requests
2
+ import json
3
+ import uuid
4
+ from typing import Any, Dict, Optional, Generator, Union
5
+ from webscout.AIutel import Optimizers
6
+ from webscout.AIutel import Conversation
7
+ from webscout.AIutel import AwesomePrompts
8
+ from webscout.AIbase import Provider
9
+ from webscout import exceptions
10
+ from webscout.litagent import LitAgent
11
+
12
+ class UncovrAI(Provider):
13
+ """
14
+ A class to interact with the Uncovr AI chat API.
15
+ """
16
+
17
+ AVAILABLE_MODELS = [
18
+ "default",
19
+ "gpt-4o-mini",
20
+ "gemini-2-flash",
21
+ "o3-mini",
22
+ "claude-3-7-sonnet",
23
+ "gpt-4o",
24
+ "claude-3-5-sonnet-v2",
25
+ "groq-llama-3-1-8b",
26
+ "deepseek-r1-distill-llama-70b",
27
+ "deepseek-r1-distill-qwen-32b",
28
+ "gemini-2-flash-lite-preview",
29
+ "qwen-qwq-32b"
30
+ ]
31
+
32
+ def __init__(
33
+ self,
34
+ is_conversation: bool = True,
35
+ max_tokens: int = 2049,
36
+ timeout: int = 30,
37
+ intro: str = None,
38
+ filepath: str = None,
39
+ update_file: bool = True,
40
+ proxies: dict = {},
41
+ history_offset: int = 10250,
42
+ act: str = None,
43
+ model: str = "default",
44
+ chat_id: str = None,
45
+ user_id: str = None,
46
+ browser: str = "chrome"
47
+ ):
48
+ """Initializes the Uncovr AI API client."""
49
+ if model not in self.AVAILABLE_MODELS:
50
+ raise ValueError(f"Invalid model: {model}. Choose from: {self.AVAILABLE_MODELS}")
51
+
52
+ self.url = "https://uncovr.app/api/workflows/chat"
53
+
54
+ # Initialize LitAgent for user agent generation
55
+ self.agent = LitAgent()
56
+ # Use fingerprinting to create a consistent browser identity
57
+ self.fingerprint = self.agent.generate_fingerprint(browser)
58
+
59
+ # Use the fingerprint for headers
60
+ self.headers = {
61
+ "Accept": self.fingerprint["accept"],
62
+ "Accept-Encoding": "gzip, deflate, br, zstd",
63
+ "Accept-Language": self.fingerprint["accept_language"],
64
+ "Content-Type": "application/json",
65
+ "Origin": "https://uncovr.app",
66
+ "Referer": "https://uncovr.app/",
67
+ "Sec-CH-UA": self.fingerprint["sec_ch_ua"] or '"Not)A;Brand";v="99", "Microsoft Edge";v="127", "Chromium";v="127"',
68
+ "Sec-CH-UA-Mobile": "?0",
69
+ "Sec-CH-UA-Platform": f'"{self.fingerprint["platform"]}"',
70
+ "User-Agent": self.fingerprint["user_agent"],
71
+ "Sec-Fetch-Dest": "empty",
72
+ "Sec-Fetch-Mode": "cors",
73
+ "Sec-Fetch-Site": "same-origin"
74
+ }
75
+
76
+ self.session = requests.Session()
77
+ self.session.headers.update(self.headers)
78
+ self.session.proxies.update(proxies)
79
+
80
+ self.is_conversation = is_conversation
81
+ self.max_tokens_to_sample = max_tokens
82
+ self.timeout = timeout
83
+ self.last_response = {}
84
+ self.model = model
85
+ self.chat_id = chat_id or str(uuid.uuid4())
86
+ self.user_id = user_id or f"user_{str(uuid.uuid4())[:8].upper()}"
87
+
88
+ self.__available_optimizers = (
89
+ method
90
+ for method in dir(Optimizers)
91
+ if callable(getattr(Optimizers, method)) and not method.startswith("__")
92
+ )
93
+ Conversation.intro = (
94
+ AwesomePrompts().get_act(
95
+ act, raise_not_found=True, default=None, case_insensitive=True
96
+ )
97
+ if act
98
+ else intro or Conversation.intro
99
+ )
100
+
101
+ self.conversation = Conversation(
102
+ is_conversation, self.max_tokens_to_sample, filepath, update_file
103
+ )
104
+ self.conversation.history_offset = history_offset
105
+
106
+ def refresh_identity(self, browser: str = None):
107
+ """
108
+ Refreshes the browser identity fingerprint.
109
+
110
+ Args:
111
+ browser: Specific browser to use for the new fingerprint
112
+ """
113
+ browser = browser or self.fingerprint.get("browser_type", "chrome")
114
+ self.fingerprint = self.agent.generate_fingerprint(browser)
115
+
116
+ # Update headers with new fingerprint
117
+ self.headers.update({
118
+ "Accept": self.fingerprint["accept"],
119
+ "Accept-Language": self.fingerprint["accept_language"],
120
+ "Sec-CH-UA": self.fingerprint["sec_ch_ua"] or self.headers["Sec-CH-UA"],
121
+ "Sec-CH-UA-Platform": f'"{self.fingerprint["platform"]}"',
122
+ "User-Agent": self.fingerprint["user_agent"],
123
+ })
124
+
125
+ # Update session headers
126
+ for header, value in self.headers.items():
127
+ self.session.headers[header] = value
128
+
129
+ return self.fingerprint
130
+
131
+ def ask(
132
+ self,
133
+ prompt: str,
134
+ stream: bool = False,
135
+ raw: bool = False,
136
+ optimizer: str = None,
137
+ conversationally: bool = False,
138
+ temperature: int = 32,
139
+ creativity: str = "medium",
140
+ selected_focus: list = ["web"],
141
+ selected_tools: list = ["quick-cards"]
142
+ ) -> Union[Dict[str, Any], Generator]:
143
+ conversation_prompt = self.conversation.gen_complete_prompt(prompt)
144
+ if optimizer:
145
+ if optimizer in self.__available_optimizers:
146
+ conversation_prompt = getattr(Optimizers, optimizer)(
147
+ conversation_prompt if conversationally else prompt
148
+ )
149
+ else:
150
+ raise Exception(f"Optimizer is not one of {self.__available_optimizers}")
151
+
152
+ # Prepare the request payload
153
+ payload = {
154
+ "content": conversation_prompt,
155
+ "chatId": self.chat_id,
156
+ "userMessageId": str(uuid.uuid4()),
157
+ "ai_config": {
158
+ "selectedFocus": selected_focus,
159
+ "selectedTools": selected_tools,
160
+ "agentId": "chat",
161
+ "modelId": self.model,
162
+ "temperature": temperature,
163
+ "creativity": creativity
164
+ }
165
+ }
166
+
167
+ def for_stream():
168
+ try:
169
+ with self.session.post(self.url, json=payload, stream=True, timeout=self.timeout) as response:
170
+ if response.status_code != 200:
171
+ # If we get a non-200 response, try refreshing our identity once
172
+ if response.status_code in [403, 429]:
173
+ self.refresh_identity()
174
+ # Retry with new identity
175
+ with self.session.post(self.url, json=payload, stream=True, timeout=self.timeout) as retry_response:
176
+ if not retry_response.ok:
177
+ raise exceptions.FailedToGenerateResponseError(
178
+ f"Failed to generate response after identity refresh - ({retry_response.status_code}, {retry_response.reason}) - {retry_response.text}"
179
+ )
180
+ response = retry_response
181
+ else:
182
+ raise exceptions.FailedToGenerateResponseError(
183
+ f"Request failed with status code {response.status_code}"
184
+ )
185
+
186
+ streaming_text = ""
187
+ for line in response.iter_lines():
188
+ if line:
189
+ try:
190
+ line = line.decode('utf-8')
191
+ # Handle different message types
192
+ if line.startswith('0:'): # Content message
193
+ content = line[2:].strip('"')
194
+ streaming_text += content
195
+ resp = dict(text=content)
196
+ yield resp if raw else resp
197
+ except (json.JSONDecodeError, UnicodeDecodeError):
198
+ continue
199
+
200
+ self.last_response = {"text": streaming_text}
201
+ self.conversation.update_chat_history(prompt, streaming_text)
202
+
203
+ except requests.RequestException as e:
204
+ raise exceptions.FailedToGenerateResponseError(f"Request failed: {str(e)}")
205
+
206
+ def for_non_stream():
207
+ try:
208
+ response = self.session.post(self.url, json=payload, timeout=self.timeout)
209
+ if response.status_code != 200:
210
+ if response.status_code in [403, 429]:
211
+ self.refresh_identity()
212
+ response = self.session.post(self.url, json=payload, timeout=self.timeout)
213
+ if not response.ok:
214
+ raise exceptions.FailedToGenerateResponseError(
215
+ f"Failed to generate response after identity refresh - ({response.status_code}, {response.reason}) - {response.text}"
216
+ )
217
+ else:
218
+ raise exceptions.FailedToGenerateResponseError(
219
+ f"Request failed with status code {response.status_code}"
220
+ )
221
+
222
+ full_response = ""
223
+ for line in response.iter_lines():
224
+ if line:
225
+ try:
226
+ line = line.decode('utf-8')
227
+ if line.startswith('0:'): # Content message
228
+ content = line[2:].strip('"')
229
+ full_response += content
230
+ except (json.JSONDecodeError, UnicodeDecodeError):
231
+ continue
232
+
233
+ self.last_response = {"text": full_response}
234
+ self.conversation.update_chat_history(prompt, full_response)
235
+ return {"text": full_response}
236
+ except Exception as e:
237
+ raise exceptions.FailedToGenerateResponseError(f"Request failed: {e}")
238
+
239
+ return for_stream() if stream else for_non_stream()
240
+
241
+ def chat(
242
+ self,
243
+ prompt: str,
244
+ stream: bool = False,
245
+ optimizer: str = None,
246
+ conversationally: bool = False,
247
+ temperature: int = 32,
248
+ creativity: str = "medium",
249
+ selected_focus: list = ["web"],
250
+ selected_tools: list = []
251
+ ) -> Union[str, Generator[str, None, None]]:
252
+ def for_stream():
253
+ for response in self.ask(
254
+ prompt, True, optimizer=optimizer, conversationally=conversationally,
255
+ temperature=temperature, creativity=creativity,
256
+ selected_focus=selected_focus, selected_tools=selected_tools
257
+ ):
258
+ yield self.get_message(response)
259
+ def for_non_stream():
260
+ return self.get_message(
261
+ self.ask(
262
+ prompt, False, optimizer=optimizer, conversationally=conversationally,
263
+ temperature=temperature, creativity=creativity,
264
+ selected_focus=selected_focus, selected_tools=selected_tools
265
+ )
266
+ )
267
+ return for_stream() if stream else for_non_stream()
268
+
269
+ def get_message(self, response: dict) -> str:
270
+ assert isinstance(response, dict), "Response should be of dict data-type only"
271
+ return response["text"].replace('\\n', '\n').replace('\\n\\n', '\n\n')
272
+
273
+ if __name__ == "__main__":
274
+ print("-" * 80)
275
+ print(f"{'Model':<50} {'Status':<10} {'Response'}")
276
+ print("-" * 80)
277
+
278
+ for model in UncovrAI.AVAILABLE_MODELS:
279
+ try:
280
+ test_ai = UncovrAI(model=model, timeout=60)
281
+ response = test_ai.chat("Say 'Hello' in one word", stream=True)
282
+ response_text = ""
283
+ for chunk in response:
284
+ response_text += chunk
285
+
286
+ if response_text and len(response_text.strip()) > 0:
287
+ status = "✓"
288
+ # Clean and truncate response
289
+ clean_text = response_text.strip().encode('utf-8', errors='ignore').decode('utf-8')
290
+ display_text = clean_text[:50] + "..." if len(clean_text) > 50 else clean_text
291
+ else:
292
+ status = "✗"
293
+ display_text = "Empty or invalid response"
294
+ print(f"\r{model:<50} {status:<10} {display_text}")
295
+ except Exception as e:
296
+ print(f"\r{model:<50} {'✗':<10} {str(e)}")
297
+
@@ -24,6 +24,7 @@ class X0GPT(Provider):
24
24
  >>> print(response)
25
25
  'The weather today is sunny with a high of 75°F.'
26
26
  """
27
+ AVAILABLE_MODELS = ["UNKNOWN"]
27
28
 
28
29
  def __init__(
29
30
  self,
@@ -36,7 +37,8 @@ class X0GPT(Provider):
36
37
  proxies: dict = {},
37
38
  history_offset: int = 10250,
38
39
  act: str = None,
39
- system_prompt: str = "You are a helpful assistant."
40
+ system_prompt: str = "You are a helpful assistant.",
41
+ model: str = "UNKNOWN"
40
42
  ):
41
43
  """
42
44
  Initializes the X0GPT API with given parameters.
webscout/Provider/yep.py CHANGED
@@ -38,7 +38,8 @@ class YEPCHAT(Provider):
38
38
  act: str = None,
39
39
  model: str = "DeepSeek-R1-Distill-Qwen-32B",
40
40
  temperature: float = 0.6,
41
- top_p: float = 0.7
41
+ top_p: float = 0.7,
42
+ browser: str = "chrome"
42
43
  ):
43
44
  """
44
45
  Initializes the YEPCHAT provider with the specified parameters.
@@ -69,20 +70,25 @@ class YEPCHAT(Provider):
69
70
 
70
71
  # Initialize LitAgent for user agent generation
71
72
  self.agent = LitAgent()
73
+ # Use fingerprinting to create a consistent browser identity
74
+ self.fingerprint = self.agent.generate_fingerprint(browser)
72
75
 
76
+ # Use the fingerprint for headers
73
77
  self.headers = {
74
- "Accept": "*/*",
78
+ "Accept": self.fingerprint["accept"],
75
79
  "Accept-Encoding": "gzip, deflate, br, zstd",
76
- "Accept-Language": "en-US,en;q=0.9,en-IN;q=0.8",
80
+ "Accept-Language": self.fingerprint["accept_language"],
77
81
  "Content-Type": "application/json; charset=utf-8",
78
82
  "DNT": "1",
79
83
  "Origin": "https://yep.com",
80
84
  "Referer": "https://yep.com/",
81
- "Sec-CH-UA": '"Not)A;Brand";v="99", "Microsoft Edge";v="127", "Chromium";v="127"',
85
+ "Sec-CH-UA": self.fingerprint["sec_ch_ua"] or '"Not)A;Brand";v="99", "Microsoft Edge";v="127", "Chromium";v="127"',
82
86
  "Sec-CH-UA-Mobile": "?0",
83
- "Sec-CH-UA-Platform": '"Windows"',
84
- "User-Agent": self.agent.random(), # Use LitAgent to generate a random user agent
87
+ "Sec-CH-UA-Platform": f'"{self.fingerprint["platform"]}"',
88
+ "User-Agent": self.fingerprint["user_agent"],
85
89
  }
90
+
91
+ # Create session cookies with unique identifiers
86
92
  self.cookies = {"__Host-session": uuid.uuid4().hex, '__cf_bm': uuid.uuid4().hex}
87
93
 
88
94
  self.__available_optimizers = (
@@ -101,8 +107,38 @@ class YEPCHAT(Provider):
101
107
  )
102
108
  self.conversation.history_offset = history_offset
103
109
  self.session.proxies = proxies
110
+
111
+ # Set consistent headers for the scraper session
112
+ for header, value in self.headers.items():
113
+ self.session.headers[header] = value
104
114
 
105
- self.knowledge_cutoff = "December 2023"
115
+ def refresh_identity(self, browser: str = None):
116
+ """
117
+ Refreshes the browser identity fingerprint.
118
+
119
+ Args:
120
+ browser: Specific browser to use for the new fingerprint
121
+ """
122
+ browser = browser or self.fingerprint.get("browser_type", "chrome")
123
+ self.fingerprint = self.agent.generate_fingerprint(browser)
124
+
125
+ # Update headers with new fingerprint
126
+ self.headers.update({
127
+ "Accept": self.fingerprint["accept"],
128
+ "Accept-Language": self.fingerprint["accept_language"],
129
+ "Sec-CH-UA": self.fingerprint["sec_ch_ua"] or self.headers["Sec-CH-UA"],
130
+ "Sec-CH-UA-Platform": f'"{self.fingerprint["platform"]}"',
131
+ "User-Agent": self.fingerprint["user_agent"],
132
+ })
133
+
134
+ # Update session headers
135
+ for header, value in self.headers.items():
136
+ self.session.headers[header] = value
137
+
138
+ # Generate new cookies
139
+ self.cookies = {"__Host-session": uuid.uuid4().hex, '__cf_bm': uuid.uuid4().hex}
140
+
141
+ return self.fingerprint
106
142
 
107
143
  def ask(
108
144
  self,
@@ -147,9 +183,20 @@ class YEPCHAT(Provider):
147
183
  try:
148
184
  with self.session.post(self.chat_endpoint, headers=self.headers, cookies=self.cookies, json=data, stream=True, timeout=self.timeout) as response:
149
185
  if not response.ok:
150
- raise exceptions.FailedToGenerateResponseError(
151
- f"Failed to generate response - ({response.status_code}, {response.reason}) - {response.text}"
152
- )
186
+ # If we get a non-200 response, try refreshing our identity once
187
+ if response.status_code in [403, 429]:
188
+ self.refresh_identity()
189
+ # Retry with new identity
190
+ with self.session.post(self.chat_endpoint, headers=self.headers, cookies=self.cookies, json=data, stream=True, timeout=self.timeout) as retry_response:
191
+ if not retry_response.ok:
192
+ raise exceptions.FailedToGenerateResponseError(
193
+ f"Failed to generate response after identity refresh - ({retry_response.status_code}, {retry_response.reason}) - {retry_response.text}"
194
+ )
195
+ response = retry_response
196
+ else:
197
+ raise exceptions.FailedToGenerateResponseError(
198
+ f"Failed to generate response - ({response.status_code}, {response.reason}) - {response.text}"
199
+ )
153
200
 
154
201
  streaming_text = ""
155
202
  for line in response.iter_lines(decode_unicode=True):
@@ -177,9 +224,30 @@ class YEPCHAT(Provider):
177
224
  raise exceptions.FailedToGenerateResponseError(f"Request failed: {e}")
178
225
 
179
226
  def for_non_stream():
180
- for _ in for_stream():
181
- pass
182
- return self.last_response
227
+ try:
228
+ response = self.session.post(self.chat_endpoint, headers=self.headers, cookies=self.cookies, json=data, timeout=self.timeout)
229
+ if not response.ok:
230
+ if response.status_code in [403, 429]:
231
+ self.refresh_identity()
232
+ response = self.session.post(self.chat_endpoint, headers=self.headers, cookies=self.cookies, json=data, timeout=self.timeout)
233
+ if not response.ok:
234
+ raise exceptions.FailedToGenerateResponseError(
235
+ f"Failed to generate response after identity refresh - ({response.status_code}, {response.reason}) - {response.text}"
236
+ )
237
+ else:
238
+ raise exceptions.FailedToGenerateResponseError(
239
+ f"Failed to generate response - ({response.status_code}, {response.reason}) - {response.text}"
240
+ )
241
+
242
+ response_data = response.json()
243
+ if 'choices' in response_data and len(response_data['choices']) > 0:
244
+ content = response_data['choices'][0].get('message', {}).get('content', '')
245
+ self.conversation.update_chat_history(prompt, content)
246
+ return {"text": content}
247
+ else:
248
+ raise exceptions.FailedToGenerateResponseError("No response content found")
249
+ except Exception as e:
250
+ raise exceptions.FailedToGenerateResponseError(f"Request failed: {e}")
183
251
 
184
252
  return for_stream() if stream else for_non_stream()
185
253
 
@@ -189,7 +257,7 @@ class YEPCHAT(Provider):
189
257
  stream: bool = False,
190
258
  optimizer: str = None,
191
259
  conversationally: bool = False,
192
- ) -> str:
260
+ ) -> Union[str, Generator[str, None, None]]:
193
261
  """
194
262
  Initiates a chat with the Yep API using the provided prompt.
195
263
 
@@ -234,9 +302,23 @@ class YEPCHAT(Provider):
234
302
 
235
303
 
236
304
  if __name__ == "__main__":
237
- from rich import print
238
-
239
- ai = YEPCHAT(model="DeepSeek-R1-Distill-Qwen-32B")
240
- response = ai.chat("how many r in 'strawberry'", stream=True)
241
- for chunk in response:
242
- print(chunk, end="", flush=True)
305
+ print("-" * 80)
306
+ print(f"{'Model':<50} {'Status':<10} {'Response'}")
307
+ print("-" * 80)
308
+
309
+ for model in YEPCHAT.AVAILABLE_MODELS:
310
+ try:
311
+ test_ai = YEPCHAT(model=model, timeout=60)
312
+ response = test_ai.chat("Say 'Hello' in one word")
313
+ response_text = response
314
+
315
+ if response_text and len(response_text.strip()) > 0:
316
+ status = "✓"
317
+ # Truncate response if too long
318
+ display_text = response_text.strip()[:50] + "..." if len(response_text.strip()) > 50 else response_text.strip()
319
+ else:
320
+ status = "✗"
321
+ display_text = "Empty or invalid response"
322
+ print(f"{model:<50} {status:<10} {display_text}")
323
+ except Exception as e:
324
+ print(f"{model:<50} {'✗':<10} {str(e)}")
webscout/__init__.py CHANGED
@@ -31,3 +31,6 @@ except Exception:
31
31
 
32
32
  import logging
33
33
  logging.getLogger("webscout").addHandler(logging.NullHandler())
34
+
35
+ # Import models for easy access
36
+ from webscout.models import model