Skip to content

Commit a11a2fb

Browse files
committed
🇺🇸
1 parent f7f0ba3 commit a11a2fb

File tree

1 file changed

+16
-34
lines changed

1 file changed

+16
-34
lines changed

‎scripts/wtf.py

Lines changed: 16 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,19 @@
1-
import time
1+
from yaspin import yaspin
2+
3+
spinner = yaspin()
4+
spinner.start()
25

3-
start = time.time()
46
import os
57
import platform
68
import time
79

810
import pyperclip
911
from pynput.keyboard import Controller, Key
10-
from yaspin import yaspin
11-
from yaspin.spinners import Spinners
12-
13-
spinner = yaspin()
14-
spinner.start()
1512

1613
os.environ["LITELLM_LOCAL_MODEL_COST_MAP"] = "True"
1714
import litellm
1815

19-
SYSTEM_MESSAGE = """
16+
SYSTEM_MESSAGE = f"""
2017
# Terminal History Analysis Prompt
2118
2219
You are a fast, efficient AI assistant specialized in analyzing terminal history and providing quick solutions. Your task is to:
@@ -35,30 +32,12 @@
3532
- NEVER USE COMMENTS IN YOUR CODE.
3633
- Focus on the most recent error, ignoring earlier unrelated commands.
3734
- Prioritize speed and conciseness in your response. Don't use markdown headings. Don't say more than a sentence or two. Be incredibly concise.
35+
36+
User's System: {platform.system()}
37+
CWD: {os.getcwd()}
38+
{"Shell: " + os.environ.get('SHELL') if os.environ.get('SHELL') else ''}
39+
3840
"""
39-
'''
40-
import textwrap
41-
import shutil
42-
43-
def print_with_margins(text, margin=4):
44-
terminal_width = shutil.get_terminal_size().columns
45-
text_width = terminal_width - 2 * margin
46-
47-
wrapper = textwrap.TextWrapper(width=text_width)
48-
lines = text.split('\n')
49-
for line in lines:
50-
wrapped_lines = wrapper.wrap(line)
51-
for wrapped_line in wrapped_lines:
52-
print(' ' * margin + wrapped_line + ' ' * margin)
53-
54-
# Example usage
55-
print("")
56-
text = """\nThis is an example of text that will be printed with margins on either side.
57-
If the line is very long, it will be wrapped to fit within the specifieds very long, it will be wrapped to fit within the specifieds very long, it will be wrapped to fit within the specifieds very long, it will be wrapped to fit within the specifieds very long, it will be wrapped to fit within the specifieds very long, it will be wrapped to fit within the specified width based on the terminal size.\n"""
58-
print_with_margins(text, margin=4)
59-
print("")
60-
61-
'''
6241

6342

6443
def main():
@@ -133,14 +112,15 @@ def main():
133112
backtick_count = 0
134113
language_buffer = ""
135114

136-
start = None
115+
started = False
137116

138117
for chunk in litellm.completion(
139118
model="gpt-3.5-turbo", messages=messages, temperature=0, stream=True
140119
):
141-
if not start:
142-
start = time.time()
120+
if not started:
121+
started = True
143122
spinner.stop()
123+
print("")
144124

145125
content = chunk.choices[0].delta.content
146126
if content:
@@ -152,6 +132,8 @@ def main():
152132
backtick_count = 0
153133
language_buffer = ""
154134
if not in_code: # We've just exited a code block
135+
time.sleep(0.1)
136+
print("\n")
155137
return # Exit after typing the command
156138
else: # Entered code block
157139
print("Press `enter` to run: ", end="", flush=True)

0 commit comments

Comments
 (0)