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
@@ -2,15 +2,14 @@ import time
2
2
  import requests
3
3
  import pathlib
4
4
  import urllib.parse
5
- from typing import Union, Generator
6
- from playsound import playsound
5
+ import tempfile
6
+ from typing import Union
7
+ from io import BytesIO
7
8
  from webscout import exceptions
8
9
  from webscout.AIbase import TTSProvider
9
- from webscout.Litlogger import Logger, LogFormat
10
10
  from webscout.litagent import LitAgent
11
- from . import utils
12
11
  from concurrent.futures import ThreadPoolExecutor, as_completed
13
- from io import BytesIO
12
+ from . import utils
14
13
 
15
14
  class StreamElements(TTSProvider):
16
15
  """
@@ -21,7 +20,6 @@ class StreamElements(TTSProvider):
21
20
  headers: dict[str, str] = {
22
21
  "User-Agent": LitAgent().random()
23
22
  }
24
- cache_dir = pathlib.Path("./audio_cache")
25
23
  all_voices: list[str] = [
26
24
  "Filiz",
27
25
  "Astrid",
@@ -238,11 +236,7 @@ class StreamElements(TTSProvider):
238
236
  if proxies:
239
237
  self.session.proxies.update(proxies)
240
238
  self.timeout = timeout
241
- self.logger = Logger(
242
- name="StreamElementsTTS",
243
- format=LogFormat.MODERN_EMOJI,
244
-
245
- )
239
+ self.temp_dir = tempfile.mkdtemp(prefix="webscout_tts_")
246
240
 
247
241
  def tts(self, text: str, voice: str = "Mathieu", verbose: bool = True) -> str:
248
242
  """
@@ -260,7 +254,7 @@ class StreamElements(TTSProvider):
260
254
  voice in self.all_voices
261
255
  ), f"Voice '{voice}' not one of [{', '.join(self.all_voices)}]"
262
256
 
263
- filename = self.cache_dir / f"{int(time.time())}.mp3"
257
+ filename = pathlib.Path(tempfile.mktemp(suffix=".mp3", dir=self.temp_dir))
264
258
 
265
259
  # Split text into sentences
266
260
  sentences = utils.split_sentences(text)
@@ -278,20 +272,17 @@ class StreamElements(TTSProvider):
278
272
  response = self.session.get(url, headers=self.headers, timeout=self.timeout)
279
273
  response.raise_for_status()
280
274
 
281
- # Create the audio_cache directory if it doesn't exist
282
- self.cache_dir.mkdir(parents=True, exist_ok=True)
283
-
284
275
  # Check if the request was successful
285
276
  if response.ok and response.status_code == 200:
286
277
  if verbose:
287
- self.logger.success(f"Chunk {part_number} processed successfully 🎉")
278
+ print(f"[debug] Chunk {part_number} processed successfully")
288
279
  return part_number, response.content
289
280
  else:
290
281
  if verbose:
291
- self.logger.warning(f"No data received for chunk {part_number}. Retrying...")
282
+ print(f"[debug] No data received for chunk {part_number}. Retrying...")
292
283
  except requests.RequestException as e:
293
284
  if verbose:
294
- self.logger.error(f"Error for chunk {part_number}: {e}. Retrying... 🔄")
285
+ print(f"[debug] Error for chunk {part_number}: {e}. Retrying...")
295
286
  time.sleep(1)
296
287
  try:
297
288
  # Using ThreadPoolExecutor to handle requests concurrently
@@ -309,52 +300,34 @@ class StreamElements(TTSProvider):
309
300
  audio_chunks[part_number] = audio_data # Store the audio data in correct sequence
310
301
  except Exception as e:
311
302
  if verbose:
312
- self.logger.error(f"Failed to generate audio for chunk {chunk_num}: {e} 🚨")
303
+ print(f"[debug] Failed to generate audio for chunk {chunk_num}: {e}")
313
304
 
314
305
  # Combine audio chunks in the correct sequence
315
306
  combined_audio = BytesIO()
316
307
  for part_number in sorted(audio_chunks.keys()):
