webscout 7.5__py3-none-any.whl → 7.6__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 (118) 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/autocoder_utiles.py +0 -4
  9. webscout/Extra/autocoder/rawdog.py +13 -41
  10. webscout/Extra/gguf.py +652 -428
  11. webscout/Extra/weather.py +178 -156
  12. webscout/Extra/weather_ascii.py +70 -17
  13. webscout/Litlogger/core/logger.py +1 -2
  14. webscout/Litlogger/handlers/file.py +1 -1
  15. webscout/Litlogger/styles/formats.py +0 -2
  16. webscout/Litlogger/utils/detectors.py +0 -1
  17. webscout/Provider/AISEARCH/DeepFind.py +0 -1
  18. webscout/Provider/AISEARCH/ISou.py +1 -1
  19. webscout/Provider/AISEARCH/felo_search.py +0 -1
  20. webscout/Provider/AllenAI.py +24 -9
  21. webscout/Provider/C4ai.py +29 -11
  22. webscout/Provider/ChatGPTGratis.py +24 -56
  23. webscout/Provider/DeepSeek.py +25 -17
  24. webscout/Provider/Deepinfra.py +115 -48
  25. webscout/Provider/Gemini.py +1 -1
  26. webscout/Provider/Glider.py +25 -8
  27. webscout/Provider/HF_space/qwen_qwen2.py +2 -2
  28. webscout/Provider/HeckAI.py +23 -7
  29. webscout/Provider/Jadve.py +20 -5
  30. webscout/Provider/Netwrck.py +42 -19
  31. webscout/Provider/PI.py +4 -2
  32. webscout/Provider/Perplexitylabs.py +26 -6
  33. webscout/Provider/PizzaGPT.py +10 -51
  34. webscout/Provider/TTI/AiForce/async_aiforce.py +4 -37
  35. webscout/Provider/TTI/AiForce/sync_aiforce.py +41 -38
  36. webscout/Provider/TTI/FreeAIPlayground/__init__.py +9 -9
  37. webscout/Provider/TTI/FreeAIPlayground/async_freeaiplayground.py +206 -206
  38. webscout/Provider/TTI/FreeAIPlayground/sync_freeaiplayground.py +192 -192
  39. webscout/Provider/TTI/MagicStudio/__init__.py +2 -0
  40. webscout/Provider/TTI/MagicStudio/async_magicstudio.py +111 -0
  41. webscout/Provider/TTI/MagicStudio/sync_magicstudio.py +109 -0
  42. webscout/Provider/TTI/PollinationsAI/async_pollinations.py +5 -24
  43. webscout/Provider/TTI/PollinationsAI/sync_pollinations.py +2 -22
  44. webscout/Provider/TTI/__init__.py +2 -3
  45. webscout/Provider/TTI/aiarta/async_aiarta.py +14 -14
  46. webscout/Provider/TTI/aiarta/sync_aiarta.py +52 -21
  47. webscout/Provider/TTI/fastflux/__init__.py +22 -0
  48. webscout/Provider/TTI/fastflux/async_fastflux.py +257 -0
  49. webscout/Provider/TTI/fastflux/sync_fastflux.py +247 -0
  50. webscout/Provider/TTS/__init__.py +2 -2
  51. webscout/Provider/TTS/deepgram.py +12 -39
  52. webscout/Provider/TTS/elevenlabs.py +14 -40
  53. webscout/Provider/TTS/gesserit.py +11 -35
  54. webscout/Provider/TTS/murfai.py +13 -39
  55. webscout/Provider/TTS/parler.py +17 -40
  56. webscout/Provider/TTS/speechma.py +180 -0
  57. webscout/Provider/TTS/streamElements.py +17 -44
  58. webscout/Provider/TextPollinationsAI.py +39 -59
  59. webscout/Provider/Venice.py +25 -8
  60. webscout/Provider/WiseCat.py +27 -5
  61. webscout/Provider/Youchat.py +64 -37
  62. webscout/Provider/__init__.py +0 -6
  63. webscout/Provider/akashgpt.py +20 -5
  64. webscout/Provider/flowith.py +20 -5
  65. webscout/Provider/freeaichat.py +32 -45
  66. webscout/Provider/koala.py +20 -5
  67. webscout/Provider/llamatutor.py +1 -1
  68. webscout/Provider/llmchat.py +30 -8
  69. webscout/Provider/multichat.py +65 -9
  70. webscout/Provider/talkai.py +1 -0
  71. webscout/Provider/turboseek.py +3 -0
  72. webscout/Provider/tutorai.py +2 -0
  73. webscout/Provider/typegpt.py +154 -64
  74. webscout/Provider/x0gpt.py +3 -1
  75. webscout/Provider/yep.py +102 -20
  76. webscout/__init__.py +3 -0
  77. webscout/cli.py +4 -40
  78. webscout/conversation.py +1 -10
  79. webscout/litagent/__init__.py +2 -2
  80. webscout/litagent/agent.py +351 -20
  81. webscout/litagent/constants.py +34 -5
  82. webscout/litprinter/__init__.py +0 -3
  83. webscout/models.py +181 -0
  84. webscout/optimizers.py +1 -1
  85. webscout/prompt_manager.py +2 -8
  86. webscout/scout/core/scout.py +1 -4
  87. webscout/scout/core/search_result.py +1 -1
  88. webscout/scout/core/text_utils.py +1 -1
  89. webscout/scout/core.py +2 -5
  90. webscout/scout/element.py +1 -1
  91. webscout/scout/parsers/html_parser.py +1 -1
  92. webscout/scout/utils.py +0 -1
  93. webscout/swiftcli/__init__.py +1 -3
  94. webscout/tempid.py +1 -1
  95. webscout/update_checker.py +1 -3
  96. webscout/version.py +1 -1
  97. webscout/webscout_search_async.py +1 -2
  98. webscout/yep_search.py +297 -297
  99. {webscout-7.5.dist-info → webscout-7.6.dist-info}/LICENSE.md +4 -4
  100. {webscout-7.5.dist-info → webscout-7.6.dist-info}/METADATA +101 -390
  101. {webscout-7.5.dist-info → webscout-7.6.dist-info}/RECORD +104 -110
  102. webscout/Extra/autollama.py +0 -231
  103. webscout/Provider/Amigo.py +0 -274
  104. webscout/Provider/Bing.py +0 -243
  105. webscout/Provider/DiscordRocks.py +0 -253
  106. webscout/Provider/TTI/blackbox/__init__.py +0 -4
  107. webscout/Provider/TTI/blackbox/async_blackbox.py +0 -212
  108. webscout/Provider/TTI/blackbox/sync_blackbox.py +0 -199
  109. webscout/Provider/TTI/deepinfra/__init__.py +0 -4
  110. webscout/Provider/TTI/deepinfra/async_deepinfra.py +0 -227
  111. webscout/Provider/TTI/deepinfra/sync_deepinfra.py +0 -199
  112. webscout/Provider/TTI/imgninza/__init__.py +0 -4
  113. webscout/Provider/TTI/imgninza/async_ninza.py +0 -214
  114. webscout/Provider/TTI/imgninza/sync_ninza.py +0 -209
  115. webscout/Provider/TTS/voicepod.py +0 -117
  116. {webscout-7.5.dist-info → webscout-7.6.dist-info}/WHEEL +0 -0
  117. {webscout-7.5.dist-info → webscout-7.6.dist-info}/entry_points.txt +0 -0
  118. {webscout-7.5.dist-info → webscout-7.6.dist-info}/top_level.txt +0 -0
