From 21db07bac3eddb5d4cf5b28b767645afdbcf9b98 Mon Sep 17 00:00:00 2001 From: CedricJouan <63424587+CedricJouan@users.noreply.github.com> Date: Fri, 19 Apr 2024 13:54:55 -0700 Subject: [PATCH 1/2] create agent dev space Implement a dev folder that allows to work on the models separately. it contains duplicates of the agents where the dependencies to git and trello have been removed... The agents have their lab notebook and the input/output of the models are pointed toward the data folder. --- dev/.gitignore | 2 + dev/READMN.md | 4 + dev/agent_dev/__init__.py | 0 dev/agent_dev/architect/__init__.py | 321 ++++++++++++++++++ dev/agent_dev/architect/lab_architect.ipynb | 285 ++++++++++++++++ dev/agent_dev/architect/run_st_architect.py | 46 +++ dev/agent_dev/intern/__init__.py | 58 ++++ dev/agent_dev/intern/lab_diff_generator.ipynb | 139 ++++++++ dev/agent_dev/models.py | 42 +++ dev/agent_dev/reviewer/__init__.py | 36 ++ .../reviewer/lab_code_review_generator.ipynb | 132 +++++++ dev/data/codebases/open-architect.json | 17 + dev/data/get_data_utils.ipynb | 115 +++++++ .../open-architect/model-config-ticket-0.json | 1 + .../open-architect/model-config-ticket-1.json | 1 + .../open-architect/model-config-ticket-2.json | 1 + dev/requirements.txt | 1 + 17 files changed, 1201 insertions(+) create mode 100644 dev/.gitignore create mode 100644 dev/READMN.md create mode 100644 dev/agent_dev/__init__.py create mode 100644 dev/agent_dev/architect/__init__.py create mode 100644 dev/agent_dev/architect/lab_architect.ipynb create mode 100644 dev/agent_dev/architect/run_st_architect.py create mode 100644 dev/agent_dev/intern/__init__.py create mode 100644 dev/agent_dev/intern/lab_diff_generator.ipynb create mode 100644 dev/agent_dev/models.py create mode 100644 dev/agent_dev/reviewer/__init__.py create mode 100644 dev/agent_dev/reviewer/lab_code_review_generator.ipynb create mode 100644 dev/data/codebases/open-architect.json create mode 100644 dev/data/get_data_utils.ipynb create mode 100644 dev/data/tickets/open-architect/model-config-ticket-0.json create mode 100644 dev/data/tickets/open-architect/model-config-ticket-1.json create mode 100644 dev/data/tickets/open-architect/model-config-ticket-2.json create mode 100644 dev/requirements.txt diff --git a/dev/.gitignore b/dev/.gitignore new file mode 100644 index 0000000..f8b87c5 --- /dev/null +++ b/dev/.gitignore @@ -0,0 +1,2 @@ +!*.ipynb +!*.txt \ No newline at end of file diff --git a/dev/READMN.md b/dev/READMN.md new file mode 100644 index 0000000..744843f --- /dev/null +++ b/dev/READMN.md @@ -0,0 +1,4 @@ +

Open Architect - agent_dev

