Pythagora-io / gpt-pilot

The first real AI developer
Other
31.98k stars 3.23k forks source link

Consider splitting by agent, not by aspect #182

Open mnieber opened 1 year ago

mnieber commented 1 year ago

Hi,

I'm currently reading the code, and I wanted to make a suggestion regarding the folder structure. I know people will usually not be that inclined to make big structural changes, but I wanted to propose it anyway.

I believe that in general cohesion is better if the code is split by feature (which in this case mostly means: agent) instead of by aspect. Currently, the code for the different agents is spread over const/function_calls.py, database/models, helpers/agents and prompts. I would propose to instead use this structure:

pilot
-- agents
---- <agent-name>                                   // e.g. architect, techlead, codemonkey
------ models.py                                    // Related database models
------ agents.py                                    // Related agent classes (usually just one)
------ function_calls.py                            // Related function calls
------ prompts                                      // Directory with the prompts that this agent sends to other agents

Since many of the code files logically belong to a single agent, I think this structure would make it easier to understand the purpose of the code. Also, it will lead to shorter files (e.g. multiple short function_calls.py files, instead of one big one).

nalbion commented 1 year ago

@mnieber I like the idea. It fits in well with my thinking here - https://github.com/Pythagora-io/gpt-pilot/issues/91#issuecomment-1751964079

wayland commented 1 year ago

I was likewise reading the prompts directory, and thought the same thing, but with the following variations:

AgentRoles

AgentRoles should be made (equivalent to the current Agents). They have attributes and methods (like classes), but also prompts (a cross between an attribute and an incorporated class) and tasks (a cross between a method and an incorporated class). They can be composed eg. the AgentRole called Developer can be composed by Peter the PostgreSQL Developer and Wendy the Web Developer (each of which has their own set of prompts that may override the ones from the Developer AgentRole).

Attributes and Methods

These are just like regular classes; an example of an attribute might be a keyed list (I think that's a dictionary in Python terms) that maps technologies to the slots they belong in (ie. 'test' => 'Jest').

Prompts

Tasks

Workflows

Easy things easy, hard things possible

The things that should be easy:

So, that's my theory. Hope this helps.

wayland commented 1 year ago

As a side thing, I'd like to see most of function_calls.py turned into .yml files (to make the easy things easier, and to enable better separation of code and data).

wayland commented 1 year ago

According to my scheme, we'd end up with something like the following (note: I'm not yet familiar enough with the code to be sure what to do with all the YAML files):