317
308
  combined_audio.write(audio_chunks[part_number])
318
309
  if verbose:
319
- self.logger.debug(f"Added chunk {part_number} to the combined file.")
310
+ print(f"[debug] Added chunk {part_number} to the combined file.")
320
311
 
321
312
  # Save the combined audio data to a single file
322
313
  with open(filename, 'wb') as f:
323
314
  f.write(combined_audio.getvalue())
324
315
  if verbose:
325
- self.logger.info(f"Final Audio Saved as {filename} 🔊")
316
+ print(f"[debug] Final Audio Saved as {filename}")
326
317
  return filename.as_posix()
327
318
 
328
319
  except requests.exceptions.RequestException as e:
329
- self.logger.critical(f"Failed to perform the operation: {e} 🚨")
320
+ if verbose:
321
+ print(f"[debug] Failed to perform the operation: {e}")
330
322
  raise exceptions.FailedToGenerateResponseError(
331
323
  f"Failed to perform the operation: {e}"
332
324
  )
333
-
334
- def play_audio(self, filename: str):
335
- """
336
- Plays an audio file using playsound.
337
-
338
- Args:
339
- filename (str): The path to the audio file.
340
-
341
- Raises:
342
- RuntimeError: If there is an error playing the audio.
343
- """
344
- try:
345
- self.logger.info(f"Playing audio: {filename} 🎵")
346
- playsound(filename)
347
- except Exception as e:
348
- self.logger.error(f"Error playing audio: {e} 🔇")
349
- raise RuntimeError(f"Error playing audio: {e}")
350
325
 
351
326
  # Example usage
352
327
  if __name__ == "__main__":
353
328
  streamelements = StreamElements()
354
329
  text = "This is a test of the StreamElements text-to-speech API. It supports multiple sentences and advanced logging."
355
330
 
356
- streamelements.logger.info("Generating audio...")
357
- audio_file = streamelements.tts(text, voice="Mathieu")
358
-
359
- streamelements.logger.info("Playing audio...")
360
- streamelements.play_audio(audio_file)
331
+ print("[debug] Generating audio...")
332
+ audio_file = streamelements.tts(text, voice="Mathieu")
333
+ print(f"Audio saved to: {audio_file}")
@@ -4,11 +4,11 @@ from typing import Any, Dict, Generator
4
4
  from webscout.AIutel import Optimizers, Conversation, AwesomePrompts
5
5
  from webscout.AIbase import Provider
6
6
  from webscout import exceptions
7
- from webscout.Litlogger import Logger, LogFormat
8
7
  from webscout import LitAgent as Lit
8
+
9
9
  class TextPollinationsAI(Provider):
10
10
  """
11
- A class to interact with the Pollinations AI API with comprehensive logging.
11
+ A class to interact with the Pollinations AI API.
12
12
  """
13
13
 
14
14
  AVAILABLE_MODELS = [
@@ -23,21 +23,21 @@ class TextPollinationsAI(Provider):
23
23
  "rtist", # Rtist image generator
24
24
  "searchgpt", # SearchGPT with realtime search
25
25
  "evil", # Evil Mode - Experimental
26
- "deepseek", # DeepSeek-V3
26
+ # "deepseek", # DeepSeek-V3 >>>> NOT WORKING
27
27
  "claude-hybridspace", # Claude Hybridspace
28
28
  "deepseek-r1", # DeepSeek-R1 Distill Qwen 32B
29
- "deepseek-reasoner", # DeepSeek R1 - Full
30
- "llamalight", # Llama 3.1 8B Instruct
31
- "llamaguard", # Llamaguard 7B AWQ
29
+ # "deepseek-reasoner", # DeepSeek R1 - Full >>>> NOT WORKING
30
+ # "llamalight", # Llama 3.1 8B Instruct >>>> NOT WORKING
31
+ # "llamaguard", # Llamaguard 7B AWQ >>>> NOT WORKING
32
32
  "gemini", # Gemini 2.0 Flash
33
33
  "gemini-thinking", # Gemini 2.0 Flash Thinking
34
34
  "hormoz", # Hormoz 8b
35
35
  "hypnosis-tracy", # Hypnosis Tracy
36
36
  "sur", # Sur AI Assistant
37
37
  "sur-mistral", # Sur AI Assistant (Mistral)
38
- "llama-scaleway", # Llama (Scaleway)
38
+ # "llama-scaleway", # Llama (Scaleway) >>>> NOT WORKING
39
39
  "phi", # Phi model
40
- "openai-audio" # OpenAI Audio model
40
+ # "openai-audio" # OpenAI Audio model >>>> NOT WORKING
41
41
  ]