@@ -25,16 +25,8 @@ from pathlib import Path
25
25
  from typing import AsyncGenerator
26
26
 
27
27
  from webscout.AIbase import AsyncImageProvider
28
- from webscout.Litlogger import Logger, LogFormat
29
28
  from webscout.litagent import LitAgent
30
29
 
31
- # Set up logging with cyberpunk style! 🎨
32
- logger = Logger(
33
- name="AsyncPollinationsAI",
34
- format=LogFormat.MODERN_EMOJI,
35
-
36
- )
37
-
38
30
  # Get a fresh user agent! 🔄
39
31
  agent = LitAgent()
40
32
 
@@ -91,20 +83,13 @@ class AsyncPollinationsAI(AsyncImageProvider):
91
83
  - "any-dark": Dark/gothic style
92
84
  - "flux-pro": Professional quality
93
85
  - "turbo": Fast generation
94
- DEFAULT_MODEL (str): Default model to use ("flux")
86
+
95
87
  """
96
88
 
97
89
  AVAILABLE_MODELS = [
98
90
  "flux",
99
- "flux-realism",
100
- "flux-cablyai",
101
- "flux-anime",
102
- "flux-3d",
103
- "any-dark",
104
- "flux-pro",
105
91
  "turbo"
106
92
  ]
107
- DEFAULT_MODEL = "flux"
108
93
 
109
94
  def __init__(
110
95
  self,
@@ -141,7 +126,7 @@ class AsyncPollinationsAI(AsyncImageProvider):
141
126
  additives: bool = True,
142
127
  width: int = 768,
143
128
  height: int = 768,
144
- model: str = DEFAULT_MODEL,
129
+ model: str = "flux",
145
130
  max_retries: int = 3,
146
131
  retry_delay: int = 5,
147
132
  negative_prompt: Optional[str] = None,
@@ -214,11 +199,10 @@ class AsyncPollinationsAI(AsyncImageProvider):
214
199
  params_str = "&".join(f"{k}={v}" for k, v in base_params.items())
215
200
  url = f"{self.image_gen_endpoint.format(prompt=current_prompt)}?{params_str}"
216
201
 
217
- logger.info(f"Queueing image {_ + 1}/{amount} generation... ⚡")
218
202
  tasks.append(self._generate_single(session, url, max_retries, retry_delay))
219
203
 
220
204
  response = await asyncio.gather(*tasks)
221
- logger.success(f"Successfully generated {amount} images! 🎨")
205
+
222
206
 
223
207
  return response
224
208
 
@@ -237,9 +221,9 @@ class AsyncPollinationsAI(AsyncImageProvider):
237
221
  return await resp.read()
238
222
  except aiohttp.ClientError as e:
239
223
  if attempt == max_retries - 1:
240
- logger.error(f"Failed to generate image: {e} 😢")
224
+
241
225
  raise
242
- logger.warning(f"Attempt {attempt + 1} failed. Retrying in {retry_delay} seconds... 🔄")
226
+
243
227
  await asyncio.sleep(retry_delay)
244
228
 
245
229
  async def save(
@@ -277,7 +261,6 @@ class AsyncPollinationsAI(AsyncImageProvider):
277
261
  save_dir = dir if dir else os.getcwd()
278
262
  if not os.path.exists(save_dir):
279
263
  os.makedirs(save_dir)
280
- logger.info(f"Created directory: {save_dir} 📁")
281
264
 
282
265
  saved_paths = []
283
266
  timestamp = int(time.time())
@@ -295,7 +278,6 @@ class AsyncPollinationsAI(AsyncImageProvider):
295
278
  with open(filepath, "wb") as f:
296
279
  f.write(image_bytes)
297
280
 
298
- logger.success(f"Saved image to: {filepath} 💾")
299
281
  return filepath
300
282
 
301
283
  # Handle both List[bytes] and AsyncGenerator
@@ -306,7 +288,6 @@ class AsyncPollinationsAI(AsyncImageProvider):
306
288
 
307
289
  tasks = [save_single_image(img, i) for i, img in enumerate(image_list)]
308
290
  saved_paths = await asyncio.gather(*tasks)
309
- logger.success(f"Successfully saved all {len(saved_paths)} images! 🎉")
310
291
  return saved_paths
311
292
 
312
293
 
@@ -28,15 +28,8 @@ from requests.exceptions import RequestException
28
28
  from pathlib import Path
29
29
 
30
30
  from webscout.AIbase import ImageProvider
31
- from webscout.Litlogger import Logger, LogFormat
32
31
  from webscout.litagent import LitAgent
33
32
 
34
- # Set up logging with cyberpunk style! 🎨
35
- logger = Logger(
36
- name="PollinationsAI",
37
- format=LogFormat.MODERN_EMOJI,
38
-
39
- )
40
33
 
41
34
  # Get a fresh user agent! 🔄
42
35
  agent = LitAgent()
@@ -83,20 +76,13 @@ class PollinationsAI(ImageProvider):
83
76
  - "any-dark": Dark/gothic style
84
77
  - "flux-pro": Professional quality
85
78
  - "turbo": Fast generation
86
- DEFAULT_MODEL (str): Default model to use ("flux")
87
79
  """
