haesleinhuepf / git-bob

git-bob uses AI to solve Github-issues and review pull-requests. It runs inside the Github CI, no need to install anything on your computer.
BSD 3-Clause "New" or "Revised" License
11 stars 2 forks source link

LLM-based task decision #337

Open haesleinhuepf opened 6 days ago

haesleinhuepf commented 6 days ago

If we had another environment variable "GIT_BOB_FREE_LLM_NAME" giving the name of an LLM that is free of charge (e.g. githubmodels:...) we change the logic in _terminal.py. Instead of replacing aliases and searching for terms such as "{agent_name} comment" or "{agent_name} solve", we could use the prompt function using the free LLM to read the last issue description and decide what to do. I'm curious how this could be implemented.

git-bob ask claude-3-5-sonnet-20240620 to think about this.

github-actions[bot] commented 6 days ago

This message was generated by git-bob (version: 0.7.0, model: claude-3-5-sonnet-20240620, log), an experimental AI-based assistant. It can make mistakes and has limitations. Check its messages carefully.

To implement the proposed change, we could modify the command_line_interface() function in _terminal.py as follows:

def command_line_interface():
    # ... (existing imports and setup)

    free_llm_name = os.environ.get("GIT_BOB_FREE_LLM_NAME")

    if free_llm_name:
        # Use the free LLM to determine the task
        task_prompt = f"Read the following issue description and decide what action to take. Respond with one of: 'comment', 'solve', 'split', or 'deploy'.\n\nIssue description:\n{text}"
        task_decision = prompt(task_prompt)

        if 'comment' in task_decision.lower():
            text += f"\n{agent_name} comment"
        elif 'solve' in task_decision.lower():
            text += f"\n{agent_name} solve"
        elif 'split' in task_decision.lower():
            text += f"\n{agent_name} split"
        elif 'deploy' in task_decision.lower():
            text += f"\n{agent_name} deploy"
        else:
            print(f"Unrecognized task decision: {task_decision}. Exiting.")
            sys.exit(0)
    else:
        # Existing logic for determining the task
        if not (f"{agent_name} comment" in text or f"{agent_name} solve" in text or f"{agent_name} split" in text or f"{agent_name} deploy" in text):
            print("They didn't speak to me. I show myself out:", text)
            sys.exit(0)

    # ... (rest of the function remains the same)

This change introduces a new environment variable GIT_BOB_FREE_LLM_NAME and uses it to determine the task using the free LLM when available, falling back to the existing logic if not set.