switch detection of linux distribution to distro package

This commit is contained in:
wunderwuzzi23
2023-03-07 22:15:17 -08:00
parent 5974cb5271
commit bbcea52970
2 changed files with 12 additions and 12 deletions
+2 -1
View File
@@ -1,4 +1,5 @@
openai==0.27 openai==0.27
termcolor==2.2.0 termcolor==2.2.0
colorama colorama
python-dotenv python-dotenv
distro
+10 -11
View File
@@ -9,11 +9,12 @@ import platform
import openai import openai
import sys import sys
import subprocess import subprocess
import dotenv
import distro
from termcolor import colored from termcolor import colored
from colorama import init from colorama import init
import dotenv #Allow .env file to be used
# Check if the user globally disabled the safety switch # Check if the user globally disabled the safety switch
def get_yolo_safety_switch_config(): def get_yolo_safety_switch_config():
@@ -60,8 +61,7 @@ def get_os_friendly_name():
os_name = platform.system() os_name = platform.system()
if os_name == "Linux": if os_name == "Linux":
dist_name = platform.freedesktop_os_release()["NAME"] return "Linux/"+distro.name(pretty=True)
return "Linux/"+dist_name
elif os_name == "Windows": elif os_name == "Windows":
return os_name return os_name
elif os_name == "Darwin": elif os_name == "Darwin":
@@ -115,12 +115,14 @@ if __name__ == "__main__":
print ("No user prompt specified.") print ("No user prompt specified.")
sys.exit(-1) sys.exit(-1)
# Load the correct prompt based on Shell and OS and append the user's prompt # Load the correct prompt based on Shell and OS and append the user's prompt
prompt = get_full_prompt(user_prompt, shell) prompt = get_full_prompt(user_prompt, shell)
# Make the first line also the system prompt # Make the first line also the system prompt
system_prompt = prompt.split("\n")[0] system_prompt = prompt[1]
#print(prompt)
# Call the ChatGPT API # Call the ChatGPT API
response = openai.ChatCompletion.create( response = openai.ChatCompletion.create(
model="gpt-3.5-turbo", model="gpt-3.5-turbo",
@@ -129,10 +131,7 @@ if __name__ == "__main__":
{"role": "user", "content": prompt} {"role": "user", "content": prompt}
], ],
temperature=0, temperature=0,
max_tokens=100, max_tokens=500,
# top_p=1,
# frequency_penalty=0.2,
# presence_penalty=0
) )
#print (response) #print (response)
@@ -162,4 +161,4 @@ if yolo == "Y" or yolo == "":
subprocess.run([shell, "/c", res_command], shell=False) subprocess.run([shell, "/c", res_command], shell=False)
else: else:
# Unix: /bin/bash /bin/zsh: uses -c both Ubuntu and macOS should work, others might not # Unix: /bin/bash /bin/zsh: uses -c both Ubuntu and macOS should work, others might not
subprocess.run([shell, "-c", res_command], shell=False) subprocess.run([shell, "-c", res_command], shell=False)