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

Simplify PrepromptsHolder to just be a function #980

Closed
AntonOsika opened this issue Jan 19, 2024 · 5 comments
Closed

Simplify PrepromptsHolder to just be a function #980

AntonOsika opened this issue Jan 19, 2024 · 5 comments
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@AntonOsika
Copy link
Collaborator

AntonOsika commented Jan 19, 2024

Currently preprompt holders is this:

class PrepromptsHolder:
    def __init__(self, preprompts_path: Path):
        self.preprompts_path = preprompts_path

    def get_preprompts(self) -> Dict[str, str]:
        preprompts_repo = DiskMemory(self.preprompts_path)
        return {file_name: preprompts_repo[file_name] for file_name in preprompts_repo}

We could change it to just a function:

def get_preprompts(preprompts_path: Path) -> Dict[str, str]:
    return dict(DiskMemory(preprompts_path).items())
@AntonOsika AntonOsika added enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers labels Jan 19, 2024
@TheoMcCabe
Copy link
Collaborator

TheoMcCabe commented Jan 21, 2024

There are 6 or so uses of preprompts_holder.get_preprompts() . It seems to me if we made this change we would have to pass the preprompts path around everywhere so that we could call this new function with the path as the argument. I think its better how it is, setting the path once in this singleton class which can then be reused all over the place without needing to know the path. Especially as in the future there may be use cases where we might want to override the preprompts holder with a new class which retrievs them from a database or something

@ATheorell
Copy link
Collaborator

I agree with @TheoMcCabe .

@AntonOsika
Copy link
Collaborator Author

AntonOsika commented Jan 22, 2024

Are you sure? @ATheorell @TheoMcCabe

Now we're passing preprompts_holder around. Which is weird.

I'm suggesting we call the function immediately, and pass Dict[str, str] with preprompts around.

This means that "file access" fails early, which is better in this case (file access will be so fast user will never notice).

@TheoMcCabe
Copy link
Collaborator

TheoMcCabe commented Jan 22, 2024

Ah yeah - I was wondering why the file system was accessed at get time rather than in the construction of the preprompts holder. Your solution of retrieving the preprompts early and passing them in memory sounds good.

We could also leave most of the code the same and retrieve the dictionary in the init of the preprompts_holder and then return this dict when get is called ? Seems equivalent to what your suggesting. But yeah as long as we are passing around an object or a dict not a file path thats fine for me

@ATheorell
Copy link
Collaborator

I see that there could be a gain in fail early, but of all things that needs to be done/refactored/implemented, this looks like very low priority to me. This post in ruby on rails highlights the hidden costs of cosmetic changes: rails/rails#13771 (comment)

When I originally made the prepromptsholder, I wanted it to be general and allow for advanced editing of the preprompts during runtime, in case this would be requested when using gpt-engineer through a GUI.

All this said, if you really think this is priority and someone wants to implement it and someone else wants to supervise that and check the solution before merging, I'm not gonna hinder this development.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
Status: Done
Development

No branches or pull requests

3 participants