webscout 6.4__py3-none-any.whl → 6.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/AIutel.py +7 -54
- webscout/DWEBS.py +48 -26
- webscout/{YTdownloader.py → Extra/YTToolkit/YTdownloader.py} +990 -1103
- webscout/Extra/YTToolkit/__init__.py +3 -0
- webscout/{transcriber.py → Extra/YTToolkit/transcriber.py} +1 -1
- webscout/Extra/YTToolkit/ytapi/__init__.py +6 -0
- webscout/Extra/YTToolkit/ytapi/channel.py +307 -0
- webscout/Extra/YTToolkit/ytapi/errors.py +13 -0
- webscout/Extra/YTToolkit/ytapi/extras.py +45 -0
- webscout/Extra/YTToolkit/ytapi/https.py +88 -0
- webscout/Extra/YTToolkit/ytapi/patterns.py +61 -0
- webscout/Extra/YTToolkit/ytapi/playlist.py +59 -0
- webscout/Extra/YTToolkit/ytapi/pool.py +8 -0
- webscout/Extra/YTToolkit/ytapi/query.py +37 -0
- webscout/Extra/YTToolkit/ytapi/stream.py +60 -0
- webscout/Extra/YTToolkit/ytapi/utils.py +62 -0
- webscout/Extra/YTToolkit/ytapi/video.py +102 -0
- webscout/Extra/__init__.py +2 -1
- webscout/Extra/autocoder/autocoder_utiles.py +119 -101
- webscout/Extra/autocoder/rawdog.py +679 -680
- webscout/Extra/gguf.py +441 -441
- webscout/Extra/markdownlite/__init__.py +862 -0
- webscout/Extra/weather_ascii.py +2 -2
- webscout/Provider/AISEARCH/__init__.py +2 -0
- webscout/Provider/AISEARCH/ooai.py +155 -0
- webscout/Provider/Amigo.py +70 -85
- webscout/Provider/{prefind.py → Jadve.py} +72 -70
- webscout/Provider/Netwrck.py +235 -0
- webscout/Provider/Openai.py +4 -3
- webscout/Provider/PI.py +292 -221
- webscout/Provider/PizzaGPT.py +3 -3
- webscout/Provider/Reka.py +0 -1
- webscout/Provider/TTS/__init__.py +5 -1
- webscout/Provider/TTS/deepgram.py +183 -0
- webscout/Provider/TTS/elevenlabs.py +137 -0
- webscout/Provider/TTS/gesserit.py +151 -0
- webscout/Provider/TTS/murfai.py +139 -0
- webscout/Provider/TTS/parler.py +134 -107
- webscout/Provider/TTS/streamElements.py +360 -275
- webscout/Provider/TTS/utils.py +280 -0
- webscout/Provider/TTS/voicepod.py +116 -116
- webscout/Provider/TeachAnything.py +15 -2
- webscout/Provider/Youchat.py +42 -8
- webscout/Provider/__init__.py +8 -21
- webscout/Provider/meta.py +794 -779
- webscout/Provider/multichat.py +230 -0
- webscout/Provider/promptrefine.py +2 -2
- webscout/Provider/talkai.py +10 -13
- webscout/Provider/turboseek.py +5 -4
- webscout/Provider/tutorai.py +8 -112
- webscout/Provider/typegpt.py +5 -7
- webscout/Provider/x0gpt.py +81 -9
- webscout/Provider/yep.py +123 -361
- webscout/__init__.py +33 -28
- webscout/conversation.py +24 -9
- webscout/exceptions.py +188 -20
- webscout/litprinter/__init__.py +719 -831
- webscout/litprinter/colors.py +54 -0
- webscout/optimizers.py +420 -270
- webscout/prompt_manager.py +279 -279
- webscout/scout/__init__.py +8 -0
- webscout/scout/core/__init__.py +7 -0
- webscout/scout/core/crawler.py +140 -0
- webscout/scout/core/scout.py +571 -0
- webscout/scout/core/search_result.py +96 -0
- webscout/scout/core/text_analyzer.py +63 -0
- webscout/scout/core/text_utils.py +277 -0
- webscout/scout/core/web_analyzer.py +52 -0
- webscout/scout/core.py +884 -0
- webscout/scout/element.py +460 -0
- webscout/scout/parsers/__init__.py +69 -0
- webscout/scout/parsers/html5lib_parser.py +172 -0
- webscout/scout/parsers/html_parser.py +236 -0
- webscout/scout/parsers/lxml_parser.py +178 -0
- webscout/scout/utils.py +38 -0
- webscout/update_checker.py +184 -125
- webscout/version.py +1 -1
- webscout/zeroart/__init__.py +55 -0
- webscout/zeroart/base.py +60 -0
- webscout/zeroart/effects.py +99 -0
- webscout/zeroart/fonts.py +816 -0
- webscout/zerodir/__init__.py +225 -0
- {webscout-6.4.dist-info → webscout-6.6.dist-info}/METADATA +18 -231
- webscout-6.6.dist-info/RECORD +197 -0
- webscout-6.6.dist-info/top_level.txt +2 -0
- webstoken/__init__.py +30 -0
- webstoken/classifier.py +189 -0
- webstoken/keywords.py +216 -0
- webstoken/language.py +128 -0
- webstoken/ner.py +164 -0
- webstoken/normalizer.py +35 -0
- webstoken/processor.py +77 -0
- webstoken/sentiment.py +206 -0
- webstoken/stemmer.py +73 -0
- webstoken/t.py +75 -0
- webstoken/tagger.py +60 -0
- webstoken/tokenizer.py +158 -0
- webscout/Agents/Onlinesearcher.py +0 -182
- webscout/Agents/__init__.py +0 -2
- webscout/Agents/functioncall.py +0 -248
- webscout/Bing_search.py +0 -251
- webscout/Provider/Perplexity.py +0 -599
- webscout/Provider/RoboCoders.py +0 -206
- webscout/Provider/genspark.py +0 -225
- webscout/Provider/perplexitylabs.py +0 -265
- webscout/Provider/twitterclone.py +0 -251
- webscout/Provider/upstage.py +0 -230
- webscout/gpt4free.py +0 -666
- webscout/requestsHTMLfix.py +0 -775
- webscout/webai.py +0 -2590
- webscout-6.4.dist-info/RECORD +0 -154
- webscout-6.4.dist-info/top_level.txt +0 -1
- /webscout/Provider/{felo_search.py → AISEARCH/felo_search.py} +0 -0
- {webscout-6.4.dist-info → webscout-6.6.dist-info}/LICENSE.md +0 -0
- {webscout-6.4.dist-info → webscout-6.6.dist-info}/WHEEL +0 -0
- {webscout-6.4.dist-info → webscout-6.6.dist-info}/entry_points.txt +0 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import re
|
|
2
|
+
from typing import Dict, Any
|
|
3
|
+
|
|
4
|
+
from .pool import collect
|
|
5
|
+
from .https import video_data
|
|
6
|
+
from .patterns import _VideoPatterns as Patterns
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class Video:
|
|
10
|
+
|
|
11
|
+
_HEAD = 'https://www.youtube.com/watch?v='
|
|
12
|
+
|
|
13
|
+
def __init__(self, video_id: str):
|
|
14
|
+
pattern = re.compile('.be/(.*?)$|=(.*?)$|^(\w{11})$') # noqa
|
|
15
|
+
self._matched_id = (
|
|
16
|
+
pattern.search(video_id).group(1)
|
|
17
|
+
or pattern.search(video_id).group(2)
|
|
18
|
+
or pattern.search(video_id).group(3)
|
|
19
|
+
)
|
|
20
|
+
if self._matched_id:
|
|
21
|
+
self._url = self._HEAD + self._matched_id
|
|
22
|
+
self._video_data = video_data(self._matched_id)
|
|
23
|
+
else:
|
|
24
|
+
raise ValueError('invalid video id or url')
|
|
25
|
+
|
|
26
|
+
def __repr__(self):
|
|
27
|
+
return f'<Video {self._url}>'
|
|
28
|
+
|
|
29
|
+
@property
|
|
30
|
+
def metadata(self) -> Dict[str, Any]:
|
|
31
|
+
patterns = [
|
|
32
|
+
Patterns.title,
|
|
33
|
+
Patterns.views,
|
|
34
|
+
Patterns.likes,
|
|
35
|
+
Patterns.duration,
|
|
36
|
+
Patterns.author_id,
|
|
37
|
+
Patterns.upload_date,
|
|
38
|
+
Patterns.thumbnail,
|
|
39
|
+
Patterns.tags,
|
|
40
|
+
Patterns.description,
|
|
41
|
+
Patterns.is_streamed,
|
|
42
|
+
Patterns.is_premiered
|
|
43
|
+
]
|
|
44
|
+
ext = collect(lambda x: x.findall(self._video_data) or None, patterns)
|
|
45
|
+
data = [i[0] if i else i for i in ext]
|
|
46
|
+
return {
|
|
47
|
+
'title': data[0],
|
|
48
|
+
'id': self._matched_id,
|
|
49
|
+
'views': data[1][:-6] if data[1] else None,
|
|
50
|
+
'likes': data[2],
|
|
51
|
+
'streamed': data[9] is not None,
|
|
52
|
+
'premiered': data[10],
|
|
53
|
+
'duration': int(data[3]) / 1000 if data[3] else None,
|
|
54
|
+
'author': data[4],
|
|
55
|
+
'upload_date': data[5],
|
|
56
|
+
'url': self._url,
|
|
57
|
+
'thumbnail': data[6],
|
|
58
|
+
'tags': data[7].split(',') if data[7] else None,
|
|
59
|
+
'description': data[8].replace('\\n', '\n') if data[8] else None
|
|
60
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
from urllib.request import Request, urlopen
|
|
2
|
+
from collections import OrderedDict
|
|
3
|
+
from urllib.error import HTTPError
|
|
4
|
+
from .errors import TooManyRequests, InvalidURL, RequestError
|
|
5
|
+
from webscout.litagent import LitAgent
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
__all__ = ['dup_filter', 'request']
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
_USER_AGENT_GENERATOR = LitAgent()
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def request(url: str, retry_attempts: int = 3) -> str:
|
|
15
|
+
"""
|
|
16
|
+
Send a request with a random user agent and built-in retry mechanism.
|
|
17
|
+
|
|
18
|
+
Args:
|
|
19
|
+
url (str): The URL to request
|
|
20
|
+
retry_attempts (int, optional): Number of retry attempts. Defaults to 3.
|
|
21
|
+
|
|
22
|
+
Raises:
|
|
23
|
+
InvalidURL: If the URL cannot be found
|
|
24
|
+
TooManyRequests: If rate-limited
|
|
25
|
+
RequestError: For other request-related errors
|
|
26
|
+
|
|
27
|
+
Returns:
|
|
28
|
+
str: Decoded response content
|
|
29
|
+
"""
|
|
30
|
+
for attempt in range(retry_attempts):
|
|
31
|
+
try:
|
|
32
|
+
headers = {
|
|
33
|
+
"User-Agent": _USER_AGENT_GENERATOR.random()
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
req = Request(url, headers=headers)
|
|
37
|
+
response = urlopen(req)
|
|
38
|
+
return response.read().decode('utf-8')
|
|
39
|
+
|
|
40
|
+
except HTTPError as e:
|
|
41
|
+
if e.code == 404:
|
|
42
|
+
raise InvalidURL(f'Cannot find anything with the requested URL: {url}')
|
|
43
|
+
if e.code == 429:
|
|
44
|
+
raise TooManyRequests(f'Rate-limited on attempt {attempt + 1}')
|
|
45
|
+
|
|
46
|
+
if attempt == retry_attempts - 1:
|
|
47
|
+
raise RequestError(f'HTTP Error {e.code}: {e.reason}') from e
|
|
48
|
+
|
|
49
|
+
except Exception as e:
|
|
50
|
+
if attempt == retry_attempts - 1:
|
|
51
|
+
raise RequestError(f'Request failed: {e!r}') from None
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def dup_filter(iterable: list, limit: int = None) -> list:
|
|
55
|
+
if not iterable:
|
|
56
|
+
return []
|
|
57
|
+
lim = limit if limit else len(iterable)
|
|
58
|
+
converted = list(OrderedDict.fromkeys(iterable))
|
|
59
|
+
if len(converted) - lim > 0:
|
|
60
|
+
return converted[:-len(converted) + lim]
|
|
61
|
+
else:
|
|
62
|
+
return converted
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import re
|
|
2
|
+
import json
|
|
3
|
+
from .https import video_data
|
|
4
|
+
from typing import Dict, Any
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class Video:
|
|
8
|
+
|
|
9
|
+
_HEAD = 'https://www.youtube.com/watch?v='
|
|
10
|
+
|
|
11
|
+
def __init__(self, video_id: str):
|
|
12
|
+
"""
|
|
13
|
+
Represents a YouTube video
|
|
14
|
+
|
|
15
|
+
Parameters
|
|
16
|
+
----------
|
|
17
|
+
video_id : str
|
|
18
|
+
The id or url of the video
|
|
19
|
+
"""
|
|
20
|
+
pattern = re.compile('.be/(.*?)$|=(.*?)$|^(\w{11})$') # noqa
|
|
21
|
+
self._matched_id = (
|
|
22
|
+
pattern.search(video_id).group(1)
|
|
23
|
+
or pattern.search(video_id).group(2)
|
|
24
|
+
or pattern.search(video_id).group(3)
|
|
25
|
+
)
|
|
26
|
+
if self._matched_id:
|
|
27
|
+
self._url = self._HEAD + self._matched_id
|
|
28
|
+
self._video_data = video_data(self._matched_id)
|
|
29
|
+
else:
|
|
30
|
+
raise ValueError('invalid video id or url')
|
|
31
|
+
|
|
32
|
+
def __repr__(self):
|
|
33
|
+
return f'<Video {self._url}>'
|
|
34
|
+
|
|
35
|
+
@property
|
|
36
|
+
def metadata(self):
|
|
37
|
+
"""
|
|
38
|
+
Fetches video metadata in a dict format
|
|
39
|
+
|
|
40
|
+
Returns
|
|
41
|
+
-------
|
|
42
|
+
Dict
|
|
43
|
+
Video metadata in a dict format containing keys: title, id, views, duration, author_id,
|
|
44
|
+
upload_date, url, thumbnails, tags, description
|
|
45
|
+
"""
|
|
46
|
+
details_pattern = re.compile('videoDetails\":(.*?)\"isLiveContent\":.*?}')
|
|
47
|
+
upload_date_pattern = re.compile("<meta itemprop=\"uploadDate\" content=\"(.*?)\">")
|
|
48
|
+
genre_pattern = re.compile("<meta itemprop=\"genre\" content=\"(.*?)\">")
|
|
49
|
+
like_count_pattern = re.compile("iconType\":\"LIKE\"},\"defaultText\":(.*?)}}")
|
|
50
|
+
|
|
51
|
+
# Add robust error handling
|
|
52
|
+
raw_details_match = details_pattern.search(self._video_data)
|
|
53
|
+
if not raw_details_match:
|
|
54
|
+
# Fallback metadata for search results or incomplete video data
|
|
55
|
+
return {
|
|
56
|
+
'title': getattr(self, 'title', None),
|
|
57
|
+
'id': getattr(self, 'id', None),
|
|
58
|
+
'views': getattr(self, 'views', None),
|
|
59
|
+
'streamed': False,
|
|
60
|
+
'duration': None,
|
|
61
|
+
'author_id': None,
|
|
62
|
+
'upload_date': None,
|
|
63
|
+
'url': f"https://www.youtube.com/watch?v={getattr(self, 'id', '')}" if hasattr(self, 'id') else None,
|
|
64
|
+
'thumbnails': None,
|
|
65
|
+
'tags': None,
|
|
66
|
+
'description': None,
|
|
67
|
+
'likes': None,
|
|
68
|
+
'genre': None
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
raw_details = raw_details_match.group(0)
|
|
72
|
+
|
|
73
|
+
# Add None checking for upload_date
|
|
74
|
+
upload_date_match = upload_date_pattern.search(self._video_data)
|
|
75
|
+
upload_date = upload_date_match.group(1) if upload_date_match else None
|
|
76
|
+
|
|
77
|
+
metadata = json.loads(raw_details.replace('videoDetails\":', ''))
|
|
78
|
+
data = {
|
|
79
|
+
'title': metadata['title'],
|
|
80
|
+
'id': metadata['videoId'],
|
|
81
|
+
'views': metadata.get('viewCount'),
|
|
82
|
+
'streamed': metadata['isLiveContent'],
|
|
83
|
+
'duration': metadata['lengthSeconds'],
|
|
84
|
+
'author_id': metadata['channelId'],
|
|
85
|
+
'upload_date': upload_date,
|
|
86
|
+
'url': f"https://www.youtube.com/watch?v={metadata['videoId']}",
|
|
87
|
+
'thumbnails': metadata.get('thumbnail', {}).get('thumbnails'),
|
|
88
|
+
'tags': metadata.get('keywords'),
|
|
89
|
+
'description': metadata.get('shortDescription'),
|
|
90
|
+
}
|
|
91
|
+
try:
|
|
92
|
+
likes_count = like_count_pattern.search(self._video_data).group(1)
|
|
93
|
+
data['likes'] = json.loads(likes_count + '}}}')[
|
|
94
|
+
'accessibility'
|
|
95
|
+
]['accessibilityData']['label'].split(' ')[0].replace(',', '')
|
|
96
|
+
except (AttributeError, KeyError, json.decoder.JSONDecodeError):
|
|
97
|
+
data['likes'] = None
|
|
98
|
+
try:
|
|
99
|
+
data['genre'] = genre_pattern.search(self._video_data).group(1)
|
|
100
|
+
except AttributeError:
|
|
101
|
+
data['genre'] = None
|
|
102
|
+
return data
|
webscout/Extra/__init__.py
CHANGED
|
@@ -5,117 +5,135 @@ import platform
|
|
|
5
5
|
import datetime
|
|
6
6
|
import pygetwindow as gw
|
|
7
7
|
import sys
|
|
8
|
+
from typing import List, Optional
|
|
8
9
|
|
|
9
10
|
from webscout.optimizers import Optimizers
|
|
10
11
|
|
|
11
|
-
|
|
12
|
+
|
|
13
|
+
def get_current_app() -> str:
|
|
12
14
|
"""Get the current active application name."""
|
|
13
15
|
try:
|
|
14
|
-
active_window = gw.getActiveWindow()
|
|
16
|
+
active_window: Optional[gw.Window] = gw.getActiveWindow()
|
|
15
17
|
return f"{active_window.title if active_window else 'Unknown'}"
|
|
16
18
|
except Exception as e:
|
|
17
19
|
return "Unknown"
|
|
18
20
|
|
|
19
|
-
def get_intro_prompt():
|
|
20
|
-
"""Get the introduction prompt for the AutoCoder."""
|
|
21
|
-
current_app = get_current_app()
|
|
22
|
-
python_version = sys.version.split()[0]
|
|
23
|
-
|
|
24
|
-
return f"""
|
|
25
|
-
You are a command-line coding assistant called Rawdog that generates and auto-executes Python scripts.
|
|
26
|
-
|
|
27
|
-
A typical interaction goes like this:
|
|
28
|
-
1. The user gives you a natural language PROMPT.
|
|
29
|
-
2. You:
|
|
30
|
-
i. Determine what needs to be done
|
|
31
|
-
ii. Write a short Python SCRIPT to do it
|
|
32
|
-
iii. Communicate back to the user by printing to the console in that SCRIPT
|
|
33
|
-
3. The compiler extracts the script and then runs it using exec(). If there will be an exception raised,
|
|
34
|
-
it will be send back to you starting with "PREVIOUS SCRIPT EXCEPTION:".
|
|
35
|
-
4. In case of exception, regenerate error free script.
|
|
36
|
-
|
|
37
|
-
If you need to review script outputs before completing the task, you can print the word "CONTINUE" at the end of your SCRIPT.
|
|
38
|
-
This can be useful for summarizing documents or technical readouts, reading instructions before
|
|
39
|
-
deciding what to do, or other tasks that require multi-step reasoning.
|
|
40
|
-
A typical 'CONTINUE' interaction looks like this:
|
|
41
|
-
1. The user gives you a natural language PROMPT.
|
|
42
|
-
2. You:
|
|
43
|
-
i. Determine what needs to be done
|
|
44
|
-
ii. Determine that you need to see the output of some subprocess call to complete the task
|
|
45
|
-
iii. Write a short Python SCRIPT to print that and then print the word "CONTINUE"
|
|
46
|
-
3. The compiler
|
|
47
|
-
i. Checks and runs your SCRIPT
|
|
48
|
-
ii. Captures the output and appends it to the conversation as "LAST SCRIPT OUTPUT:"
|
|
49
|
-
iii. Finds the word "CONTINUE" and sends control back to you
|
|
50
|
-
4. You again:
|
|
51
|
-
i. Look at the original PROMPT + the "LAST SCRIPT OUTPUT:" to determine what needs to be done
|
|
52
|
-
ii. Write a short Python SCRIPT to do it
|
|
53
|
-
iii. Communicate back to the user by printing to the console in that SCRIPT
|
|
54
|
-
5. The compiler...
|
|
55
21
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
- If asked to do something, print a concise summary of what you've done as confirmation.
|
|
61
|
-
- If asked a question, respond in a friendly, conversational way. Use programmatically-generated and natural language responses as appropriate.
|
|
62
|
-
- If you need clarification, return a SCRIPT that prints your question. In the next interaction, continue based on the user's response.
|
|
63
|
-
- Assume the user would like something concise. For example rather than printing a massive table, filter or summarize it to what's likely of interest.
|
|
64
|
-
- Actively clean up any temporary processes or files you use.
|
|
65
|
-
- When looking through files, use git as available to skip files, and skip hidden files (.env, .git, etc) by default.
|
|
66
|
-
- You can plot anything with matplotlib.
|
|
67
|
-
- ALWAYS Return your SCRIPT inside of a single pair of ``` delimiters. Only the console output of the first such SCRIPT is visible to the user, so make sure that it's complete and don't bother returning anything else.
|
|
22
|
+
def get_intro_prompt(name: str = "Vortex") -> str:
|
|
23
|
+
"""Get the introduction prompt for the AutoCoder."""
|
|
24
|
+
current_app: str = get_current_app()
|
|
25
|
+
python_version: str = sys.version.split()[0]
|
|
68
26
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
-
|
|
73
|
-
|
|
74
|
-
|
|
27
|
+
return f"""
|
|
28
|
+
<system_context>
|
|
29
|
+
<purpose>
|
|
30
|
+
You are a command-line coding assistant named Rawdog, designed to generate and auto-execute Python scripts for {name}.
|
|
31
|
+
Your core function is to understand natural language requests, transform them into executable Python code,
|
|
32
|
+
and return results to the user via console output. You must adhere to all instructions.
|
|
33
|
+
</purpose>
|
|
34
|
+
|
|
35
|
+
<process_description>
|
|
36
|
+
A typical interaction unfolds as follows:
|
|
37
|
+
1. The user provides a natural language PROMPT.
|
|
38
|
+
2. You:
|
|
39
|
+
i. Analyze the PROMPT to determine required actions.
|
|
40
|
+
ii. Craft a short Python SCRIPT to execute those actions.
|
|
41
|
+
iii. Provide clear and concise feedback to the user by printing to the console within your SCRIPT.
|
|
42
|
+
3. The compiler will then:
|
|
43
|
+
i. Extract and execute the SCRIPT using exec().
|
|
44
|
+
ii. Handle any exceptions that arise during script execution. Exceptions are returned to you starting with "PREVIOUS SCRIPT EXCEPTION:".
|
|
45
|
+
4. In cases of exceptions, ensure that you regenerate the script and return one that has no errors.
|
|
46
|
+
|
|
47
|
+
<continue_process>
|
|
48
|
+
If you need to review script outputs before task completion, include the word "CONTINUE" at the end of your SCRIPT.
|
|
49
|
+
This allows multi-step reasoning for tasks like summarizing documents, reviewing instructions, or performing other multi-part operations.
|
|
50
|
+
A typical 'CONTINUE' interaction looks like this:
|
|
51
|
+
1. The user gives you a natural language PROMPT.
|
|
52
|
+
2. You:
|
|
53
|
+
i. Determine what needs to be done.
|
|
54
|
+
ii. Determine that you need to see the output of some subprocess call to complete the task
|
|
55
|
+
iii. Write a short Python SCRIPT to print that and then print the word "CONTINUE"
|
|
56
|
+
3. The compiler will:
|
|
57
|
+
i. Check and run your SCRIPT.
|
|
58
|
+
ii. Capture the output and append it to the conversation as "LAST SCRIPT OUTPUT:".
|
|
59
|
+
iii. Find the word "CONTINUE" and return control back to you.
|
|
60
|
+
4. You will then:
|
|
61
|
+
i. Review the original PROMPT + the "LAST SCRIPT OUTPUT:" to determine what to do
|
|
62
|
+
ii. Write a short Python SCRIPT to complete the task.
|
|
63
|
+
iii. Communicate back to the user by printing to the console in that SCRIPT.
|
|
64
|
+
5. The compiler repeats the above process...
|
|
65
|
+
</continue_process>
|
|
66
|
+
|
|
67
|
+
</process_description>
|
|
68
|
+
|
|
69
|
+
<conventions>
|
|
70
|
+
- Decline any tasks that seem dangerous, irreversible, or that you don't understand.
|
|
71
|
+
- Always review the full conversation prior to answering and maintain continuity.
|
|
72
|
+
- If asked for information, just print the information clearly and concisely.
|
|
73
|
+
- If asked to do something, print a concise summary of what you've done as confirmation.
|
|
74
|
+
- If asked a question, respond in a friendly, conversational way. Use programmatically-generated and natural language responses as appropriate.
|
|
75
|
+
- If you need clarification, return a SCRIPT that prints your question. In the next interaction, continue based on the user's response.
|
|
76
|
+
- Assume the user would like something concise. For example rather than printing a massive table, filter or summarize it to what's likely of interest.
|
|
77
|
+
- Actively clean up any temporary processes or files you use.
|
|
78
|
+
- When looking through files, use git as available to skip files, and skip hidden files (.env, .git, etc) by default.
|
|
79
|
+
- You can plot anything with matplotlib.
|
|
80
|
+
- **IMPORTANT**: ALWAYS Return your SCRIPT inside of a single pair of \`\`\` delimiters. Only the console output of the first such SCRIPT is visible to the user, so make sure that it's complete and don't bother returning anything else.
|
|
81
|
+
</conventions>
|
|
82
|
+
|
|
83
|
+
<environment_info>
|
|
84
|
+
- System: {platform.system()}
|
|
85
|
+
- Python: {python_version}
|
|
86
|
+
- Directory: {os.getcwd()}
|
|
87
|
+
- Datetime: {datetime.datetime.now()}
|
|
88
|
+
- Active App: {current_app}
|
|
89
|
+
</environment_info>
|
|
90
|
+
</system_context>
|
|
75
91
|
"""
|
|
76
92
|
|
|
77
|
-
EXAMPLES = """
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
files
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
```python
|
|
116
|
-
from webscout import weather as w
|
|
117
|
-
weather = w.get("Qazigund")
|
|
118
|
-
w.print_weather(weather)
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
|
|
93
|
+
EXAMPLES: str = """
|
|
94
|
+
<examples>
|
|
95
|
+
<example>
|
|
96
|
+
<user_request>Kill the process running on port 3000</user_request>
|
|
97
|
+
<rawdog_response>
|
|
98
|
+
```python
|
|
99
|
+
import os
|
|
100
|
+
os.system("kill $(lsof -t -i:3000)")
|
|
101
|
+
print("Process killed")
|
|
102
|
+
```
|
|
103
|
+
</rawdog_response>
|
|
104
|
+
</example>
|
|
105
|
+
<example>
|
|
106
|
+
<user_request>Summarize my essay</user_request>
|
|
107
|
+
<rawdog_response>
|
|
108
|
+
```python
|
|
109
|
+
import glob
|
|
110
|
+
files = glob.glob("*essay*.*")
|
|
111
|
+
with open(files[0], "r") as f:
|
|
112
|
+
print(f.read())
|
|
113
|
+
```
|
|
114
|
+
CONTINUE
|
|
115
|
+
</rawdog_response>
|
|
116
|
+
<user_response>
|
|
117
|
+
LAST SCRIPT OUTPUT:
|
|
118
|
+
John Smith
|
|
119
|
+
Essay 2021-09-01
|
|
120
|
+
...
|
|
121
|
+
</user_response>
|
|
122
|
+
<rawdog_response>
|
|
123
|
+
```python
|
|
124
|
+
print("The essay is about...")
|
|
125
|
+
```
|
|
126
|
+
</rawdog_response>
|
|
127
|
+
</example>
|
|
128
|
+
<example>
|
|
129
|
+
<user_request>Weather in qazigund</user_request>
|
|
130
|
+
<rawdog_response>
|
|
131
|
+
```python
|
|
132
|
+
from webscout import weather as w
|
|
133
|
+
weather = w.get("Qazigund")
|
|
134
|
+
w.print_weather(weather)
|
|
135
|
+
```
|
|
136
|
+
</rawdog_response>
|
|
137
|
+
</example>
|
|
138
|
+
</examples>
|
|
139
|
+
"""
|