webscout 6.3__py3-none-any.whl → 6.4__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 (85) hide show
  1. webscout/AIauto.py +191 -176
  2. webscout/AIbase.py +0 -197
  3. webscout/AIutel.py +488 -1130
  4. webscout/Bing_search.py +250 -153
  5. webscout/DWEBS.py +151 -19
  6. webscout/Extra/__init__.py +2 -1
  7. webscout/Extra/autocoder/__init__.py +9 -0
  8. webscout/Extra/autocoder/autocoder_utiles.py +121 -0
  9. webscout/Extra/autocoder/rawdog.py +681 -0
  10. webscout/Extra/autollama.py +246 -195
  11. webscout/Extra/gguf.py +441 -416
  12. webscout/LLM.py +206 -43
  13. webscout/Litlogger/__init__.py +681 -0
  14. webscout/Provider/DARKAI.py +1 -1
  15. webscout/Provider/EDITEE.py +1 -1
  16. webscout/Provider/NinjaChat.py +1 -1
  17. webscout/Provider/PI.py +221 -207
  18. webscout/Provider/Perplexity.py +598 -598
  19. webscout/Provider/RoboCoders.py +206 -0
  20. webscout/Provider/TTI/AiForce/__init__.py +22 -0
  21. webscout/Provider/TTI/AiForce/async_aiforce.py +257 -0
  22. webscout/Provider/TTI/AiForce/sync_aiforce.py +242 -0
  23. webscout/Provider/TTI/Nexra/__init__.py +22 -0
  24. webscout/Provider/TTI/Nexra/async_nexra.py +286 -0
  25. webscout/Provider/TTI/Nexra/sync_nexra.py +258 -0
  26. webscout/Provider/TTI/PollinationsAI/__init__.py +23 -0
  27. webscout/Provider/TTI/PollinationsAI/async_pollinations.py +330 -0
  28. webscout/Provider/TTI/PollinationsAI/sync_pollinations.py +285 -0
  29. webscout/Provider/TTI/__init__.py +2 -4
  30. webscout/Provider/TTI/artbit/__init__.py +22 -0
  31. webscout/Provider/TTI/artbit/async_artbit.py +184 -0
  32. webscout/Provider/TTI/artbit/sync_artbit.py +176 -0
  33. webscout/Provider/TTI/blackbox/__init__.py +4 -0
  34. webscout/Provider/TTI/blackbox/async_blackbox.py +212 -0
  35. webscout/Provider/TTI/{blackboximage.py → blackbox/sync_blackbox.py} +199 -153
  36. webscout/Provider/TTI/deepinfra/__init__.py +4 -0
  37. webscout/Provider/TTI/deepinfra/async_deepinfra.py +227 -0
  38. webscout/Provider/TTI/deepinfra/sync_deepinfra.py +199 -0
  39. webscout/Provider/TTI/huggingface/__init__.py +22 -0
  40. webscout/Provider/TTI/huggingface/async_huggingface.py +199 -0
  41. webscout/Provider/TTI/huggingface/sync_huggingface.py +195 -0
  42. webscout/Provider/TTI/imgninza/__init__.py +4 -0
  43. webscout/Provider/TTI/imgninza/async_ninza.py +214 -0
  44. webscout/Provider/TTI/{imgninza.py → imgninza/sync_ninza.py} +209 -136
  45. webscout/Provider/TTI/talkai/__init__.py +4 -0
  46. webscout/Provider/TTI/talkai/async_talkai.py +229 -0
  47. webscout/Provider/TTI/talkai/sync_talkai.py +207 -0
  48. webscout/Provider/__init__.py +146 -139
  49. webscout/Provider/askmyai.py +2 -2
  50. webscout/Provider/cerebras.py +227 -219
  51. webscout/Provider/llama3mitril.py +0 -1
  52. webscout/Provider/mhystical.py +176 -0
  53. webscout/Provider/perplexitylabs.py +265 -0
  54. webscout/Provider/twitterclone.py +251 -245
  55. webscout/Provider/typegpt.py +359 -0
  56. webscout/__init__.py +28 -23
  57. webscout/__main__.py +5 -5
  58. webscout/cli.py +252 -280
  59. webscout/conversation.py +227 -0
  60. webscout/exceptions.py +161 -29
  61. webscout/litagent/__init__.py +172 -0
  62. webscout/litprinter/__init__.py +831 -0
  63. webscout/optimizers.py +270 -0
  64. webscout/prompt_manager.py +279 -0
  65. webscout/swiftcli/__init__.py +810 -0
  66. webscout/transcriber.py +479 -551
  67. webscout/update_checker.py +125 -0
  68. webscout/version.py +1 -1
  69. {webscout-6.3.dist-info → webscout-6.4.dist-info}/METADATA +26 -45
  70. {webscout-6.3.dist-info → webscout-6.4.dist-info}/RECORD +75 -45
  71. webscout/Provider/TTI/AIuncensoredimage.py +0 -103
  72. webscout/Provider/TTI/Nexra.py +0 -120
  73. webscout/Provider/TTI/PollinationsAI.py +0 -138
  74. webscout/Provider/TTI/WebSimAI.py +0 -142
  75. webscout/Provider/TTI/aiforce.py +0 -160
  76. webscout/Provider/TTI/artbit.py +0 -141
  77. webscout/Provider/TTI/deepinfra.py +0 -148
  78. webscout/Provider/TTI/huggingface.py +0 -155
  79. webscout/Provider/TTI/talkai.py +0 -116
  80. webscout/models.py +0 -23
  81. /webscout/{g4f.py → gpt4free.py} +0 -0
  82. {webscout-6.3.dist-info → webscout-6.4.dist-info}/LICENSE.md +0 -0
  83. {webscout-6.3.dist-info → webscout-6.4.dist-info}/WHEEL +0 -0
  84. {webscout-6.3.dist-info → webscout-6.4.dist-info}/entry_points.txt +0 -0
  85. {webscout-6.3.dist-info → webscout-6.4.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,195 @@
1
+ """
2
+ HFimager - Your go-to provider for generating fire images with HuggingFace! 🔥
3
+
4
+ Examples:
5
+ >>> from webscout import HFimager
6
+ >>>
7
+ >>> # Initialize with your API key
8
+ >>> provider = HFimager(api_token="your-hf-token")
9
+ >>>
10
+ >>> # Generate a single image
11
+ >>> images = provider.generate("A shiny red sports car", model="stabilityai/stable-diffusion-xl-base-1.0")
12
+ >>> paths = provider.save(images)
13
+ >>>
14
+ >>> # Generate multiple images with parameters
15
+ >>> images = provider.generate(
16
+ ... prompt="Epic dragon in cyberpunk city",
17
+ ... amount=3,
18
+ ... model="runwayml/stable-diffusion-v1-5",
19
+ ... guidance_scale=7.5,
20
+ ... negative_prompt="blurry, bad quality",
21
+ ... num_inference_steps=50,
22
+ ... width=768,
23
+ ... height=768
24
+ ... )
25
+ >>> paths = provider.save(images, name="dragon", dir="outputs")
26
+ """
27
+
28
+ import os
29
+ import requests
30
+ import io
31
+ from PIL import Image
32
+ from typing import Any, List, Optional, Dict
33
+ from webscout.AIbase import ImageProvider
34
+ from webscout.Litlogger import LitLogger, LogFormat, ColorScheme
35
+ from webscout.litagent import LitAgent
36
+
37
+ # Initialize our fire logger and agent 🔥
38
+ logger = LitLogger(
39
+ "HuggingFace",
40
+ format=LogFormat.MODERN_EMOJI,
41
+ color_scheme=ColorScheme.CYBERPUNK
42
+ )
43
+ agent = LitAgent()
44
+
45
+ class HFimager(ImageProvider):
46
+ """Your go-to provider for generating fire images with HuggingFace! 🔥"""
47
+
48
+ def __init__(
49
+ self,
50
+ api_token: str = None,
51
+ timeout: int = 60,
52
+ proxies: dict = {},
53
+ logging: bool = True
54
+ ):
55
+ """Initialize your HuggingFace provider with custom settings! ⚙️
56
+
57
+ Args:
58
+ api_token (str, optional): HuggingFace API token. Uses env var "HUGGINGFACE_API_TOKEN" if None
59
+ timeout (int): Request timeout in seconds (default: 60)
60
+ proxies (dict): Proxy settings for requests (default: {})
61
+ logging (bool): Enable fire logging (default: True)
62
+ """
63
+ self.base_url = "https://api-inference.huggingface.co/models/"
64
+ self.api_token = api_token or os.environ["HUGGINGFACE_API_TOKEN"]
65
+ self.headers = {
66
+ "Authorization": f"Bearer {self.api_token}",
67
+ "User-Agent": agent.random(),
68
+ "Accept": "application/json"
69
+ }
70
+ self.session = requests.Session()
71
+ self.session.headers.update(self.headers)
72
+ self.session.proxies.update(proxies)
73
+ self.timeout = timeout
74
+ self.prompt: str = "AI-generated image - webscout"
75
+ self.image_extension: str = "jpg"
76
+ self.logging = logging
77
+ if self.logging:
78
+ logger.info("HuggingFace provider initialized! 🚀")
79
+
80
+ def generate(
81
+ self,
82
+ prompt: str,
83
+ amount: int = 1,
84
+ model: str = "stabilityai/stable-diffusion-xl-base-1.0",
85
+ guidance_scale: Optional[float] = None,
86
+ negative_prompt: Optional[str] = None,
87
+ num_inference_steps: Optional[int] = None,
88
+ width: Optional[int] = None,
89
+ height: Optional[int] = None,
90
+ scheduler: Optional[str] = None,
91
+ seed: Optional[int] = None,
92
+ ) -> List[bytes]:
93
+ """Generate some fire images! 🎨
94
+
95
+ Args:
96
+ prompt (str): Your lit image description
97
+ amount (int): How many images to generate (default: 1)
98
+ model (str): Which model to use (default: "stabilityai/stable-diffusion-xl-base-1.0")
99
+ guidance_scale (float, optional): Control how much to follow your prompt
100
+ negative_prompt (str, optional): What you don't want in the image
101
+ num_inference_steps (int, optional): More steps = better quality but slower
102
+ width (int, optional): Image width
103
+ height (int, optional): Image height
104
+ scheduler (str, optional): Which scheduler to use
105
+ seed (int, optional): Random seed for reproducibility
106
+
107
+ Returns:
108
+ List[bytes]: Your generated images as bytes
109
+ """
110
+ assert bool(prompt), "Yo fam, prompt can't be empty! 🚫"
111
+ assert isinstance(amount, int), f"Amount gotta be an integer, not {type(amount)} 🤔"
112
+ assert amount > 0, "Amount gotta be greater than 0! 📈"
113
+
114
+ self.prompt = prompt
115
+ response = []
116
+ if self.logging:
117
+ logger.info(f"Generating {amount} images with {model}... 🎨")
118
+
119
+ for _ in range(amount):
120
+ url = self.base_url + model
121
+ payload: Dict[str, Any] = {"inputs": prompt}
122
+ parameters = {}
123
+
124
+ if guidance_scale is not None:
125
+ parameters["guidance_scale"] = guidance_scale
126
+ if negative_prompt is not None:
127
+ parameters["negative_prompt"] = negative_prompt
128
+ if num_inference_steps is not None:
129
+ parameters["num_inference_steps"] = num_inference_steps
130
+ if width is not None and height is not None:
131
+ parameters["target_size"] = {"width": width, "height": height}
132
+ if scheduler is not None:
133
+ parameters["scheduler"] = scheduler
134
+ if seed is not None:
135
+ parameters["seed"] = seed
136
+
137
+ if parameters:
138
+ payload["parameters"] = parameters
139
+
140
+ try:
141
+ resp = self.session.post(url, headers=self.headers, json=payload, timeout=self.timeout)
142
+ resp.raise_for_status()
143
+ response.append(resp.content)
144
+ if self.logging:
145
+ logger.success("Image generated successfully! 🎉")
146
+ except requests.RequestException as e:
147
+ if self.logging:
148
+ logger.error(f"Failed to generate image: {e} 😢")
149
+ raise
150
+
151
+ return response
152
+
153
+ def save(
154
+ self,
155
+ response: List[bytes],
156
+ name: str = None,
157
+ dir: str = os.getcwd(),
158
+ filenames_prefix: str = "",
159
+ ) -> List[str]:
160
+ """Save your fire images! 💾
161
+
162
+ Args:
163
+ response (List[bytes]): Your generated images
164
+ name (str, optional): Custom name (default: uses prompt)
165
+ dir (str, optional): Where to save (default: current directory)
166
+ filenames_prefix (str, optional): Add prefix to filenames
167
+
168
+ Returns:
169
+ List[str]: Where your images were saved
170
+ """
171
+ assert isinstance(response, list), f"Response gotta be a list, not {type(response)} 🤔"
172
+ name = self.prompt if name is None else name
173
+
174
+ filenames = []
175
+ count = 0
176
+ if self.logging:
177
+ logger.info(f"Saving {len(response)} images... 💾")
178
+
179
+ for image_bytes in response:
180
+ def complete_path():
181
+ count_value = "" if count == 0 else f"_{count}"
182
+ return os.path.join(dir, name + count_value + "." + self.image_extension)
183
+
184
+ while os.path.isfile(complete_path()):
185
+ count += 1
186
+
187
+ absolute_path_to_file = complete_path()
188
+ filenames.append(filenames_prefix + os.path.split(absolute_path_to_file)[1])
189
+
190
+ with open(absolute_path_to_file, "wb") as fh:
191
+ fh.write(image_bytes)
192
+
193
+ if self.logging:
194
+ logger.success(f"Images saved successfully! Check {dir} 🎉")
195
+ return filenames
@@ -0,0 +1,4 @@
1
+ from .sync_ninza import NinjaImager
2
+ from .async_ninza import AsyncNinjaImager
3
+
4
+ __all__ = ["NinjaImager", "AsyncNinjaImager"]
@@ -0,0 +1,214 @@
1
+ import aiohttp
2
+ import asyncio
3
+ import json
4
+ import os
5
+ from typing import List, Dict, Optional, Union, AsyncGenerator
6
+ import aiofiles
7
+
8
+ from webscout.AIbase import AsyncImageProvider
9
+ from webscout import exceptions
10
+ from webscout.litagent import agent # Import our fire user agent generator 🔥
11
+ from webscout.Litlogger import LitLogger # For that cyberpunk logging swag ⚡
12
+
13
+ # Initialize our fire logger 🚀
14
+ logger = LitLogger("AsyncNinjaImager", "MODERN_EMOJI")
15
+
16
+ class AsyncNinjaImager(AsyncImageProvider):
17
+ """
18
+ Async image provider for NinjaChat.ai - Your go-to for fire AI art! 🎨
19
+
20
+ >>> # Generate some fire art asynchronously! 🔥
21
+ >>> async def generate_art():
22
+ ... imager = AsyncNinjaImager(logging=True)
23
+ ... images = await imager.generate("Epic dragon breathing fire", amount=2)
24
+ ... paths = await imager.save(images)
25
+ ... print(paths)
26
+ >>> asyncio.run(generate_art())
27
+ ['epic_dragon_0.png', 'epic_dragon_1.png']
28
+
29
+ >>> # Turn off logging for stealth mode 🥷
30
+ >>> async def stealth_art():
31
+ ... quiet_imager = AsyncNinjaImager(logging=False)
32
+ ... images = await quiet_imager.generate("Cyberpunk city at night")
33
+ ... paths = await quiet_imager.save(images)
34
+ >>> asyncio.run(stealth_art())
35
+ """
36
+
37
+ AVAILABLE_MODELS = {
38
+ "stable-diffusion": "https://www.ninjachat.ai/api/image-generator",
39
+ "flux-dev": "https://www.ninjachat.ai/api/flux-image-generator",
40
+ }
41
+
42
+ def __init__(self, timeout: int = 60, proxies: dict = {}, logging: bool = True):
43
+ """Initialize your async NinjaChatImager with custom settings! ⚙️
44
+
45
+ Args:
46
+ timeout (int): Request timeout in seconds (default: 60)
47
+ proxies (dict): Proxy settings for requests (default: {})
48
+ logging (bool): Enable fire logging (default: True)
49
+ """
50
+ self.headers = {
51
+ "Accept": "*/*",
52
+ "Accept-Encoding": "gzip, deflate, br, zstd",
53
+ "Accept-Language": "en-US,en;q=0.9,en-IN;q=0.8",
54
+ "Content-Type": "application/json",
55
+ "DNT": "1",
56
+ "Origin": "https://www.ninjachat.ai",
57
+ "Priority": "u=1, i",
58
+ "Referer": "https://www.ninjachat.ai/image-generation",
59
+ "Sec-CH-UA": '"Microsoft Edge";v="129", "Not=A?Brand";v="8", "Chromium";v="129"',
60
+ "Sec-CH-UA-Mobile": "?0",
61
+ "Sec-CH-UA-Platform": '"Windows"',
62
+ "Sec-Fetch-Dest": "empty",
63
+ "Sec-Fetch-Mode": "cors",
64
+ "Sec-Fetch-Site": "same-origin",
65
+ "User-Agent": agent.random() # Using our fire random agent! 🔥
66
+ }
67
+ self.timeout = timeout
68
+ self.proxies = proxies
69
+ self.prompt = "AI-generated image - webscout"
70
+ self.image_extension = "png"
71
+ self.logging = logging
72
+ if self.logging:
73
+ logger.info("AsyncNinjaImager initialized! Ready to create some fire art! 🚀")
74
+
75
+ async def generate(
76
+ self, prompt: str, amount: int = 1, model: str = "flux-dev"
77
+ ) -> List[bytes]:
78
+ """Generate some fire images from your prompt! 🎨
79
+
80
+ Args:
81
+ prompt (str): Your creative prompt
82
+ amount (int): How many images to generate
83
+ model (str): Which model to use (default: flux-dev)
84
+
85
+ Returns:
86
+ List[bytes]: Your generated images as bytes
87
+ """
88
+ assert bool(prompt), "Prompt cannot be null"
89
+ assert isinstance(amount, int) and amount > 0, "Amount should be a positive integer"
90
+
91
+ if model not in self.AVAILABLE_MODELS:
92
+ raise exceptions.ModelNotFoundError(
93
+ f"Model '{model}' not found. Available models: {', '.join(self.AVAILABLE_MODELS)}"
94
+ )
95
+
96
+ self.prompt = prompt
97
+ url = self.AVAILABLE_MODELS[model]
98
+
99
+ payload = {
100
+ "prompt": prompt,
101
+ "model": model if model == "flux-dev" else "stable-diffusion",
102
+ "negativePrompt": "",
103
+ "cfg": 7,
104
+ "aspectRatio": "1:1",
105
+ "outputFormat": self.image_extension,
106
+ "numOutputs": amount,
107
+ "outputQuality": 90
108
+ }
109
+
110
+ if self.logging:
111
+ logger.info(f"Generating {amount} images with {model}... 🎨")
112
+
113
+ response = []
114
+ async with aiohttp.ClientSession(headers=self.headers) as session:
115
+ try:
116
+ async with session.post(url, json=payload, timeout=self.timeout) as resp:
117
+ if resp.status != 200:
118
+ if self.logging:
119
+ logger.error(f"Request failed with status {resp.status} 😢")
120
+ raise exceptions.FailedToGenerateResponseError(
121
+ f"Request failed with status code: {resp.status}, {await resp.text()}"
122
+ )
123
+
124
+ data = await resp.json()
125
+
126
+ if 'output' not in data:
127
+ if self.logging:
128
+ logger.error("Invalid API response format 😢")
129
+ raise exceptions.InvalidResponseError("Invalid API response format: 'output' key missing.")
130
+
131
+ for img_url in data['output']:
132
+ async with session.get(img_url) as img_resp:
133
+ img_resp.raise_for_status()
134
+ response.append(await img_resp.read())
135
+ if self.logging:
136
+ logger.success(f"Generated image {len(response)}/{amount}! 🎨")
137
+
138
+ except aiohttp.ClientError as e:
139
+ if self.logging:
140
+ logger.error(f"Connection error: {e} 😢")
141
+ raise exceptions.APIConnectionError(f"An error occurred during the request: {e}")
142
+ except json.JSONDecodeError as e:
143
+ if self.logging:
144
+ logger.error(f"Failed to parse response: {e} 😢")
145
+ raise exceptions.InvalidResponseError(f"Failed to parse JSON response: {e}")
146
+
147
+ if self.logging:
148
+ logger.success("All images generated successfully! 🎉")
149
+ return response
150
+
151
+ async def save(
152
+ self,
153
+ response: Union[List[bytes], AsyncGenerator[bytes, None]],
154
+ name: str = None,
155
+ dir: str = os.getcwd(),
156
+ filenames_prefix: str = "",
157
+ ) -> List[str]:
158
+ """Save your fire images! 💾
159
+
160
+ Args:
161
+ response (Union[List[bytes], AsyncGenerator[bytes, None]]): Image data
162
+ name (str, optional): Base name for saved files
163
+ dir (str, optional): Where to save the images
164
+ filenames_prefix (str, optional): Prefix for filenames
165
+
166
+ Returns:
167
+ List[str]: List of saved filenames
168
+ """
169
+ if not os.path.exists(dir):
170
+ os.makedirs(dir)
171
+ if self.logging:
172
+ logger.info(f"Created directory: {dir} 📁")
173
+
174
+ name = self.prompt if name is None else name
175
+ saved_paths = []
176
+
177
+ async def save_single_image(image_bytes: bytes, index: int) -> str:
178
+ filename = f"{filenames_prefix}{name}_{index}.{self.image_extension}"
179
+ filepath = os.path.join(dir, filename)
180
+
181
+ async with aiofiles.open(filepath, "wb") as f:
182
+ await f.write(image_bytes)
183
+
184
+ if self.logging:
185
+ logger.success(f"Saved image to: {filepath} 💾")
186
+ return filename
187
+
188
+ if isinstance(response, list):
189
+ image_list = response
190
+ else:
191
+ image_list = [chunk async for chunk in response]
192
+
193
+ if self.logging:
194
+ logger.info(f"Saving {len(image_list)} images... 💾")
195
+
196
+ tasks = [save_single_image(img, i) for i, img in enumerate(image_list)]
197
+ saved_paths = await asyncio.gather(*tasks)
198
+
199
+ if self.logging:
200
+ logger.success(f"All images saved successfully! Check {dir} 🎉")
201
+ return saved_paths
202
+
203
+
204
+ if __name__ == "__main__":
205
+ async def main():
206
+ bot = AsyncNinjaImager()
207
+ try:
208
+ resp = await bot.generate("A shiny red sports car speeding down a scenic mountain road", 1)
209
+ paths = await bot.save(resp)
210
+ print(paths)
211
+ except Exception as e:
212
+ print(f"An error occurred: {e}")
213
+
214
+ asyncio.run(main())