Skip to content

Commit c73e2eb

Browse files
committed
Update
1 parent ee02041 commit c73e2eb

7 files changed

Lines changed: 52 additions & 123 deletions

File tree

README.md

Lines changed: 18 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,10 @@
33

44
![GitHub stars](https://img.shields.io/github/stars/blazickjp/GPT-CodeApp?style=social) ![GitHub release (latest by date)](https://img.shields.io/github/v/release/blazickjp/GPT-CodeApp) ![GitHub All Releases](https://img.shields.io/github/downloads/blazickjp/GPT-CodeApp/total) [![Run Pytest](https://github.com/blazickjp/GPT-CodeApp/actions/workflows/pytest_ubuntu.yml/badge.svg)](https://github.com/blazickjp/GPT-CodeApp/actions/workflows/pytest_ubuntu.yml) ![GitHub contributors](https://img.shields.io/github/contributors/blazickjp/GPT-CodeApp) ![GitHub](https://img.shields.io/github/license/blazickjp/GPT-CodeApp)
55

6-
Welcome to GPT-CodeApp, the coding companion you didn't know you needed! 🎉 This project is a clone of Chat-GPT, but with all the features we wish were available. Tired of constantly copying and pasting from VS Code into the UI? Losing context in the conversation memory? Having little visibility into what's going on under the hood? We've got you covered!
6+
Embark on a coding adventure with GPT-CodeApp, your new AI-powered coding companion! 🎉 This isn't just another Chat-GPT clone; it's your gateway to a smoother coding experience, packed with features you've always wished for.
77

8-
GPT-CodeApp started as a tool to better manage the model's conversational memory and context, but we didn't stop there. We're giving the models access to read, write, and edit files, all under your control! We're offloading all the tedious work to the models, so you can focus on what matters.
98

10-
We're continuously improving and setting new goals. So, come join us on this exciting journey! 🚀
11-
12-
13-
![](images/Snip20231015_2.png)
9+
![](images/Snip20240321_1.png)
1410

1511
## 📚 Table of Contents
1612

@@ -21,65 +17,40 @@ We're continuously improving and setting new goals. So, come join us on this exc
2117
- [License](#license)
2218
- [Questions](#questions)
2319

24-
## 🔥 Recent Updates 🔥
25-
26-
- **Bedrock Support:** We've added support for Bedrock, specifically the ClaudEv2 model, allowing you to leverage their AI models in addition to OpenAI's GPT-3.5 and GPT-4 models. 🧠
27-
- **Sagemaker Endpoint Support:** We're working on adding support for any Sagemaker endpoint. This will allow you to sause any model hosted on Amazon Sagemaker.
28-
- **Prompt Management:** We've added backend support for prompt management, giving you more control over the prompts that are sent to the AI models.
29-
- **SQLite Database:** We've moved from Postgres to SQLite for our database needs. This makes setup easier and reduces the resources required to run the application.
30-
- **UI-Controlled Project Configuration:** You can now control the project configuration directly from the user interface, making it easier to customize the application to your needs.
31-
32-
3320
## 🛠️ Installation and Setup
3421

35-
Setting up GPT-CodeApp is as easy as 1, 2, 3! Our application consists of a frontend and a backend, both of which need to be set up separately. Follow the steps below to get started:
22+
Setting up GPT-CodeApp is as easy as 1, 2, 3! Our application consists of a frontend and a backend, both of which need to be set up separately.
3623

37-
### Backend Setup
24+
Jump straight into action with these simple setup steps for both the frontend and backend. Let's get the engines running!
3825

39-
The backend is a Python application that uses FastAPI. Here's how to set it up:
40-
41-
42-
1. Navigate to the backend directory:
26+
### Backend: The Brain 🧠
4327

28+
1. **Enter the Backend Lair:**
4429
```bash
4530
cd backend
4631
```
47-
48-
2. Install the necessary Python dependencies. We recommend doing this in a virtual environment:
49-
50-
32+
2. **Summon the Python Dependencies:**
5133
```bash
5234
python3 -m venv env
5335
source env/bin/activate
5436
pip install -r requirements.txt
5537
```
56-
57-
3. Start the backend server:
58-
38+
3. **Awaken the Backend Beast:**
5939
```bash
6040
uvicorn main:app --reload
6141
```
6242

63-
The backend server will start running at `http://localhost:8000`.
64-
65-
### Frontend Setup
66-
67-
The frontend is a React application that uses Next.js. To set it up, follow these steps:
68-
69-
1. Navigate to the frontend directory:
43+
### Frontend: The Face 😎
7044

45+
1. **Dive into the Frontend Fortress:**
7146
```bash
7247
cd frontend
7348
```
74-
75-
2. Install the necessary JavaScript dependencies:
76-
49+
2. **Gather the JavaScript Warriors:**
7750
```bash
7851
npm install
7952
```
80-
81-
3. Start the frontend server:
82-
53+
3. **Launch the Visual Vanguard:**
8354
```bash
8455
npm run dev
8556
```
@@ -121,82 +92,15 @@ OpenAI uses environment variables for authentication. Follow these steps to set
12192
Now you're ready to start using the GPT-CodeApp with Anthropic and OpenAI models!
12293
12394
## 🎮 Usage
95+
Dive into the GPT-CodeApp experience with these simple steps:
12496
125-
Now that you've set everything up, you're ready to start using GPT-CodeApp! Open `http://localhost:3000` in your web browser and start exploring.
126-
127-
Using GPT-CodeApp is as simple as chatting with an AI. Here's how to get started:
128-
129-
* Open http://localhost:3000 in your web browser to access the GPT-CodeApp interface.
130-
* Open the sidebar on the left side of the interface. This is where you'll input the directory of your coding project.
131-
* Enter the directory of your coding project in the sidebar. This will allow the GPT-CodeApp to access your project files.
132-
133-
Start interacting with the GPT-CodeApp just like you would with ChatGPT. You can ask questions, request code snippets, and more. One of the biggest advantages of GPT-CodeApp is the ability to use the search functionality to locate and add files directly to the system prompt. This is a powerful feature that allows you to quickly and easily reference specific parts of your codebase.
134-
135-
136-
Recently, we've also began experiemnting with some cool features like On-Demand Agent Functions that can be called on demand from the user interface (OpenAI Only). They perform specific tasks based on your input and can greatly enhance the functionality and interactivity of the application. To call an On-Demand Agent function, simply prepend the command with a "/".
137-
138-
### On-Demand Agent Function (OpenAI Only)
139-
This feature is currently being revamped. Stay tuned for exciting updates!
140-
141-
On-Demand Agent functions are special functions that can be called on demand from the user interface differing from typical OpenAI functions in that we're forcing the function call instead of relying on the LLM to recognize when to call the function. They are designed to perform specific tasks based on user input and can greatly enhance the functionality and interactivity of the application. To call an On-Demand Agent function, you simply prepend the command with a "/".
142-
143-
Current On-Demand Agent Functions
97+
- **Step 1:** Launch your browser and head over to `http://localhost:3000` to greet your new AI coding companion.
14498
145-
- Changes
146-
- Edits a file from the repository given a set of instructions. The memory of the conversation is included so you do not need
147-
to be overly specific in your instructions. See example below.
148-
- CommandPlanner
149-
- Allows the agent to run a sequence of bash operations in a plan and execute paradigm.
150-
151-
#### Example
152-
153-
Call Agent Function - changes.py needs to be loaded into context
154-
155-
```
156-
/Changes add docstring to the match_partial function
157-
```
158-
159-
Function Call response are streamed back into the UI
160-
161-
```json
162-
{
163-
"file_name": "backend/agent/agent_functions/changes.py",
164-
"thought": "The user wants to add a docstring to the match_partial function. Docstrings are important for code readability and maintainability, as they explain the purpose of a function, its arguments, and its return value.",
165-
"changes": [
166-
{
167-
"original": "def match_partial(\n self, original_lines: List[str], partial_lines: List[str]\n ) -> Tuple[Optional[int], Optional[int], Optional[int]]:",
168-
"updated": "def match_partial(\n self, original_lines: List[str], partial_lines: List[str]\n ) -> Tuple[Optional[int], Optional[int], Optional[int]]:\n \"\"\"\n This function matches a part of the original code with a given part.\n\n Args:\n original_lines (List[str]): The original lines of code.\n partial_lines (List[str]): The lines of code that need to be matched.\n\n Returns:\n Tuple[Optional[int], Optional[int], Optional[int]]: The start and end indices of the match in the original code and the number of leading spaces in the matched part.\n \"\"\""
169-
}
170-
]
171-
}
172-
```
173-
174-
Then the Agent also responds in the UI with the final diff of changes that were made
175-
176-
```diff
177-
--- a
178-
179-
+++ b
180-
181-
@@ -236,2 +236,12 @@
182-
183-
- self, original_lines: List[str], partial_lines: List[str]
184-
- ) -> Tuple[Optional[int], Optional[int], Optional[int]]:
185-
+ self, original_lines: List[str], partial_lines: List[str]
186-
+ ) -> Tuple[Optional[int], Optional[int], Optional[int]]:
187-
+ """
188-
+ This function matches a part of the original code with a given part.
189-
+
190-
+ Args:
191-
+ original_lines (List[str]): The original lines of code.
192-
+ partial_lines (List[str]): The lines of code that need to be matched.
193-
+
194-
+ Returns:
195-
+ Tuple[Optional[int], Optional[int], Optional[int]]: The start and end indices of the match in the original code and the number of leading spaces in the matched part.
196-
+ """
197-
```
99+
- **Step 3:** Ensure you've setup authentication with either OpenAI (API KEY) or Bedrock (for Anthropic models). With authentication out of the way, you're ready to roll! Look for the sidebar on the main interface. Here, you'll find a spot to input the **full path** to the directory of your project. This is crucial for GPT-CodeApp to understand the context of your work and provide tailored assistance.
100+
- **Step 4:** Now, it's time to ask away! Load *focus* files into the search bar at the top. Make sure to send them to the backend with the send button. Type your coding queries or dilemmas into the text box and hit submit. GPT-CodeApp will churn through its AI brain to bring you crisp, accurate coding advice or solutions.
101+
- **Step 5:** Explore the responses, refine your questions for deeper insights, or kick off a new query. The AI is here to assist you through thick and thin code.
102+
- **Step 6:** Base prompts can be found in the backend/agent/agent_prompts.py file and set to load in the app_setup.py. You can also add your own prompts to the file anytime.
198103
199-
The changes were automatically saved and can always be un-done with `cntrl + z`
200104
201105
## 🤝 Contributing
202106

backend/database/my_codebase.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
ENCODER = tiktoken.encoding_for_model("gpt-3.5-turbo")
77

88

9-
# new comment
109
class MyCodebase:
1110
UPDATE_FULL = False
1211

@@ -27,6 +26,16 @@ def __init__(
2726
self.remove_old_files()
2827

2928
def set_directory(self, directory: str) -> None:
29+
"""
30+
Sets the root directory to scan for code.
31+
32+
This updates the 'directory' value in the config table of the database,
33+
and triggers a re-scan of all files and embeddings. It also removes any old files that
34+
are no longer in the directory.
35+
36+
Args:
37+
directory (str): The path to the new root directory to scan.
38+
"""
3039
print(f"Setting directory to {directory}")
3140
self.directory = directory
3241
self.cur.execute(

backend/main.py

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,12 @@ async def get_functions():
9797

9898

9999
@app.get("/get_messages")
100-
async def get_messages(chatbox: (bool | None) = None):
100+
async def get_messages(chatbox: bool | None = None):
101101
return {"messages": AGENT.memory_manager.get_messages(chat_box=chatbox)[1:]}
102102

103103

104104
@app.get("/get_summaries")
105-
async def get_summaries(reset: (bool | None) = None):
105+
async def get_summaries(reset: bool | None = None):
106106
if reset:
107107
CODEBASE._update_files_and_embeddings()
108108
cur = CODEBASE.conn.cursor()
@@ -132,6 +132,18 @@ async def generate_readme():
132132

133133
@app.post("/set_files_in_prompt")
134134
async def set_files_in_prompt(input: dict):
135+
"""Sets the files to be included in the prompt.
136+
137+
This endpoint accepts a JSON input with a key "files", which should contain a list of file names.
138+
These files are then stored in the database and updated in the agent's memory manager for use in
139+
generating prompts.
140+
141+
Args:
142+
input (dict): A dictionary containing the "files" key with a list of file names as its value.
143+
144+
Returns:
145+
JSONResponse: A response with a 200 status code on success, or an error message on failure.
146+
"""
135147
files = [file for file in input.get("files", None)]
136148
AGENT.memory_manager.cur.execute(
137149
"""
@@ -154,6 +166,16 @@ async def get_files_in_prompt():
154166
return {"files": AGENT.memory_manager.prompt_handler.files_in_prompt}
155167

156168

169+
async def get_user_directory_tree():
170+
"""Returns the directory tree of the user's codebase.
171+
172+
Returns:
173+
dict: A dictionary containing the directory tree of the user's codebase.
174+
175+
"""
176+
return {"directory_tree": CODEBASE.tree()}
177+
178+
157179
@app.post("/set_model")
158180
async def set_model(input: dict):
159181
model = input.get("model")
@@ -316,4 +338,3 @@ def get_error_logs():
316338
error_logs = [line for line in log_lines if "INFO" in line]
317339

318340
return JSONResponse(status_code=200, content={"error_logs": error_logs})
319-

frontend/pages/index.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ const Chat = () => {
5252

5353
const submitMessage = async (input, command = null) => {
5454
console.log(input);
55-
let messageData = null;
5655
let currentId = null;
5756
let body = null;
5857

@@ -105,10 +104,6 @@ const Chat = () => {
105104
}
106105
};
107106

108-
109-
110-
111-
112107
useEffect(() => {
113108
const fetchHistoricalMessages = async () => {
114109
console.log(`${process.env.NEXT_PUBLIC_API_URL}`)

image-1.png

499 KB
Loading

image.png

499 KB
Loading

images/Snip20240321_1.png

499 KB
Loading

0 commit comments

Comments
 (0)