Skip to content

Commit 7e097bb

Browse files
committed
New interpreter --os powered by Anthropic
1 parent fffb575 commit 7e097bb

File tree

13 files changed

+1630
-16
lines changed

13 files changed

+1630
-16
lines changed

interpreter/__init__.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,59 @@
1+
import sys
2+
3+
if "--os" in sys.argv:
4+
from rich import print as rich_print
5+
from rich.markdown import Markdown
6+
from rich.rule import Rule
7+
8+
def print_markdown(message):
9+
"""
10+
Display markdown message. Works with multiline strings with lots of indentation.
11+
Will automatically make single line > tags beautiful.
12+
"""
13+
14+
for line in message.split("\n"):
15+
line = line.strip()
16+
if line == "":
17+
print("")
18+
elif line == "---":
19+
rich_print(Rule(style="white"))
20+
else:
21+
try:
22+
rich_print(Markdown(line))
23+
except UnicodeEncodeError as e:
24+
# Replace the problematic character or handle the error as needed
25+
print("Error displaying line:", line)
26+
27+
if "\n" not in message and message.startswith(">"):
28+
# Aesthetic choice. For these tags, they need a space below them
29+
print("")
30+
31+
import pkg_resources
32+
import requests
33+
from packaging import version
34+
35+
def check_for_update():
36+
# Fetch the latest version from the PyPI API
37+
response = requests.get(f"https://pypi.org/pypi/open-interpreter/json")
38+
latest_version = response.json()["info"]["version"]
39+
40+
# Get the current version using pkg_resources
41+
current_version = pkg_resources.get_distribution("open-interpreter").version
42+
43+
return version.parse(latest_version) > version.parse(current_version)
44+
45+
if check_for_update():
46+
print_markdown(
47+
"> **A new version of Open Interpreter is available.**\n>Please run: `pip install --upgrade open-interpreter`\n\n---"
48+
)
49+
50+
if "--voice" in sys.argv:
51+
print("Coming soon...")
52+
from .computer_use.loop import run_async_main
53+
54+
run_async_main()
55+
exit()
56+
157
from .core.async_core import AsyncInterpreter
258
from .core.computer.terminal.base_language import BaseLanguage
359
from .core.core import OpenInterpreter

interpreter/computer_use/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)