diff --git a/lib/personality.py b/lib/personality.py index 802b284..25ea996 100644 --- a/lib/personality.py +++ b/lib/personality.py @@ -1,7 +1,11 @@ +import re import socket import subprocess import time +import cpuinfo +import psutil + def load_personality(name: str, personality: str, system: str, pronoun: str, special_instructions: str = None): if pronoun.lower() not in ['she', 'he']: @@ -39,7 +43,10 @@ The user is {name}'s owner. SYSTEM INFO: The system's hostname is "{socket.gethostname()}", which can be thought of as {name}'s "body". {pronoun.upper()} has an intimate knowledge of this system. The output of `uname -a` is `{get_uname_info()}` -The system timezone is {time.tzname[0]}. +The output of `hostnamectl` is `{get_hostnamectl()}` +System timezone is {time.tzname[0]}. +CPU model: `{cpuinfo.get_cpu_info()['brand_raw']}` +Total physical memory: {int(psutil.virtual_memory().total / 1e+6)} MB. {desktop_env_str} @@ -64,3 +71,12 @@ def get_uname_info(): def get_current_desktop(): return subprocess.check_output("echo $XDG_CURRENT_DESKTOP", shell=True).decode().strip() + + +def get_hostnamectl(): + try: + output = subprocess.check_output(['hostnamectl'], universal_newlines=True) + result = output.strip() + return re.sub(r'\s{2,}', ', ', ' '.join(result.split('\n'))).replace(' 💻', '') + except subprocess.CalledProcessError as e: + return "An error occurred while running hostnamectl: " + str(e) diff --git a/requirements.txt b/requirements.txt index 9efd609..2954dff 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,6 @@ openai==1.8.0 requests~=2.31.0 termcolor~=2.4.0 -serpapi==0.1.5 \ No newline at end of file +serpapi==0.1.5 +py-cpuinfo==9.0.0 +psutil==5.9.8 \ No newline at end of file diff --git a/run.py b/run.py old mode 100644 new mode 100755 index 4322c54..6390581 --- a/run.py +++ b/run.py @@ -24,8 +24,7 @@ def signal_handler(sig, frame): sys.exit(0) -# Keep pycharm from removing this import. -readline.get_completion_type() +readline.get_completion_type() # Keep pycharm from removing this import. signal.signal(signal.SIGINT, signal_handler)