42
42
 
43
43
  def __init__(
@@ -53,20 +53,11 @@ class TextPollinationsAI(Provider):
53
53
  act: str = None,
54
54
  model: str = "openai-large",
55
55
  system_prompt: str = "You are a helpful AI assistant.",
56
- logging: bool = False
57
56
  ):
58
- """Initializes the TextPollinationsAI API client with logging capabilities."""
57
+ """Initializes the TextPollinationsAI API client."""
59
58
  if model not in self.AVAILABLE_MODELS:
60
59
  raise ValueError(f"Invalid model: {model}. Choose from: {self.AVAILABLE_MODELS}")
61
60
 
62
- self.logger = Logger(
63
- name="TextPollinationsAI",
64
- format=LogFormat.MODERN_EMOJI,
65
- ) if logging else None
66
-
67
- if self.logger:
68
- self.logger.info(f"Initializing TextPollinationsAI with model: {model}")
69
-
70
61
  self.session = requests.Session()
71
62
  self.is_conversation = is_conversation
72
63
  self.max_tokens_to_sample = max_tokens
@@ -105,9 +96,6 @@ class TextPollinationsAI(Provider):
105
96
  )
106
97
  self.conversation.history_offset = history_offset
107
98
 
108
- if self.logger:
109
- self.logger.info("TextPollinationsAI initialized successfully")
110
-
111
99
  def ask(
112
100
  self,
113
101
  prompt: str,
@@ -116,22 +104,14 @@ class TextPollinationsAI(Provider):
116
104
  optimizer: str = None,
117
105
  conversationally: bool = False,
118
106
  ) -> Dict[str, Any] | Generator[Dict[str, Any], None, None]:
119
- """Chat with AI with logging capabilities"""
120
- if self.logger:
121
- self.logger.debug(f"Processing request - Prompt: {prompt[:50]}...")
122
- self.logger.debug(f"Stream: {stream}, Optimizer: {optimizer}")
123
-
107
+ """Chat with AI"""
124
108
  conversation_prompt = self.conversation.gen_complete_prompt(prompt)
125
109
  if optimizer:
126
110
  if optimizer in self.__available_optimizers:
127
111
  conversation_prompt = getattr(Optimizers, optimizer)(
128
112
  conversation_prompt if conversationally else prompt
129
113
  )
130
- if self.logger:
131
- self.logger.debug(f"Applied optimizer: {optimizer}")
132
114
  else:
133
- if self.logger:
134
- self.logger.error(f"Invalid optimizer requested: {optimizer}")
135
115
  raise Exception(f"Optimizer is not one of {self.__available_optimizers}")
136
116
 
137
117
  payload = {
@@ -144,9 +124,6 @@ class TextPollinationsAI(Provider):
144
124
  }
145
125
 
146
126
  def for_stream():
147
- if self.logger:
148
- self.logger.debug("Initiating streaming request to API")
149
-
150
127
  response = self.session.post(
151
128
  self.api_endpoint,
152
129
  headers=self.headers,
@@ -156,22 +133,15 @@ class TextPollinationsAI(Provider):
156
133
  )
157
134
 
158
135
  if not response.ok:
159
- if self.logger:
160
- self.logger.error(f"API request failed. Status: {response.status_code}, Reason: {response.reason}")
161
136
  raise exceptions.FailedToGenerateResponseError(
162
137
  f"Failed to generate response - ({response.status_code}, {response.reason}) - {response.text}"
163
138
  )
