add more system info

This commit is contained in:
Cyberes 2024-02-01 15:03:16 -07:00
parent c207f1a2be
commit 28a139f0f6
3 changed files with 21 additions and 4 deletions

View File

@ -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)

View File

@ -1,4 +1,6 @@
openai==1.8.0
requests~=2.31.0
termcolor~=2.4.0
serpapi==0.1.5
serpapi==0.1.5
py-cpuinfo==9.0.0
psutil==5.9.8

3
run.py Normal file → Executable file
View File

@ -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)