88
80
 
89
81
  AVAILABLE_MODELS = [
90
82
  "flux",
91
- "flux-realism",
92
- "flux-cablyai",
93
- "flux-anime",
94
- "flux-3d",
95
- "any-dark",
96
- "flux-pro",
97
83
  "turbo"
98
84
  ]
99
- DEFAULT_MODEL = "flux"
85
+
100
86
 
101
87
  def __init__(
102
88
  self,
@@ -136,7 +122,7 @@ class PollinationsAI(ImageProvider):
136
122
  additives: bool = True,
137
123
  width: int = 768,
138
124
  height: int = 768,
139
- model: str = DEFAULT_MODEL,
125
+ model: str = "flux",
140
126
  max_retries: int = 3,
141
127
  retry_delay: int = 5,
142
128
  negative_prompt: Optional[str] = None,
@@ -197,17 +183,13 @@ class PollinationsAI(ImageProvider):
197
183
 
198
184
  for attempt in range(max_retries):
199
185
  try:
200
- logger.info(f"Generating image {_ + 1}/{amount} with prompt: {current_prompt[:50]}...")
201
186
  resp = self.session.get(url, timeout=self.timeout)
202
187
  resp.raise_for_status()
203
188
  response.append(resp.content)
204
- logger.success(f"Successfully generated image {_ + 1}/{amount}! 🎨")
205
189
  break
206
190
  except RequestException as e:
207
191
  if attempt == max_retries - 1:
208
- logger.error(f"Failed to generate image after {max_retries} attempts: {e} 😢")
209
192
  raise
210
- logger.warning(f"Attempt {attempt + 1} failed. Retrying in {retry_delay} seconds... 🔄")
211
193
  time.sleep(retry_delay)
212
194
 
213
195
  return response
@@ -246,7 +228,6 @@ class PollinationsAI(ImageProvider):
246
228
  save_dir = dir if dir else os.getcwd()
247
229
  if not os.path.exists(save_dir):
248
230
  os.makedirs(save_dir)
249
- logger.info(f"Created directory: {save_dir} 📁")
250
231
 
251
232
  saved_paths = []
252
233
  timestamp = int(time.time())
@@ -263,7 +244,6 @@ class PollinationsAI(ImageProvider):
263
244
  f.write(image_bytes)
264
245
 
265
246
  saved_paths.append(filepath)
266
- logger.success(f"Saved image to: {filepath} 💾")
267
247
 
268
248
  return saved_paths
269
249
 
@@ -1,11 +1,10 @@
1
1
  from .FreeAIPlayground import *
2
- from .deepinfra import *
3
2
  from .PollinationsAI import *
4
3
  from .AiForce import *
5
- from .blackbox import *
6
4
  from .Nexra import *
7
5
  from .huggingface import *
8
6
  from .artbit import *
9
- from .imgninza import *
10
7
  from .talkai import *
11
8
  from .piclumen import *
9
+ from .MagicStudio import *
10
+ from .fastflux import *
@@ -70,7 +70,7 @@ class AsyncAIArtaImager(AsyncImageProvider):
70
70
  status_check_url = "https://img-gen-prod.ai-arta.com/api/v1/text2image/{record_id}/status"
71
71
 
72
72
  # Available models
73
- model_aliases = {
73
+ AVAILABLE_MODELS = {
74
74
  "flux": "Flux",
75
75
  "medieval": "Medieval",
76
76
  "vincent_van_gogh": "Vincent Van Gogh",
@@ -109,17 +109,17 @@ class AsyncAIArtaImager(AsyncImageProvider):
109
109
  "surrealism": "Surrealism",
110
110
  "neo_traditional": "Neo-traditional",
111
111
  "on_limbs_black": "On limbs black",
112
- "yamers_realistic_xl": "Yamers-realistic-xl",
113
- "pony_xl": "Pony-xl",
114
- "playground_xl": "Playground-xl",
115
- "anything_xl": "Anything-xl",
116
- "flame_design": "Flame design",
117
- "kawaii": "Kawaii",
118
- "cinematic_art": "Cinematic Art",
119
- "professional": "Professional",
120
- "flux_black_ink": "Flux Black Ink"
112
+ # "yamers_realistic_xl": "Yamers-realistic-xl",
113
+ # "pony_xl": "Pony-xl",
114
+ # "playground_xl": "Playground-xl",
115
+ # "anything_xl": "Anything-xl",
116
+ # "flame_design": "Flame design",
117
+ # "kawaii": "Kawaii",
118
+ # "cinematic_art": "Cinematic Art",
119
+ # "professional": "Professional",
120
+ # "flux_black_ink": "Flux Black Ink"
121
121
  }
122
- models = list(model_aliases.keys())
122
+ models = list(AVAILABLE_MODELS.keys())
123
123
 
124
124
  def __init__(self, timeout: int = 60, proxies: dict = None, logging: bool = True):
125
125
  """Initialize your async AIArtaImager provider with custom settings ⚙️
@@ -226,8 +226,8 @@ class AsyncAIArtaImager(AsyncImageProvider):
226
226
 
227
227
  def get_model(self, model_name: str) -> str:
228
228
  """Get actual model name from alias"""
229
- if model_name.lower() in self.model_aliases:
230
- return self.model_aliases[model_name.lower()]
229
+ if model_name.lower() in self.AVAILABLE_MODELS:
230
+ return self.AVAILABLE_MODELS[model_name.lower()]
231
231
  return model_name
232
232
 
233
233
  async def generate(
@@ -261,7 +261,7 @@ class AsyncAIArtaImager(AsyncImageProvider):
261
261
  Args:
262
262
  prompt (str): Your image description
263
263
  amount (int): How many images you want (default: 1)
264
- model (str): Model to use - check model_aliases (default: "flux")
264
+ model (str): Model to use - check AVAILABLE_MODELS (default: "flux")
265
265
  negative_prompt (str): What you don't want in the image
266
266
  guidance_scale (int): Controls how closely the model follows your prompt
267
267
  num_inference_steps (int): More steps = better quality but slower
@@ -56,7 +56,7 @@ class AIArtaImager(ImageProvider):
56
56
  status_check_url = "https://img-gen-prod.ai-arta.com/api/v1/text2image/{record_id}/status"
57
57
 
58
58
  # Available models
59
- model_aliases = {
59
+ AVAILABLE_MODELS = {
60
60
  "flux": "Flux",
61
61
  "medieval": "Medieval",
62
62
  "vincent_van_gogh": "Vincent Van Gogh",
@@ -95,17 +95,17 @@ class AIArtaImager(ImageProvider):
95
95
  "surrealism": "Surrealism",
96
96
  "neo_traditional": "Neo-traditional",
97
97
  "on_limbs_black": "On limbs black",
98
- "yamers_realistic_xl": "Yamers-realistic-xl",
99
- "pony_xl": "Pony-xl",
100
- "playground_xl": "Playground-xl",
101
- "anything_xl": "Anything-xl",
102
- "flame_design": "Flame design",
103
- "kawaii": "Kawaii",
104
- "cinematic_art": "Cinematic Art",
105
- "professional": "Professional",
106
- "flux_black_ink": "Flux Black Ink"
98
+ # "yamers_realistic_xl": "Yamers-realistic-xl",
99
+ # "pony_xl": "Pony-xl",
100
+ # "playground_xl": "Playground-xl",
101
+ # "anything_xl": "Anything-xl",
102
+ # "flame_design": "Flame design",
103
+ # "kawaii": "Kawaii",
104
+ # "cinematic_art": "Cinematic Art",
105
+ # "professional": "Professional",
106
+ # "flux_black_ink": "Flux Black Ink"
107
107
  }
108
- models = list(model_aliases.keys())
108
+ models = list(AVAILABLE_MODELS.keys())
109
109
 
110
110
  def __init__(self, timeout: int = 60, proxies: dict = None, logging: bool = True):
111
111
  """Initialize your AIArtaImager provider with custom settings
@@ -196,8 +196,8 @@ class AIArtaImager(ImageProvider):
196
196
 
197
197
  def get_model(self, model_name: str) -> str:
198
198
  """Get actual model name from alias"""
199
- if model_name.lower() in self.model_aliases:
200
- return self.model_aliases[model_name.lower()]
199
+ if model_name.lower() in self.AVAILABLE_MODELS:
200
+ return self.AVAILABLE_MODELS[model_name.lower()]
201
201
  return model_name
202
202
 
203
203
  def generate(
@@ -230,7 +230,7 @@ class AIArtaImager(ImageProvider):
230
230
  Args:
231
231
  prompt (str): Your image description
232
232
  amount (int): How many images you want (default: 1)
233
- model (str): Model to use - check model_aliases (default: "flux")
233
+ model (str): Model to use - check AVAILABLE_MODELS (default: "flux")
234
234
  negative_prompt (str): What you don't want in the image
235
235
  guidance_scale (int): Controls how closely the model follows your prompt
236
236
  num_inference_steps (int): More steps = better quality but slower
@@ -400,10 +400,41 @@ class AIArtaImager(ImageProvider):
400
400
 
401
401
  if __name__ == "__main__":
402
402
  # Example usage
403
- provider = AIArtaImager()
404
- try:
405
- images = provider.generate("A beautiful sunset over mountains", amount=1)
406
- paths = provider.save(images, dir="generated_images")
407
- print(f"Images saved to: {paths}")
408
- except Exception as e:
409
- print(f"An error occurred: {e}")
403
+ bot = AIArtaImager()
404
+ test_prompt = "A shiny red sports car speeding down a scenic mountain road"
405
+
406
+ print(f"Testing all available models with prompt: '{test_prompt}'")
407
+ print("-" * 50)
408
+
409
+ # Create a directory for test images if it doesn't exist
410
+ test_dir = "model_test_images"
411
+ if not os.path.exists(test_dir):
412
+ os.makedirs(test_dir)
413
+
414
+ for model in bot.AVAILABLE_MODELS:
415
+ print(f"Testing model: {model}")
416
+ try:
417
+ # Generate an image with the current model
418
+ resp = bot.generate(
419
+ prompt=test_prompt,
420
+ amount=1,
421
+ model=model,
422
+ width=768,
423
+ height=768
424
+ )
425
+
426
+ # Save the image with model name as prefix
427
+ saved_paths = bot.save(
428
+ resp,
429
+ name=f"{model}_test",
430
+ dir=test_dir,
431
+ filenames_prefix=f"{model}_"
432
+ )
433
+
434
+ print(f"✓ Success! Saved image: {saved_paths[0]}")
435
+ except Exception as e:
436
+ print(f"✗ Failed with model {model}: {str(e)}")
437
+
438
+ print("-" * 30)
439
+
440
+ print("All model tests completed!")
@@ -0,0 +1,22 @@
1
+ """
2
+ FastFlux Image Generator - Your go-to provider for generating fire images! 🔥
3
+
4
+ Examples:
5
+ >>> # Sync Usage
6
+ >>> from webscout import FastFluxImager
7
+ >>> provider = FastFluxImager()
8
+ >>> images = provider.generate("Cool art")
9
+ >>> paths = provider.save(images)
10
+ >>>
11
+ >>> # Async Usage
12
+ >>> from webscout import AsyncFastFluxImager
13
+ >>> async def example():
14
+ ... provider = AsyncFastFluxImager()
15
+ ... images = await provider.generate("Epic dragon")
16
+ ... paths = await provider.save(images)
17
+ """
18
+
19
+ from .sync_fastflux import FastFluxImager
20
+ from .async_fastflux import AsyncFastFluxImager
21
+
22
+ __all__ = ["FastFluxImager", "AsyncFastFluxImager"]
@@ -0,0 +1,257 @@
1
+ """AsyncFastFluxImager - Generate stunning AI art with FastFlux (async version)! ⚡
2
+
3
+ Examples:
4
+ >>> from webscout import AsyncFastFluxImager
5
+ >>> import asyncio
6
+ >>>
7
+ >>> async def main():
8
+ ... provider = AsyncFastFluxImager()
9
+ ... # Generate a single image
10
+ ... images = await provider.generate("A cool cyberpunk city at night")
11
+ ... paths = await provider.save(images, dir="my_images")
12
+ ... print(f"Saved images to: {paths}")
13
+ ...
14
+ >>> asyncio.run(main())
15
+ """
16
+
17
+ import aiohttp
18
+ import asyncio
19
+ import base64
20
+ import os
21
+ import time
22
+ from typing import List, Optional, Union, AsyncGenerator
23
+ from pathlib import Path
24
+ import aiofiles
25
+
26
+ from webscout.AIbase import AsyncImageProvider
27
+ from webscout.litagent import LitAgent
28
+
29
+
30
+ class AsyncFastFluxImager(AsyncImageProvider):
31
+ """Your go-to async provider for generating fire images with FastFlux! ⚡
32
+
33
+ Examples:
34
+ >>> provider = AsyncFastFluxImager()
35
+ >>>
36
+ >>> # Generate one image with default model
37
+ >>> async def single_image():
38
+ ... image = await provider.generate("A futuristic city")
39
+ ... await provider.save(image, "city.png")
40
+ >>>
41
+ >>> # Generate multiple with specific model
42
+ >>> async def multiple_images():
43
+ ... images = await provider.generate(
44
+ ... prompt="Space station",
45
+ ... amount=3,
46
+ ... model="flux_1_dev",
47
+ ... size="16_9"
48
+ ... )
49
+ ... await provider.save(images, dir="space_pics")
50
+ """
51
+
52
+ AVAILABLE_MODELS = [
53
+ "flux_1_schnell", # Fast generation model (default)
54
+ "flux_1_dev", # Developer model
55
+ "sana_1_6b" # SANA 1.6B model
56
+ ]
57
+
58
+
59
+
60
+ def __init__(self, timeout: int = 60, proxies: dict = None):
61
+ """Initialize your async FastFluxImager provider with custom settings ⚙️
62
+
63
+ Examples:
64
+ >>> provider = AsyncFastFluxImager(timeout=120)
65
+ >>> provider = AsyncFastFluxImager(proxies={"http": "http://proxy:8080"})
66
+
67
+ Args:
68
+ timeout (int): HTTP request timeout in seconds (default: 60)
69
+ proxies (dict, optional): Proxy configuration for requests
70
+ logging (bool): Enable/disable logging (default: True)
71
+ """
72
+ self.api_endpoint = "https://api.fastflux.co/v1/images/generate"
73
+ self.headers = {
74
+ "accept": "application/json, text/plain, */*",
75
+ "content-type": "application/json",
76
+ "origin": "https://fastflux.co",
77
+ "referer": "https://fastflux.co/",
78
+ "user-agent": LitAgent().random()
79
+ }
80
+ self.timeout = timeout
81
+ self.proxies = proxies
82
+ self.prompt: str = "AI-generated image - webscout"
83
+ self.image_extension: str = "png"
84
+
85
+
86
+ async def generate(
87
+ self,
88
+ prompt: str,
89
+ amount: int = 1,
90
+ model: str = "flux_1_schnell",
91
+ size: str = "1_1",
92
+ is_public: bool = False,
93
+ max_retries: int = 3,
94
+ retry_delay: int = 5
95
+ ) -> List[bytes]:
96
+ """Generate some fire images from your prompt asynchronously! ⚡
97
+
98
+ Examples:
99
+ >>> provider = AsyncFastFluxImager()
100
+ >>> async def example():
101
+ ... # Basic usage
102
+ ... images = await provider.generate("Cool art")
103
+ ... # Advanced usage
104
+ ... images = await provider.generate(
105
+ ... prompt="Epic dragon",
106
+ ... amount=2,
107
+ ... model="flux_1_dev",
108
+ ... size="16_9"
109
+ ... )
110
+
111
+ Args:
112
+ prompt (str): Your image description
113
+ amount (int): How many images you want (default: 1)
114
+ model (str): Model to use - check AVAILABLE_MODELS (default: "flux_1_schnell")
115
+ size (str): Image size ratio (default: "1_1")
116
+ is_public (bool): Whether to make the image public (default: False)
117
+ max_retries (int): Max retry attempts if something fails (default: 3)
118
+ retry_delay (int): Seconds to wait between retries (default: 5)
119
+
120
+ Returns:
121
+ List[bytes]: Your generated images
122
+
123
+ Raises:
124
+ ValueError: If the inputs ain't valid
125
+ aiohttp.ClientError: If the API calls fail after retries
126
+ """
127
+ if not prompt:
128
+ raise ValueError("Yo fam, the prompt can't be empty! 🤔")
129
+ if not isinstance(amount, int) or amount < 1:
130
+ raise ValueError("Amount needs to be a positive number! 📈")
131
+ if model not in self.AVAILABLE_MODELS:
132
+ raise ValueError(f"Model must be one of {self.AVAILABLE_MODELS}! 🎯")
133
+ if size not in self.AVAILABLE_SIZES:
134
+ raise ValueError(f"Size must be one of {self.AVAILABLE_SIZES}! 📏")
135
+
136
+ self.prompt = prompt
137
+ response = []
138
+
139
+ # Prepare payload
140
+ payload = {
141
+ "prompt": prompt,
142
+ "model": model,
143
+ "size": size,
144
+ "isPublic": is_public
145
+ }
146
+
147
+
148
+ async with aiohttp.ClientSession(headers=self.headers) as session:
149
+ for i in range(amount):
150
+ for attempt in range(max_retries):
151
+ try:
152
+ async with session.post(
153
+ self.api_endpoint,
154
+ json=payload,
155
+ timeout=self.timeout,
156
+ proxy=self.proxies.get('http') if self.proxies else None
157
+ ) as resp:
158
+ resp.raise_for_status()
159
+ result = await resp.json()
160
+
161
+ if result and 'result' in result:
162
+ # Get base64 data and remove header
163
+ image_data = result['result']
164
+ base64_data = image_data.split(',')[1]
165
+
166
+ # Decode base64 data
167
+ image_bytes = base64.b64decode(base64_data)
168
+ response.append(image_bytes)
169
+ break
170
+ else:
171
+ raise aiohttp.ClientError("Invalid response format")
172
+
173
+ except aiohttp.ClientError as e:
174
+ if attempt == max_retries - 1:
175
+ raise aiohttp.ClientError(f"Failed to generate image after {max_retries} attempts: {e}")
176
+ await asyncio.sleep(retry_delay)
177
+
178
+ return response
179
+
180
+ async def save(
181
+ self,
182
+ response: Union[AsyncGenerator[bytes, None], List[bytes]],
183
+ name: Optional[str] = None,
184
+ dir: Optional[Union[str, Path]] = None,
185
+ filenames_prefix: str = "",
186
+ ) -> List[str]:
187
+ """Save your fire generated images asynchronously! 💾
188
+
189
+ Examples:
190
+ >>> provider = AsyncFastFluxImager()
191
+ >>> async def example():
192
+ ... images = await provider.generate("Cool art")
193
+ ... # Save with default settings
194
+ ... paths = await provider.save(images)
195
+ ... # Save with custom name and directory
196
+ ... paths = await provider.save(
197
+ ... images,
198
+ ... name="my_art",
199
+ ... dir="my_images",
200
+ ... filenames_prefix="test_"
201
+ ... )
202
+
203
+ Args:
204
+ response (Union[AsyncGenerator[bytes, None], List[bytes]]): Your generated images
205
+ name (Optional[str]): Custom name for your images
206
+ dir (Optional[Union[str, Path]]): Where to save the images (default: current directory)
207
+ filenames_prefix (str): Prefix for your image files
208
+
209
+ Returns:
210
+ List[str]: Paths to your saved images
211
+ """
212
+ save_dir = dir if dir else os.getcwd()
213
+ if not os.path.exists(save_dir):
214
+ os.makedirs(save_dir)
215
+
216
+
217
+ name = self.prompt if name is None else name
218
+
219
+ # Clean up name for filename use
220
+ safe_name = "".join(c if c.isalnum() or c in "_-" else "_" for c in name)
221
+ safe_name = safe_name[:50] # Truncate if too long
222
+
223
+ # Handle both List[bytes] and AsyncGenerator
224
+ if isinstance(response, list):
225
+ image_list = response
226
+ else:
227
+ image_list = [chunk async for chunk in response]
228
+
229
+
230
+ async def save_single_image(image_bytes: bytes, index: int) -> str:
231
+ filename = f"{filenames_prefix}{safe_name}_{index}.{self.image_extension}"
232
+ filepath = os.path.join(save_dir, filename)
233
+
234
+ async with aiofiles.open(filepath, "wb") as f:
235
+ await f.write(image_bytes)
236
+
237
+ return filename
238
+
239
+ tasks = [save_single_image(img, i) for i, img in enumerate(image_list)]
240
+ saved_paths = await asyncio.gather(*tasks)
241
+
242
+
243
+ return saved_paths
244
+
245
+
246
+ if __name__ == "__main__":
247
+ # Example usage
248
+ async def main():
249
+ provider = AsyncFastFluxImager()
250
+ try:
251
+ images = await provider.generate("A cyberpunk city at night with neon lights", amount=1)
252
+ paths = await provider.save(images, dir="generated_images")
253
+ print(f"Successfully saved images to: {paths}")
254
+ except Exception as e:
255
+ print(f"Oops, something went wrong: {e}")
256
+
257
+ asyncio.run(main())