Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 2 additions & 0 deletions dev/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
!*.ipynb
!*.txt
4 changes: 4 additions & 0 deletions dev/READMN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<h1>Open Architect - agent_dev</h1>

Development space for researching and developing the agent independently from the rest of the app.

Empty file added dev/agent_dev/__init__.py
Empty file.
321 changes: 321 additions & 0 deletions dev/agent_dev/architect/__init__.py

Large diffs are not rendered by default.

285 changes: 285 additions & 0 deletions dev/agent_dev/architect/lab_architect.ipynb
Original file line number Diff line number Diff line change
@@ -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: <bound method Architect.reference_existing_code of <architect.Architect object at 0x116c3a150>>\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: <bound method Architect.create_subtasks of <architect.Architect object at 0x116c3a150>>\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: <bound method Architect.create_tasks of <architect.Architect object at 0x116c3a150>>\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
}
46 changes: 46 additions & 0 deletions dev/agent_dev/architect/run_st_architect.py
Original file line number Diff line number Diff line change
@@ -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})
Loading