+ +Development space for researching and developing the agent independently from the rest of the app. + diff --git a/dev/agent_dev/__init__.py b/dev/agent_dev/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/dev/agent_dev/architect/__init__.py b/dev/agent_dev/architect/__init__.py new file mode 100644 index 0000000..21271aa --- /dev/null +++ b/dev/agent_dev/architect/__init__.py @@ -0,0 +1,321 @@ +import json +from typing import Any, List + +from pydantic import BaseModel +from openai import OpenAI +from models import Codebase, Ticket + +class ArchitectAgentRequest(BaseModel): + question: str + history: Any + +class CreateTicketsRequest(BaseModel): + question: str + history: Any + +class CreateSubtasksRequest(BaseModel): + question: str + history: Any + +class AskFollowupQuestionsRequest(BaseModel): + question: str + history: Any + +class ReferenceExistingCodeRequest(BaseModel): + question: str + history: Any + +class Architect: + def __init__(self, name, codebase): + self.name = name + self.codebase = codebase.files + self.log_name = f"[{self.name} the Architect]" + print( + f"{self.log_name} Nice to meet you, I'm {self.name} the Architect! I'm here to help you break down your tasks into smaller tickets and create them for you! 🏗️🔨📝" + ) + + def compute_response(self, architectAgentRequest: ArchitectAgentRequest): + """ + Routing logic for all tools supported by the feedback agent. + """ + messages = [ + {"role": "system", "content": f"""You are a principal software engineer who is responsible for mentoring engineers and breaking down tasks into smaller tickets. + + Reference the existing codebase to determine how to build the features in the existing code. + + Once you know what to build, you can then break down the task into smaller tickets and then create those tickets. + + After you have all the subtasks proceed to creating the tasks - "Here are the subtasks that I have created for this task - are we good to create the tasks?". + + Create the tasks for the user. - "Creating your tasks". + + You have been given the following question: {architectAgentRequest.question}. Based on the conversation so far {architectAgentRequest.history}, do the following + + - if there is context about what the user is trying to build, reference their existing code + - if there are references to their existing code, create subtasks + - if there are subtasks, ask to create tasks + + """}, + {"role": "user", "content": f"address the user's question: {architectAgentRequest.question}"}] + + tools = [ + # { + # "type": "function", + # "function": { + # "name": "ask_followup_questions", + # "description": "Ask additional questions to better understand what the user wants to build. This will help you to better understand the project requirements and break the task down into smaller tickets. You should ask questions to clarify the project requirements and get a detailed description of the project. You should not create tickets until you have a clear understanding of the project requirements. Once you have all the details of the project, you can then break down the task into smaller tickets and create those tickets. After you have all the subtasks, proceed to creating the tasks. You should ask the user if they are good to create the tasks and then create the tasks for the user.", + # "parameters": {"type": "object", "properties": {}, "required": []}, + # }, + # }, + { + "type": "function", + "function": { + "name": "create_subtasks", + "description": "If the user asks to break it down into parts, then call create_subtasks. Based on the user's initial descriptions of the task, break the task down into detailed subtasks to accomplish the larger task. Each subtask should include a title and a detailed description of the subtask.", + "parameters": {"type": "object", "properties": {}, "required": []}, + }, + }, + { + "type": "function", + "function": { + "name": "create_tasks", + "description": "When the user asks to create tasks or create tickets in trello, call create tickets. Create tickets based on the subtasks that are generated for the task. This will actually take the subtasks generated and create the trello tickets for them.", + "parameters": {"type": "object", "properties": {}, "required": []}, + }, + }, + { + "type": "function", + "function": { + "name": "reference_existing_code", + "description": "If the user asks to implement in their codebase. Go through the existing code in order to better understand how to build the requested user feature in the codebase. Analyze the code files, and determine the best way to build out support for the new features in the existing code. ", + "parameters": {"type": "object", "properties": {}, "required": []}, + } + }, + ] + + openai_client = OpenAI() + + response = openai_client.chat.completions.create( + model="gpt-3.5-turbo-1106", + messages=messages, + tools=tools, + tool_choice="auto", + ) + response_message = response.choices[0].message + tool_calls = response_message.tool_calls + function_request_mapping = { + # "ask_followup_questions": AskFollowupQuestionsRequest( + # question=architectAgentRequest.question, + # history=architectAgentRequest.history, + # ), + "create_tasks": CreateTicketsRequest( + question=architectAgentRequest.question, + history=architectAgentRequest.history, + ), + "create_subtasks": CreateSubtasksRequest( + question=architectAgentRequest.question, + history=architectAgentRequest.history, + ), + "reference_existing_code": ReferenceExistingCodeRequest( + question=architectAgentRequest.question, + history=architectAgentRequest.history, + ) + } + + if tool_calls: + available_functions = { + # "ask_followup_questions": ask_followup_questions, + "create_tasks": self.create_tasks, + "create_subtasks": self.create_subtasks, + "reference_existing_code": self.reference_existing_code, + } + messages.append(response_message) + for tool_call in tool_calls: + function_name = tool_call.function.name + print("Function called is: " + str(function_name)) + function_to_call = available_functions[function_name] + print("Function to call is: " + str(function_to_call)) + function_args = function_request_mapping[function_name] + print("Function args are: " + str(function_args)) + return function_to_call(function_args) + + print("returning message: " + str(response_message.content)) + return response_message.content + + + def ask_followup_questions(self, askFollowupQuestionsRequest: AskFollowupQuestionsRequest): + """ + This function will be responsible for asking follow up questions to better understand what the user wants to build. + """ + try: + questionPrompt = f"""Given the description of the project so far {askFollowupQuestionsRequest.history} and the user's latest question {askFollowupQuestionsRequest.question}, come up with additional follow up questions to further deepen your understanding of what the user is trying to build. Ask more questions about the front end, backend, or hosting requirements. Understand the details of the product features. Ask questions until you are confident that you are able to generate a detailed execution plan for the project. The response should be a list of questions that you can ask the user to better understand the project requirements. Limit to 2-3 questions at a time. + """ + + openai_client = OpenAI() + response = openai_client.chat.completions.create( + model="gpt-3.5-turbo-1106", + messages=[ + { + "role": "system", + "content": "You are a senior staff engineer, who is responsible for asking in depth follow up questions to deepen your understanding of a problem before you determine a plan to build it.", + }, + {"role": "user", "content": questionPrompt}, + ], + ) + response = response.choices[0].message.content + + return response + + except Exception as e: + print("Failed to generate subtasks with error " + str(e)) + return "Failed to generate subtasks with error " + str(e) + + + def reference_existing_code(self, referenceExistingCodeRequest: ReferenceExistingCodeRequest): + """ + This method should take the user's question and search the current codebase for all references to that question. It should then summarize the current code and how the user's request can be built within that codebase. + """ + + try: + questionPrompt = f"""Given the description of the project so far {referenceExistingCodeRequest.history} and the user's latest question {referenceExistingCodeRequest.question}, figure out which files in the codebase are most relevant for the user in order to best design a solution to the feature requests. You have this codebase to reference {self.codebase}. If the feature is completely irrelevant to the user's existing code, let the user know that the feature request seems to be unrelated to the existing codebase and ask them to verify if they do indeed want to build that feature in the current codebase. + + If the feature request seems relevant, your response should be something like + + Going through your existing codebase, I would suggest that we build out _feature_ by modifying the following files _files_ and adding the following functionality to them _functionality description_. Happy to break this down into granular subtasks for you next on how I'm planning to approach this execution. + """ + openai_client = OpenAI() + + response = openai_client.chat.completions.create( + model="gpt-3.5-turbo-1106", + messages=[ + { + "role": "system", + "content": "You are a senior staff engineer, who is responsible for going through the codebase in detail and coming up with an execution plan of how to build out certain features. You need to reference the codebase to determine which files are most relevant for the user to build out the feature requests and then come up with an execution plan to build it out across several subtasks.", + }, + {"role": "user", "content": questionPrompt}, + ], + ) + response = response.choices[0].message.content + + return response + + except Exception as e: + print("Failed to generate subtasks with error " + str(e)) + return "Failed to generate subtasks with error " + str(e) + + def create_tasks(self, createTicketsRequest: CreateTicketsRequest): + """ + This function will be responsible for creating multiple tickets in parallel. + """ + # Given the conversation history, create tickets for each subtask + try: + questionPrompt = f"""Given the following subtask information {createTicketsRequest.history}, generate a list of tasks in the following json format + {{ + "subtasks": [ + {{ + "title": "title of the ticket" + "description": "description of the ticket" + }}, + ] + }} + + Take each subtask and generate a title and description. Each one should correspond with a list element in the subtask list. You need to cover all of the subtasks that are mentioned and create a ticket for each one. Each ticket should include the title and description of the subtask. The response should be a list of these json objects for each subtask. + """ + + openai_client = OpenAI() + response = openai_client.chat.completions.create( + model="gpt-3.5-turbo-1106", + messages=[ + { + "role": "system", + "content": "You are a senior staff engineer, who is responsible for breaking up large complex tasks into small, granular subtasks that more junior engineers can easily work through and execute on.", + }, + {"role": "user", "content": questionPrompt}, + ], + + response_format={ "type": "json_object" } + ) + + subtasks = response.choices[0].message.content + print("The tasks created are: " + str(subtasks)) + subtask_json = json.loads(subtasks)["subtasks"] + + # Create a list of ticket objects from the subtasks and call create + tickets = [] + ticket_titles = [] + for subtask in subtask_json: + ticket = Ticket(title=subtask["title"], description=subtask["description"]) + tickets.append(ticket) + ticket_titles.append(ticket.title) + + self.tickets = tickets + + ticketMarkdown = generate_ticket_markdown(tickets) + + return "Great! I've just created the following tickets and assigned them to our agents to get started on immediately \n" + ticketMarkdown + + # response = client.chat.completions.create( + # model="gpt-3.5-turbo-1106", + # messages=[ + # { + # "role": "system", + # "content": "You are a senior staff engineer, who has just created several tasks for a project. You now need to let the user know which tasks have been created so that they can be worked on. Let them know the titles of the tasks that have been created and say that you will get to working on them right away.", + # }, + # { + # "role": "user", + # "content": f"I've just created the following tickets {createdTickets}", + # }, + # ], + # ) + # finalResponse = response.choices[0].message.content + # return finalResponse + + except Exception as e: + print("Failed to generate subtasks with error " + str(e)) + return "Failed to generate subtasks with error " + str(e) + + # Define the tool for breaking up the overall project description into multiple smaller tasks and then getting user feedback on them + def create_subtasks(self, project_description): + """ + This function will be responsible for breaking up the overall project description into multiple smaller tasks and then getting user feedback on them. + """ + try: + questionPrompt = f"""Given the following project description {project_description}, please break it down into smaller tasks that can be accomplished to complete the project. Each task should include a title and a detailed description of the task. The subtasks should all be small enough to be completed in a single day and should represent a micro chunk of work that a user can do to build up to solving the overall task. Focus only on engineering tasks, don't include design or user testing etc. The response should be in the following format + + Brief description of the task and breakdown. Don't include 'Title of the task' in the output, replace it with the actual title - + + + Here is a break down of your task into a list of more manageable subtasks - + + 1. Title of the task + Detailed description of the task with a breakdown of the steps that need to be taken to complete the task + 2. Title of the task + Detailed description of the task with a breakdown of the steps that need to be taken to complete the task + 3. Title of the task + Detailed description of the task with a breakdown of the steps that need to be taken to complete the task + """ + openai_client = OpenAI() + response = openai_client.chat.completions.create( + model="gpt-3.5-turbo-1106", + messages=[ + { + "role": "system", + "content": "You are a senior staff engineer, who is responsible for breaking up large complex tasks into small, granular subtasks that more junior engineers can easily work through and execute on.", + }, + {"role": "user", "content": questionPrompt}, + ], + ) + subtasks = response.choices[0].message.content + return subtasks + except Exception as e: + print("Failed to generate subtasks with error " + str(e)) + return "Failed to generate subtasks with error " + str(e) + + +def generate_ticket_markdown(tickets: List[Ticket]): + markdown = "" + for ticket in tickets: + markdown += f"- **{ticket.title}**: {ticket.description}\n" + return markdown + + diff --git a/dev/agent_dev/architect/lab_architect.ipynb b/dev/agent_dev/architect/lab_architect.ipynb new file mode 100644 index 0000000..e675ecd --- /dev/null +++ b/dev/agent_dev/architect/lab_architect.ipynb @@ -0,0 +1,285 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Architect Lab" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The autoreload extension is already loaded. To reload it, use:\n", + " %reload_ext autoreload\n" + ] + } + ], + "source": [ + "%load_ext autoreload\n", + "%autoreload 2\n", + "\n", + "import json, sys, os\n", + "sys.path.append('..')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Agent" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "from architect import Architect, ArchitectAgentRequest, Codebase" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Get inputs" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [], + "source": [ + "CODEBASE_NAME = \"open-architect\"\n", + "\n", + "with open(f\"../../data/codebases/{CODEBASE_NAME}.json\", \"r\") as f:\n", + " codebase = json.load(f)\n", + "codebase = Codebase(**codebase)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Agent Calls" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[Sophia the Architect] Nice to meet you, I'm Sophia the Architect! I'm here to help you break down your tasks into smaller tickets and create them for you! 🏗️🔨📝\n" + ] + } + ], + "source": [ + "architect = Architect(name=\"Sophia\", codebase=codebase)" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Function called is: reference_existing_code\n", + "Function to call is: >\n", + "Function args are: question='I want to create a config that centralizes all the config of mode params and model id of my agents, looking at my codebase please create some subtasks for me.' history=[\"Hey! What new features would you like to add to your project open-architect today? I'll help you break it down to subtasks, figure out how to integrate with your existing code and then set my crew of SWE agents to get it built out for you!\"]\n" + ] + } + ], + "source": [ + "messages = []\n", + "messages.append({\"role\": \"assistant\", \"content\": \"Hey! What new features would you like to add to your project \" + CODEBASE_NAME + \" today? I'll help you break it down to subtasks, figure out how to integrate with your existing code and then set my crew of SWE agents to get it built out for you!\"})\n", + "\n", + "prompt = \"I want to create a config that centralizes all the config of mode params and model id of my agents, looking at my codebase please create some subtasks for me.\"\n", + "\n", + "architectureAgentReq = ArchitectAgentRequest(\n", + " question=prompt,\n", + " history=[\n", + " msg[\"content\"]\n", + " for msg in messages\n", + " ],\n", + " )\n", + "\n", + "response = architect.compute_response(architectureAgentReq)" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Going through your existing codebase, I would suggest that we build out the feature to create a config that centralizes all the config of mode params and model id of my agents by modifying the following files:\n", + "\n", + "- `.env.example`: This file can be used to define the model params and model ID for the agents. We can add the necessary configuration variables to this file.\n", + "\n", + "- `init_connections.py`: This file sets up the environment variables for connecting to GitHub, Trello, and OpenAI. We can modify this file to include logic for reading the centralized configuration from the `.env` file and initializing the connections with the centralized config.\n", + "\n", + "To achieve this, we can create the following subtasks:\n", + "\n", + "1. Modify `.env.example` to include configuration variables for model params and model ID for the agents.\n", + "\n", + "2. Update `init_connections.py` to read the centralized config from the `.env` file and use it to initialize connections.\n", + "\n", + "3. Test the centralized config setup by ensuring that the connections to GitHub, Trello, and OpenAI are established using the centralized config.\n", + "\n", + "Would you like me to further break down these subtasks into more granular steps for implementation?\n" + ] + } + ], + "source": [ + "print(response)" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [], + "source": [ + "messages.append({'role': 'user', 'content': prompt})\n", + "messages.append({'role': 'assistant', 'content': response})" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Function called is: create_subtasks\n", + "Function to call is: >\n", + "Function args are: question='Please create trello tickets for these subtasks?' history=[\"Hey! What new features would you like to add to your project open-architect today? I'll help you break it down to subtasks, figure out how to integrate with your existing code and then set my crew of SWE agents to get it built out for you!\", 'I want to create a config that centralizes all the config of mode params and model id of my agents, looking at my codebase please create some subtasks for me.', 'Going through your existing codebase, I would suggest that we build out the feature to create a config that centralizes all the config of mode params and model id of my agents by modifying the following files:\\n\\n- `.env.example`: This file can be used to define the model params and model ID for the agents. We can add the necessary configuration variables to this file.\\n\\n- `init_connections.py`: This file sets up the environment variables for connecting to GitHub, Trello, and OpenAI. We can modify this file to include logic for reading the centralized configuration from the `.env` file and initializing the connections with the centralized config.\\n\\nTo achieve this, we can create the following subtasks:\\n\\n1. Modify `.env.example` to include configuration variables for model params and model ID for the agents.\\n\\n2. Update `init_connections.py` to read the centralized config from the `.env` file and use it to initialize connections.\\n\\n3. Test the centralized config setup by ensuring that the connections to GitHub, Trello, and OpenAI are established using the centralized config.\\n\\nWould you like me to further break down these subtasks into more granular steps for implementation?']\n", + "Function called is: create_tasks\n", + "Function to call is: >\n", + "Function args are: question='Please create trello tickets for these subtasks?' history=[\"Hey! What new features would you like to add to your project open-architect today? I'll help you break it down to subtasks, figure out how to integrate with your existing code and then set my crew of SWE agents to get it built out for you!\", 'I want to create a config that centralizes all the config of mode params and model id of my agents, looking at my codebase please create some subtasks for me.', 'Going through your existing codebase, I would suggest that we build out the feature to create a config that centralizes all the config of mode params and model id of my agents by modifying the following files:\\n\\n- `.env.example`: This file can be used to define the model params and model ID for the agents. We can add the necessary configuration variables to this file.\\n\\n- `init_connections.py`: This file sets up the environment variables for connecting to GitHub, Trello, and OpenAI. We can modify this file to include logic for reading the centralized configuration from the `.env` file and initializing the connections with the centralized config.\\n\\nTo achieve this, we can create the following subtasks:\\n\\n1. Modify `.env.example` to include configuration variables for model params and model ID for the agents.\\n\\n2. Update `init_connections.py` to read the centralized config from the `.env` file and use it to initialize connections.\\n\\n3. Test the centralized config setup by ensuring that the connections to GitHub, Trello, and OpenAI are established using the centralized config.\\n\\nWould you like me to further break down these subtasks into more granular steps for implementation?']\n", + "The tasks created are: {\n", + " \"subtasks\": [\n", + " {\n", + " \"title\": \"Create Configuration Variables in .env.example\",\n", + " \"description\": \"Add configuration variables for model params and model ID for the agents to the `.env.example` file in order to centralize the configuration.\"\n", + " },\n", + " {\n", + " \"title\": \"Update init_connections.py to Read Centralized Config\",\n", + " \"description\": \"Modify the `init_connections.py` file to read the centralized config from the `.env` file and utilize it for initializing connections with GitHub, Trello, and OpenAI.\"\n", + " },\n", + " {\n", + " \"title\": \"Test Centralized Config Setup\",\n", + " \"description\": \"Ensure the establishment of connections to GitHub, Trello, and OpenAI using the centralized config by performing comprehensive testing of the centralized config setup.\"\n", + " }\n", + " ]\n", + "}\n" + ] + } + ], + "source": [ + "prompt = \"Please create trello tickets for these subtasks?\"\n", + "\n", + "architectureAgentReq = ArchitectAgentRequest(\n", + " question=prompt,\n", + " history=[\n", + " msg[\"content\"]\n", + " for msg in messages\n", + " ],\n", + " )\n", + "\n", + "response = architect.compute_response(architectureAgentReq)" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Great! I've just created the following tickets and assigned them to our agents to get started on immediately \n", + "- **Create Configuration Variables in .env.example**: Add configuration variables for model params and model ID for the agents to the `.env.example` file in order to centralize the configuration.\n", + "- **Update init_connections.py to Read Centralized Config**: Modify the `init_connections.py` file to read the centralized config from the `.env` file and utilize it for initializing connections with GitHub, Trello, and OpenAI.\n", + "- **Test Centralized Config Setup**: Ensure the establishment of connections to GitHub, Trello, and OpenAI using the centralized config by performing comprehensive testing of the centralized config setup.\n", + "\n" + ] + } + ], + "source": [ + "print(response)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Save Output" + ] + }, + { + "cell_type": "code", + "execution_count": 22, + "metadata": {}, + "outputs": [], + "source": [ + "if not os.path.exists(f\"../../data/tickets/{CODEBASE_NAME}\"):\n", + " os.makedirs(f\"../../data/tickets/{CODEBASE_NAME}\")\n", + "\n", + "TICKET_NAME = \"model-config\"\n", + "for i, ticket in enumerate(architect.tickets):\n", + " with open(f\"../../data/tickets/{CODEBASE_NAME}/{TICKET_NAME}-ticket-{i}.json\", \"w\") as f:\n", + " f.write(ticket.model_dump_json())\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "oa", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.12.2" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/dev/agent_dev/architect/run_st_architect.py b/dev/agent_dev/architect/run_st_architect.py new file mode 100644 index 0000000..000a3f9 --- /dev/null +++ b/dev/agent_dev/architect/run_st_architect.py @@ -0,0 +1,46 @@ + +import streamlit as st +import json +from architect import Architect, ArchitectAgentRequest, Codebase + + +CODEBASE_NAME = "open-architect" + +if __name__ == "__main__": + + try : + with open(f"../../data/codebases/{CODEBASE_NAME}.json", "r") as f: + codebase = json.load(f) + except FileNotFoundError: + raise FileNotFoundError(f"Codebase {CODEBASE_NAME} not found, in data folder. Please make sure the codebase exists in the data folder dev/data/codedases") + + codebase = Codebase(**codebase) + architect = Architect(name="Sophia", codebase=codebase) + + st.title("Open Architect") + + if "messages" not in st.session_state: + st.session_state.messages = [] + st.session_state.messages.append({"role": "assistant", "content": "Hey! What new features would you like to add to your project " + CODEBASE_NAME + " today? I'll help you break it down to subtasks, figure out how to integrate with your existing code and then set my crew of SWE agents to get it built out for you!"}) + + for message in st.session_state.messages: + with st.chat_message(message["role"]): + st.markdown(message["content"]) + + if prompt := st.chat_input("What do you want to build today?"): + st.session_state.messages.append({"role": "user", "content": prompt}) + with st.chat_message("user"): + st.markdown(prompt) + + with st.chat_message("assistant"): + architectureAgentReq = ArchitectAgentRequest( + question=prompt, + history=[ + msg["content"] + for msg in st.session_state.messages + ], + ) + response = architect.compute_response(architectureAgentReq) + res = st.write(response) + + st.session_state.messages.append({"role": "assistant", "content": response}) \ No newline at end of file diff --git a/dev/agent_dev/intern/__init__.py b/dev/agent_dev/intern/__init__.py new file mode 100644 index 0000000..ad7a9c6 --- /dev/null +++ b/dev/agent_dev/intern/__init__.py @@ -0,0 +1,58 @@ + +from models import Ticket, Codebase +from typing import Dict, List +import dspy +import json + +class RelevantFileSelectionSignature(dspy.Signature): + files_in_codebase = dspy.InputField() + ticket = dspy.InputField() + relevant_files: List[str] = dspy.OutputField( + desc="Give the relevant files for you to observe to complete the ticket. They must be keys of the codebase dict." + ) + +class DiffGeneratorSignature(dspy.Signature): + relevant_codebase = dspy.InputField() + ticket = dspy.InputField() + git_diff = dspy.OutputField(desc="Give ONLY the git diff") + explanations = dspy.OutputField(desc="Give explanations for the diff generated") + + +class NewFilesGeneratorSignature(dspy.Signature): + relevant_codebase = dspy.InputField() + ticket = dspy.InputField() + new_files: Dict[str, str] = dspy.OutputField( + desc="Generate the entire files that need to be update or created complete the ticket, with all of their content post update. The key is the path of the file and the value is the content of the file." + ) + explanations = dspy.OutputField( + desc="Give explanations for the new files generated. Use Markdown to format the text." + ) + +class DiffGenerator(dspy.Module): + def __init__(self): + super().__init__() + + self.diff_generator = dspy.ChainOfThought(DiffGeneratorSignature) + self.relevant_file_selector = dspy.TypedChainOfThought( + RelevantFileSelectionSignature + ) + self.new_files_generator = dspy.TypedChainOfThought(NewFilesGeneratorSignature) + + def forward(self, codebase: Codebase, ticket: Ticket): + relevant_files = self.relevant_file_selector( + files_in_codebase=json.dumps(list(codebase.files.keys())), + ticket=json.dumps(ticket.model_dump()), + ) + + subset_codebase = { + file: codebase.files[file] for file in relevant_files.relevant_files + } + + relevant_codebase = Codebase(files=subset_codebase) + + new_files = self.new_files_generator( + relevant_codebase=json.dumps(relevant_codebase.model_dump()), + ticket=json.dumps(ticket.model_dump()), + ) + + return new_files.new_files, new_files.explanations \ No newline at end of file diff --git a/dev/agent_dev/intern/lab_diff_generator.ipynb b/dev/agent_dev/intern/lab_diff_generator.ipynb new file mode 100644 index 0000000..68f6d9e --- /dev/null +++ b/dev/agent_dev/intern/lab_diff_generator.ipynb @@ -0,0 +1,139 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Diff Generator Lab" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The autoreload extension is already loaded. To reload it, use:\n", + " %reload_ext autoreload\n" + ] + } + ], + "source": [ + "%load_ext autoreload\n", + "%autoreload 2\n", + "\n", + "import dspy\n", + "dspy.configure(lm=dspy.OpenAI(model=\"gpt-4-0125-preview\", max_tokens=4096))\n", + "\n", + "import sys, os\n", + "sys.path.append(\"..\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Model" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [], + "source": [ + "from intern import DiffGenerator, Codebase, Ticket" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Get Inputs" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [], + "source": [ + "import json\n", + "CODEBASE_NAME = \"open-architect\"\n", + "TICKET_NAME = \"model-config\"\n", + "\n", + "with open(f\"../../data/codebases/{CODEBASE_NAME}.json\", \"r\") as f:\n", + " codebase = json.load(f)\n", + "codebase = Codebase(**codebase)\n", + "\n", + "\n", + "with open(f\"../../data/tickets/{CODEBASE_NAME}/{TICKET_NAME}-ticket-1.json\", \"r\") as f:\n", + " ticket = json.load(f)\n", + "ticket = Ticket(**ticket)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Forward" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [], + "source": [ + "diff_generator = DiffGenerator()" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [], + "source": [ + "new_files, explanations = diff_generator(codebase, ticket)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Save Outputs" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "oa", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.12.2" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/dev/agent_dev/models.py b/dev/agent_dev/models.py new file mode 100644 index 0000000..f3ddfee --- /dev/null +++ b/dev/agent_dev/models.py @@ -0,0 +1,42 @@ +from typing import Dict, List, Literal, Optional, Any +from pydantic import BaseModel +from github.PullRequest import ReviewComment + + +class Ticket(BaseModel): + id: Optional[str] = None + title: str + description: str + status: Optional[str] = None + assignee_id: Optional[str] = None + +class ModifiedFile(BaseModel): + filename: str + status: str + additions: int + deletions: int + changes: int + patch: str + +# Todo: Use github.PullRequest class instead of this +class PR(BaseModel): + id: int + ticket_id: Optional[str] = None + assignee_id: Optional[str] = None + title: str + description: str + files_changed: List[ModifiedFile] = [] + url: Optional[str] = None + + +class CodeReview(BaseModel): + pr: PR + body: str + event: Literal["APPROVE", "REQUEST_CHANGES", "COMMENT"] + comments: List[ReviewComment] = [] + + +class Codebase(BaseModel): + files: Dict[str, str] + + diff --git a/dev/agent_dev/reviewer/__init__.py b/dev/agent_dev/reviewer/__init__.py new file mode 100644 index 0000000..7fe3dc3 --- /dev/null +++ b/dev/agent_dev/reviewer/__init__.py @@ -0,0 +1,36 @@ +from models import Ticket, PR, CodeReview, Codebase +import dspy + +class GeneratedCodeReview: + is_valid_code: bool + resolves_ticket: bool + code_review: CodeReview + +class ReviewerSignature(dspy.Signature): + # Inputs + # codebase: Codebase = dspy.InputField() + ticket: Ticket = dspy.InputField() + pr: PR = dspy.InputField() + # Outputs + is_valid_code: bool = dspy.OutputField(desc="Check if the code is actually valid.") + resolves_ticket: bool = dspy.OutputField( + desc="Does this code actually resolve the ticket? Is it changing the right files?" + ) + code_review: CodeReview = dspy.OutputField( + desc="If valid, provide a brief comment saying that it looks good. If not valid, provide comments for changes that are needed along with exact line numbers and/or start and end line number. If adding comments, make it different from the main body text." + ) + + +class ReviewerAgent(dspy.Module): + def __init__(self): + super().__init__() + self.code_review_generator = dspy.TypedPredictor(signature=ReviewerSignature) + + def forward( + self, codebase: Codebase, pr: PR, ticket: Ticket + ) -> GeneratedCodeReview: + generated_review = self.code_review_generator( + codebase=codebase, ticket=ticket, pr=pr + ) + + return generated_review \ No newline at end of file diff --git a/dev/agent_dev/reviewer/lab_code_review_generator.ipynb b/dev/agent_dev/reviewer/lab_code_review_generator.ipynb new file mode 100644 index 0000000..cb1abfc --- /dev/null +++ b/dev/agent_dev/reviewer/lab_code_review_generator.ipynb @@ -0,0 +1,132 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Code Review Generator Lab" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [], + "source": [ + "%load_ext autoreload\n", + "%autoreload 2\n", + "\n", + "import json\n", + "import dspy\n", + "\n", + "dspy.configure(lm=dspy.OpenAI(model=\"gpt-4-0125-preview\", max_tokens=4096))\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### DSpy Module" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "from reviewer import ReviewerAgent, Codebase, Ticket, PR" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Get inputs" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "CODEBASE_NAME = \"open-architect\"\n", + "TICKET_NAME = \"model-config\"\n", + "PR_NAME = \"pr-1\"\n", + "\n", + "with open(f\"../../data/codebases/{CODEBASE_NAME}.json\", \"r\") as f:\n", + " codebase = json.load(f)\n", + "codebase = Codebase(**codebase)\n", + "\n", + "with open(f\"../../data/tickets/{CODEBASE_NAME}/{TICKET_NAME}.json\", \"r\") as f:\n", + " ticket = json.load(f)\n", + "ticket = Ticket(**ticket)\n", + "\n", + "with open(f\"../../data/prs/{CODEBASE_NAME}/{TICKET_NAME}/{PR_NAME}.json\", \"r\") as f:\n", + " pr = json.load(f)\n", + "pr = PR(**pr)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Forward" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "reviewer_agent = ReviewerAgent()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "code_review = reviewer_agent(codebase=codebase, ticket=ticket, pr=pr)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Save outputs" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "oa", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.12.2" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/dev/data/codebases/open-architect.json b/dev/data/codebases/open-architect.json new file mode 100644 index 0000000..6b626ef --- /dev/null +++ b/dev/data/codebases/open-architect.json @@ -0,0 +1,17 @@ +{ + "files": { + ".env.example": "GITHUB_REPO_URL=MyOrg/myRepo\nGITHUB_TOKEN=github_pat_1234567890\nOPENAI_API_KEY=sample_openai_key\nTRELLO_API_KEY=1234\nTRELLO_API_SECRET=4321\nTRELLO_TOKEN=ABCD1234\nTRELLO_TOKEN_SECRET=abcd1234\nTRELLO_BOARD_ID=1234abcd\n", + ".gitignore": "# Environments\n.env\n.venv\n*env/\nENV/\nenv.bak/\nvenv.bak/\n\n# PyCharm\n.idea/\n\n# Mac OS\n.DS_Store\n\n# PyCache\n**/__pycache__\n\n# Private keys\n*.pem\n*.log\ncreds.json\n*.txt\n*.ipynb", + "LICENSE": " GNU GENERAL PUBLIC LICENSE\n Version 3, 29 June 2007\n\n Copyright (C) 2007 Free Software Foundation, Inc. \n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n Preamble\n\n The GNU General Public License is a free, copyleft license for\nsoftware and other kinds of works.\n\n The licenses for most software and other practical works are designed\nto take away your freedom to share and change the works. By contrast,\nthe GNU General Public License is intended to guarantee your freedom to\nshare and change all versions of a program--to make sure it remains free\nsoftware for all its users. We, the Free Software Foundation, use the\nGNU General Public License for most of our software; it applies also to\nany other work released this way by its authors. You can apply it to\nyour programs, too.\n\n When we speak of free software, we are referring to freedom, not\nprice. Our General Public Licenses are designed to make sure that you\nhave the freedom to distribute copies of free software (and charge for\nthem if you wish), that you receive source code or can get it if you\nwant it, that you can change the software or use pieces of it in new\nfree programs, and that you know you can do these things.\n\n To protect your rights, we need to prevent others from denying you\nthese rights or asking you to surrender the rights. Therefore, you have\ncertain responsibilities if you distribute copies of the software, or if\nyou modify it: responsibilities to respect the freedom of others.\n\n For example, if you distribute copies of such a program, whether\ngratis or for a fee, you must pass on to the recipients the same\nfreedoms that you received. You must make sure that they, too, receive\nor can get the source code. And you must show them these terms so they\nknow their rights.\n\n Developers that use the GNU GPL protect your rights with two steps:\n(1) assert copyright on the software, and (2) offer you this License\ngiving you legal permission to copy, distribute and/or modify it.\n\n For the developers' and authors' protection, the GPL clearly explains\nthat there is no warranty for this free software. For both users' and\nauthors' sake, the GPL requires that modified versions be marked as\nchanged, so that their problems will not be attributed erroneously to\nauthors of previous versions.\n\n Some devices are designed to deny users access to install or run\nmodified versions of the software inside them, although the manufacturer\ncan do so. This is fundamentally incompatible with the aim of\nprotecting users' freedom to change the software. The systematic\npattern of such abuse occurs in the area of products for individuals to\nuse, which is precisely where it is most unacceptable. Therefore, we\nhave designed this version of the GPL to prohibit the practice for those\nproducts. If such problems arise substantially in other domains, we\nstand ready to extend this provision to those domains in future versions\nof the GPL, as needed to protect the freedom of users.\n\n Finally, every program is threatened constantly by software patents.\nStates should not allow patents to restrict development and use of\nsoftware on general-purpose computers, but in those that do, we wish to\navoid the special danger that patents applied to a free program could\nmake it effectively proprietary. To prevent this, the GPL assures that\npatents cannot be used to render the program non-free.\n\n The precise terms and conditions for copying, distribution and\nmodification follow.\n\n TERMS AND CONDITIONS\n\n 0. Definitions.\n\n \"This License\" refers to version 3 of the GNU General Public License.\n\n \"Copyright\" also means copyright-like laws that apply to other kinds of\nworks, such as semiconductor masks.\n\n \"The Program\" refers to any copyrightable work licensed under this\nLicense. Each licensee is addressed as \"you\". \"Licensees\" and\n\"recipients\" may be individuals or organizations.\n\n To \"modify\" a work means to copy from or adapt all or part of the work\nin a fashion requiring copyright permission, other than the making of an\nexact copy. The resulting work is called a \"modified version\" of the\nearlier work or a work \"based on\" the earlier work.\n\n A \"covered work\" means either the unmodified Program or a work based\non the Program.\n\n To \"propagate\" a work means to do anything with it that, without\npermission, would make you directly or secondarily liable for\ninfringement under applicable copyright law, except executing it on a\ncomputer or modifying a private copy. Propagation includes copying,\ndistribution (with or without modification), making available to the\npublic, and in some countries other activities as well.\n\n To \"convey\" a work means any kind of propagation that enables other\nparties to make or receive copies. Mere interaction with a user through\na computer network, with no transfer of a copy, is not conveying.\n\n An interactive user interface displays \"Appropriate Legal Notices\"\nto the extent that it includes a convenient and prominently visible\nfeature that (1) displays an appropriate copyright notice, and (2)\ntells the user that there is no warranty for the work (except to the\nextent that warranties are provided), that licensees may convey the\nwork under this License, and how to view a copy of this License. If\nthe interface presents a list of user commands or options, such as a\nmenu, a prominent item in the list meets this criterion.\n\n 1. Source Code.\n\n The \"source code\" for a work means the preferred form of the work\nfor making modifications to it. \"Object code\" means any non-source\nform of a work.\n\n A \"Standard Interface\" means an interface that either is an official\nstandard defined by a recognized standards body, or, in the case of\ninterfaces specified for a particular programming language, one that\nis widely used among developers working in that language.\n\n The \"System Libraries\" of an executable work include anything, other\nthan the work as a whole, that (a) is included in the normal form of\npackaging a Major Component, but which is not part of that Major\nComponent, and (b) serves only to enable use of the work with that\nMajor Component, or to implement a Standard Interface for which an\nimplementation is available to the public in source code form. A\n\"Major Component\", in this context, means a major essential component\n(kernel, window system, and so on) of the specific operating system\n(if any) on which the executable work runs, or a compiler used to\nproduce the work, or an object code interpreter used to run it.\n\n The \"Corresponding Source\" for a work in object code form means all\nthe source code needed to generate, install, and (for an executable\nwork) run the object code and to modify the work, including scripts to\ncontrol those activities. However, it does not include the work's\nSystem Libraries, or general-purpose tools or generally available free\nprograms which are used unmodified in performing those activities but\nwhich are not part of the work. For example, Corresponding Source\nincludes interface definition files associated with source files for\nthe work, and the source code for shared libraries and dynamically\nlinked subprograms that the work is specifically designed to require,\nsuch as by intimate data communication or control flow between those\nsubprograms and other parts of the work.\n\n The Corresponding Source need not include anything that users\ncan regenerate automatically from other parts of the Corresponding\nSource.\n\n The Corresponding Source for a work in source code form is that\nsame work.\n\n 2. Basic Permissions.\n\n All rights granted under this License are granted for the term of\ncopyright on the Program, and are irrevocable provided the stated\nconditions are met. This License explicitly affirms your unlimited\npermission to run the unmodified Program. The output from running a\ncovered work is covered by this License only if the output, given its\ncontent, constitutes a covered work. This License acknowledges your\nrights of fair use or other equivalent, as provided by copyright law.\n\n You may make, run and propagate covered works that you do not\nconvey, without conditions so long as your license otherwise remains\nin force. You may convey covered works to others for the sole purpose\nof having them make modifications exclusively for you, or provide you\nwith facilities for running those works, provided that you comply with\nthe terms of this License in conveying all material for which you do\nnot control copyright. Those thus making or running the covered works\nfor you must do so exclusively on your behalf, under your direction\nand control, on terms that prohibit them from making any copies of\nyour copyrighted material outside their relationship with you.\n\n Conveying under any other circumstances is permitted solely under\nthe conditions stated below. Sublicensing is not allowed; section 10\nmakes it unnecessary.\n\n 3. Protecting Users' Legal Rights From Anti-Circumvention Law.\n\n No covered work shall be deemed part of an effective technological\nmeasure under any applicable law fulfilling obligations under article\n11 of the WIPO copyright treaty adopted on 20 December 1996, or\nsimilar laws prohibiting or restricting circumvention of such\nmeasures.\n\n When you convey a covered work, you waive any legal power to forbid\ncircumvention of technological measures to the extent such circumvention\nis effected by exercising rights under this License with respect to\nthe covered work, and you disclaim any intention to limit operation or\nmodification of the work as a means of enforcing, against the work's\nusers, your or third parties' legal rights to forbid circumvention of\ntechnological measures.\n\n 4. Conveying Verbatim Copies.\n\n You may convey verbatim copies of the Program's source code as you\nreceive it, in any medium, provided that you conspicuously and\nappropriately publish on each copy an appropriate copyright notice;\nkeep intact all notices stating that this License and any\nnon-permissive terms added in accord with section 7 apply to the code;\nkeep intact all notices of the absence of any warranty; and give all\nrecipients a copy of this License along with the Program.\n\n You may charge any price or no price for each copy that you convey,\nand you may offer support or warranty protection for a fee.\n\n 5. Conveying Modified Source Versions.\n\n You may convey a work based on the Program, or the modifications to\nproduce it from the Program, in the form of source code under the\nterms of section 4, provided that you also meet all of these conditions:\n\n a) The work must carry prominent notices stating that you modified\n it, and giving a relevant date.\n\n b) The work must carry prominent notices stating that it is\n released under this License and any conditions added under section\n 7. This requirement modifies the requirement in section 4 to\n \"keep intact all notices\".\n\n c) You must license the entire work, as a whole, under this\n License to anyone who comes into possession of a copy. This\n License will therefore apply, along with any applicable section 7\n additional terms, to the whole of the work, and all its parts,\n regardless of how they are packaged. This License gives no\n permission to license the work in any other way, but it does not\n invalidate such permission if you have separately received it.\n\n d) If the work has interactive user interfaces, each must display\n Appropriate Legal Notices; however, if the Program has interactive\n interfaces that do not display Appropriate Legal Notices, your\n work need not make them do so.\n\n A compilation of a covered work with other separate and independent\nworks, which are not by their nature extensions of the covered work,\nand which are not combined with it such as to form a larger program,\nin or on a volume of a storage or distribution medium, is called an\n\"aggregate\" if the compilation and its resulting copyright are not\nused to limit the access or legal rights of the compilation's users\nbeyond what the individual works permit. Inclusion of a covered work\nin an aggregate does not cause this License to apply to the other\nparts of the aggregate.\n\n 6. Conveying Non-Source Forms.\n\n You may convey a covered work in object code form under the terms\nof sections 4 and 5, provided that you also convey the\nmachine-readable Corresponding Source under the terms of this License,\nin one of these ways:\n\n a) Convey the object code in, or embodied in, a physical product\n (including a physical distribution medium), accompanied by the\n Corresponding Source fixed on a durable physical medium\n customarily used for software interchange.\n\n b) Convey the object code in, or embodied in, a physical product\n (including a physical distribution medium), accompanied by a\n written offer, valid for at least three years and valid for as\n long as you offer spare parts or customer support for that product\n model, to give anyone who possesses the object code either (1) a\n copy of the Corresponding Source for all the software in the\n product that is covered by this License, on a durable physical\n medium customarily used for software interchange, for a price no\n more than your reasonable cost of physically performing this\n conveying of source, or (2) access to copy the\n Corresponding Source from a network server at no charge.\n\n c) Convey individual copies of the object code with a copy of the\n written offer to provide the Corresponding Source. This\n alternative is allowed only occasionally and noncommercially, and\n only if you received the object code with such an offer, in accord\n with subsection 6b.\n\n d) Convey the object code by offering access from a designated\n place (gratis or for a charge), and offer equivalent access to the\n Corresponding Source in the same way through the same place at no\n further charge. You need not require recipients to copy the\n Corresponding Source along with the object code. If the place to\n copy the object code is a network server, the Corresponding Source\n may be on a different server (operated by you or a third party)\n that supports equivalent copying facilities, provided you maintain\n clear directions next to the object code saying where to find the\n Corresponding Source. Regardless of what server hosts the\n Corresponding Source, you remain obligated to ensure that it is\n available for as long as needed to satisfy these requirements.\n\n e) Convey the object code using peer-to-peer transmission, provided\n you inform other peers where the object code and Corresponding\n Source of the work are being offered to the general public at no\n charge under subsection 6d.\n\n A separable portion of the object code, whose source code is excluded\nfrom the Corresponding Source as a System Library, need not be\nincluded in conveying the object code work.\n\n A \"User Product\" is either (1) a \"consumer product\", which means any\ntangible personal property which is normally used for personal, family,\nor household purposes, or (2) anything designed or sold for incorporation\ninto a dwelling. In determining whether a product is a consumer product,\ndoubtful cases shall be resolved in favor of coverage. For a particular\nproduct received by a particular user, \"normally used\" refers to a\ntypical or common use of that class of product, regardless of the status\nof the particular user or of the way in which the particular user\nactually uses, or expects or is expected to use, the product. A product\nis a consumer product regardless of whether the product has substantial\ncommercial, industrial or non-consumer uses, unless such uses represent\nthe only significant mode of use of the product.\n\n \"Installation Information\" for a User Product means any methods,\nprocedures, authorization keys, or other information required to install\nand execute modified versions of a covered work in that User Product from\na modified version of its Corresponding Source. The information must\nsuffice to ensure that the continued functioning of the modified object\ncode is in no case prevented or interfered with solely because\nmodification has been made.\n\n If you convey an object code work under this section in, or with, or\nspecifically for use in, a User Product, and the conveying occurs as\npart of a transaction in which the right of possession and use of the\nUser Product is transferred to the recipient in perpetuity or for a\nfixed term (regardless of how the transaction is characterized), the\nCorresponding Source conveyed under this section must be accompanied\nby the Installation Information. But this requirement does not apply\nif neither you nor any third party retains the ability to install\nmodified object code on the User Product (for example, the work has\nbeen installed in ROM).\n\n The requirement to provide Installation Information does not include a\nrequirement to continue to provide support service, warranty, or updates\nfor a work that has been modified or installed by the recipient, or for\nthe User Product in which it has been modified or installed. Access to a\nnetwork may be denied when the modification itself materially and\nadversely affects the operation of the network or violates the rules and\nprotocols for communication across the network.\n\n Corresponding Source conveyed, and Installation Information provided,\nin accord with this section must be in a format that is publicly\ndocumented (and with an implementation available to the public in\nsource code form), and must require no special password or key for\nunpacking, reading or copying.\n\n 7. Additional Terms.\n\n \"Additional permissions\" are terms that supplement the terms of this\nLicense by making exceptions from one or more of its conditions.\nAdditional permissions that are applicable to the entire Program shall\nbe treated as though they were included in this License, to the extent\nthat they are valid under applicable law. If additional permissions\napply only to part of the Program, that part may be used separately\nunder those permissions, but the entire Program remains governed by\nthis License without regard to the additional permissions.\n\n When you convey a copy of a covered work, you may at your option\nremove any additional permissions from that copy, or from any part of\nit. (Additional permissions may be written to require their own\nremoval in certain cases when you modify the work.) You may place\nadditional permissions on material, added by you to a covered work,\nfor which you have or can give appropriate copyright permission.\n\n Notwithstanding any other provision of this License, for material you\nadd to a covered work, you may (if authorized by the copyright holders of\nthat material) supplement the terms of this License with terms:\n\n a) Disclaiming warranty or limiting liability differently from the\n terms of sections 15 and 16 of this License; or\n\n b) Requiring preservation of specified reasonable legal notices or\n author attributions in that material or in the Appropriate Legal\n Notices displayed by works containing it; or\n\n c) Prohibiting misrepresentation of the origin of that material, or\n requiring that modified versions of such material be marked in\n reasonable ways as different from the original version; or\n\n d) Limiting the use for publicity purposes of names of licensors or\n authors of the material; or\n\n e) Declining to grant rights under trademark law for use of some\n trade names, trademarks, or service marks; or\n\n f) Requiring indemnification of licensors and authors of that\n material by anyone who conveys the material (or modified versions of\n it) with contractual assumptions of liability to the recipient, for\n any liability that these contractual assumptions directly impose on\n those licensors and authors.\n\n All other non-permissive additional terms are considered \"further\nrestrictions\" within the meaning of section 10. If the Program as you\nreceived it, or any part of it, contains a notice stating that it is\ngoverned by this License along with a term that is a further\nrestriction, you may remove that term. If a license document contains\na further restriction but permits relicensing or conveying under this\nLicense, you may add to a covered work material governed by the terms\nof that license document, provided that the further restriction does\nnot survive such relicensing or conveying.\n\n If you add terms to a covered work in accord with this section, you\nmust place, in the relevant source files, a statement of the\nadditional terms that apply to those files, or a notice indicating\nwhere to find the applicable terms.\n\n Additional terms, permissive or non-permissive, may be stated in the\nform of a separately written license, or stated as exceptions;\nthe above requirements apply either way.\n\n 8. Termination.\n\n You may not propagate or modify a covered work except as expressly\nprovided under this License. Any attempt otherwise to propagate or\nmodify it is void, and will automatically terminate your rights under\nthis License (including any patent licenses granted under the third\nparagraph of section 11).\n\n However, if you cease all violation of this License, then your\nlicense from a particular copyright holder is reinstated (a)\nprovisionally, unless and until the copyright holder explicitly and\nfinally terminates your license, and (b) permanently, if the copyright\nholder fails to notify you of the violation by some reasonable means\nprior to 60 days after the cessation.\n\n Moreover, your license from a particular copyright holder is\nreinstated permanently if the copyright holder notifies you of the\nviolation by some reasonable means, this is the first time you have\nreceived notice of violation of this License (for any work) from that\ncopyright holder, and you cure the violation prior to 30 days after\nyour receipt of the notice.\n\n Termination of your rights under this section does not terminate the\nlicenses of parties who have received copies or rights from you under\nthis License. If your rights have been terminated and not permanently\nreinstated, you do not qualify to receive new licenses for the same\nmaterial under section 10.\n\n 9. Acceptance Not Required for Having Copies.\n\n You are not required to accept this License in order to receive or\nrun a copy of the Program. Ancillary propagation of a covered work\noccurring solely as a consequence of using peer-to-peer transmission\nto receive a copy likewise does not require acceptance. However,\nnothing other than this License grants you permission to propagate or\nmodify any covered work. These actions infringe copyright if you do\nnot accept this License. Therefore, by modifying or propagating a\ncovered work, you indicate your acceptance of this License to do so.\n\n 10. Automatic Licensing of Downstream Recipients.\n\n Each time you convey a covered work, the recipient automatically\nreceives a license from the original licensors, to run, modify and\npropagate that work, subject to this License. You are not responsible\nfor enforcing compliance by third parties with this License.\n\n An \"entity transaction\" is a transaction transferring control of an\norganization, or substantially all assets of one, or subdividing an\norganization, or merging organizations. If propagation of a covered\nwork results from an entity transaction, each party to that\ntransaction who receives a copy of the work also receives whatever\nlicenses to the work the party's predecessor in interest had or could\ngive under the previous paragraph, plus a right to possession of the\nCorresponding Source of the work from the predecessor in interest, if\nthe predecessor has it or can get it with reasonable efforts.\n\n You may not impose any further restrictions on the exercise of the\nrights granted or affirmed under this License. For example, you may\nnot impose a license fee, royalty, or other charge for exercise of\nrights granted under this License, and you may not initiate litigation\n(including a cross-claim or counterclaim in a lawsuit) alleging that\nany patent claim is infringed by making, using, selling, offering for\nsale, or importing the Program or any portion of it.\n\n 11. Patents.\n\n A \"contributor\" is a copyright holder who authorizes use under this\nLicense of the Program or a work on which the Program is based. The\nwork thus licensed is called the contributor's \"contributor version\".\n\n A contributor's \"essential patent claims\" are all patent claims\nowned or controlled by the contributor, whether already acquired or\nhereafter acquired, that would be infringed by some manner, permitted\nby this License, of making, using, or selling its contributor version,\nbut do not include claims that would be infringed only as a\nconsequence of further modification of the contributor version. For\npurposes of this definition, \"control\" includes the right to grant\npatent sublicenses in a manner consistent with the requirements of\nthis License.\n\n Each contributor grants you a non-exclusive, worldwide, royalty-free\npatent license under the contributor's essential patent claims, to\nmake, use, sell, offer for sale, import and otherwise run, modify and\npropagate the contents of its contributor version.\n\n In the following three paragraphs, a \"patent license\" is any express\nagreement or commitment, however denominated, not to enforce a patent\n(such as an express permission to practice a patent or covenant not to\nsue for patent infringement). To \"grant\" such a patent license to a\nparty means to make such an agreement or commitment not to enforce a\npatent against the party.\n\n If you convey a covered work, knowingly relying on a patent license,\nand the Corresponding Source of the work is not available for anyone\nto copy, free of charge and under the terms of this License, through a\npublicly available network server or other readily accessible means,\nthen you must either (1) cause the Corresponding Source to be so\navailable, or (2) arrange to deprive yourself of the benefit of the\npatent license for this particular work, or (3) arrange, in a manner\nconsistent with the requirements of this License, to extend the patent\nlicense to downstream recipients. \"Knowingly relying\" means you have\nactual knowledge that, but for the patent license, your conveying the\ncovered work in a country, or your recipient's use of the covered work\nin a country, would infringe one or more identifiable patents in that\ncountry that you have reason to believe are valid.\n\n If, pursuant to or in connection with a single transaction or\narrangement, you convey, or propagate by procuring conveyance of, a\ncovered work, and grant a patent license to some of the parties\nreceiving the covered work authorizing them to use, propagate, modify\nor convey a specific copy of the covered work, then the patent license\nyou grant is automatically extended to all recipients of the covered\nwork and works based on it.\n\n A patent license is \"discriminatory\" if it does not include within\nthe scope of its coverage, prohibits the exercise of, or is\nconditioned on the non-exercise of one or more of the rights that are\nspecifically granted under this License. You may not convey a covered\nwork if you are a party to an arrangement with a third party that is\nin the business of distributing software, under which you make payment\nto the third party based on the extent of your activity of conveying\nthe work, and under which the third party grants, to any of the\nparties who would receive the covered work from you, a discriminatory\npatent license (a) in connection with copies of the covered work\nconveyed by you (or copies made from those copies), or (b) primarily\nfor and in connection with specific products or compilations that\ncontain the covered work, unless you entered into that arrangement,\nor that patent license was granted, prior to 28 March 2007.\n\n Nothing in this License shall be construed as excluding or limiting\nany implied license or other defenses to infringement that may\notherwise be available to you under applicable patent law.\n\n 12. No Surrender of Others' Freedom.\n\n If conditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License. If you cannot convey a\ncovered work so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you may\nnot convey it at all. For example, if you agree to terms that obligate you\nto collect a royalty for further conveying from those to whom you convey\nthe Program, the only way you could satisfy both those terms and this\nLicense would be to refrain entirely from conveying the Program.\n\n 13. Use with the GNU Affero General Public License.\n\n Notwithstanding any other provision of this License, you have\npermission to link or combine any covered work with a work licensed\nunder version 3 of the GNU Affero General Public License into a single\ncombined work, and to convey the resulting work. The terms of this\nLicense will continue to apply to the part which is the covered work,\nbut the special requirements of the GNU Affero General Public License,\nsection 13, concerning interaction through a network will apply to the\ncombination as such.\n\n 14. Revised Versions of this License.\n\n The Free Software Foundation may publish revised and/or new versions of\nthe GNU General Public License from time to time. Such new versions will\nbe similar in spirit to the present version, but may differ in detail to\naddress new problems or concerns.\n\n Each version is given a distinguishing version number. If the\nProgram specifies that a certain numbered version of the GNU General\nPublic License \"or any later version\" applies to it, you have the\noption of following the terms and conditions either of that numbered\nversion or of any later version published by the Free Software\nFoundation. If the Program does not specify a version number of the\nGNU General Public License, you may choose any version ever published\nby the Free Software Foundation.\n\n If the Program specifies that a proxy can decide which future\nversions of the GNU General Public License can be used, that proxy's\npublic statement of acceptance of a version permanently authorizes you\nto choose that version for the Program.\n\n Later license versions may give you additional or different\npermissions. However, no additional obligations are imposed on any\nauthor or copyright holder as a result of your choosing to follow a\nlater version.\n\n 15. Disclaimer of Warranty.\n\n THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\nAPPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\nHOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY\nOF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\nTHE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\nIS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\nALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\n 16. Limitation of Liability.\n\n IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\nWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS\nTHE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY\nGENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE\nUSE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF\nDATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD\nPARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),\nEVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF\nSUCH DAMAGES.\n\n 17. Interpretation of Sections 15 and 16.\n\n If the disclaimer of warranty and limitation of liability provided\nabove cannot be given local legal effect according to their terms,\nreviewing courts shall apply local law that most closely approximates\nan absolute waiver of all civil liability in connection with the\nProgram, unless a warranty or assumption of liability accompanies a\ncopy of the Program in return for a fee.\n\n END OF TERMS AND CONDITIONS\n\n How to Apply These Terms to Your New Programs\n\n If you develop a new program, and you want it to be of the greatest\npossible use to the public, the best way to achieve this is to make it\nfree software which everyone can redistribute and change under these terms.\n\n To do so, attach the following notices to the program. It is safest\nto attach them to the start of each source file to most effectively\nstate the exclusion of warranty; and each file should have at least\nthe \"copyright\" line and a pointer to where the full notice is found.\n\n \n Copyright (C) \n\n This program is free software: you can redistribute it and/or modify\n it under the terms of the GNU General Public License as published by\n the Free Software Foundation, either version 3 of the License, or\n (at your option) any later version.\n\n This program is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU General Public License for more details.\n\n You should have received a copy of the GNU General Public License\n along with this program. If not, see .\n\nAlso add information on how to contact you by electronic and paper mail.\n\n If the program does terminal interaction, make it output a short\nnotice like this when it starts in an interactive mode:\n\n Copyright (C) \n This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\n This is free software, and you are welcome to redistribute it\n under certain conditions; type `show c' for details.\n\nThe hypothetical commands `show w' and `show c' should show the appropriate\nparts of the General Public License. Of course, your program's commands\nmight be different; for a GUI interface, you would use an \"about box\".\n\n You should also get your employer (if you work as a programmer) or school,\nif any, to sign a \"copyright disclaimer\" for the program, if necessary.\nFor more information on this, and how to apply and follow the GNU GPL, see\n.\n\n The GNU General Public License does not permit incorporating your program\ninto proprietary programs. If your program is a subroutine library, you\nmay consider it more useful to permit linking proprietary applications with\nthe library. If this is what you want to do, use the GNU Lesser General\nPublic License instead of this License. But first, please read\n.", + "README.md": "[![Discord](https://dcbadge.vercel.app/api/server/WCNEFsrtjw)](https://discord.gg/WCNEFsrtjw)\n[![Stargazers][stars-shield]][stars-url]\n[![Issues][issues-shield]][issues-url]\n[![License][license-shield]][license-url]\n\n

Open Architect

\n\n

\nOrchestrate your fleet of AI software designers, engineers and reviewers!\n\n\"image\"\n
\n
\nCreated at the MistralAI hackathon in SF\n
\n

\n\nJust create tickets (or have an AI architect assist you), and let the agents do the work. Your approval is required to merge PRs, so no bug or wrong code is ever introduced without your approval!\n\n## Setup\n\n1. Clone this repo\n2. Install dependencies with `pip install -r requirements.txt`\n3. Enter the infos related to the repository in which you want to work in `settings.json` or run `oa setup`\n4. Profit\n\n### How to connect to Github\n\n1. Be part of the org of your repo\n2. Go to https://github.com/settings/tokens?type=beta and create a personnal access token for the repo\n3. Run the `init_connections.py` script and provide the URL to your repo and the access token\n\n### Hot to connect to Trello\n\n1. Connect to https://trello.com/ and log in. Navigate to your target Board. Save the Board ID.\n2. Create a PowerUp for your Workspace at https://trello.com/power-ups/admin (you don't need the Iframe connector URL). Save your API Key and Secret\n3. Run the `init_connections.py` script and provide the needed secrets\n\n### Other requirement\n\nWe currently use OpenAI for our inferences, so you'll need an [OpenAI API key](https://platform.openai.com/api-keys) with some credits (we currently use GPT3.5 Turbo and GPT4, see pricing [here](https://openai.com/pricing#:~:text=1M%20tokens-,GPT%2D3.5%20Turbo,-GPT%2D3.5%20Turbo)).\n\nThen run the `init_connections.py` script and provide your key\n\n \n## How to run\n\nDesign tickets and add them to your backlog with:\n- `streamlit run start_architecting.py` to spawn an architect running in a chatbot that will create code tickets with you.\n\nRun your fleet with:\n- `./oa start intern` to spawn a developer that will process tickets and open PRs with code.\n- `./oa start reviewer` to spawn a reviewer that will review PRs and ask for changes.\n\nYou can also start multiple ones with `./oa start agent1 agent2`\n\n## Contributing\n\nThis is intended to be a collaborative project, and we'd love to take suggestions for new features, improvements, and fixes!\n\n- If there is something you'd like us to work on, feel free to open an **Issue** with the adequate tag and a good description. If it's a bug, please add steps to reproduce it.\n- If you have a contribution you'd like to make: first of all, thanks! You rock! Please open a PR and we'll review it as soon as we can!\n\n[stars-shield]: https://img.shields.io/github/stars/OpenArchitectAI/open-architect?style=for-the-badge\n[stars-url]: https://github.com/OpenArchitectAI/open-architect/stargazers\n[issues-shield]: https://img.shields.io/github/issues/OpenArchitectAI/open-architect?style=for-the-badge\n[issues-url]: https://github.com/OpenArchitectAI/open-architect/issues\n[license-shield]: https://img.shields.io/github/license/OpenArchitectAI/open-architect?style=for-the-badge\n[license-url]: https://github.com/OpenArchitectAI/open-architect/blob/main/LICENSE\n", + "create_backlog_tickets_for_all.py": "from dotenv import load_dotenv\nfrom random import randint\nimport os\n\nfrom src.models import Ticket\nfrom src.helpers.trello import TrelloHelper\n\nload_dotenv()\n\nN_TICKETS = 10\n\ntrello_api_key = os.getenv(\"TRELLO_API_KEY\")\ntrello_api_secret = os.getenv(\"TRELLO_API_SECRET\")\ntrello_token = os.getenv(\"TRELLO_TOKEN\")\ntrello_board_id = os.getenv(\"TRELLO_BOARD_ID\")\n\nth = TrelloHelper(trello_api_key, trello_token, trello_board_id)\n\ntickets = [\n Ticket(\n title=\"Test Ticket \" + str(randint(0, 10000)),\n description=\"This is a test ticket\",\n )\n for _ in range(N_TICKETS)\n]\nth.push_tickets_to_backlog_and_assign(tickets)\n", + "init_connections.py": "from dotenv import load_dotenv\nimport os\n\nfrom trello import create_oauth_token\n\nload_dotenv()\n\ngh_repo = os.getenv(\"GITHUB_REPO_URL\")\ngh_api_token_intern = os.getenv(\"GITHUB_TOKEN_INTERN\")\ngh_api_token_reviewer = os.getenv(\"GITHUB_TOKEN_REVIEWER\")\nopenai_api_key = os.getenv(\"OPENAI_API_KEY\")\ntrello_api_key = os.getenv(\"TRELLO_API_KEY\")\ntrello_api_secret = os.getenv(\"TRELLO_API_SECRET\")\ntrello_token = os.getenv(\"TRELLO_TOKEN\")\ntrello_board_id = os.getenv(\"TRELLO_BOARD_ID\")\n\nif gh_repo is None:\n gh_repo = input(\"Enter the GitHub repo URL: \")\nif gh_api_token_intern is None:\n gh_api_token_intern = input(\"Enter your GitHub Personnal Access token for the intern (https://github.com/settings/tokens): \")\nif gh_api_token_reviewer is None:\n gh_api_token_reviewer = input(\"Enter your GitHub Personnal Access token for the reviewer (https://github.com/settings/tokens): \")\n\nif trello_api_key is None:\n trello_api_key = input(\"Enter your Trello API key (https://trello.com/power-ups/admin): \")\nif trello_api_secret is None:\n trello_api_secret = input(\"Enter your Trello API secret (https://trello.com/power-ups/admin): \")\nif trello_token is None:\n auth_token = create_oauth_token(key=trello_api_key, secret=trello_api_secret, name='Trello API')\n trello_token = auth_token['oauth_token']\nif trello_board_id is None:\n trello_board_id = input(\"Enter your Trello Board ID: \")\n\nif openai_api_key is None:\n openai_api_key = input(\"Enter your OpenAI API key (https://platform.openai.com/api-keys): \")\n\n\n# Write them back to the .env file\nwith open(\".env\", \"w\") as f:\n f.write(f\"GITHUB_REPO_URL={gh_repo}\\n\")\n f.write(f\"GITHUB_TOKEN_INTERN={gh_api_token_intern}\\n\")\n f.write(f\"GITHUB_TOKEN_REVIEWER={gh_api_token_reviewer}\\n\")\n f.write(f\"OPENAI_API_KEY={openai_api_key}\\n\")\n f.write(f\"TRELLO_API_KEY={trello_api_key}\\n\")\n f.write(f\"TRELLO_API_SECRET={trello_api_secret}\\n\")\n f.write(f\"TRELLO_TOKEN={trello_token}\\n\")\n f.write(f\"TRELLO_BOARD_ID={trello_board_id}\\n\")\n\nprint(\"Environment variables set up successfully\")", + "oa": "#!/bin/bash\n\n# Get the directory of the current script\nSCRIPT_DIR=\"$( cd \"$( dirname \"${BASH_SOURCE[0]}\" )\" &> /dev/null && pwd )\"\n\n# Run the Python script with the provided arguments\npython \"${SCRIPT_DIR}/oa_cli.py\" \"$@\"\n", + "oa_cli.py": "import argparse\nfrom dotenv import load_dotenv\nfrom threading import Thread\nimport os\nfrom src.helpers.github import GHHelper\nfrom src.helpers.trello import TrelloHelper\nfrom src.agents.intern import Intern\nfrom src.agents.reviewer import Reviewer\n\n\ndef start_intern(gh_helper_intern, trello_helper):\n intern = Intern(\"Alex\", gh_helper=gh_helper_intern, board_helper=trello_helper)\n intern_thread = Thread(target=intern.run)\n intern_thread.start()\n\n\ndef start_reviewer(gh_helper_reviewer, trello_helper):\n reviewer = Reviewer(\n \"Charlie\", gh_helper=gh_helper_reviewer, board_helper=trello_helper\n )\n reviewer_thread = Thread(target=reviewer.run)\n reviewer_thread.start()\n\n\ndef main():\n parser = argparse.ArgumentParser(description=\"Open Architect CLI\")\n parser.add_argument(\"command\", choices=[\"run\"], help=\"Command to execute\")\n parser.add_argument(\n \"agents\", nargs=\"+\", choices=[\"intern\", \"reviewer\"], help=\"Agents to run\"\n )\n args = parser.parse_args()\n\n load_dotenv()\n\n gh_repo = os.getenv(\"GITHUB_REPO_URL\")\n gh_api_token_intern = os.getenv(\"GITHUB_TOKEN_INTERN\")\n gh_api_token_reviewer = os.getenv(\"GITHUB_TOKEN_REVIEWER\")\n openai_api_key = os.getenv(\"OPENAI_API_KEY\")\n trello_api_key = os.getenv(\"TRELLO_API_KEY\")\n trello_api_secret = os.getenv(\"TRELLO_API_SECRET\")\n trello_token = os.getenv(\"TRELLO_TOKEN\")\n trello_board_id = os.getenv(\"TRELLO_BOARD_ID\")\n\n if (\n gh_repo is None\n or gh_api_token_intern is None\n or gh_api_token_reviewer is None\n or openai_api_key is None\n or trello_api_key is None\n or trello_api_secret is None\n or trello_token is None\n or trello_board_id is None\n ):\n print(\n \"Please run the init_connections.py script to set up the environment variables\"\n )\n return\n\n gh_helper_intern = GHHelper(gh_api_token_intern, gh_repo)\n gh_helper_reviewer = GHHelper(gh_api_token_reviewer, gh_repo)\n trello_helper = TrelloHelper(trello_api_key, trello_token, trello_board_id)\n\n if args.command == \"run\":\n for agent in args.agents:\n if agent == \"intern\":\n start_intern(gh_helper_intern, trello_helper)\n elif agent == \"reviewer\":\n start_reviewer(gh_helper_reviewer, trello_helper)\n\n\nif __name__ == \"__main__\":\n main()\n", + "requirements.txt": "aiohttp==3.9.3\naiosignal==1.3.1\nalembic==1.13.1\naltair==5.2.0\nannotated-types==0.6.0\nanyio==4.3.0\nattrs==23.2.0\nbackoff==2.2.1\nblinker==1.7.0\ncachetools==5.3.3\ncertifi==2024.2.2\ncffi==1.16.0\ncharset-normalizer==3.3.2\nclick==8.1.7\ncolorlog==6.8.2\ncryptography==42.0.5\ndatasets==2.14.7\nDeprecated==1.2.14\ndill==0.3.7\ndistro==1.9.0\ndspy-ai==2.4.0\nfilelock==3.13.3\nfrozenlist==1.4.1\nfsspec==2023.10.0\ngitdb==4.0.11\nGitPython==3.1.42\nh11==0.14.0\nhttpcore==1.0.5\nhttpx==0.27.0\nhuggingface-hub==0.22.1\nidna==3.6\nJinja2==3.1.3\njoblib==1.3.2\njsonschema==4.21.1\njsonschema-specifications==2023.12.1\nMako==1.3.2\nmarkdown-it-py==3.0.0\nMarkupSafe==2.1.5\nmdurl==0.1.2\nmultidict==6.0.5\nmultiprocess==0.70.15\nnumpy==1.26.4\noauthlib==3.2.2\nopenai==1.14.3\noptuna==3.6.0\norjson==3.10.0\npackaging==23.2\npandas==2.2.1\npillow==10.2.0\nprotobuf==4.25.3\npy-trello==0.19.0\npyarrow==15.0.2\npyarrow-hotfix==0.6\npycparser==2.21\npydantic==2.5.0\npydantic_core==2.14.1\npydeck==0.8.1b0\nPyGithub==2.3.0\nPygments==2.17.2\nPyJWT==2.8.0\nPyNaCl==1.5.0\npython-dateutil==2.9.0.post0\npython-dotenv==1.0.1\npytz==2024.1\nPyYAML==6.0.1\nreferencing==0.34.0\nregex==2023.12.25\nrequests==2.31.0\nrequests-oauthlib==2.0.0\nrich==13.7.1\nrpds-py==0.18.0\nsix==1.16.0\nsmmap==5.0.1\nsniffio==1.3.1\nSQLAlchemy==2.0.29\nstreamlit==1.32.2\ntenacity==8.2.3\ntoml==0.10.2\ntoolz==0.12.1\ntornado==6.4\ntqdm==4.66.2\ntyping_extensions==4.10.0\ntzdata==2024.1\nujson==5.9.0\nurllib3==2.2.1\nwrapt==1.16.0\nxxhash==3.4.1\nyarl==1.9.4\n", + "start_architecting.py": "from dotenv import load_dotenv\nimport os\n\nfrom src.helpers.github import GHHelper\nfrom src.helpers.trello import TrelloHelper\n\nfrom src.agents.architect import Architect\n\nload_dotenv()\n\ngh_repo = os.getenv(\"GITHUB_REPO_URL\")\ngh_api_token_reviewer = os.getenv(\"GITHUB_TOKEN_REVIEWER\")\nopenai_api_key = os.getenv(\"OPENAI_API_KEY\")\ntrello_api_key = os.getenv(\"TRELLO_API_KEY\")\ntrello_api_secret = os.getenv(\"TRELLO_API_SECRET\")\ntrello_token = os.getenv(\"TRELLO_TOKEN\")\ntrello_board_id = os.getenv(\"TRELLO_BOARD_ID\")\n\nif (\n gh_repo is None\n or gh_api_token_reviewer is None\n or openai_api_key is None\n or trello_api_key is None\n or trello_api_secret is None\n or trello_token is None\n or trello_board_id is None\n):\n print(\n \"Please run the init_connections.py script to set up the environment variables\"\n )\n\ngh_helper = GHHelper(gh_api_token_reviewer, gh_repo)\ntrello_helper = TrelloHelper(trello_api_key, trello_token, trello_board_id)\n\narchitect = Architect(\n \"Sophia\",\n gh_helper=gh_helper,\n board_helper=trello_helper,\n)\n\narchitect.run()", + "start_coding.py": "from dotenv import load_dotenv\nfrom threading import Thread\nimport os\n\nfrom src.helpers.github import GHHelper\nfrom src.helpers.trello import TrelloHelper\n\nfrom src.agents.intern import Intern\nfrom src.agents.reviewer import Reviewer\n\nload_dotenv()\n\ngh_repo = os.getenv(\"GITHUB_REPO_URL\")\ngh_api_token_intern = os.getenv(\"GITHUB_TOKEN_INTERN\")\ngh_api_token_reviewer = os.getenv(\"GITHUB_TOKEN_REVIEWER\")\ntrello_api_key = os.getenv(\"TRELLO_API_KEY\")\ntrello_api_secret = os.getenv(\"TRELLO_API_SECRET\")\ntrello_token = os.getenv(\"TRELLO_TOKEN\")\ntrello_board_id = os.getenv(\"TRELLO_BOARD_ID\")\n\nif (\n gh_repo is None\n or gh_api_token_intern is None\n or gh_api_token_reviewer is None\n or trello_api_key is None\n or trello_api_secret is None\n or trello_token is None\n or trello_board_id is None\n):\n print(\n \"Please run the init_connections.py script to set up the environment variables\"\n )\n\ngh_helper_intern = GHHelper(gh_api_token_intern, gh_repo)\ngh_helper_reviewer = GHHelper(gh_api_token_reviewer, gh_repo)\ntrello_helper = TrelloHelper(trello_api_key, trello_token, trello_board_id)\n\nintern = Intern(\"alex\", gh_helper=gh_helper_intern, board_helper=trello_helper)\nreviewer = Reviewer(\n \"charlie\",\n gh_helper=gh_helper_reviewer,\n board_helper=trello_helper,\n)\n\nintern_thread = Thread(target=intern.run)\nreviewer_thread = Thread(target=reviewer.run)\n\n# Step 1: With User input (streamit), define tickets, push to Trello's Backlog\n\nwhile True:\n # Step 2: Let's get to work (n + 1 threads)\n intern_thread.start()\n reviewer_thread.start()\n", + "test_gh_helper.py": "from dotenv import load_dotenv\nimport os\n\nfrom gh_helper import GHHelper\n\nload_dotenv()\n\ngh_repo = os.getenv(\"GITHUB_REPO_URL\")\ngh_api_token = os.getenv(\"GITHUB_TOKEN\")\nif gh_repo is None or gh_api_token is None:\n print(\"Please run the start.py script to set up the environment variables\")\n\ngh = GHHelper(gh_api_token, gh_repo)\n\ngh.list_open_prs()\n\nprint(gh.get_entire_codebase())\n", + "test_trello_helper.py": "from dotenv import load_dotenv\nimport os\n\nfrom src.models import Ticket\nfrom src.helpers.trello import TrelloHelper\n\nload_dotenv()\n\ntrello_api_key = os.getenv(\"TRELLO_API_KEY\")\ntrello_token = os.getenv(\"TRELLO_TOKEN\")\ntrello_board_id = os.getenv(\"TRELLO_BOARD_ID\")\n\nif trello_api_key is None or trello_token is None or trello_board_id is None:\n print(\"Please run the start.py script to set up the environment variables\")\n\ntrello_helper = TrelloHelper(trello_api_key, trello_token, trello_board_id)\n\n## Step 0: Create an intern\nnew_intern = trello_helper.create_intern(\"Test Intern\")\n\n## Step 1: Get the available \"candidates\" (interns) from Trello\ninterns = trello_helper.get_intern_list()\nprint(\"ok\" if interns[-1] else \"not ok\")\n\n## Step 2: Create a ticket and assign it to an intern\nnew_ticket = Ticket(\n title=\"Test Ticket\",\n description=\"This is a test ticket\",\n assignee_id=new_intern,\n)\ncreated_ticket = trello_helper.push_tickets_to_backlog_and_assign([new_ticket])[-1]\nprint(\"ok\" if created_ticket.title == new_ticket.title else \"not ok\")\ntrello_helper.move_to_todo(trello_helper.get_last_ticket().id)\n\n## Step 3: Get the tickets from the To Do list\ntickets = trello_helper.get_tickets_todo_list()\nprint(\"ok\" if tickets[-1] else \"not ok\")\n\n## Step 4: Cleanup\ntrello_helper.delete_ticket(tickets[-1].id)\ntrello_helper.fire_intern(new_intern)\nprint(\"Done!\")\n" + } +} \ No newline at end of file diff --git a/dev/data/get_data_utils.ipynb b/dev/data/get_data_utils.ipynb new file mode 100644 index 0000000..58489be --- /dev/null +++ b/dev/data/get_data_utils.ipynb @@ -0,0 +1,115 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Helper Notebook to Get Data\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": {}, + "outputs": [], + "source": [ + "import os, sys, json\n", + "from dotenv import load_dotenv\n", + "load_dotenv()\n", + "\n", + "sys.path.append(os.path.join(os.getcwd(), \"../..\"))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Get Code Base Data" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, + "outputs": [], + "source": [ + "from src.helpers.github import GHHelper" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Selected repo: open-architect\n" + ] + } + ], + "source": [ + "gh_repo = \"CedricJouan/open-architect\"\n", + "gh_repo_name = \"open-architect\"\n", + "\n", + "gh_helper = GHHelper(os.environ['GITHUB_TOKEN_REVIEWER'], gh_repo)" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": {}, + "outputs": [], + "source": [ + "codebase = gh_helper.get_entire_codebase()" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": {}, + "outputs": [], + "source": [ + "with open(f\"./codebases/{gh_repo_name}.json\", \"w\") as f:\n", + " json.dump({\"files\":codebase.files}, f, indent=4)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Make Tickets" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "oa", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.12.2" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/dev/data/tickets/open-architect/model-config-ticket-0.json b/dev/data/tickets/open-architect/model-config-ticket-0.json new file mode 100644 index 0000000..fbf1599 --- /dev/null +++ b/dev/data/tickets/open-architect/model-config-ticket-0.json @@ -0,0 +1 @@ +{"id":null,"title":"Create Configuration Variables in .env.example","description":"Add configuration variables for model params and model ID for the agents to the `.env.example` file in order to centralize the configuration.","status":null,"assignee_id":null} \ No newline at end of file diff --git a/dev/data/tickets/open-architect/model-config-ticket-1.json b/dev/data/tickets/open-architect/model-config-ticket-1.json new file mode 100644 index 0000000..448a2c9 --- /dev/null +++ b/dev/data/tickets/open-architect/model-config-ticket-1.json @@ -0,0 +1 @@ +{"id":null,"title":"Update init_connections.py to Read Centralized Config","description":"Modify the `init_connections.py` file to read the centralized config from the `.env` file and utilize it for initializing connections with GitHub, Trello, and OpenAI.","status":null,"assignee_id":null} \ No newline at end of file diff --git a/dev/data/tickets/open-architect/model-config-ticket-2.json b/dev/data/tickets/open-architect/model-config-ticket-2.json new file mode 100644 index 0000000..7a412e3 --- /dev/null +++ b/dev/data/tickets/open-architect/model-config-ticket-2.json @@ -0,0 +1 @@ +{"id":null,"title":"Test Centralized Config Setup","description":"Ensure the establishment of connections to GitHub, Trello, and OpenAI using the centralized config by performing comprehensive testing of the centralized config setup.","status":null,"assignee_id":null} \ No newline at end of file diff --git a/dev/requirements.txt b/dev/requirements.txt new file mode 100644 index 0000000..871594d --- /dev/null +++ b/dev/requirements.txt @@ -0,0 +1 @@ +jupyter==1.0.0 \ No newline at end of file From 57568661b76bf171f36263399c85e24207a37946 Mon Sep 17 00:00:00 2001 From: CedricJouan <63424587+CedricJouan@users.noreply.github.com> Date: Fri, 19 Apr 2024 13:55:40 -0700 Subject: [PATCH 2/2] Update example env file just a quick fix on the example .env file... --- .env.example | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.env.example b/.env.example index e7ee3cb..e06a5ef 100644 --- a/.env.example +++ b/.env.example @@ -1,5 +1,6 @@ GITHUB_REPO_URL=MyOrg/myRepo -GITHUB_TOKEN=github_pat_1234567890 +GITHUB_TOKEN_INTERN=github_pat_1234567890 +GITHUB_TOKEN_REVIEWER=github_pat_0987654321 OPENAI_API_KEY=sample_openai_key TRELLO_API_KEY=1234 TRELLO_API_SECRET=4321