Skip to content

Commit

Permalink
New interpreter --os powered by Anthropic
Browse files Browse the repository at this point in the history
  • Loading branch information
KillianLucas committed Oct 23, 2024
1 parent fffb575 commit 7e097bb
Show file tree
Hide file tree
Showing 13 changed files with 1,630 additions and 16 deletions.
56 changes: 56 additions & 0 deletions interpreter/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,59 @@
import sys

if "--os" in sys.argv:
from rich import print as rich_print
from rich.markdown import Markdown
from rich.rule import Rule

def print_markdown(message):
"""
Display markdown message. Works with multiline strings with lots of indentation.
Will automatically make single line > tags beautiful.
"""

for line in message.split("\n"):
line = line.strip()
if line == "":
print("")
elif line == "---":
rich_print(Rule(style="white"))
else:
try:
rich_print(Markdown(line))
except UnicodeEncodeError as e:
# Replace the problematic character or handle the error as needed
print("Error displaying line:", line)

if "\n" not in message and message.startswith(">"):
# Aesthetic choice. For these tags, they need a space below them
print("")

import pkg_resources
import requests
from packaging import version

def check_for_update():
# Fetch the latest version from the PyPI API
response = requests.get(f"https://pypi.org/pypi/open-interpreter/json")
latest_version = response.json()["info"]["version"]

# Get the current version using pkg_resources
current_version = pkg_resources.get_distribution("open-interpreter").version

return version.parse(latest_version) > version.parse(current_version)

if check_for_update():
print_markdown(
"> **A new version of Open Interpreter is available.**\n>Please run: `pip install --upgrade open-interpreter`\n\n---"
)

if "--voice" in sys.argv:
print("Coming soon...")
from .computer_use.loop import run_async_main

run_async_main()
exit()

from .core.async_core import AsyncInterpreter
from .core.computer.terminal.base_language import BaseLanguage
from .core.core import OpenInterpreter
Expand Down
Empty file.
Loading

0 comments on commit 7e097bb

Please sign in to comment.