Skip to content

Added more useful info to system info #750

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion interpreter/terminal_interface/terminal_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,5 +251,5 @@ def terminal_interface(interpreter, message):
else:
break
except:
system_info()
system_info(interpreter)
raise
84 changes: 70 additions & 14 deletions interpreter/utils/system_debug_info.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,90 @@
import platform
import psutil
import subprocess

import pkg_resources
import psutil


def get_python_version():
return platform.python_version()


def get_pip_version():
try:
pip_version = subprocess.check_output(['pip', '--version']).decode().split()[1]
pip_version = subprocess.check_output(["pip", "--version"]).decode().split()[1]
except Exception as e:
pip_version = str(e)
return pip_version


def get_oi_version():
try:
oi_version_cmd = (
subprocess.check_output(["interpreter", "--version"]).decode().split()[1]
)
except Exception as e:
oi_version_cmd = str(e)
oi_version_pkg = pkg_resources.get_distribution("open-interpreter").version
oi_version = oi_version_cmd, oi_version_pkg
return oi_version


def get_os_version():
return platform.platform()


def get_cpu_info():
return platform.processor()


def get_ram_info():
vm = psutil.virtual_memory()
used_ram = vm.used
free_ram = vm.free
used_ram_gb = used_ram / (1024 ** 3)
free_ram_gb = free_ram / (1024 ** 3)
total_ram_gb = vm.total / (1024 ** 3)
return f"{total_ram_gb:.2f} GB used: {used_ram_gb:.2f}, free: {free_ram_gb:.2f}"

def system_info():
print(f"Python Version: {get_python_version()}\nPip Version: {get_pip_version()}\nOS Version and Architecture: {get_os_version()}\nCPU Info: {get_cpu_info()}\nRAM Info: {get_ram_info()}\n")

if __name__ == '__main__':
system_info()
used_ram_gb = vm.used / (1024**3)
free_ram_gb = vm.free / (1024**3)
total_ram_gb = vm.total / (1024**3)
return f"{total_ram_gb:.2f} GB, used: {used_ram_gb:.2f}, free: {free_ram_gb:.2f}"


def interpreter_info(interpreter):
try:
if interpreter.local:
try:
curl = subprocess.check_output(f"curl {interpreter.api_base}")
except Exception as e:
curl = str(e)
else:
curl = "Not local"

# System message:{interpreter.system_message}
return f"""

Interpreter Info
Vision: {interpreter.vision}
Model: {interpreter.model}
Function calling: {interpreter.function_calling_llm}
Context window: {interpreter.context_window}
Max tokens: {interpreter.max_tokens}

Auto run: {interpreter.auto_run}
API base: {interpreter.api_base}
Local: {interpreter.local}

Curl output: {curl}
"""
except:
return "Error, couldn't get interpreter info"


def system_info(interpreter):
oi_version = get_oi_version()
print(
f"""
Python Version: {get_python_version()}
Pip Version: {get_pip_version()}
Open-interpreter Version: cmd:{oi_version[0]}, pkg: {oi_version[1]}
OS Version and Architecture: {get_os_version()}
CPU Info: {get_cpu_info()}
RAM Info: {get_ram_info()}
{interpreter_info(interpreter)}
"""
)