webscout 8.2.2__py3-none-any.whl → 8.2.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.
- webscout/AIauto.py +112 -22
- webscout/AIbase.py +144 -7
- webscout/AIutel.py +249 -131
- webscout/Bard.py +579 -206
- webscout/DWEBS.py +78 -35
- webscout/__init__.py +0 -1
- webscout/cli.py +256 -0
- webscout/conversation.py +307 -436
- webscout/exceptions.py +23 -0
- webscout/prompt_manager.py +56 -42
- webscout/version.py +1 -1
- webscout/webscout_search.py +65 -47
- webscout/webscout_search_async.py +81 -126
- webscout/yep_search.py +93 -43
- {webscout-8.2.2.dist-info → webscout-8.2.7.dist-info}/METADATA +172 -52
- webscout-8.2.7.dist-info/RECORD +26 -0
- {webscout-8.2.2.dist-info → webscout-8.2.7.dist-info}/WHEEL +1 -1
- webscout-8.2.7.dist-info/entry_points.txt +3 -0
- webscout-8.2.7.dist-info/top_level.txt +1 -0
- inferno/__init__.py +0 -6
- inferno/__main__.py +0 -9
- inferno/cli.py +0 -6
- webscout/Extra/GitToolkit/__init__.py +0 -10
- webscout/Extra/GitToolkit/gitapi/__init__.py +0 -12
- webscout/Extra/GitToolkit/gitapi/repository.py +0 -195
- webscout/Extra/GitToolkit/gitapi/user.py +0 -96
- webscout/Extra/GitToolkit/gitapi/utils.py +0 -62
- webscout/Extra/YTToolkit/YTdownloader.py +0 -957
- webscout/Extra/YTToolkit/__init__.py +0 -3
- webscout/Extra/YTToolkit/transcriber.py +0 -476
- webscout/Extra/YTToolkit/ytapi/__init__.py +0 -6
- webscout/Extra/YTToolkit/ytapi/channel.py +0 -307
- webscout/Extra/YTToolkit/ytapi/errors.py +0 -13
- webscout/Extra/YTToolkit/ytapi/extras.py +0 -45
- webscout/Extra/YTToolkit/ytapi/https.py +0 -88
- webscout/Extra/YTToolkit/ytapi/patterns.py +0 -61
- webscout/Extra/YTToolkit/ytapi/playlist.py +0 -59
- webscout/Extra/YTToolkit/ytapi/pool.py +0 -8
- webscout/Extra/YTToolkit/ytapi/query.py +0 -40
- webscout/Extra/YTToolkit/ytapi/stream.py +0 -63
- webscout/Extra/YTToolkit/ytapi/utils.py +0 -62
- webscout/Extra/YTToolkit/ytapi/video.py +0 -232
- webscout/Extra/__init__.py +0 -7
- webscout/Extra/autocoder/__init__.py +0 -9
- webscout/Extra/autocoder/autocoder.py +0 -849
- webscout/Extra/autocoder/autocoder_utiles.py +0 -332
- webscout/Extra/gguf.py +0 -682
- webscout/Extra/tempmail/__init__.py +0 -28
- webscout/Extra/tempmail/async_utils.py +0 -141
- webscout/Extra/tempmail/base.py +0 -161
- webscout/Extra/tempmail/cli.py +0 -187
- webscout/Extra/tempmail/emailnator.py +0 -84
- webscout/Extra/tempmail/mail_tm.py +0 -361
- webscout/Extra/tempmail/temp_mail_io.py +0 -292
- webscout/Extra/weather.py +0 -194
- webscout/Extra/weather_ascii.py +0 -76
- webscout/LLM.py +0 -442
- webscout/Litlogger/__init__.py +0 -67
- webscout/Litlogger/core/__init__.py +0 -6
- webscout/Litlogger/core/level.py +0 -23
- webscout/Litlogger/core/logger.py +0 -165
- webscout/Litlogger/handlers/__init__.py +0 -12
- webscout/Litlogger/handlers/console.py +0 -33
- webscout/Litlogger/handlers/file.py +0 -143
- webscout/Litlogger/handlers/network.py +0 -173
- webscout/Litlogger/styles/__init__.py +0 -7
- webscout/Litlogger/styles/colors.py +0 -249
- webscout/Litlogger/styles/formats.py +0 -458
- webscout/Litlogger/styles/text.py +0 -87
- webscout/Litlogger/utils/__init__.py +0 -6
- webscout/Litlogger/utils/detectors.py +0 -153
- webscout/Litlogger/utils/formatters.py +0 -200
- webscout/Local/__init__.py +0 -12
- webscout/Local/__main__.py +0 -9
- webscout/Local/api.py +0 -576
- webscout/Local/cli.py +0 -516
- webscout/Local/config.py +0 -75
- webscout/Local/llm.py +0 -287
- webscout/Local/model_manager.py +0 -253
- webscout/Local/server.py +0 -721
- webscout/Local/utils.py +0 -93
- webscout/Provider/AI21.py +0 -177
- webscout/Provider/AISEARCH/DeepFind.py +0 -250
- webscout/Provider/AISEARCH/ISou.py +0 -256
- webscout/Provider/AISEARCH/Perplexity.py +0 -359
- webscout/Provider/AISEARCH/__init__.py +0 -10
- webscout/Provider/AISEARCH/felo_search.py +0 -228
- webscout/Provider/AISEARCH/genspark_search.py +0 -208
- webscout/Provider/AISEARCH/hika_search.py +0 -194
- webscout/Provider/AISEARCH/iask_search.py +0 -436
- webscout/Provider/AISEARCH/monica_search.py +0 -246
- webscout/Provider/AISEARCH/scira_search.py +0 -324
- webscout/Provider/AISEARCH/webpilotai_search.py +0 -281
- webscout/Provider/Aitopia.py +0 -292
- webscout/Provider/AllenAI.py +0 -413
- webscout/Provider/Andi.py +0 -228
- webscout/Provider/Blackboxai.py +0 -229
- webscout/Provider/C4ai.py +0 -432
- webscout/Provider/ChatGPTClone.py +0 -226
- webscout/Provider/ChatGPTES.py +0 -237
- webscout/Provider/ChatGPTGratis.py +0 -194
- webscout/Provider/Chatify.py +0 -175
- webscout/Provider/Cloudflare.py +0 -273
- webscout/Provider/Cohere.py +0 -208
- webscout/Provider/DeepSeek.py +0 -196
- webscout/Provider/Deepinfra.py +0 -297
- webscout/Provider/ElectronHub.py +0 -709
- webscout/Provider/ExaAI.py +0 -261
- webscout/Provider/ExaChat.py +0 -342
- webscout/Provider/Free2GPT.py +0 -241
- webscout/Provider/GPTWeb.py +0 -193
- webscout/Provider/Gemini.py +0 -169
- webscout/Provider/GithubChat.py +0 -367
- webscout/Provider/Glider.py +0 -211
- webscout/Provider/Groq.py +0 -670
- webscout/Provider/HF_space/__init__.py +0 -0
- webscout/Provider/HF_space/qwen_qwen2.py +0 -206
- webscout/Provider/HeckAI.py +0 -233
- webscout/Provider/HuggingFaceChat.py +0 -462
- webscout/Provider/Hunyuan.py +0 -272
- webscout/Provider/Jadve.py +0 -266
- webscout/Provider/Koboldai.py +0 -381
- webscout/Provider/LambdaChat.py +0 -392
- webscout/Provider/Llama.py +0 -200
- webscout/Provider/Llama3.py +0 -204
- webscout/Provider/Marcus.py +0 -148
- webscout/Provider/Netwrck.py +0 -228
- webscout/Provider/OLLAMA.py +0 -396
- webscout/Provider/OPENAI/__init__.py +0 -25
- webscout/Provider/OPENAI/base.py +0 -46
- webscout/Provider/OPENAI/c4ai.py +0 -367
- webscout/Provider/OPENAI/chatgpt.py +0 -549
- webscout/Provider/OPENAI/chatgptclone.py +0 -460
- webscout/Provider/OPENAI/deepinfra.py +0 -272
- webscout/Provider/OPENAI/e2b.py +0 -1350
- webscout/Provider/OPENAI/exaai.py +0 -404
- webscout/Provider/OPENAI/exachat.py +0 -433
- webscout/Provider/OPENAI/freeaichat.py +0 -352
- webscout/Provider/OPENAI/glider.py +0 -316
- webscout/Provider/OPENAI/heckai.py +0 -337
- webscout/Provider/OPENAI/llmchatco.py +0 -327
- webscout/Provider/OPENAI/netwrck.py +0 -348
- webscout/Provider/OPENAI/opkfc.py +0 -488
- webscout/Provider/OPENAI/scirachat.py +0 -463
- webscout/Provider/OPENAI/sonus.py +0 -294
- webscout/Provider/OPENAI/standardinput.py +0 -425
- webscout/Provider/OPENAI/textpollinations.py +0 -285
- webscout/Provider/OPENAI/toolbaz.py +0 -405
- webscout/Provider/OPENAI/typegpt.py +0 -346
- webscout/Provider/OPENAI/uncovrAI.py +0 -455
- webscout/Provider/OPENAI/utils.py +0 -211
- webscout/Provider/OPENAI/venice.py +0 -413
- webscout/Provider/OPENAI/wisecat.py +0 -381
- webscout/Provider/OPENAI/writecream.py +0 -156
- webscout/Provider/OPENAI/x0gpt.py +0 -371
- webscout/Provider/OPENAI/yep.py +0 -327
- webscout/Provider/OpenGPT.py +0 -199
- webscout/Provider/Openai.py +0 -496
- webscout/Provider/PI.py +0 -344
- webscout/Provider/Perplexitylabs.py +0 -415
- webscout/Provider/Phind.py +0 -535
- webscout/Provider/PizzaGPT.py +0 -198
- webscout/Provider/QwenLM.py +0 -254
- webscout/Provider/Reka.py +0 -214
- webscout/Provider/StandardInput.py +0 -278
- webscout/Provider/TTI/AiForce/__init__.py +0 -22
- webscout/Provider/TTI/AiForce/async_aiforce.py +0 -224
- webscout/Provider/TTI/AiForce/sync_aiforce.py +0 -245
- webscout/Provider/TTI/FreeAIPlayground/__init__.py +0 -9
- webscout/Provider/TTI/FreeAIPlayground/async_freeaiplayground.py +0 -181
- webscout/Provider/TTI/FreeAIPlayground/sync_freeaiplayground.py +0 -180
- webscout/Provider/TTI/ImgSys/__init__.py +0 -23
- webscout/Provider/TTI/ImgSys/async_imgsys.py +0 -202
- webscout/Provider/TTI/ImgSys/sync_imgsys.py +0 -195
- webscout/Provider/TTI/MagicStudio/__init__.py +0 -2
- webscout/Provider/TTI/MagicStudio/async_magicstudio.py +0 -111
- webscout/Provider/TTI/MagicStudio/sync_magicstudio.py +0 -109
- webscout/Provider/TTI/Nexra/__init__.py +0 -22
- webscout/Provider/TTI/Nexra/async_nexra.py +0 -286
- webscout/Provider/TTI/Nexra/sync_nexra.py +0 -258
- webscout/Provider/TTI/PollinationsAI/__init__.py +0 -23
- webscout/Provider/TTI/PollinationsAI/async_pollinations.py +0 -311
- webscout/Provider/TTI/PollinationsAI/sync_pollinations.py +0 -265
- webscout/Provider/TTI/__init__.py +0 -12
- webscout/Provider/TTI/aiarta/__init__.py +0 -2
- webscout/Provider/TTI/aiarta/async_aiarta.py +0 -482
- webscout/Provider/TTI/aiarta/sync_aiarta.py +0 -440
- webscout/Provider/TTI/artbit/__init__.py +0 -22
- webscout/Provider/TTI/artbit/async_artbit.py +0 -155
- webscout/Provider/TTI/artbit/sync_artbit.py +0 -148
- webscout/Provider/TTI/fastflux/__init__.py +0 -22
- webscout/Provider/TTI/fastflux/async_fastflux.py +0 -261
- webscout/Provider/TTI/fastflux/sync_fastflux.py +0 -252
- webscout/Provider/TTI/huggingface/__init__.py +0 -22
- webscout/Provider/TTI/huggingface/async_huggingface.py +0 -199
- webscout/Provider/TTI/huggingface/sync_huggingface.py +0 -195
- webscout/Provider/TTI/piclumen/__init__.py +0 -23
- webscout/Provider/TTI/piclumen/async_piclumen.py +0 -268
- webscout/Provider/TTI/piclumen/sync_piclumen.py +0 -233
- webscout/Provider/TTI/pixelmuse/__init__.py +0 -4
- webscout/Provider/TTI/pixelmuse/async_pixelmuse.py +0 -249
- webscout/Provider/TTI/pixelmuse/sync_pixelmuse.py +0 -182
- webscout/Provider/TTI/talkai/__init__.py +0 -4
- webscout/Provider/TTI/talkai/async_talkai.py +0 -229
- webscout/Provider/TTI/talkai/sync_talkai.py +0 -207
- webscout/Provider/TTS/__init__.py +0 -7
- webscout/Provider/TTS/deepgram.py +0 -156
- webscout/Provider/TTS/elevenlabs.py +0 -111
- webscout/Provider/TTS/gesserit.py +0 -127
- webscout/Provider/TTS/murfai.py +0 -113
- webscout/Provider/TTS/parler.py +0 -111
- webscout/Provider/TTS/speechma.py +0 -180
- webscout/Provider/TTS/streamElements.py +0 -333
- webscout/Provider/TTS/utils.py +0 -280
- webscout/Provider/TeachAnything.py +0 -187
- webscout/Provider/TextPollinationsAI.py +0 -231
- webscout/Provider/TwoAI.py +0 -199
- webscout/Provider/Venice.py +0 -219
- webscout/Provider/VercelAI.py +0 -234
- webscout/Provider/WebSim.py +0 -228
- webscout/Provider/WiseCat.py +0 -196
- webscout/Provider/Writecream.py +0 -211
- webscout/Provider/WritingMate.py +0 -197
- webscout/Provider/Youchat.py +0 -330
- webscout/Provider/__init__.py +0 -198
- webscout/Provider/ai4chat.py +0 -202
- webscout/Provider/aimathgpt.py +0 -189
- webscout/Provider/akashgpt.py +0 -342
- webscout/Provider/askmyai.py +0 -158
- webscout/Provider/asksteve.py +0 -203
- webscout/Provider/bagoodex.py +0 -145
- webscout/Provider/cerebras.py +0 -242
- webscout/Provider/chatglm.py +0 -205
- webscout/Provider/cleeai.py +0 -213
- webscout/Provider/copilot.py +0 -428
- webscout/Provider/elmo.py +0 -234
- webscout/Provider/freeaichat.py +0 -271
- webscout/Provider/gaurish.py +0 -244
- webscout/Provider/geminiapi.py +0 -208
- webscout/Provider/geminiprorealtime.py +0 -160
- webscout/Provider/granite.py +0 -187
- webscout/Provider/hermes.py +0 -219
- webscout/Provider/julius.py +0 -223
- webscout/Provider/koala.py +0 -268
- webscout/Provider/labyrinth.py +0 -340
- webscout/Provider/learnfastai.py +0 -266
- webscout/Provider/lepton.py +0 -194
- webscout/Provider/llama3mitril.py +0 -180
- webscout/Provider/llamatutor.py +0 -192
- webscout/Provider/llmchat.py +0 -213
- webscout/Provider/llmchatco.py +0 -311
- webscout/Provider/meta.py +0 -794
- webscout/Provider/multichat.py +0 -325
- webscout/Provider/promptrefine.py +0 -193
- webscout/Provider/scira_chat.py +0 -277
- webscout/Provider/scnet.py +0 -187
- webscout/Provider/searchchat.py +0 -293
- webscout/Provider/sonus.py +0 -208
- webscout/Provider/talkai.py +0 -194
- webscout/Provider/toolbaz.py +0 -320
- webscout/Provider/turboseek.py +0 -219
- webscout/Provider/tutorai.py +0 -252
- webscout/Provider/typefully.py +0 -280
- webscout/Provider/typegpt.py +0 -232
- webscout/Provider/uncovr.py +0 -312
- webscout/Provider/x0gpt.py +0 -256
- webscout/Provider/yep.py +0 -376
- webscout/litagent/__init__.py +0 -29
- webscout/litagent/agent.py +0 -455
- webscout/litagent/constants.py +0 -60
- webscout/litprinter/__init__.py +0 -59
- webscout/scout/__init__.py +0 -8
- webscout/scout/core/__init__.py +0 -7
- webscout/scout/core/crawler.py +0 -140
- webscout/scout/core/scout.py +0 -568
- webscout/scout/core/search_result.py +0 -96
- webscout/scout/core/text_analyzer.py +0 -63
- webscout/scout/core/text_utils.py +0 -277
- webscout/scout/core/web_analyzer.py +0 -52
- webscout/scout/core.py +0 -881
- webscout/scout/element.py +0 -460
- webscout/scout/parsers/__init__.py +0 -69
- webscout/scout/parsers/html5lib_parser.py +0 -172
- webscout/scout/parsers/html_parser.py +0 -236
- webscout/scout/parsers/lxml_parser.py +0 -178
- webscout/scout/utils.py +0 -37
- webscout/swiftcli/__init__.py +0 -809
- webscout/zeroart/__init__.py +0 -55
- webscout/zeroart/base.py +0 -60
- webscout/zeroart/effects.py +0 -99
- webscout/zeroart/fonts.py +0 -816
- webscout-8.2.2.dist-info/RECORD +0 -309
- webscout-8.2.2.dist-info/entry_points.txt +0 -5
- webscout-8.2.2.dist-info/top_level.txt +0 -3
- webstoken/__init__.py +0 -30
- webstoken/classifier.py +0 -189
- webstoken/keywords.py +0 -216
- webstoken/language.py +0 -128
- webstoken/ner.py +0 -164
- webstoken/normalizer.py +0 -35
- webstoken/processor.py +0 -77
- webstoken/sentiment.py +0 -206
- webstoken/stemmer.py +0 -73
- webstoken/tagger.py +0 -60
- webstoken/tokenizer.py +0 -158
- {webscout-8.2.2.dist-info → webscout-8.2.7.dist-info/licenses}/LICENSE.md +0 -0
|
@@ -1,278 +0,0 @@
|
|
|
1
|
-
from os import system
|
|
2
|
-
import requests
|
|
3
|
-
import json
|
|
4
|
-
import uuid
|
|
5
|
-
import re
|
|
6
|
-
from datetime import datetime
|
|
7
|
-
from typing import Any, Dict, Optional, Union, Generator
|
|
8
|
-
from webscout.AIutel import Optimizers
|
|
9
|
-
from webscout.AIutel import Conversation
|
|
10
|
-
from webscout.AIutel import AwesomePrompts
|
|
11
|
-
from webscout.AIbase import Provider
|
|
12
|
-
from webscout import exceptions
|
|
13
|
-
from webscout.litagent import LitAgent
|
|
14
|
-
|
|
15
|
-
class StandardInputAI(Provider):
|
|
16
|
-
"""
|
|
17
|
-
A class to interact with the Standard Input chat API.
|
|
18
|
-
"""
|
|
19
|
-
|
|
20
|
-
AVAILABLE_MODELS = {
|
|
21
|
-
"standard-quick": "quick",
|
|
22
|
-
"standard-reasoning": "quick", # Same model but with reasoning enabled
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
def __init__(
|
|
26
|
-
self,
|
|
27
|
-
is_conversation: bool = True,
|
|
28
|
-
max_tokens: int = 2049,
|
|
29
|
-
timeout: int = 30,
|
|
30
|
-
intro: str = None,
|
|
31
|
-
filepath: str = None,
|
|
32
|
-
update_file: bool = True,
|
|
33
|
-
proxies: dict = {},
|
|
34
|
-
history_offset: int = 10250,
|
|
35
|
-
act: str = None,
|
|
36
|
-
model: str = "standard-quick",
|
|
37
|
-
chat_id: str = None,
|
|
38
|
-
user_id: str = None,
|
|
39
|
-
browser: str = "chrome",
|
|
40
|
-
system_prompt: str = "You are a helpful assistant.",
|
|
41
|
-
enable_reasoning: bool = False,
|
|
42
|
-
):
|
|
43
|
-
"""
|
|
44
|
-
Initializes the Standard Input API client.
|
|
45
|
-
|
|
46
|
-
Args:
|
|
47
|
-
is_conversation (bool): Whether to maintain conversation history.
|
|
48
|
-
max_tokens (int): Maximum number of tokens to generate.
|
|
49
|
-
timeout (int): Request timeout in seconds.
|
|
50
|
-
intro (str): Introduction text for the conversation.
|
|
51
|
-
filepath (str): Path to save conversation history.
|
|
52
|
-
update_file (bool): Whether to update the conversation history file.
|
|
53
|
-
proxies (dict): Proxy configuration for requests.
|
|
54
|
-
history_offset (int): Maximum history length in characters.
|
|
55
|
-
act (str): Persona for the AI to adopt.
|
|
56
|
-
model (str): Model to use, must be one of AVAILABLE_MODELS.
|
|
57
|
-
chat_id (str): Unique identifier for the chat session.
|
|
58
|
-
user_id (str): Unique identifier for the user.
|
|
59
|
-
browser (str): Browser to emulate in requests.
|
|
60
|
-
system_prompt (str): System prompt for the AI.
|
|
61
|
-
enable_reasoning (bool): Whether to enable reasoning feature.
|
|
62
|
-
"""
|
|
63
|
-
if model not in self.AVAILABLE_MODELS:
|
|
64
|
-
raise ValueError(f"Invalid model: {model}. Choose from: {self.AVAILABLE_MODELS}")
|
|
65
|
-
|
|
66
|
-
self.url = "https://chat.standard-input.com/api/chat"
|
|
67
|
-
|
|
68
|
-
# Initialize LitAgent for user agent generation
|
|
69
|
-
self.agent = LitAgent()
|
|
70
|
-
# Use fingerprinting to create a consistent browser identity
|
|
71
|
-
self.fingerprint = self.agent.generate_fingerprint(browser)
|
|
72
|
-
self.system_prompt = system_prompt
|
|
73
|
-
|
|
74
|
-
# Use the fingerprint for headers
|
|
75
|
-
self.headers = {
|
|
76
|
-
"accept": "*/*",
|
|
77
|
-
"accept-encoding": "gzip, deflate, br, zstd",
|
|
78
|
-
"accept-language": self.fingerprint["accept_language"],
|
|
79
|
-
"content-type": "application/json",
|
|
80
|
-
"dnt": "1",
|
|
81
|
-
"origin": "https://chat.standard-input.com",
|
|
82
|
-
"referer": "https://chat.standard-input.com/",
|
|
83
|
-
"sec-ch-ua": self.fingerprint["sec_ch_ua"] or '"Microsoft Edge";v="135", "Not-A.Brand";v="8", "Chromium";v="135"',
|
|
84
|
-
"sec-ch-ua-mobile": "?0",
|
|
85
|
-
"sec-ch-ua-platform": f'"{self.fingerprint["platform"]}"',
|
|
86
|
-
"sec-fetch-dest": "empty",
|
|
87
|
-
"sec-fetch-mode": "cors",
|
|
88
|
-
"sec-fetch-site": "same-origin",
|
|
89
|
-
"sec-gpc": "1",
|
|
90
|
-
"user-agent": self.fingerprint["user_agent"],
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
# Default cookies - these should be updated for production use
|
|
94
|
-
self.cookies = {
|
|
95
|
-
"auth-chat": '''%7B%22user%22%3A%7B%22id%22%3A%2243a26ebd-7691-4a5a-8321-12aff017af86%22%2C%22email%22%3A%22iu511inmev%40illubd.com%22%2C%22accountId%22%3A%22057d78c9-06db-48eb-aeaa-0efdbaeb9446%22%2C%22provider%22%3A%22password%22%7D%2C%22tokens%22%3A%7B%22access%22%3A%22eyJhbGciOiJFUzI1NiIsImtpZCI6Ijg1NDhmZWY1LTk5MjYtNDk2Yi1hMjI2LTQ5OTExYjllYzU2NSIsInR5cCI6IkpXVCJ9.eyJtb2RlIjoiYWNjZXNzIiwidHlwZSI6InVzZXIiLCJwcm9wZXJ0aWVzIjp7ImlkIjoiNDNhMjZlYmQtNzY5MS00YTVhLTgzMzEtMTJhZmYwMTdhZjg2IiwiZW1haWwiOiJpdTUxMWlubWV2QGlsbHViZC5jb20iLCJhY2NvdW50SWQiOiIwNTdkNzhjOS0wNmRiLTQ4ZWItYWVhYS0wZWZkYmFlYjk0NDYiLCJwcm92aWRlciI6InBhc3N3b3JkIn0sImF1ZCI6InN0YW5kYXJkLWlucHV0LWlvcyIsImlzcyI6Imh0dHBzOi8vYXV0aC5zdGFuZGFyZC1pbnB1dC5jb20iLCJzdWIiOiJ1c2VyOjRmYWMzMTllZjA4MDRiZmMiLCJleHAiOjE3NDU0MDU5MDN9.d3VsEq-UCNsQWkiPlTVw7caS0wTXfCYe6yeFLeb4Ce6ZYTIFFn685SF-aKvLOxaYaq7Pyk4D2qr24riPVhxUWQ%22%2C%22refresh%22%3A%22user%3A4fac319ef0804bfc%3A3a757177-5507-4a36-9356-492f5ed06105%22%7D%7D''',
|
|
96
|
-
"auth": '''%7B%22user%22%3A%7B%22id%22%3A%22c51e291f-8f44-439d-a38b-9ea147581a13%22%2C%22email%22%3A%22r6cigexlsb%40mrotzis.com%22%2C%22accountId%22%3A%22599fd4ce-04a2-40f6-a78f-d33d0059b77f%22%2C%22provider%22%3A%22password%22%7D%2C%22tokens%22%3A%7B%22access%22%3A%22eyJhbGciOiJFUzI1NiIsImtpZCI6Ijg1NDhmZWY1LTk5MjYtNDk2Yi1hMjI2LTQ5OTExYjllYzU2NSIsInR5cCI6IkpXVCJ9.eyJtb2RlIjoiYWNjZXNzIiwidHlwZSI6InVzZXIiLCJwcm9wZXJ0aWVzIjp7ImlkIjoiYzUxZTI5MWYtOGY0NC00MzlkLWEzOGItOWVhMTQ3NTgxYTEzIiwiZW1haWwiOiJyNmNpZ2V4bHNiQG1yb3R6aXMuY29tIiwiYWNjb3VudElkIjoiNTk5ZmQ0Y2UtMDRhMi00MGY2LWE3OGYtZDMzZDAwNTliNzdmIiwicHJvdmlkZXIiOiJwYXNzd29yZCJ9LCJhdWQiOiJzdGFuZGFyZC1pbnB1dC1pb3MiLCJpc3MiOiJodHRwczovL2F1dGguc3RhbmRhcmQtaW5wdXQuY29tIiwic3ViIjoidXNlcjo4Y2FmMjRkYzUxNDc4MmNkIiwiZXhwIjoxNzQ2NzI0MTU3fQ.a3970nBJkd8JoU-khRA2JlRMuYeJ7378QS4ZL446kOkDi35uTwuC4qGrWH9efk9GkFaVcWPtYeOJjRb7f2SeJA%22%2C%22refresh%22%3A%22user%3A8caf24dc514782cd%3A14e24386-8443-4df0-ae25-234ad59218ef%22%7D%7D''',
|
|
97
|
-
"sidebar:state": "true",
|
|
98
|
-
"ph_phc_f3wUUyCfmKlKtkc2pfT7OsdcW2mBEVGN2A87yEYbG3c_posthog": '''%7B%22distinct_id%22%3A%220195c7cc-ac8f-79ff-b901-e14a78fc2a67%22%2C%22%24sesid%22%3A%5B1744688627860%2C%220196377f-9f12-77e6-a9ea-0e9669423803%22%2C1744687832850%5D%2C%22%24initial_person_info%22%3A%7B%22r%22%3A%22%24direct%22%2C%22u%22%3A%22https%3A%2F%2Fstandard-input.com%2F%22%7D%7D'''
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
self.session = requests.Session()
|
|
102
|
-
self.session.headers.update(self.headers)
|
|
103
|
-
self.session.proxies.update(proxies)
|
|
104
|
-
|
|
105
|
-
self.is_conversation = is_conversation
|
|
106
|
-
self.max_tokens_to_sample = max_tokens
|
|
107
|
-
self.timeout = timeout
|
|
108
|
-
self.last_response = {}
|
|
109
|
-
self.model = model
|
|
110
|
-
self.chat_id = chat_id or str(uuid.uuid4())
|
|
111
|
-
self.user_id = user_id or f"user_{str(uuid.uuid4())[:8].upper()}"
|
|
112
|
-
self.enable_reasoning = enable_reasoning
|
|
113
|
-
|
|
114
|
-
self.__available_optimizers = (
|
|
115
|
-
method
|
|
116
|
-
for method in dir(Optimizers)
|
|
117
|
-
if callable(getattr(Optimizers, method)) and not method.startswith("__")
|
|
118
|
-
)
|
|
119
|
-
Conversation.intro = (
|
|
120
|
-
AwesomePrompts().get_act(
|
|
121
|
-
act, raise_not_found=True, default=None, case_insensitive=True
|
|
122
|
-
)
|
|
123
|
-
if act
|
|
124
|
-
else intro or Conversation.intro
|
|
125
|
-
)
|
|
126
|
-
|
|
127
|
-
self.conversation = Conversation(
|
|
128
|
-
is_conversation, self.max_tokens_to_sample, filepath, update_file
|
|
129
|
-
)
|
|
130
|
-
self.conversation.history_offset = history_offset
|
|
131
|
-
|
|
132
|
-
def refresh_identity(self, browser: str = None):
|
|
133
|
-
"""
|
|
134
|
-
Refreshes the browser identity fingerprint.
|
|
135
|
-
|
|
136
|
-
Args:
|
|
137
|
-
browser: Specific browser to use for the new fingerprint
|
|
138
|
-
"""
|
|
139
|
-
browser = browser or self.fingerprint.get("browser_type", "chrome")
|
|
140
|
-
self.fingerprint = self.agent.generate_fingerprint(browser)
|
|
141
|
-
|
|
142
|
-
# Update headers with new fingerprint
|
|
143
|
-
self.headers.update({
|
|
144
|
-
"Accept-Language": self.fingerprint["accept_language"],
|
|
145
|
-
"Sec-CH-UA": self.fingerprint["sec_ch_ua"] or self.headers["sec-ch-ua"],
|
|
146
|
-
"Sec-CH-UA-Platform": f'"{self.fingerprint["platform"]}"',
|
|
147
|
-
"User-Agent": self.fingerprint["user_agent"],
|
|
148
|
-
})
|
|
149
|
-
|
|
150
|
-
# Update session headers
|
|
151
|
-
for header, value in self.headers.items():
|
|
152
|
-
self.session.headers[header] = value
|
|
153
|
-
|
|
154
|
-
return self.fingerprint
|
|
155
|
-
|
|
156
|
-
def ask(
|
|
157
|
-
self,
|
|
158
|
-
prompt: str,
|
|
159
|
-
optimizer: str = None,
|
|
160
|
-
conversationally: bool = False,
|
|
161
|
-
) -> Dict[str, Any]:
|
|
162
|
-
conversation_prompt = self.conversation.gen_complete_prompt(prompt)
|
|
163
|
-
if optimizer:
|
|
164
|
-
if optimizer in self.__available_optimizers:
|
|
165
|
-
conversation_prompt = getattr(Optimizers, optimizer)(
|
|
166
|
-
conversation_prompt if conversationally else prompt
|
|
167
|
-
)
|
|
168
|
-
else:
|
|
169
|
-
raise Exception(f"Optimizer is not one of {self.__available_optimizers}")
|
|
170
|
-
|
|
171
|
-
# Prepare the messages
|
|
172
|
-
messages = [
|
|
173
|
-
{"role": "system", "content": self.system_prompt},
|
|
174
|
-
{"role": "user", "content": conversation_prompt, "parts": [{"type": "text", "text": conversation_prompt}]}
|
|
175
|
-
]
|
|
176
|
-
|
|
177
|
-
# Prepare the request payload
|
|
178
|
-
payload = {
|
|
179
|
-
"id": self.chat_id,
|
|
180
|
-
"messages": messages,
|
|
181
|
-
"modelId": self.AVAILABLE_MODELS[self.model],
|
|
182
|
-
"enabledFeatures": ["reasoning"] if self.enable_reasoning or self.model == "standard-reasoning" else []
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
try:
|
|
186
|
-
response = self.session.post(self.url, cookies=self.cookies, json=payload, stream=True, timeout=self.timeout)
|
|
187
|
-
if response.status_code != 200:
|
|
188
|
-
# Try to get response content for better error messages
|
|
189
|
-
try:
|
|
190
|
-
error_content = response.text
|
|
191
|
-
except:
|
|
192
|
-
error_content = "<could not read response content>"
|
|
193
|
-
|
|
194
|
-
if response.status_code in [403, 429]:
|
|
195
|
-
print(f"Received status code {response.status_code}, refreshing identity...")
|
|
196
|
-
self.refresh_identity()
|
|
197
|
-
response = self.session.post(self.url, cookies=self.cookies, json=payload, stream=True, timeout=self.timeout)
|
|
198
|
-
if not response.ok:
|
|
199
|
-
raise exceptions.FailedToGenerateResponseError(
|
|
200
|
-
f"Failed to generate response after identity refresh - ({response.status_code}, {response.reason}) - {error_content}"
|
|
201
|
-
)
|
|
202
|
-
print("Identity refreshed successfully.")
|
|
203
|
-
else:
|
|
204
|
-
raise exceptions.FailedToGenerateResponseError(
|
|
205
|
-
f"Request failed with status code {response.status_code}. Response: {error_content}"
|
|
206
|
-
)
|
|
207
|
-
|
|
208
|
-
full_response = ""
|
|
209
|
-
debug_lines = []
|
|
210
|
-
|
|
211
|
-
# Process the streaming response
|
|
212
|
-
for i, line in enumerate(response.iter_lines(decode_unicode=True)):
|
|
213
|
-
if line:
|
|
214
|
-
try:
|
|
215
|
-
line_str = line
|
|
216
|
-
debug_lines.append(line_str)
|
|
217
|
-
|
|
218
|
-
# Extract content from the response
|
|
219
|
-
match = re.search(r'0:"(.*?)"', line_str)
|
|
220
|
-
if match:
|
|
221
|
-
content = match.group(1)
|
|
222
|
-
full_response += content
|
|
223
|
-
continue
|
|
224
|
-
except: pass
|
|
225
|
-
|
|
226
|
-
self.last_response = {"text": full_response}
|
|
227
|
-
self.conversation.update_chat_history(prompt, full_response)
|
|
228
|
-
return {"text": full_response}
|
|
229
|
-
except Exception as e:
|
|
230
|
-
raise exceptions.FailedToGenerateResponseError(f"Request failed: {e}")
|
|
231
|
-
|
|
232
|
-
def chat(
|
|
233
|
-
self,
|
|
234
|
-
prompt: str,
|
|
235
|
-
optimizer: str = None,
|
|
236
|
-
conversationally: bool = False,
|
|
237
|
-
) -> str:
|
|
238
|
-
return self.get_message(
|
|
239
|
-
self.ask(
|
|
240
|
-
prompt, optimizer=optimizer, conversationally=conversationally
|
|
241
|
-
)
|
|
242
|
-
)
|
|
243
|
-
|
|
244
|
-
def get_message(self, response: dict) -> str:
|
|
245
|
-
assert isinstance(response, dict), "Response should be of dict data-type only"
|
|
246
|
-
return response["text"].replace('\\n', '\n').replace('\\n\\n', '\n\n')
|
|
247
|
-
|
|
248
|
-
if __name__ == "__main__":
|
|
249
|
-
print("-" * 100)
|
|
250
|
-
print(f"{'Model':<50} {'Status':<10} {'Response'}")
|
|
251
|
-
print("-" * 100)
|
|
252
|
-
|
|
253
|
-
test_prompt = "Say 'Hello' in one word"
|
|
254
|
-
|
|
255
|
-
# Test each model
|
|
256
|
-
for model in StandardInputAI.AVAILABLE_MODELS:
|
|
257
|
-
print(f"\rTesting {model}...", end="")
|
|
258
|
-
|
|
259
|
-
try:
|
|
260
|
-
test_ai = StandardInputAI(model=model, timeout=120) # Increased timeout
|
|
261
|
-
response = test_ai.chat(test_prompt)
|
|
262
|
-
|
|
263
|
-
if response and len(response.strip()) > 0:
|
|
264
|
-
status = "✓"
|
|
265
|
-
# Clean and truncate response
|
|
266
|
-
clean_text = response.strip().encode('utf-8', errors='ignore').decode('utf-8')
|
|
267
|
-
display_text = clean_text[:50] + "..." if len(clean_text) > 50 else clean_text
|
|
268
|
-
else:
|
|
269
|
-
status = "✗"
|
|
270
|
-
display_text = "Empty or invalid response"
|
|
271
|
-
|
|
272
|
-
print(f"\r{model:<50} {status:<10} {display_text}")
|
|
273
|
-
except Exception as e:
|
|
274
|
-
error_msg = str(e)
|
|
275
|
-
# Truncate very long error messages
|
|
276
|
-
if len(error_msg) > 100:
|
|
277
|
-
error_msg = error_msg[:97] + "..."
|
|
278
|
-
print(f"\r{model:<50} {'✗':<10} Error: {error_msg}")
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
AiForce - Your go-to provider for generating fire images! 🔥
|
|
3
|
-
|
|
4
|
-
Examples:
|
|
5
|
-
>>> # Sync Usage
|
|
6
|
-
>>> from webscout import AiForceimager
|
|
7
|
-
>>> provider = AiForceimager()
|
|
8
|
-
>>> images = provider.generate("Cool art")
|
|
9
|
-
>>> paths = provider.save(images)
|
|
10
|
-
>>>
|
|
11
|
-
>>> # Async Usage
|
|
12
|
-
>>> from webscout import AsyncAiForceimager
|
|
13
|
-
>>> async def example():
|
|
14
|
-
... provider = AsyncAiForceimager()
|
|
15
|
-
... images = await provider.generate("Epic dragon")
|
|
16
|
-
... paths = await provider.save(images)
|
|
17
|
-
"""
|
|
18
|
-
|
|
19
|
-
from .sync_aiforce import AiForceimager
|
|
20
|
-
from .async_aiforce import AsyncAiForceimager
|
|
21
|
-
|
|
22
|
-
__all__ = ["AiForceimager", "AsyncAiForceimager"]
|
|
@@ -1,224 +0,0 @@
|
|
|
1
|
-
import aiohttp
|
|
2
|
-
import asyncio
|
|
3
|
-
import os
|
|
4
|
-
import time
|
|
5
|
-
from typing import List, Optional, Union, AsyncGenerator
|
|
6
|
-
from string import punctuation
|
|
7
|
-
from random import choice
|
|
8
|
-
from aiohttp import ClientError
|
|
9
|
-
from pathlib import Path
|
|
10
|
-
|
|
11
|
-
from webscout.AIbase import AsyncImageProvider
|
|
12
|
-
from webscout.litagent import LitAgent
|
|
13
|
-
|
|
14
|
-
agent = LitAgent()
|
|
15
|
-
|
|
16
|
-
class AsyncAiForceimager(AsyncImageProvider):
|
|
17
|
-
"""Your go-to async provider for generating fire images with AiForce! ⚡
|
|
18
|
-
|
|
19
|
-
Examples:
|
|
20
|
-
>>> # Basic usage
|
|
21
|
-
>>> provider = AsyncAiForceimager()
|
|
22
|
-
>>> async def example():
|
|
23
|
-
... images = await provider.generate("Cool art")
|
|
24
|
-
... paths = await provider.save(images)
|
|
25
|
-
>>>
|
|
26
|
-
>>> # Advanced usage
|
|
27
|
-
>>> provider = AsyncAiForceimager(timeout=120)
|
|
28
|
-
>>> async def example():
|
|
29
|
-
... images = await provider.generate(
|
|
30
|
-
... prompt="Epic dragon",
|
|
31
|
-
... amount=3,
|
|
32
|
-
... model="Flux-1.1-Pro",
|
|
33
|
-
... width=1024,
|
|
34
|
-
... height=1024
|
|
35
|
-
... )
|
|
36
|
-
... paths = await provider.save(images, name="dragon", dir="my_art")
|
|
37
|
-
"""
|
|
38
|
-
|
|
39
|
-
AVAILABLE_MODELS = [
|
|
40
|
-
"stable-diffusion-xl-lightning",
|
|
41
|
-
"stable-diffusion-xl-base",
|
|
42
|
-
"flux",
|
|
43
|
-
"flux-realism",
|
|
44
|
-
"flux-anime",
|
|
45
|
-
"flux-3d",
|
|
46
|
-
"flux-disney",
|
|
47
|
-
"flux-pixel",
|
|
48
|
-
"flux-4o",
|
|
49
|
-
"any-dark"
|
|
50
|
-
]
|
|
51
|
-
|
|
52
|
-
def __init__(self, timeout: int = 60, proxies: dict = {}):
|
|
53
|
-
"""Initialize your async AiForce provider with custom settings! ⚙️
|
|
54
|
-
|
|
55
|
-
Args:
|
|
56
|
-
timeout (int): Request timeout in seconds (default: 60)
|
|
57
|
-
proxies (dict): Proxy settings for requests (default: {})
|
|
58
|
-
"""
|
|
59
|
-
self.api_endpoint = "https://api.airforce/imagine2"
|
|
60
|
-
self.headers = {
|
|
61
|
-
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8",
|
|
62
|
-
"Accept-Language": "en-US,en;q=0.5",
|
|
63
|
-
"Accept-Encoding": "gzip, deflate",
|
|
64
|
-
"User-Agent": agent.random()
|
|
65
|
-
}
|
|
66
|
-
self.timeout = timeout
|
|
67
|
-
self.proxies = proxies
|
|
68
|
-
self.prompt: str = "AI-generated image - webscout"
|
|
69
|
-
self.image_extension: str = "png"
|
|
70
|
-
|
|
71
|
-
async def generate(
|
|
72
|
-
self,
|
|
73
|
-
prompt: str,
|
|
74
|
-
amount: int = 1,
|
|
75
|
-
additives: bool = True,
|
|
76
|
-
model: str = "flux-3d",
|
|
77
|
-
width: int = 768,
|
|
78
|
-
height: int = 768,
|
|
79
|
-
seed: Optional[int] = None,
|
|
80
|
-
max_retries: int = 3,
|
|
81
|
-
retry_delay: int = 5
|
|
82
|
-
) -> List[bytes]:
|
|
83
|
-
"""Generate some fire images from your prompt asynchronously! ⚡
|
|
84
|
-
|
|
85
|
-
Examples:
|
|
86
|
-
>>> provider = AsyncAiForceimager()
|
|
87
|
-
>>> async def example():
|
|
88
|
-
... # Basic usage
|
|
89
|
-
... images = await provider.generate("Cool art")
|
|
90
|
-
... # Advanced usage
|
|
91
|
-
... images = await provider.generate(
|
|
92
|
-
... prompt="Epic dragon",
|
|
93
|
-
... amount=3,
|
|
94
|
-
... model="flux-3d"
|
|
95
|
-
... )
|
|
96
|
-
|
|
97
|
-
Args:
|
|
98
|
-
prompt (str): Your image description
|
|
99
|
-
amount (int): How many images you want (default: 1)
|
|
100
|
-
additives (bool): Make each prompt unique (default: True)
|
|
101
|
-
model (str): Model to use - check AVAILABLE_MODELS (default: "Flux-1.1-Pro")
|
|
102
|
-
width (int): Image width (default: 768)
|
|
103
|
-
height (int): Image height (default: 768)
|
|
104
|
-
seed (int, optional): Seed for reproducible results
|
|
105
|
-
max_retries (int): Max retry attempts if something fails (default: 3)
|
|
106
|
-
retry_delay (int): Seconds to wait between retries (default: 5)
|
|
107
|
-
|
|
108
|
-
Returns:
|
|
109
|
-
List[bytes]: Your generated images
|
|
110
|
-
|
|
111
|
-
Raises:
|
|
112
|
-
ValueError: If the inputs ain't valid
|
|
113
|
-
ClientError: If the API calls fail after retries
|
|
114
|
-
"""
|
|
115
|
-
assert bool(prompt), "Prompt cannot be null"
|
|
116
|
-
assert isinstance(amount, int), f"Amount should be an integer only not {type(amount)}"
|
|
117
|
-
assert amount > 0, "Amount should be greater than 0"
|
|
118
|
-
assert model in self.AVAILABLE_MODELS, f"Model should be one of {self.AVAILABLE_MODELS}"
|
|
119
|
-
|
|
120
|
-
ads = lambda: (
|
|
121
|
-
""
|
|
122
|
-
if not additives
|
|
123
|
-
else choice(punctuation)
|
|
124
|
-
+ choice(punctuation)
|
|
125
|
-
+ choice(punctuation)
|
|
126
|
-
+ choice(punctuation)
|
|
127
|
-
+ choice(punctuation)
|
|
128
|
-
)
|
|
129
|
-
|
|
130
|
-
self.prompt = prompt
|
|
131
|
-
response = []
|
|
132
|
-
|
|
133
|
-
async with aiohttp.ClientSession(headers=self.headers) as session:
|
|
134
|
-
for i in range(amount):
|
|
135
|
-
url = f"{self.api_endpoint}?model={model}&prompt={prompt}&size={width}:{height}"
|
|
136
|
-
if seed:
|
|
137
|
-
url += f"&seed={seed}"
|
|
138
|
-
|
|
139
|
-
for attempt in range(max_retries):
|
|
140
|
-
try:
|
|
141
|
-
async with session.get(url, timeout=self.timeout, proxy=self.proxies.get('http')) as resp:
|
|
142
|
-
resp.raise_for_status()
|
|
143
|
-
response.append(await resp.read())
|
|
144
|
-
break
|
|
145
|
-
except ClientError as e:
|
|
146
|
-
if attempt == max_retries - 1:
|
|
147
|
-
raise
|
|
148
|
-
else:
|
|
149
|
-
await asyncio.sleep(retry_delay)
|
|
150
|
-
|
|
151
|
-
return response
|
|
152
|
-
|
|
153
|
-
async def save(
|
|
154
|
-
self,
|
|
155
|
-
response: Union[AsyncGenerator[bytes, None], List[bytes]],
|
|
156
|
-
name: Optional[str] = None,
|
|
157
|
-
dir: Optional[Union[str, Path]] = None,
|
|
158
|
-
filenames_prefix: str = "",
|
|
159
|
-
) -> List[str]:
|
|
160
|
-
"""Save your fire generated images asynchronously! 💾
|
|
161
|
-
|
|
162
|
-
Examples:
|
|
163
|
-
>>> provider = AsyncAiForceimager()
|
|
164
|
-
>>> async def example():
|
|
165
|
-
... images = await provider.generate("Cool art")
|
|
166
|
-
... # Save with default settings
|
|
167
|
-
... paths = await provider.save(images)
|
|
168
|
-
... # Save with custom name and directory
|
|
169
|
-
... paths = await provider.save(
|
|
170
|
-
... images,
|
|
171
|
-
... name="my_art",
|
|
172
|
-
... dir="my_images",
|
|
173
|
-
... filenames_prefix="test_"
|
|
174
|
-
... )
|
|
175
|
-
|
|
176
|
-
Args:
|
|
177
|
-
response (Union[AsyncGenerator[bytes, None], List[bytes]]): Your generated images
|
|
178
|
-
name (Optional[str]): Custom name for your images
|
|
179
|
-
dir (Optional[Union[str, Path]]): Where to save the images (default: current directory)
|
|
180
|
-
filenames_prefix (str): Prefix for your image files
|
|
181
|
-
|
|
182
|
-
Returns:
|
|
183
|
-
List[str]: Paths to your saved images
|
|
184
|
-
"""
|
|
185
|
-
save_dir = dir if dir else os.getcwd()
|
|
186
|
-
if not os.path.exists(save_dir):
|
|
187
|
-
os.makedirs(save_dir)
|
|
188
|
-
|
|
189
|
-
name = self.prompt if name is None else name
|
|
190
|
-
saved_paths = []
|
|
191
|
-
timestamp = int(time.time())
|
|
192
|
-
|
|
193
|
-
async def save_single_image(image_bytes: bytes, index: int) -> str:
|
|
194
|
-
filename = f"{filenames_prefix}{name}_{index}.{self.image_extension}"
|
|
195
|
-
filepath = os.path.join(save_dir, filename)
|
|
196
|
-
|
|
197
|
-
# Write file using asyncio
|
|
198
|
-
async with asyncio.Lock():
|
|
199
|
-
with open(filepath, "wb") as f:
|
|
200
|
-
f.write(image_bytes)
|
|
201
|
-
|
|
202
|
-
return filepath
|
|
203
|
-
|
|
204
|
-
# Handle both List[bytes] and AsyncGenerator
|
|
205
|
-
if isinstance(response, list):
|
|
206
|
-
image_list = response
|
|
207
|
-
else:
|
|
208
|
-
image_list = [chunk async for chunk in response]
|
|
209
|
-
|
|
210
|
-
tasks = [save_single_image(img, i) for i, img in enumerate(image_list)]
|
|
211
|
-
saved_paths = await asyncio.gather(*tasks)
|
|
212
|
-
return saved_paths
|
|
213
|
-
|
|
214
|
-
if __name__ == "__main__":
|
|
215
|
-
async def main():
|
|
216
|
-
bot = AsyncAiForceimager()
|
|
217
|
-
try:
|
|
218
|
-
resp = await bot.generate("A shiny red sports car speeding down a scenic mountain road", 1)
|
|
219
|
-
paths = await bot.save(resp)
|
|
220
|
-
print(paths)
|
|
221
|
-
except Exception as e:
|
|
222
|
-
print(f"An error occurred: {e}")
|
|
223
|
-
|
|
224
|
-
asyncio.run(main())
|