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
|
@@ -1,27 +1,24 @@
|
|
|
1
1
|
from datetime import datetime
|
|
2
2
|
import json
|
|
3
|
-
from webscout.Litlogger import Logger
|
|
4
3
|
from webscout.litagent import LitAgent
|
|
5
4
|
from time import sleep
|
|
6
5
|
import requests
|
|
7
6
|
from tqdm import tqdm
|
|
8
7
|
from colorama import Fore
|
|
9
|
-
from os import makedirs, path, getcwd
|
|
8
|
+
from os import makedirs, path, getcwd
|
|
10
9
|
from threading import Thread
|
|
11
|
-
from sys import stdout
|
|
12
10
|
import os
|
|
13
11
|
import subprocess
|
|
14
12
|
import sys
|
|
15
13
|
import tempfile
|
|
16
14
|
from webscout.version import __prog__, __version__
|
|
17
|
-
from webscout.swiftcli import CLI, option, argument
|
|
15
|
+
from webscout.swiftcli import CLI, option, argument
|
|
18
16
|
|
|
19
17
|
# Define cache directory using tempfile
|
|
20
18
|
user_cache_dir = os.path.join(tempfile.gettempdir(), 'webscout')
|
|
21
19
|
if not os.path.exists(user_cache_dir):
|
|
22
20
|
os.makedirs(user_cache_dir)
|
|
23
21
|
|
|
24
|
-
logging = Logger(name="YTDownloader")
|
|
25
22
|
|
|
26
23
|
session = requests.session()
|
|
27
24
|
|
|
@@ -63,13 +60,10 @@ class utils:
|
|
|
63
60
|
return func(*args, **kwargs)
|
|
64
61
|
except KeyboardInterrupt as e:
|
|
65
62
|
print()
|
|
66
|
-
logging.info(f"^KeyboardInterrupt quitting. Goodbye!")
|
|
67
63
|
exit(1)
|
|
68
64
|
except Exception as e:
|
|
69
65
|
if log:
|
|
70
|
-
|
|
71
|
-
logging.debug(f"Function ({func.__name__}) : {get_excep(e)}")
|
|
72
|
-
logging.error(get_excep(e))
|
|
66
|
+
raise(f"Error - {get_excep(e)}")
|
|
73
67
|
if exit_on_error:
|
|
74
68
|
exit(1)
|
|
75
69
|
|
|
@@ -110,7 +104,7 @@ class utils:
|
|
|
110
104
|
with open(history_path, "w") as fh:
|
|
111
105
|
json.dump({__prog__: saved_data}, fh, indent=4)
|
|
112
106
|
except Exception as e:
|
|
113
|
-
|
|
107
|
+
pass
|
|
114
108
|
|
|
115
109
|
@staticmethod
|
|
116
110
|
def get_history(dump: bool = False) -> list:
|
|
@@ -133,7 +127,6 @@ class utils:
|
|
|
133
127
|
resp.append(entry.get("vid"))
|
|
134
128
|
return resp
|
|
135
129
|
except Exception as e:
|
|
136
|
-
logging.error(f"Failed to load history - {get_excep(e)}")
|
|
137
130
|
return []
|
|
138
131
|
|
|
139
132
|
|
|
@@ -185,7 +178,6 @@ class first_query:
|
|
|
185
178
|
:param timeout: (Optional) Http requests timeout
|
|
186
179
|
:type timeout: int
|
|
187
180
|
"""
|
|
188
|
-
logging.debug(f"Making first query : {self.payload.get('k_query')}")
|
|
189
181
|
okay_status, resp = utils.post(self.url, data=self.payload, timeout=timeout)
|
|
190
182
|
# print(resp.headers["content-type"])
|
|
191
183
|
# print(resp.content)
|
|
@@ -197,8 +189,9 @@ class first_query:
|
|
|
197
189
|
self.is_link = not hasattr(self, "vitems")
|
|
198
190
|
self.processed = True
|
|
199
191
|
else:
|
|
200
|
-
|
|
201
|
-
|
|
192
|
+
raise Exception(
|
|
193
|
+
f"First query failed - [{resp.status_code} : {resp.reason}]"
|
|
194
|
+
)
|
|
202
195
|
return self
|
|
203
196
|
|
|
204
197
|
|
|
@@ -321,9 +314,6 @@ class second_query:
|
|
|
321
314
|
self.__setattr__("raw", dict_data)
|
|
322
315
|
self.processed = True
|
|
323
316
|
|
|
324
|
-
else:
|
|
325
|
-
logging.debug(f"{resp.headers.get('content-type')} - {resp.content}")
|
|
326
|
-
logging.error(f"Second query failed - [{resp.status_code} : {resp.reason}]")
|
|
327
317
|
return self
|
|
328
318
|
|
|
329
319
|
|
|
@@ -430,9 +420,6 @@ class third_query:
|
|
|
430
420
|
if repeat_count >= 4:
|
|
431
421
|
return (False, {})
|
|
432
422
|
else:
|
|
433
|
-
logging.debug(
|
|
434
|
-
f"Converting video : sleeping for 5s - round {repeat_count+1}"
|
|
435
|
-
)
|
|
436
423
|
sleep(5)
|
|
437
424
|
repeat_count += 1
|
|
438
425
|
return hunter_manager(souped_entry)
|
|
@@ -447,15 +434,8 @@ class third_query:
|
|
|
447
434
|
return resp_data
|
|
448
435
|
|
|
449
436
|
else:
|
|
450
|
-
logging.debug(f"{resp.headers.get('content-type')} - {resp.content}")
|
|
451
|
-
logging.error(
|
|
452
|
-
f"Third query failed - [{resp.status_code} : {resp.reason}]"
|
|
453
|
-
)
|
|
454
437
|
return {}
|
|
455
438
|
else:
|
|
456
|
-
logging.error(
|
|
457
|
-
f"Zero media hunted with params : {{quality : {quality}, format : {format} }}"
|
|
458
|
-
)
|
|
459
439
|
return {}
|
|
460
440
|
|
|
461
441
|
|
|
@@ -567,16 +547,10 @@ class Handler:
|
|
|
567
547
|
if query_2.vid in self.dropped:
|
|
568
548
|
continue
|
|
569
549
|
if self.author and not self.author.lower() in query_2.a.lower():
|
|
570
|
-
logging.warning(
|
|
571
|
-
f"Dropping {Fore.YELLOW+query_2.title+Fore.RESET} by {Fore.RED+query_2.a+Fore.RESET}"
|
|
572
|
-
)
|
|
573
550
|
continue
|
|
574
551
|
else:
|
|
575
552
|
yes_download, reason = self.__verify_item(query_2)
|
|
576
553
|
if not yes_download:
|
|
577
|
-
logging.warning(
|
|
578
|
-
f"Skipping {Fore.YELLOW+query_2.title+Fore.RESET} by {Fore.MAGENTA+query_2.a+Fore.RESET} - Reason : {Fore.BLUE+reason+Fore.RESET}"
|
|
579
|
-
)
|
|
580
554
|
self.dropped.append(query_2.vid)
|
|
581
555
|
continue
|
|
582
556
|
self.related.append(query_2.related)
|
|
@@ -585,9 +559,10 @@ class Handler:
|
|
|
585
559
|
if x >= self.total:
|
|
586
560
|
break
|
|
587
561
|
else:
|
|
588
|
-
|
|
562
|
+
print(
|
|
589
563
|
f"Dropping unprocessed query_two object of index {x}"
|
|
590
564
|
)
|
|
565
|
+
yield
|
|
591
566
|
|
|
592
567
|
else:
|
|
593
568
|
query_2 = init_query_two.main(timeout=self.timeout)
|
|
@@ -606,16 +581,11 @@ class Handler:
|
|
|
606
581
|
self.author
|
|
607
582
|
and not self.author.lower() in query_2.a.lower()
|
|
608
583
|
):
|
|
609
|
-
logging.warning(
|
|
610
|
-
f"Dropping {Fore.YELLOW+query_2.title+Fore.RESET} by {Fore.RED+query_2.a+Fore.RESET}"
|
|
611
|
-
)
|
|
612
584
|
continue
|
|
613
585
|
else:
|
|
614
586
|
yes_download, reason = self.__verify_item(query_2)
|
|
615
587
|
if not yes_download:
|
|
616
|
-
|
|
617
|
-
f"Skipping {Fore.YELLOW+query_2.title+Fore.RESET} by {Fore.MAGENTA+query_2.a+Fore.RESET} - Reason : {Fore.BLUE+reason+Fore.RESET}"
|
|
618
|
-
)
|
|
588
|
+
|
|
619
589
|
self.dropped.append(query_2.vid)
|
|
620
590
|
continue
|
|
621
591
|
|
|
@@ -625,12 +595,8 @@ class Handler:
|
|
|
625
595
|
if x >= self.total:
|
|
626
596
|
break
|
|
627
597
|
else:
|
|
628
|
-
logging.warning(
|
|
629
|
-
f"Dropping unprocessed query_two object of index {x}"
|
|
630
|
-
)
|
|
631
598
|
yield
|
|
632
599
|
else:
|
|
633
|
-
logging.warning("Dropping unprocessed query_two object")
|
|
634
600
|
yield
|
|
635
601
|
|
|
636
602
|
def run(
|
|
@@ -670,8 +636,7 @@ class Handler:
|
|
|
670
636
|
timeout=self.timeout,
|
|
671
637
|
)
|
|
672
638
|
)
|
|
673
|
-
|
|
674
|
-
logging.error(f"Empty object - {query_two_obj}")
|
|
639
|
+
|
|
675
640
|
|
|
676
641
|
def generate_filename(self, third_dict: dict, naming_format: str = None) -> str:
|
|
677
642
|
r"""Generate filename based on the response of `third_query`
|
|
@@ -760,9 +725,6 @@ class Handler:
|
|
|
760
725
|
t1.start()
|
|
761
726
|
thread_count = x + 1
|
|
762
727
|
if thread_count % self.thread == 0 or thread_count == self.total:
|
|
763
|
-
logging.debug(
|
|
764
|
-
f"Waiting for current running threads to finish - thread_count : {thread_count}"
|
|
765
|
-
)
|
|
766
728
|
t1.join()
|
|
767
729
|
else:
|
|
768
730
|
self.save(
|
|
@@ -814,7 +776,7 @@ class Handler:
|
|
|
814
776
|
"dlink"
|
|
815
777
|
), "The video selected does not support that quality, try lower qualities."
|
|
816
778
|
if third_dict.get("mess"):
|
|
817
|
-
|
|
779
|
+
pass
|
|
818
780
|
|
|
819
781
|
current_downloaded_size = 0
|
|
820
782
|
current_downloaded_size_in_mb = 0
|
|
@@ -892,10 +854,9 @@ class Handler:
|
|
|
892
854
|
utils.add_history(third_dict)
|
|
893
855
|
|
|
894
856
|
try_play_media()
|
|
895
|
-
|
|
857
|
+
|
|
896
858
|
return save_to
|
|
897
|
-
|
|
898
|
-
logging.error(f"Empty `third_dict` parameter parsed : {third_dict}")
|
|
859
|
+
|
|
899
860
|
|
|
900
861
|
|
|
901
862
|
mp4_qualities = [
|
|
@@ -6,23 +6,22 @@
|
|
|
6
6
|
|
|
7
7
|
"""
|
|
8
8
|
|
|
9
|
-
import requests
|
|
10
|
-
import http.cookiejar as cookiejar
|
|
11
|
-
import json
|
|
12
|
-
from xml.etree import ElementTree
|
|
13
|
-
import re
|
|
14
|
-
import html
|
|
15
|
-
from typing import List, Dict, Union, Optional
|
|
16
|
-
from functools import lru_cache #
|
|
17
|
-
from concurrent.futures import ThreadPoolExecutor
|
|
18
|
-
import
|
|
19
|
-
from webscout.exceptions import * # All our custom exceptions 🛠️
|
|
9
|
+
import requests
|
|
10
|
+
import http.cookiejar as cookiejar
|
|
11
|
+
import json
|
|
12
|
+
from xml.etree import ElementTree
|
|
13
|
+
import re
|
|
14
|
+
import html
|
|
15
|
+
from typing import List, Dict, Union, Optional
|
|
16
|
+
from functools import lru_cache #
|
|
17
|
+
from concurrent.futures import ThreadPoolExecutor
|
|
18
|
+
from webscout.exceptions import *
|
|
20
19
|
|
|
21
20
|
WATCH_URL = 'https://www.youtube.com/watch?v={video_id}'
|
|
22
|
-
MAX_WORKERS = 4
|
|
21
|
+
MAX_WORKERS = 4
|
|
23
22
|
|
|
24
23
|
class YTTranscriber:
|
|
25
|
-
"""
|
|
24
|
+
"""Transcribe YouTube videos with style! 🎤
|
|
26
25
|
|
|
27
26
|
>>> transcript = YTTranscriber.get_transcript('https://youtu.be/dQw4w9WgXcQ')
|
|
28
27
|
>>> print(transcript[0]['text'])
|
webscout/Extra/__init__.py
CHANGED
|
@@ -4,33 +4,23 @@ import os
|
|
|
4
4
|
import re
|
|
5
5
|
import sys
|
|
6
6
|
import queue
|
|
7
|
+
import tempfile
|
|
7
8
|
import threading
|
|
8
|
-
import platform
|
|
9
|
-
import datetime
|
|
10
9
|
import subprocess
|
|
11
|
-
import pygetwindow as gw
|
|
12
|
-
from rich import print as rprint
|
|
13
10
|
from rich.panel import Panel
|
|
14
11
|
from rich.syntax import Syntax
|
|
15
12
|
from rich.console import Console, Group
|
|
16
13
|
from rich.markdown import Markdown
|
|
17
14
|
from rich.table import Table
|
|
18
|
-
from rich.style import Style
|
|
19
15
|
from rich.theme import Theme
|
|
20
16
|
from rich.live import Live
|
|
21
|
-
from rich.status import Status
|
|
22
17
|
from rich.rule import Rule
|
|
23
|
-
from typing import Optional,
|
|
24
|
-
from webscout.AIutel import run_system_command
|
|
25
|
-
from webscout import Logger, LogFormat
|
|
18
|
+
from typing import Optional, Generator, List, Tuple
|
|
19
|
+
from webscout.AIutel import run_system_command
|
|
26
20
|
from .autocoder_utiles import EXAMPLES, get_intro_prompt
|
|
27
21
|
|
|
28
22
|
# Initialize LitLogger with custom format and colors
|
|
29
|
-
|
|
30
|
-
name="RawDog",
|
|
31
|
-
format=LogFormat.MODERN_EMOJI,
|
|
32
|
-
|
|
33
|
-
)
|
|
23
|
+
default_path = tempfile.mkdtemp(prefix="webscout_autocoder")
|
|
34
24
|
|
|
35
25
|
# Custom theme for consistent styling
|
|
36
26
|
CUSTOM_THEME = Theme({
|
|
@@ -96,11 +86,6 @@ class AutoCoder:
|
|
|
96
86
|
self.ai_instance = ai_instance
|
|
97
87
|
|
|
98
88
|
# Initialize logger with modern format and cyberpunk colors
|
|
99
|
-
self.logger = Logger(
|
|
100
|
-
name="AutoCoder",
|
|
101
|
-
format=LogFormat.MODERN_EMOJI,
|
|
102
|
-
|
|
103
|
-
)
|
|
104
89
|
|
|
105
90
|
# Get Python version with enhanced logging
|
|
106
91
|
self.logger.info("Initializing AutoCoder...")
|
|
@@ -119,19 +104,6 @@ class AutoCoder:
|
|
|
119
104
|
|
|
120
105
|
self.logger.success("AutoCoder initialized successfully!")
|
|
121
106
|
|
|
122
|
-
def get_current_app(self) -> str:
|
|
123
|
-
"""Get the name of the currently active application.
|
|
124
|
-
|
|
125
|
-
Returns:
|
|
126
|
-
str: Name of the active window or "Unknown"
|
|
127
|
-
"""
|
|
128
|
-
try:
|
|
129
|
-
active_window = gw.getActiveWindow()
|
|
130
|
-
if active_window:
|
|
131
|
-
return active_window.title
|
|
132
|
-
except Exception as e:
|
|
133
|
-
self.logger.error(f"Error getting active window: {e}")
|
|
134
|
-
return "Unknown"
|
|
135
107
|
|
|
136
108
|
def _extract_code_blocks(self, response: str) -> List[Tuple[str, str]]:
|
|
137
109
|
"""Extract code blocks from a response string.
|
|
@@ -454,19 +426,19 @@ Please fix the code to handle this error. Provide only the corrected code withou
|
|
|
454
426
|
"""
|
|
455
427
|
missing_package = str(error).split("'")[1] if "'" in str(error) else str(error).split()[3]
|
|
456
428
|
try:
|
|
457
|
-
|
|
429
|
+
print(f"Installing missing package: {missing_package}")
|
|
458
430
|
result = subprocess.run(
|
|
459
431
|
[sys.executable, "-m", "pip", "install", missing_package],
|
|
460
432
|
capture_output=True,
|
|
461
433
|
text=True
|
|
462
434
|
)
|
|
463
435
|
if result.returncode == 0:
|
|
464
|
-
|
|
436
|
+
print(f"Successfully installed {missing_package}")
|
|
465
437
|
return code # Retry with same code after installing package
|
|
466
438
|
else:
|
|
467
439
|
raise Exception(f"Failed to install {missing_package}: {result.stderr}")
|
|
468
440
|
except Exception as e:
|
|
469
|
-
|
|
441
|
+
print(f"Error installing package: {str(e)}")
|
|
470
442
|
return None
|
|
471
443
|
|
|
472
444
|
def _is_similar_solution(self, new_code: str, threshold: float = 0.8) -> bool:
|
|
@@ -514,7 +486,7 @@ Please fix the code to handle this error. Provide only the corrected code withou
|
|
|
514
486
|
ai_instance = self.ai_instance or globals().get('ai')
|
|
515
487
|
|
|
516
488
|
if not ai_instance:
|
|
517
|
-
|
|
489
|
+
print("AI instance not found, error correction disabled")
|
|
518
490
|
try:
|
|
519
491
|
if self.path_to_script:
|
|
520
492
|
script_dir = os.path.dirname(self.path_to_script)
|
|
@@ -524,10 +496,10 @@ Please fix the code to handle this error. Provide only the corrected code withou
|
|
|
524
496
|
f.write(code)
|
|
525
497
|
|
|
526
498
|
if self.internal_exec:
|
|
527
|
-
|
|
499
|
+
print("[INFO] Executing code internally")
|
|
528
500
|
exec(code, globals())
|
|
529
501
|
else:
|
|
530
|
-
|
|
502
|
+
print("[INFO] Executing code as external process")
|
|
531
503
|
result = subprocess.run(
|
|
532
504
|
[self.interpreter, self.path_to_script],
|
|
533
505
|
capture_output=True,
|
|
@@ -537,7 +509,7 @@ Please fix the code to handle this error. Provide only the corrected code withou
|
|
|
537
509
|
raise Exception(result.stderr or result.stdout)
|
|
538
510
|
return None
|
|
539
511
|
except Exception as e:
|
|
540
|
-
|
|
512
|
+
print(f"Execution error: {str(e)}")
|
|
541
513
|
|
|
542
514
|
return self._execute_with_retry(code, ai_instance)
|
|
543
515
|
|
|
@@ -562,9 +534,9 @@ Please fix the code to handle this error. Provide only the corrected code withou
|
|
|
562
534
|
|
|
563
535
|
message = "[Webscout] - " + message
|
|
564
536
|
if category == "error":
|
|
565
|
-
|
|
537
|
+
print(f"[ERROR] {message}")
|
|
566
538
|
else:
|
|
567
|
-
|
|
539
|
+
print(message)
|
|
568
540
|
|
|
569
541
|
def stdout(self, message: str, style: str = "info") -> None:
|
|
570
542
|
"""Enhanced stdout with Rich formatting.
|