pilot
+- agents
  +-Agent.py                                  (from pilot/helpers/Agent.py)                
  +-AGENTS.md                                 (from pilot/helpers/agents/AGENTS.md)        
  +-__init__.py                               (from pilot/helpers/agents/__init__.py)      
  +-prompts/__init__.py                       (from pilot/prompts/__init__.py)             
  +-prompts/prompts.py                        (from pilot/prompts/prompts.py)              
  +-prompts/test_prompts.py                   (from pilot/prompts/test_prompts.py)         
  +-Architect                                                                              
    +-models/agenture.py                      (from pilot/database/models/architecture.py) 
    +-agent.py                                (from pilot/helpers/agents/Architect.py)     
    +-prompts                                                                              
     +- prompts
      +-change_in_tech.prompt                 (from pilot/prompts/architecture/change_in_tech.prompt)
      +-technologies.prompt                   (from pilot/prompts/architecture/technologies.prompt)
      +-system_message.prompt                 (from pilot/prompts/system_messages/architect.prompt)
    +-architecture.yml                        (from pilot/const/function_calls.py)         
  +-CodeMonkey                                                                             
    +-agent.py                                (from pilot/helpers/agents/CodeMonkey.py)    
    +-test_agent.py                           (from pilot/helpers/agents/test_CodeMonkey.py)
    +-prompts                                                                              
     +- prompts
      +-system_message.prompt                 (from pilot/prompts/system_messages/code_monkey.prompt)
    +-get_files.yml                           (from pilot/const/function_calls.py)         
    +-implement_changes.yml                   (from pilot/const/function_calls.py)         
  +-DevOps                                                                                 
    +-prompts                                                                              
     +- prompts
      +-debug.prompt                          (from pilot/prompts/dev_ops/debug.prompt)    
      +-ran_command.prompt                    (from pilot/prompts/dev_ops/ran_command.prompt)
      +-should_rerun_command.prompt           (from pilot/prompts/dev_ops/should_rerun_command.prompt)
      +-system_message.prompt                 (from pilot/prompts/system_messages/dev_ops.prompt)
  +-Developer                                                                              
    +-models/agent.py                         (from pilot/database/models/development.py)  
    +-models/agent_planning.py                (from pilot/database/models/development_planning.py)
    +-models/agent_steps.py                   (from pilot/database/models/development_steps.py)
    +-agent.py                                (from pilot/helpers/agents/Developer.py)     
    +-test_agent.py                           (from pilot/helpers/agents/test_Developer.py)
    +-prompts                                                                              
     +- prompts
      +-context.prompt                        (from pilot/prompts/development/context.prompt)
      +-define_user_review_goal.prompt        (from pilot/prompts/development/define_user_review_goal.prompt)
      +-env_setup/cli_response.prompt         (from pilot/prompts/development/env_setup/cli_response.prompt)
      +-env_setup/install_next_technology.prompt (from pilot/prompts/development/env_setup/install_next_technology.prompt)
      +-env_setup/specs.prompt                (from pilot/prompts/development/env_setup/specs.prompt)
      +-env_setup/unsuccessful_installation.prompt (from pilot/prompts/development/env_setup/unsuccessful_installation.prompt)
      +-error.prompt                          (from pilot/prompts/development/error.prompt)
      +-feature_plan.prompt                   (from pilot/prompts/development/feature_plan.prompt)
      +-feature_summary.prompt                (from pilot/prompts/development/feature_summary.prompt)
      +-get_fully_coded_file.prompt           (from pilot/prompts/development/get_fully_coded_file.prompt)
      +-get_run_command.prompt                (from pilot/prompts/development/get_run_command.prompt)
      +-get_snippet_from_comment.prompt       (from pilot/prompts/development/get_snippet_from_comment.prompt)
      +-implement_changes.prompt              (from pilot/prompts/development/implement_changes.prompt)
      +-iteration.prompt                      (from pilot/prompts/development/iteration.prompt)
      +-parse_task.prompt                     (from pilot/prompts/development/parse_task.prompt)
      +-plan.prompt                           (from pilot/prompts/development/plan.prompt) 
    +-tasks                                                                                
      +-break_down_code_changes.prompt        (from pilot/prompts/development/task/break_down_code_changes.prompt)
      +-breakdown.prompt                      (from pilot/prompts/development/task/breakdown.prompt)
      +-next_step.prompt                      (from pilot/prompts/development/task/next_step.prompt)
      +-request_files_for_code_changes.prompt (from pilot/prompts/development/task/request_files_for_code_changes.prompt)
      +-request_test_files.prompt             (from pilot/prompts/development/task/request_test_files.prompt)
      +-step/command_test.prompt              (from pilot/prompts/development/task/step/command_test.prompt)
      +-step/write_automated_test.prompt      (from pilot/prompts/development/task/step/write_automated_test.prompt)
      +-step_check.prompt                     (from pilot/prompts/development/task/step_check.prompt)
      +-step_code.prompt                      (from pilot/prompts/development/task/step_code.prompt)
      +-update_task.prompt                    (from pilot/prompts/development/task/update_task.prompt)
    +-command_to_run.yml                      (from pilot/const/function_calls.py)         
    +-debug_steps_breakdown.yml               (from pilot/const/function_calls.py)         
    +-execute_commands.yml                    (from pilot/const/function_calls.py)         
    +-filter_os_technologies.yml              (from pilot/const/function_calls.py)         
    +-get_fully_coded_file.yml                (from pilot/const/function_calls.py)         
    +-get_missing_snippets.yml                (from pilot/const/function_calls.py)         
    +-get_test_type.yml                       (from pilot/const/function_calls.py)         
    +-implement_task.yml                      (from pilot/const/function_calls.py)         
  +-ProductOwner                                                                           
    +-agent.py                                (from pilot/helpers/agents/ProductOwner.py)  
    +-test_agent.py                           (from pilot/helpers/agents/test_ProductOwner.py)
    +-prompts                                                                              
     +- prompts
      +-system_message.prompt                 (from pilot/prompts/system_messages/product_owner.prompt)
    +-user_stories.yml                        (from pilot/const/function_calls.py)         
    +-user_tasks.yml                          (from pilot/const/function_calls.py)         
  +-TechLead                                                                               
    +-agent.py                                (from pilot/helpers/agents/TechLead.py)      
    +-test_agent.py                           (from pilot/helpers/agents/test_TechLead.py) 
    +-prompts                                                                              
     +- prompts
      +-system_message.prompt                 (from pilot/prompts/system_messages/tech_lead.prompt)
    +-development_plan.yml                    (from pilot/const/function_calls.py) 

(a higher level of detail than mnieber, which may or may not be good)