Skip to content
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

Create launcher.sh #161

Merged
merged 1 commit into from
Apr 3, 2023
Merged

Create launcher.sh #161

merged 1 commit into from
Apr 3, 2023

Conversation

gourcetools
Copy link
Contributor

@gourcetools gourcetools commented Apr 1, 2023

The script detects the user's operating system, lists available .bin files and prompts the user to select a .bin file to run. Ensuring a more user-friendly experience.
image

The script detects the user's operating system, lists available .bin files and prompts the user to select a .bin file to run.
Ensuring a more user-friendly experience.
@BoQsc
Copy link
Contributor

BoQsc commented Apr 3, 2023

It would be better to implement in C or Python.

@AndriyMulyar
Copy link
Contributor

This launcher is sick

@AndriyMulyar AndriyMulyar merged commit cec1fda into nomic-ai:main Apr 3, 2023
@gourcetools
Copy link
Contributor Author

It would be better to implement in C or Python.

Can you tell me why?

@BoQsc
Copy link
Contributor

BoQsc commented Apr 5, 2023

It would be better to implement in C or Python.

Can you tell me why?

The whole project is in Python.
Python and C are more maintainable, readable and simple.
Bash, Batch and other languages that extend these languages are already outdated for decades.
Most people do not want to deal with erronious languages.
They are legacy and only exist for backwards compatibility in essential old projects before an
in-depth research to build a stable modern version. Mostly C , C# or Java.

Bash language should not be used to keep things simple.
If a script needs more than a few IF statements, a proper programming language should be used.

image

@BoQsc
Copy link
Contributor

BoQsc commented Apr 5, 2023

Here is how your script might look rewritten in python, untested, generated by GPT3.0.

Not the best example, but it is better than dealing with Bash language quirks.

So yeah, I suggest to rewrite in Python.

#!/usr/bin/env python

import os

# Display header
print("==========================================================")
print(" ██████  ██████  ████████ ██   ██  █████  ██      ██      ")
print("██       ██   ██    ██    ██   ██ ██   ██ ██      ██      ")
print("██   ███ ██████     ██    ███████ ███████ ██      ██      ")
print("██    ██ ██         ██         ██ ██   ██ ██      ██      ")
print(" ██████  ██         ██         ██ ██   ██ ███████ ███████ ")
print(" └─> https://github.com/nomic-ai/gpt4all")

# Function to detect macOS architecture and set the binary filename
def detect_mac_arch():
    mac_arch = os.uname().machine
    if mac_arch == "arm64":
        os_type = "M1 Mac/OSX"
        binary_filename = "gpt4all-lora-quantized-OSX-m1"
    elif mac_arch == "x86_64":
        os_type = "Intel Mac/OSX"
        binary_filename = "gpt4all-lora-quantized-OSX-intel"
    else:
        print("Unknown macOS architecture")
        exit(1)
    return os_type, binary_filename

# Detect operating system and set the binary filename
if os.name == "posix":
    if os.uname().sysname == "Darwin":
        os_type, binary_filename = detect_mac_arch()
    elif os.uname().sysname == "Linux":
        if "Microsoft" in open("/proc/version").read():
            os_type = "Windows (WSL)"
            binary_filename = "gpt4all-lora-quantized-win64.exe"
        else:
            os_type = "Linux"
            binary_filename = "gpt4all-lora-quantized-linux-x86"
    else:
        print("Unknown operating system")
        exit(1)
    print("================================")
    print(f"== You are using {os_type}.")

elif os.name == "nt":
    os_type = "Windows (Cygwin/MSYS/MINGW)"
    binary_filename = "gpt4all-lora-quantized-win64.exe"
    print("================================")
    print(f"== You are using {os_type}.")

else:
    print("Unknown operating system")
    exit(1)

# Change to the chat directory
os.chdir("chat")

# List .bin files and prompt user to select one
bin_files = [file for file in os.listdir() if file.endswith(".bin")]
print("== Available .bin files:")
for i, file in enumerate(bin_files):
    print(f"   [{i 1}] {file}")
    
# Function to get user input and validate it
def get_valid_user_input():
    input_valid = False
    while not input_valid:
        print("==> Please enter a number:")
        user_selection = input().strip()
        if user_selection.isdigit() and 1 <= int(user_selection) <= len(bin_files):
            input_valid = True
        else:
            print(f"Invalid input. Please enter a number between 1 and {len(bin_files)}")
    return int(user_selection)

user_selection = get_valid_user_input()
selected_bin_file = bin_files[user_selection-1]

# Run the selected .bin file with the appropriate command
os.system(f"./{binary_filename} -m {selected_bin_file}")

@gourcetools
Copy link
Contributor Author

I don't see the point, at all.
Bash is fine. And run on every system by default. The script is simple. Bash allow users to click and run. Thank's anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants