TheR1D / shell_gpt

A command-line productivity tool powered by AI large language models like GPT-4, will help you accomplish your tasks faster and more efficiently.
MIT License
8.84k stars 696 forks source link

multiple script edition/creation #498

Open manucarbonell opened 4 months ago

manucarbonell commented 4 months ago

Adding the option to modify or create multiple scripts in a given project with a single prompt. It works as follows:

Existing scripts:

example/calculate.py
from add import add

def calculate(x,y):
    result = add(x,y)*add(x,y)
    return result
example/add.py
def add(x,y):
   return x+y

Run sgpt with --multiscript-code option

sgpt --multiscript-code --project-path example/ "can you extract the multiplication in calculate as an import from an external script?"

Resulting modified and created scripts:

example/calculate.py
from add import add
from multiply import multiply

def calculate(x, y):
    result = multiply(add(x, y), add(x, y))
    return result

print(calculate(2, 3))
example/add.py
def add(x,y):
   return x+y
example/multiply.py
def multiply(x, y):
    return x * y