import os

# Get the current working directory
path = os.getcwd()

# Read the template file
with open(
    os.path.join(path, "SFT_Model", "supervisor", "ModelFile_tem.txt"), "r"
) as file:
    data = file.read()

    # Replace the placeholder with the actual path
    data = data.replace(
        "{path}",
        os.path.join(path, "SFT_Model", "supervisor", "model.gguf").replace("\\", "/"),
    )
    print(data)

    # Write the modified data to a new file
    with open(
        os.path.join(path, "SFT_Model", "supervisor", "ModelFile.txt"), "w"
    ) as file:
        file.write(data)

# Running the ollama setup
print("Running the ollama setup \n \n")

# Construct the command
path = path.replace("\\", "/")  # Replace backslashes with forward slashes
script = f'ollama create myllama2 --file "{path}/SFT_Model/supervisor/ModelFile.txt"'
print(script)
os.system(script)