webscout 7.4__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.
- webscout/AIauto.py +5 -53
- webscout/AIutel.py +8 -318
- webscout/DWEBS.py +460 -489
- webscout/Extra/YTToolkit/YTdownloader.py +14 -53
- webscout/Extra/YTToolkit/transcriber.py +12 -13
- webscout/Extra/YTToolkit/ytapi/video.py +0 -1
- webscout/Extra/__init__.py +0 -1
- webscout/Extra/autocoder/autocoder_utiles.py +0 -4
- webscout/Extra/autocoder/rawdog.py +13 -41
- webscout/Extra/gguf.py +652 -428
- webscout/Extra/weather.py +178 -156
- webscout/Extra/weather_ascii.py +70 -17
- webscout/Litlogger/core/logger.py +1 -2
- webscout/Litlogger/handlers/file.py +1 -1
- webscout/Litlogger/styles/formats.py +0 -2
- webscout/Litlogger/utils/detectors.py +0 -1
- webscout/Provider/AISEARCH/DeepFind.py +0 -1
- webscout/Provider/AISEARCH/ISou.py +1 -1
- webscout/Provider/AISEARCH/felo_search.py +0 -1
- webscout/Provider/AllenAI.py +24 -9
- webscout/Provider/C4ai.py +432 -0
- webscout/Provider/ChatGPTGratis.py +24 -56
- webscout/Provider/Cloudflare.py +18 -21
- webscout/Provider/DeepSeek.py +27 -48
- webscout/Provider/Deepinfra.py +129 -53
- webscout/Provider/Gemini.py +1 -1
- webscout/Provider/GithubChat.py +362 -0
- webscout/Provider/Glider.py +25 -8
- webscout/Provider/HF_space/qwen_qwen2.py +2 -2
- webscout/Provider/HeckAI.py +38 -5
- webscout/Provider/HuggingFaceChat.py +462 -0
- webscout/Provider/Jadve.py +20 -5
- webscout/Provider/Marcus.py +7 -50
- webscout/Provider/Netwrck.py +43 -67
- webscout/Provider/PI.py +4 -2
- webscout/Provider/Perplexitylabs.py +26 -6
- webscout/Provider/Phind.py +29 -3
- webscout/Provider/PizzaGPT.py +10 -51
- webscout/Provider/TTI/AiForce/async_aiforce.py +4 -37
- webscout/Provider/TTI/AiForce/sync_aiforce.py +41 -38
- webscout/Provider/TTI/FreeAIPlayground/__init__.py +9 -9
- webscout/Provider/TTI/FreeAIPlayground/async_freeaiplayground.py +206 -206
- webscout/Provider/TTI/FreeAIPlayground/sync_freeaiplayground.py +192 -192
- webscout/Provider/TTI/MagicStudio/__init__.py +2 -0
- webscout/Provider/TTI/MagicStudio/async_magicstudio.py +111 -0
- webscout/Provider/TTI/MagicStudio/sync_magicstudio.py +109 -0
- webscout/Provider/TTI/PollinationsAI/async_pollinations.py +5 -24
- webscout/Provider/TTI/PollinationsAI/sync_pollinations.py +2 -22
- webscout/Provider/TTI/__init__.py +2 -3
- webscout/Provider/TTI/aiarta/__init__.py +2 -0
- webscout/Provider/TTI/aiarta/async_aiarta.py +482 -0
- webscout/Provider/TTI/aiarta/sync_aiarta.py +440 -0
- webscout/Provider/TTI/fastflux/__init__.py +22 -0
- webscout/Provider/TTI/fastflux/async_fastflux.py +257 -0
- webscout/Provider/TTI/fastflux/sync_fastflux.py +247 -0
- webscout/Provider/TTS/__init__.py +2 -2
- webscout/Provider/TTS/deepgram.py +12 -39
- webscout/Provider/TTS/elevenlabs.py +14 -40
- webscout/Provider/TTS/gesserit.py +11 -35
- webscout/Provider/TTS/murfai.py +13 -39
- webscout/Provider/TTS/parler.py +17 -40
- webscout/Provider/TTS/speechma.py +180 -0
- webscout/Provider/TTS/streamElements.py +17 -44
- webscout/Provider/TextPollinationsAI.py +39 -59
- webscout/Provider/Venice.py +217 -200
- webscout/Provider/WiseCat.py +27 -5
- webscout/Provider/Youchat.py +63 -36
- webscout/Provider/__init__.py +13 -8
- webscout/Provider/akashgpt.py +28 -10
- webscout/Provider/copilot.py +416 -0
- webscout/Provider/flowith.py +196 -0
- webscout/Provider/freeaichat.py +32 -45
- webscout/Provider/granite.py +17 -53
- webscout/Provider/koala.py +20 -5
- webscout/Provider/llamatutor.py +7 -47
- webscout/Provider/llmchat.py +36 -53
- webscout/Provider/multichat.py +92 -98
- webscout/Provider/talkai.py +1 -0
- webscout/Provider/turboseek.py +3 -0
- webscout/Provider/tutorai.py +2 -0
- webscout/Provider/typegpt.py +154 -64
- webscout/Provider/x0gpt.py +3 -1
- webscout/Provider/yep.py +102 -20
- webscout/__init__.py +3 -0
- webscout/cli.py +4 -40
- webscout/conversation.py +1 -10
- webscout/exceptions.py +19 -9
- webscout/litagent/__init__.py +2 -2
- webscout/litagent/agent.py +351 -20
- webscout/litagent/constants.py +34 -5
- webscout/litprinter/__init__.py +0 -3
- webscout/models.py +181 -0
- webscout/optimizers.py +1 -1
- webscout/prompt_manager.py +2 -8
- webscout/scout/core/scout.py +1 -4
- webscout/scout/core/search_result.py +1 -1
- webscout/scout/core/text_utils.py +1 -1
- webscout/scout/core.py +2 -5
- webscout/scout/element.py +1 -1
- webscout/scout/parsers/html_parser.py +1 -1
- webscout/scout/utils.py +0 -1
- webscout/swiftcli/__init__.py +1 -3
- webscout/tempid.py +1 -1
- webscout/update_checker.py +55 -95
- webscout/version.py +1 -1
- webscout/webscout_search_async.py +1 -2
- webscout/yep_search.py +297 -297
- webscout-7.6.dist-info/LICENSE.md +146 -0
- {webscout-7.4.dist-info → webscout-7.6.dist-info}/METADATA +104 -514
- {webscout-7.4.dist-info → webscout-7.6.dist-info}/RECORD +113 -120
- webscout/Extra/autollama.py +0 -231
- webscout/Local/__init__.py +0 -10
- webscout/Local/_version.py +0 -3
- webscout/Local/formats.py +0 -747
- webscout/Local/model.py +0 -1368
- webscout/Local/samplers.py +0 -125
- webscout/Local/thread.py +0 -539
- webscout/Local/ui.py +0 -401
- webscout/Local/utils.py +0 -388
- webscout/Provider/Amigo.py +0 -274
- webscout/Provider/Bing.py +0 -243
- webscout/Provider/DiscordRocks.py +0 -253
- webscout/Provider/TTI/blackbox/__init__.py +0 -4
- webscout/Provider/TTI/blackbox/async_blackbox.py +0 -212
- webscout/Provider/TTI/blackbox/sync_blackbox.py +0 -199
- webscout/Provider/TTI/deepinfra/__init__.py +0 -4
- webscout/Provider/TTI/deepinfra/async_deepinfra.py +0 -227
- webscout/Provider/TTI/deepinfra/sync_deepinfra.py +0 -199
- webscout/Provider/TTI/imgninza/__init__.py +0 -4
- webscout/Provider/TTI/imgninza/async_ninza.py +0 -214
- webscout/Provider/TTI/imgninza/sync_ninza.py +0 -209
- webscout/Provider/TTS/voicepod.py +0 -117
- webscout/Provider/dgaf.py +0 -214
- webscout-7.4.dist-info/LICENSE.md +0 -211
- {webscout-7.4.dist-info → webscout-7.6.dist-info}/WHEEL +0 -0
- {webscout-7.4.dist-info → webscout-7.6.dist-info}/entry_points.txt +0 -0
- {webscout-7.4.dist-info → webscout-7.6.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
|
-
|
|
6
|
-
from
|
|
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
|
|
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.
|
|
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 =
|
|
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
|
-
|
|
278
|
+
print(f"[debug] Chunk {part_number} processed successfully")
|
|
288
279
|
return part_number, response.content
|
|
289
280
|
else:
|
|
290
281
|
if verbose:
|
|
291
|
-
|
|
282
|
+
print(f"[debug] No data received for chunk {part_number}. Retrying...")
|
|
292
283
|
except requests.RequestException as e:
|
|
293
284
|
if verbose:
|
|
294
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
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)}")
|