164
139
 
165
- if self.logger:
166
- self.logger.info(f"API connection established successfully. Status: {response.status_code}")
167
-
168
140
  full_response = ""
169
141
  for line in response.iter_lines():
170
142
  if line:
171
143
  line = line.decode('utf-8').strip()
172
144
  if line == "data: [DONE]":
173
- if self.logger:
174
- self.logger.debug("Stream completed")
175
145
  break
176
146
  if line.startswith('data: '):
177
147
  try:
@@ -184,9 +154,7 @@ class TextPollinationsAI(Provider):
184
154
  content = ""
185
155
  full_response += content
186
156
  yield content if raw else dict(text=content)
187
- except json.JSONDecodeError as e:
188
- if self.logger:
189
- self.logger.error(f"JSON parsing error: {str(e)}")
157
+ except json.JSONDecodeError:
190
158
  continue
191
159
 
192
160
  self.last_response.update(dict(text=full_response))
@@ -194,12 +162,7 @@ class TextPollinationsAI(Provider):
194
162
  prompt, self.get_message(self.last_response)
195
163
  )
196
164
 
197
- if self.logger:
198
- self.logger.debug("Response processing completed")
199
-
200
165
  def for_non_stream():
201
- if self.logger:
202
- self.logger.debug("Processing non-streaming request")
203
166
  for _ in for_stream():
204
167
  pass
205
168
  return self.last_response
@@ -213,10 +176,7 @@ class TextPollinationsAI(Provider):
213
176
  optimizer: str = None,
214
177
  conversationally: bool = False,
215
178
  ) -> str | Generator[str, None, None]:
216
- """Generate response as a string with logging"""
217
- if self.logger:
218
- self.logger.debug(f"Chat request initiated - Prompt: {prompt[:50]}...")
219
-
179
+ """Generate response as a string"""
220
180
  def for_stream():
