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

aider #437

Open
haesleinhuepf opened this issue Dec 12, 2024 · 3 comments · May be fixed by #438
Open

aider #437

haesleinhuepf opened this issue Dec 12, 2024 · 3 comments · May be fixed by #438

Comments

@haesleinhuepf
Copy link
Owner

git-bob comment on how to integrate aider in functions such as solve_github_issue or create_or_modify_file in _ai_github_utilities.py.

Copy link
Contributor

This message was generated by git-bob (version: 0.15.1, model: gpt-4o-2024-08-06, log), an experimental AI-based assistant. It can make mistakes and has limitations. Check its messages carefully.

To integrate aider into functions like solve_github_issue or create_or_modify_file, consider refactoring these functions to utilize aider capabilities for AI-driven assistance. You can begin by defining an aider function that encapsulates necessary functionalities, then inject it where needed by calling this function. Here's a conceptual example of how to modify one of the functions to include aider:

def solve_github_issue(repository, issue, llm_model, prompt_function, base_branch=None):
    # Integrate aider functionality
    aider_result = aider.analyze_issue(repository, issue)

    # Process aider_result further in the function logic
    # ...

Ensure aider is correctly imported and its dependencies are met in your codebase.

@haesleinhuepf
Copy link
Owner Author

I found this code example for using aideR:

from aider.coders import Coder
from aider.models import Model

# This is a list of files to add to the chat
fnames = ["greeting.py"]

model = Model("gpt-4-turbo")

# Create a coder object
coder = Coder.create(main_model=model, fnames=fnames)

# This will execute one instruction on those files and then return
coder.run("make a script that prints hello world")

# Send another instruction
coder.run("make it say goodbye")

# Print out usage / costs
coder.run("/tokens")

Could this be integrated into create_or_modify_file ?

git-bob answer

Copy link
Contributor

This message was generated by git-bob (version: 0.15.1, model: gpt-4o-2024-08-06, log), an experimental AI-based assistant. It can make mistakes and has limitations. Check its messages carefully.

To integrate the provided aider example into the create_or_modify_file function, you can modify the function to include a Coder object from aider. This will allow you to leverage aider's functionality for creating or modifying files. Here's a proposed code snippet:

from aider.coders import Coder
from aider.models import Model

def create_or_modify_file(repository, issue, filename, branch_name, issue_summary, prompt_function, number_of_attempts:int=3):
    Log().log(f"-> create_or_modify_file({repository}, {issue}, {filename}, {branch_name})")
    from ._utilities import Config

    model = Model("gpt-4-turbo")
    coder = Coder.create(main_model=model, fnames=[filename])

    created_files = {}
    for attempt in range(number_of_attempts):
        an_error_happened = False

        file_exists = Config.git_utilities.check_if_file_exists(repository, branch_name, filename)
        coder_instruction = "modify" if file_exists else "create"
        coder.run(f"{coder_instruction} the file {filename} for issue #{issue}.")
        
        # additional logic here to handle the file content as needed

        # break the loop if no error occurred
        if not an_error_happened:
            break
        print(f"An error happened. Retrying... {attempt+1}/{number_of_attempts}")

    return created_files

This modification initializes a Coder instance and runs a command based on whether the file exists. You may need to adjust the handling of file content and further integrate the coder's results as per your specific requirements.

@haesleinhuepf haesleinhuepf linked a pull request Dec 13, 2024 that will close this issue
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 a pull request may close this issue.

1 participant