221
181
  for response in self.ask(
222
182
  prompt, True, optimizer=optimizer, conversationally=conversationally
@@ -241,10 +201,30 @@ class TextPollinationsAI(Provider):
241
201
  return response["text"]
242
202
 
243
203
  if __name__ == "__main__":
244
- from rich import print
245
- # Enable logging for testing
246
- ai = TextPollinationsAI(model="deepseek-r1", logging=True)
247
- response = ai.chat(input(">>> "), stream=True)
248
- for chunk in response:
249
- print(chunk, end="", flush=True)
250
-
204
+ print("-" * 80)
205
+ print(f"{'Model':<50} {'Status':<10} {'Response'}")
206
+ print("-" * 80)
207
+
208
+ # Test all available models
209
+ working = 0
210
+ total = len(TextPollinationsAI.AVAILABLE_MODELS)
211
+
212
+ for model in TextPollinationsAI.AVAILABLE_MODELS:
213
+ try:
214
+ test_ai = TextPollinationsAI(model=model, timeout=60)
215
+ response = test_ai.chat("Say 'Hello' in one word", stream=True)
216
+ response_text = ""
217
+ for chunk in response:
218
+ response_text += chunk
219
+ print(f"\r{model:<50} {'Testing...':<10}", end="", flush=True)
220
+
221
+ if response_text and len(response_text.strip()) > 0:
222
+ status = "✓"
223
+ # Truncate response if too long
224
+ display_text = response_text.strip()[:50] + "..." if len(response_text.strip()) > 50 else response_text.strip()
225
+ else:
226
+ status = "✗"
227
+ display_text = "Empty or invalid response"
228
+ print(f"\r{model:<50} {status:<10} {display_text}")
229
+ except Exception as e:
230
+ print(f"\r{model:<50} {'✗':<10} {str(e)}")
@@ -188,13 +188,30 @@ class Venice(Provider):
188
188
  return response["text"]
189
189
 
190
190
  if __name__ == "__main__":
191
- from rich import print
191
+ print("-" * 80)
192
+ print(f"{'Model':<50} {'Status':<10} {'Response'}")
193
+ print("-" * 80)
192
194
 
193
- # Initialize Venice AI
194
- ai = Venice(model="qwen2dot5-coder-32b", timeout=50)
195
+ # Test all available models
196
+ working = 0
197
+ total = len(Venice.AVAILABLE_MODELS)
195
198
 
196
- # Test chat with streaming
197
- response = ai.chat("Write a short story about an AI assistant", stream=False)
198
- print(response)
199
- # for chunk in response:
200
- # print(chunk, end="", flush=True)
199
+ for model in Venice.AVAILABLE_MODELS:
200
+ try:
201
+ test_ai = Venice(model=model, timeout=60)
202
+ response = test_ai.chat("Say 'Hello' in one word", stream=True)
203
+ response_text = ""
204
+ for chunk in response:
205
+ response_text += chunk
206
+ print(f"\r{model:<50} {'Testing...':<10}", end="", flush=True)
207
+
208
+ if response_text and len(response_text.strip()) > 0:
209
+ status = "✓"
210
+ # Truncate response if too long
211
+ display_text = response_text.strip()[:50] + "..." if len(response_text.strip()) > 50 else response_text.strip()
212
+ else:
213
+ status = "✗"
214
+ display_text = "Empty or invalid response"
215
+ print(f"\r{model:<50} {status:<10} {display_text}")
216
+ except Exception as e:
217
+ print(f"\r{model:<50} {'✗':<10} {str(e)}")
@@ -0,0 +1,227 @@
1
+ import requests
2
+ import json
3
+ import string
4
+ import random
5
+ from typing import Any, Dict, Union
6
+
7
+ from webscout.AIutel import Optimizers
8
+ from webscout.AIutel import Conversation
9
+ from webscout.AIutel import AwesomePrompts
10
+ from webscout.AIbase import Provider
11
+ from webscout import exceptions
12
+
13
+ class WebSim(Provider):
14
+ """
15
+ A class to interact with the WebSim API.
16
+ """
17
+
18
+ url = "https://websim.ai"
19
+ chat_api_endpoint = "https://websim.ai/api/v1/inference/run_chat_completion"
20
+ image_api_endpoint = "https://websim.ai/api/v1/inference/run_image_generation"
21
+
22
+ image_models = ['flux']
23
+ AVAILABLE_MODELS = ['gemini-1.5-flash', 'gemini-1.5-pro', 'gemini-flash', 'gemini-pro', 'gemini-flash-thinking'] + image_models
24
+
25
+ @staticmethod
26
+ def generate_project_id(for_image=False):
27
+ """
28
+ Generate a project ID in the appropriate format
29
+
30
+ For chat: format like 'ke3_xh5gai3gjkmruomu'
31
+ For image: format like 'kx0m131_rzz66qb2xoy7'
32
+ """
33
+ chars = string.ascii_lowercase + string.digits
34
+
35
+ if for_image:
36
+ first_part = ''.join(random.choices(chars, k=7))
37
+ second_part = ''.join(random.choices(chars, k=12))
38
+ return f"{first_part}_{second_part}"
39
+ else:
40
+ prefix = ''.join(random.choices(chars, k=3))
41
+ suffix = ''.join(random.choices(chars, k=15))
42
+ return f"{prefix}_{suffix}"
43
+
44
+ def __init__(
45
+ self,
46
+ is_conversation: bool = True,
47
+ max_tokens: int = 2049,
48
+ timeout: int = 30,
49
+ intro: str = None,
50
+ filepath: str = None,
51
+ update_file: bool = True,
52
+ proxies: dict = {},
53
+ history_offset: int = 10250,
54
+ act: str = None,
55
+ model: str = 'gemini-1.5-pro',
56
+ aspect_ratio: str = "1:1"
57
+ ):
58
+ """Initializes the WebSim API client."""
59
+ if model not in self.AVAILABLE_MODELS:
60
+ raise ValueError(f"Invalid model: {model}. Choose from: {self.AVAILABLE_MODELS}")
61
+
62
+ self.headers = {
63
+ 'accept': '*/*',
64
+ 'accept-language': 'en-US,en;q=0.9',
65
+ 'content-type': 'text/plain;charset=UTF-8',
66
+ 'origin': 'https://websim.ai',
67
+ 'user-agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36',
68
+ 'websim-flags;': ''
69
+ }
70
+
71
+ self.session = requests.Session()
72
+ self.session.headers.update(self.headers)
73
+ self.session.proxies.update(proxies)
74
+
75
+ self.is_conversation = is_conversation
76
+ self.max_tokens_to_sample = max_tokens
77
+ self.timeout = timeout
78
+ self.last_response = {}
79
+ self.model = model
80
+ self.aspect_ratio = aspect_ratio
81
+
82
+ self.__available_optimizers = (
83
+ method
84
+ for method in dir(Optimizers)
85
+ if callable(getattr(Optimizers, method)) and not method.startswith("__")
86
+ )
87
+ Conversation.intro = (
88
+ AwesomePrompts().get_act(
89
+ act, raise_not_found=True, default=None, case_insensitive=True
90
+ )
91
+ if act
92
+ else intro or Conversation.intro
93
+ )
94
+
95
+ self.conversation = Conversation(
96
+ is_conversation, self.max_tokens_to_sample, filepath, update_file
97
+ )
98
+ self.conversation.history_offset = history_offset
99
+
100
+ def ask(
101
+ self,
102
+ prompt: str,
103
+ stream: bool = False,
104
+ raw: bool = False,
105
+ optimizer: str = None,
106
+ conversationally: bool = False,
107
+ ) -> Dict[str, Any]:
108
+ conversation_prompt = self.conversation.gen_complete_prompt(prompt)
109
+ if optimizer:
110
+ if optimizer in self.__available_optimizers:
111
+ conversation_prompt = getattr(Optimizers, optimizer)(
112
+ conversation_prompt if conversationally else prompt
113
+ )
114
+ else:
115
+ raise Exception(f"Optimizer is not one of {self.__available_optimizers}")
116
+
117
+ is_image_request = self.model in self.image_models
118
+ project_id = self.generate_project_id(for_image=is_image_request)
119
+
120
+ if is_image_request:
121
+ self.headers['referer'] = 'https://websim.ai/@ISWEARIAMNOTADDICTEDTOPILLOW/ai-image-prompt-generator'
122
+ return self._handle_image_request(project_id, conversation_prompt)
123
+ else:
124
+ self.headers['referer'] = 'https://websim.ai/@ISWEARIAMNOTADDICTEDTOPILLOW/zelos-ai-assistant'
125
+ return self._handle_chat_request(project_id, conversation_prompt)
126
+
127
+ def _handle_image_request(self, project_id: str, prompt: str) -> Dict[str, Any]:
128
+ try:
129
+ data = {
130
+ "project_id": project_id,
131
+ "prompt": prompt,
132
+ "aspect_ratio": self.aspect_ratio
133
+ }
134
+ response = self.session.post(
135
+ self.image_api_endpoint,
136
+ json=data,
137
+ timeout=self.timeout
138
+ )
139
+ response.raise_for_status()
140
+ response_json = response.json()
141
+ image_url = response_json.get("url")
142
+ if image_url:
143
+ self.last_response = {"text": image_url}
144
+ self.conversation.update_chat_history(prompt, image_url)
145
+ return {"text": image_url}
146
+ raise exceptions.FailedToGenerateResponseError("No image URL found in response")
147
+ except requests.RequestException as e:
148
+ raise exceptions.FailedToGenerateResponseError(f"Request failed: {str(e)}")
149
+
150
+ def _handle_chat_request(self, project_id: str, prompt: str) -> Dict[str, Any]:
151
+ max_retries = 3
152
+ retry_count = 0
153
+ last_error = None
154
+
155
+ while retry_count < max_retries:
156
+ try:
157
+ data = {
158
+ "project_id": project_id,
159
+ "messages": [{"role": "user", "content": prompt}]
160
+ }
161
+ response = self.session.post(
162
+ self.chat_api_endpoint,
163
+ json=data,
164
+ timeout=self.timeout
165
+ )
166
+
167
+ if response.status_code == 429:
168
+ last_error = exceptions.FailedToGenerateResponseError(
169
+ f"Rate limit exceeded: {response.text}"
170
+ )
171
+ retry_count += 1
172
+ if retry_count < max_retries:
173
+ continue
174
+ raise last_error
175
+
176
+ response.raise_for_status()
177
+ response_json = response.json()
178
+ content = response_json.get("content", "")
179
+
180
+ self.last_response = {"text": content}
181
+ self.conversation.update_chat_history(prompt, content)
182
+ return {"text": content.strip()}
183
+
184
+ except requests.RequestException as e:
185
+ if "Rate limit exceeded" in str(e) and retry_count < max_retries:
186
+ retry_count += 1
187
+ else:
188
+ raise exceptions.FailedToGenerateResponseError(f"Request failed: {str(e)}")
189
+
190
+ raise last_error or exceptions.FailedToGenerateResponseError("Max retries exceeded")
191
+
192
+ def chat(
193
+ self,
194
+ prompt: str,
195
+ stream: bool = False,
196
+ optimizer: str = None,
197
+ conversationally: bool = False,
198
+ ) -> str:
199
+ return self.get_message(
200
+ self.ask(prompt, False, optimizer=optimizer, conversationally=conversationally)
201
+ )
202
+
203
+ def get_message(self, response: dict) -> str:
204
+ assert isinstance(response, dict), "Response should be of dict data-type only"
205
+ return response["text"]
206
+
207
+ if __name__ == "__main__":
208
+ print("-" * 80)
209
+ print(f"{'Model':<50} {'Status':<10} {'Response'}")
210
+ print("-" * 80)
211
+
212
+ for model in WebSim.AVAILABLE_MODELS:
213
+ try:
214
+ test_ai = WebSim(model=model, timeout=60)
215
+ response = test_ai.chat("Say 'Hello' in one word")
216
+
217
+ if response and len(response.strip()) > 0:
218
+ status = "✓"
219
+ # Clean and truncate response
220
+ clean_text = response.strip().encode('utf-8', errors='ignore').decode('utf-8')
221
+ display_text = clean_text[:50] + "..." if len(clean_text) > 50 else clean_text
222
+ else:
223
+ status = "✗"
224
+ display_text = "Empty or invalid response"
225
+ print(f"\r{model:<50} {status:<10} {display_text}")
226
+ except Exception as e:
227
+ print(f"\r{model:<50} {'✗':<10} {str(e)}")
@@ -169,8 +169,30 @@ class WiseCat(Provider):
169
169
  return response["text"]
170
170
 
171
171
  if __name__ == "__main__":
172
- from rich import print
173
- ai = WiseCat()
174
- response = ai.chat(input(">>> "))
175
- for chunk in response:
176
- print(chunk, end="", flush=True)
172
+ print("-" * 80)
173
+ print(f"{'Model':<50} {'Status':<10} {'Response'}")
174
+ print("-" * 80)
175
+
176
+ # Test all available models
177
+ working = 0
178
+ total = len(WiseCat.AVAILABLE_MODELS)
179
+
180
+ for model in WiseCat.AVAILABLE_MODELS:
181
+ try:
182
+ test_ai = WiseCat(model=model, timeout=60)
183
+ response = test_ai.chat("Say 'Hello' in one word", stream=True)
184
+ response_text = ""
185
+ for chunk in response:
186
+ response_text += chunk
187
+ print(f"\r{model:<50} {'Testing...':<10}", end="", flush=True)
188
+
189
+ if response_text and len(response_text.strip()) > 0:
190
+ status = "✓"
191
+ # Truncate response if too long
192
+ display_text = response_text.strip()[:50] + "..." if len(response_text.strip()) > 50 else response_text.strip()
193
+ else:
194
+ status = "✗"
195
+ display_text = "Empty or invalid response"
196
+ print(f"\r{model:<50} {status:<10} {display_text}")
197
+ except Exception as e:
198
+ print(f"\r{model:<50} {'✗':<10} {str(e)}")