├── backend ├── __init__.py ├── agent │ ├── __init__.py │ ├── agent_functions │ │ ├── __init__.py │ │ ├── student_a.txt │ │ ├── student_b.txt │ │ ├── file_ops.py │ │ ├── teacher.txt │ │ ├── class_ops.py │ │ ├── function_ops.py │ │ ├── import_ops.py │ │ └── method_ops.py │ └── socratic_agent.py ├── database │ ├── __init__.py │ └── my_codebase.py ├── pytest.ini ├── requirements.txt ├── tests │ ├── test_working_context.py │ ├── test_codebase.py │ ├── test_coding_agent.py │ ├── test_memory_manager.py │ └── test_ast_ops.py ├── test.py ├── app_setup.py ├── memory │ ├── working_context.py │ ├── memory_manager.py │ └── system_prompt_handler.py └── main.py ├── .flake8 ├── frontend ├── .env.sample ├── .eslintrc.json ├── public │ ├── logo1.png │ ├── codeknot.png │ ├── favicon.ico │ ├── vercel.svg │ └── next.svg ├── jsconfig.json ├── postcss.config.js ├── pages │ ├── _document.js │ ├── _app.js │ └── index.js ├── next.config.js ├── Dockerfile ├── .gitignore ├── tailwind.config.js ├── store │ ├── messages │ │ ├── logMessagesSlice.js │ │ └── messagesSlice.js │ ├── modal_bar_modals │ │ ├── contextViewerSlice.js │ │ ├── messageHistorySlice.js │ │ ├── systemPromptSlice.js │ │ └── functionsSlice.js │ ├── sidebar │ │ └── sidebarSlice.js │ └── index.js ├── .eslintrc.js ├── styles │ └── globals.css ├── components │ ├── modal_bar_modals │ │ ├── MessageHistoryModal.js │ │ ├── ContextViewerModal.js │ │ ├── FunctionsModal.js │ │ └── SystemPromptModal.js │ ├── ModelSelector.js │ ├── ChatInput.js │ ├── ChatBox.js │ ├── RightSidebar.js │ ├── OperationCard.js │ ├── LeftSidebar.js │ ├── ModalBar.js │ ├── SearchBar.js │ └── DirectorySelectOption.js └── package.json ├── .DS_Store ├── image.png ├── image-1.png ├── images ├── code_knot.png ├── Snip20231015_2.png ├── Snip20240321_1.png └── code_knot_awesome.png ├── .github ├── workflows │ ├── pr_agent.yml │ └── pytest_ubuntu.yml └── ISSUE_TEMPLATE │ └── sweep-template.yml ├── CHANGELOG.md ├── .vscode └── settings.json ├── LICENSE ├── CONTRIBUTING.md ├── CODE_OF_CONDUCT.md ├── sweep.yaml ├── .gitignore └── README.md /backend/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /backend/agent/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /backend/database/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /backend/agent/agent_functions/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /backend/agent/agent_functions/student_a.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /backend/agent/agent_functions/student_b.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.flake8: -------------------------------------------------------------------------------- 1 | [flake8] 2 | ignore = E501,E302,E305,E203 -------------------------------------------------------------------------------- /frontend/.env.sample: -------------------------------------------------------------------------------- 1 | NEXT_PUBLIC_API_URL=https://localhost:8000 2 | -------------------------------------------------------------------------------- /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blazickjp/GPT-CodeApp/HEAD/.DS_Store -------------------------------------------------------------------------------- /frontend/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "next/core-web-vitals" 3 | } 4 | -------------------------------------------------------------------------------- /image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blazickjp/GPT-CodeApp/HEAD/image.png -------------------------------------------------------------------------------- /image-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blazickjp/GPT-CodeApp/HEAD/image-1.png -------------------------------------------------------------------------------- /images/code_knot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blazickjp/GPT-CodeApp/HEAD/images/code_knot.png -------------------------------------------------------------------------------- /frontend/public/logo1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blazickjp/GPT-CodeApp/HEAD/frontend/public/logo1.png -------------------------------------------------------------------------------- /images/Snip20231015_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blazickjp/GPT-CodeApp/HEAD/images/Snip20231015_2.png -------------------------------------------------------------------------------- /images/Snip20240321_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blazickjp/GPT-CodeApp/HEAD/images/Snip20240321_1.png -------------------------------------------------------------------------------- /frontend/public/codeknot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blazickjp/GPT-CodeApp/HEAD/frontend/public/codeknot.png -------------------------------------------------------------------------------- /frontend/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blazickjp/GPT-CodeApp/HEAD/frontend/public/favicon.ico -------------------------------------------------------------------------------- /images/code_knot_awesome.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blazickjp/GPT-CodeApp/HEAD/images/code_knot_awesome.png -------------------------------------------------------------------------------- /frontend/jsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "paths": { 4 | "@/*": ["./*"] 5 | } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /frontend/postcss.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: { 3 | tailwindcss: {}, 4 | autoprefixer: {}, 5 | }, 6 | } 7 | -------------------------------------------------------------------------------- /backend/pytest.ini: -------------------------------------------------------------------------------- 1 | [pytest] 2 | norecursedirs = .git build node_modules 3 | python_files = test_*.py 4 | python_functions = test_* 5 | python_classes = Test* 6 | addopts = -p no:cacheprovider -------------------------------------------------------------------------------- /frontend/pages/_document.js: -------------------------------------------------------------------------------- 1 | import { Html, Head, Main, NextScript } from 'next/document' 2 | 3 | export default function Document() { 4 | return ( 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | ) 13 | } 14 | -------------------------------------------------------------------------------- /frontend/next.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('next').NextConfig} */ 2 | const nextConfig = { 3 | reactStrictMode: true, 4 | 5 | webpack(config, { isServer, dev }) { 6 | config.experiments = { 7 | asyncWebAssembly: true, 8 | layers: true, 9 | }; 10 | 11 | return config; 12 | }, 13 | } 14 | 15 | module.exports = nextConfig; 16 | -------------------------------------------------------------------------------- /backend/requirements.txt: -------------------------------------------------------------------------------- 1 | fastapi==0.100.0 2 | numpy==1.23.5 3 | openai==1.2.2 4 | pydantic==2.7.0 5 | python-dotenv==1.0.0 6 | PyYAML==6.0 7 | tiktoken==0.4.0 8 | urllib3==2.0.3 9 | uvicorn==0.23.0 10 | instructor==1.2.2 11 | scikit-learn==1.2.2 12 | pytest==7.4.0 13 | tenacity==8.2.2 14 | boto3==1.28.58 15 | astor==0.8.1 16 | rdflib==7.0.0 17 | anthropic==0.23.1 -------------------------------------------------------------------------------- /frontend/pages/_app.js: -------------------------------------------------------------------------------- 1 | import '@/styles/globals.css' 2 | import React from 'react'; 3 | import store from '../store'; 4 | import { Provider } from 'react-redux'; 5 | 6 | 7 | 8 | export default function App({ Component, pageProps }) { 9 | return ( 10 | 11 | 12 | 13 | 14 | 15 | 16 | ) 17 | }; 18 | -------------------------------------------------------------------------------- /.github/workflows/pr_agent.yml: -------------------------------------------------------------------------------- 1 | on: 2 | pull_request: 3 | issue_comment: 4 | jobs: 5 | pr_agent_job: 6 | runs-on: ubuntu-latest 7 | name: Run pr agent on every pull request, respond to user comments 8 | steps: 9 | - name: PR Agent action step 10 | id: pragent 11 | uses: Codium-ai/pr-agent@main 12 | env: 13 | OPENAI_KEY: ${{ secrets.OPENAI_KEY }} 14 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} -------------------------------------------------------------------------------- /frontend/Dockerfile: -------------------------------------------------------------------------------- 1 | # Use an official Node runtime as a parent image 2 | FROM node:18 3 | 4 | # Copy package.json and package-lock.json 5 | COPY package*.json ./ 6 | 7 | # Install any needed packages specified in package.json 8 | RUN npm install 9 | 10 | # Bundle app source inside the Docker image 11 | COPY . . 12 | 13 | # Choose the port the container will listen on at runtime 14 | EXPOSE 3000 15 | 16 | # Run the specified command within the container 17 | CMD [ "npm", "run", "dev" ] 18 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 2023-11-16 2 | 3 | ### Added 4 | - Introduced Abstract Syntax Trees (ASTs) for making code changes. 5 | - Added a comprehensive suite of unit tests for testing the functionality of the AST operations. 6 | - Added new classes and methods for handling AST operations. 7 | 8 | ### Changed 9 | - Refactored the main.py file to handle different configuration settings and improve the user experience. 10 | 11 | ### Removed 12 | - Deleted some old files that are no longer needed due to the refactor. -------------------------------------------------------------------------------- /frontend/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # next.js 12 | /.next/ 13 | /out/ 14 | 15 | # production 16 | /build 17 | 18 | # misc 19 | .DS_Store 20 | *.pem 21 | 22 | # debug 23 | npm-debug.log* 24 | yarn-debug.log* 25 | yarn-error.log* 26 | 27 | # local env files 28 | .env*.local 29 | 30 | # vercel 31 | .vercel 32 | 33 | # typescript 34 | *.tsbuildinfo 35 | next-env.d.ts 36 | -------------------------------------------------------------------------------- /frontend/public/vercel.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /frontend/tailwind.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('tailwindcss').Config} */ 2 | module.exports = { 3 | content: [ 4 | './pages/**/*.{js,ts,jsx,tsx,mdx}', 5 | './components/**/*.{js,ts,jsx,tsx,mdx}', 6 | './app/**/*.{js,ts,jsx,tsx,mdx}', 7 | ], 8 | theme: { 9 | extend: { 10 | backgroundImage: { 11 | 'gradient-radial': 'radial-gradient(var(--tw-gradient-stops))', 12 | 'gradient-conic': 13 | 'conic-gradient(from 180deg at 50% 50%, var(--tw-gradient-stops))', 14 | }, 15 | colors: { 16 | 'python-blue': '#3776ab', 17 | 'python-yellow': '#ffd43b', 18 | 'onedark': '#282c34', 19 | } 20 | } 21 | }, 22 | plugins: [], 23 | } 24 | -------------------------------------------------------------------------------- /frontend/store/messages/logMessagesSlice.js: -------------------------------------------------------------------------------- 1 | // frontend/store/modal_bar_modals/contextViewerSlice.js 2 | import { createSlice } from '@reduxjs/toolkit'; 3 | 4 | export const logMessagesSlice = createSlice({ 5 | name: 'logMessages', 6 | initialState: { 7 | isLogModalOpen: false, 8 | logMessages: [], 9 | }, 10 | reducers: { 11 | setIsLogModalOpen: (state, action) => { 12 | state.isLogModalOpen = action.payload; 13 | }, 14 | setLogMessages: (state, action) => { 15 | state.logMessages = action.payload; 16 | }, 17 | }, 18 | }); 19 | 20 | export const { setIsLogModalOpen, setLogMessages } = logMessagesSlice.actions; 21 | 22 | export default logMessagesSlice.reducer; -------------------------------------------------------------------------------- /frontend/store/modal_bar_modals/contextViewerSlice.js: -------------------------------------------------------------------------------- 1 | // frontend/store/modal_bar_modals/contextViewerSlice.js 2 | import { createSlice } from '@reduxjs/toolkit'; 3 | 4 | export const contextViewerSlice = createSlice({ 5 | name: 'contextViewer', 6 | initialState: { 7 | isModalOpen: false, 8 | workingContext: '', 9 | }, 10 | reducers: { 11 | setIsContextModalOpen: (state, action) => { 12 | state.isModalOpen = action.payload; 13 | }, 14 | setWorkingContext: (state, action) => { 15 | state.workingContext = action.payload; 16 | }, 17 | }, 18 | }); 19 | 20 | export const { setIsContextModalOpen, setWorkingContext } = contextViewerSlice.actions; 21 | 22 | export default contextViewerSlice.reducer; -------------------------------------------------------------------------------- /frontend/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | "env": { 3 | "browser": true, 4 | "es2021": true, 5 | "node": true 6 | }, 7 | "extends": [ 8 | "eslint:recommended", 9 | "plugin:react/recommended" 10 | ], 11 | "overrides": [ 12 | { 13 | "env": { 14 | "node": true 15 | }, 16 | "files": [ 17 | ".eslintrc.{js,cjs}" 18 | ], 19 | "parserOptions": { 20 | "sourceType": "script" 21 | } 22 | } 23 | ], 24 | "parserOptions": { 25 | "ecmaVersion": "latest", 26 | "sourceType": "module" 27 | }, 28 | "plugins": [ 29 | "react" 30 | ], 31 | "rules": { 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /frontend/store/sidebar/sidebarSlice.js: -------------------------------------------------------------------------------- 1 | import { createSlice } from '@reduxjs/toolkit'; 2 | 3 | export const sidebarSlice = createSlice({ 4 | name: 'sidebar', 5 | initialState: { 6 | isOpen: false, 7 | currentDirectory: '', 8 | opList: [], 9 | }, 10 | reducers: { 11 | toggleSidebar: (state) => { 12 | state.isOpen = !state.isOpen; 13 | }, 14 | setDirectory: (state, action) => { 15 | state.currentDirectory = action.payload; 16 | }, 17 | setOpList: (state, action) => { 18 | state.opList = action.payload; 19 | } 20 | 21 | }, 22 | }); 23 | 24 | 25 | 26 | export const { toggleSidebar, setDirectory, setOpList } = sidebarSlice.actions; 27 | 28 | export default sidebarSlice.reducer; -------------------------------------------------------------------------------- /backend/agent/socratic_agent.py: -------------------------------------------------------------------------------- 1 | from sqlite3 import SQLITE_IOERR_COMMIT_ATOMIC 2 | from openai import OpenAIAPI, OpenAIError 3 | from instructor import patch 4 | from typing import List, Optional 5 | from pydantic import BaseModel 6 | from enum import Enum 7 | 8 | CLIENT = patch(OpenAIAPI()) 9 | CHAT_HISTORY = dict() 10 | 11 | 12 | class AgentType(str, Enum): 13 | TEACHER = "teacher" 14 | STUDENT_A = "student_a" 15 | STUDENT_B = "student_b" 16 | 17 | 18 | for agent in AgentType: 19 | CHAT_HISTORY[agent.value] = [] 20 | 21 | 22 | def main(): 23 | student_a, student_b, teacher = load_agents() 24 | speaker = None 25 | 26 | while True: 27 | speaker = select_speaker(last_speaker=speaker) 28 | 29 | 30 | 31 | if __name__ == "__main__": 32 | main() 33 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/sweep-template.yml: -------------------------------------------------------------------------------- 1 | name: Sweep Issue 2 | title: 'Sweep: ' 3 | description: For small bugs, features, refactors, and tests to be handled by Sweep, an AI-powered junior developer. 4 | labels: sweep 5 | body: 6 | - type: textarea 7 | id: description 8 | attributes: 9 | label: Details 10 | description: Tell Sweep where and what to edit and provide enough context for a new developer to the codebase 11 | placeholder: | 12 | Unit Tests: Write unit tests for . Test each function in the file. Make sure to test edge cases. 13 | Bugs: The bug might be in . Here are the logs: ... 14 | Features: the new endpoint should use the ... class from because it contains ... logic. 15 | Refactors: We are migrating this function to ... version because ... -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "[python]": { 3 | "editor.defaultFormatter": "ms-python.black-formatter" 4 | }, 5 | "python.linting.Flake8": [ 6 | "--max-line-length=150", 7 | "--ignore=E203,F841,F401,E302,E305,W503", 8 | ], 9 | "flake8.ignorePatterns": [ 10 | "**/site-packages/**/*.py", 11 | ".vscode/*.py" 12 | ], 13 | "flake8.args": [ 14 | "--max-line-length=150", 15 | "--ignore=E203,F841,F401,E302,E305,W503", 16 | ], 17 | "cody.codebase": "/Users/josephblazick/Documents/GPT-CodeApp", 18 | "cody.commandCodeLenses": true, 19 | "cody.debug.verbose": true, 20 | "cody.debug.enable": true, 21 | "cody.autocomplete.advanced.accessToken": "sgp_636f79ad2075640f_90dd54be0113cebe3b4d1ba45efed2b60ecd3f73", 22 | "cody.autocomplete.completeSuggestWidgetSelection": true, 23 | "cody.autocomplete.formatOnAccept": true, 24 | } 25 | -------------------------------------------------------------------------------- /frontend/store/modal_bar_modals/messageHistorySlice.js: -------------------------------------------------------------------------------- 1 | import { createSlice } from '@reduxjs/toolkit'; 2 | 3 | const initialState = { 4 | messageHistory: [], 5 | messageTokens: 0, 6 | isMessageModalOpen: false, 7 | }; 8 | 9 | export const messageHistorySlice = createSlice({ 10 | name: 'messageHistory', 11 | initialState, 12 | reducers: { 13 | setMessageHistory: (state, action) => { 14 | state.messageHistory = action.payload; 15 | }, 16 | setMessageTokens: (state, action) => { 17 | state.messageTokens = action.payload; 18 | }, 19 | setIsMessageModalOpen: (state, action) => { 20 | state.isMessageModalOpen = action.payload; 21 | }, 22 | }, 23 | }); 24 | 25 | export const { setMessageHistory, setMessageTokens, setIsMessageModalOpen } = messageHistorySlice.actions; 26 | 27 | export default messageHistorySlice.reducer; -------------------------------------------------------------------------------- /frontend/store/index.js: -------------------------------------------------------------------------------- 1 | import { configureStore } from '@reduxjs/toolkit'; 2 | import messageReducer from './messages/messagesSlice'; 3 | import sidebarReducer from './sidebar/sidebarSlice'; 4 | import systemPromptReducer from './modal_bar_modals/systemPromptSlice'; 5 | import functionsReducer from './modal_bar_modals/functionsSlice'; 6 | import messageHistoryReducer from './modal_bar_modals/messageHistorySlice'; 7 | import contextViewerReducer from './modal_bar_modals/contextViewerSlice'; 8 | import logMessagesReducer from './messages/logMessagesSlice'; 9 | 10 | export default configureStore({ 11 | reducer: { 12 | messages: messageReducer, 13 | sidebar: sidebarReducer, 14 | systemPrompt: systemPromptReducer, 15 | functions: functionsReducer, 16 | messageHistory: messageHistoryReducer, 17 | logMessages: logMessagesReducer, 18 | contextViewer: contextViewerReducer, 19 | }, 20 | }); -------------------------------------------------------------------------------- /.github/workflows/pytest_ubuntu.yml: -------------------------------------------------------------------------------- 1 | name: Run Pytest 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | - main # or the name of your default branch 7 | - dev 8 | 9 | jobs: 10 | test: 11 | strategy: 12 | matrix: 13 | os: [ubuntu-latest, macos-latest, windows-latest] 14 | runs-on: ${{ matrix.os }} 15 | 16 | steps: 17 | - name: Checkout code 18 | uses: actions/checkout@v2 19 | 20 | - name: Set up Python 21 | uses: actions/setup-python@v2 22 | with: 23 | python-version: 3.11 # or any othe 24 | 25 | - name: Install dependencies 26 | run: | 27 | python -m pip install --upgrade pip 28 | pip install -r backend/requirements.txt 29 | 30 | - name: Run pytest 31 | run: cd backend && python -m pytest 32 | env: 33 | PROJECT_DIRECTORY: ${{ github.workspace }} 34 | OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} # Add this line 35 | -------------------------------------------------------------------------------- /frontend/styles/globals.css: -------------------------------------------------------------------------------- 1 | @tailwind base; 2 | @tailwind components; 3 | @tailwind utilities; 4 | 5 | :root { 6 | --foreground-rgb: 0, 0, 0; 7 | --background-start-rgb: 214, 219, 220; 8 | --background-end-rgb: 255, 255, 255; 9 | } 10 | 11 | @media (prefers-color-scheme: dark) { 12 | :root { 13 | --foreground-rgb: 255, 255, 255; 14 | --background-start-rgb: 0, 0, 0; 15 | --background-end-rgb: 0, 0, 0; 16 | } 17 | } 18 | 19 | body { 20 | color: rgb(var(--foreground-rgb)); 21 | background: linear-gradient(to bottom, 22 | transparent, 23 | rgb(var(--background-end-rgb))) rgb(var(--background-start-rgb)); 24 | } 25 | 26 | /* ol { 27 | @apply list-decimal list-inside; 28 | } 29 | */ 30 | /* li { 31 | @apply pt-1; 32 | } */ 33 | 34 | ol>li { 35 | @apply !list-decimal; 36 | } 37 | 38 | ul>li { 39 | margin-left: 15px; 40 | } 41 | 42 | 43 | li>p { 44 | @apply !inline; 45 | } 46 | 47 | 48 | li>p { 49 | @apply !inline; 50 | } 51 | 52 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 blazickjp 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /frontend/store/modal_bar_modals/systemPromptSlice.js: -------------------------------------------------------------------------------- 1 | import { createSlice } from '@reduxjs/toolkit'; 2 | 3 | const initialState = { 4 | systemPrompt: "", 5 | systemTokens: 0, 6 | isModalOpen: false, 7 | editablePrompt: "", 8 | }; 9 | 10 | const systemPromptSlice = createSlice({ 11 | name: 'systemPrompt', 12 | initialState, 13 | reducers: { 14 | setSystemPrompt: (state, action) => { 15 | state.systemPrompt = action.payload; 16 | }, 17 | setSystemTokens: (state, action) => { 18 | state.systemTokens = action.payload; 19 | }, 20 | setIsModalOpen: (state, action) => { 21 | state.isModalOpen = action.payload; 22 | }, 23 | setEditablePrompt: (state, action) => { 24 | state.editablePrompt = action.payload; 25 | }, 26 | setPromptName: (state, action) => { 27 | state.promptName = action.payload; 28 | } 29 | }, 30 | }); 31 | 32 | export const { setSystemPrompt, setSystemTokens, setIsModalOpen, setEditablePrompt, setPromptName } = systemPromptSlice.actions; 33 | 34 | export default systemPromptSlice.reducer; -------------------------------------------------------------------------------- /frontend/public/next.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /frontend/store/modal_bar_modals/functionsSlice.js: -------------------------------------------------------------------------------- 1 | import { createSlice } from '@reduxjs/toolkit'; 2 | 3 | const initialState = { 4 | agent_functions: [], 5 | on_demand_functions: [], 6 | agent_tokens: 0, 7 | onDemandTokens: 0, 8 | functionTokens: 0, 9 | isFunctionModalOpen: false, 10 | }; 11 | 12 | export const functionsSlice = createSlice({ 13 | name: 'functions', 14 | initialState, 15 | reducers: { 16 | setAgentFunctions: (state, action) => { 17 | state.agent_functions = action.payload; 18 | }, 19 | setOnDemandFunctions: (state, action) => { 20 | state.on_demand_functions = action.payload; 21 | }, 22 | setFunctionTokens: (state, action) => { 23 | state.functionTokens = action.payload; 24 | }, 25 | setAgentTokens: (state, action) => { 26 | state.autoTokens = action.payload; 27 | }, 28 | setOnDemandTokens: (state, action) => { 29 | state.onDemandTokens = action.payload; 30 | }, 31 | setIsFunctionModalOpen: (state, action) => { 32 | state.isFunctionModalOpen = action.payload; 33 | }, 34 | }, 35 | }); 36 | 37 | export const { setFunctionTokens, setIsFunctionModalOpen, setAgentFunctions, setOnDemandFunctions, setAgentTokens, setOnDemandTokens } = functionsSlice.actions; 38 | 39 | export default functionsSlice.reducer; -------------------------------------------------------------------------------- /frontend/components/modal_bar_modals/MessageHistoryModal.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactModal from 'react-modal'; 3 | import { useDispatch, useSelector } from 'react-redux'; 4 | import { setIsMessageModalOpen } from '../../store/modal_bar_modals/messageHistorySlice'; 5 | 6 | const MessageHistoryModal = () => { 7 | const dispatch = useDispatch(); 8 | const messageHistory = useSelector(state => state.messageHistory.messageHistory); 9 | const isMessageModalOpen = useSelector(state => state.messageHistory.isMessageModalOpen); 10 | 11 | return ( 12 | dispatch(setIsMessageModalOpen(false))} 15 | shouldCloseOnOverlayClick={true} 16 | className="fixed inset-0 flex items-center justify-center m-96" 17 | overlayClassName="fixed inset-0 bg-black bg-opacity-50" 18 | > 19 |
20 |

Messages

21 | {messageHistory.map((m, index) => ( 22 |
23 |

{m.role.toUpperCase()}

24 |
{m.content}
25 |
26 | ))} 27 |
28 |
29 | ); 30 | } 31 | 32 | export default MessageHistoryModal; 33 | -------------------------------------------------------------------------------- /frontend/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "backend", 3 | "version": "0.1.0", 4 | "private": true, 5 | "scripts": { 6 | "dev": "next dev", 7 | "build": "next build", 8 | "start": "next start", 9 | "lint": "next lint" 10 | }, 11 | "dependencies": { 12 | "@dqbd/tiktoken": "^1.0.7", 13 | "@fortawesome/fontawesome-svg-core": "^6.4.0", 14 | "@fortawesome/free-solid-svg-icons": "^6.4.0", 15 | "@fortawesome/react-fontawesome": "^0.2.0", 16 | "@reduxjs/toolkit": "^1.9.5", 17 | "@testing-library/jest-dom": "^5.17.0", 18 | "@testing-library/react": "^14.0.0", 19 | "autoprefixer": "10.4.14", 20 | "axios": "^1.4.0", 21 | "codemirror": "^5.65.13", 22 | "d3-scale": "^4.0.2", 23 | "dotenv": "^16.3.1", 24 | "monaco-editor": "^0.38.0", 25 | "next": "^13.3.0", 26 | "next-connect": "^0.13.0", 27 | "openai": "^3.3.0", 28 | "openai-streams": "^6.1.0", 29 | "postcss": "8.4.24", 30 | "prism-react-renderer": "^2.0.6", 31 | "react": "18.2.0", 32 | "react-autocomplete-hint": "^2.0.0", 33 | "react-autosuggest": "^10.1.0", 34 | "react-copy-to-clipboard": "^5.1.0", 35 | "react-dom": "18.2.0", 36 | "react-dropzone": "^14.2.3", 37 | "react-icons": "^4.10.1", 38 | "react-markdown": "^8.0.7", 39 | "react-modal": "^3.16.1", 40 | "react-monaco-editor": "^0.53.0", 41 | "react-redux": "^8.1.1", 42 | "react-select": "^5.7.4", 43 | "react-select-search": "^4.1.6", 44 | "react-syntax-highlighter": "^15.5.0", 45 | "react-testing-library": "^8.0.1", 46 | "react-tooltip": "^4.2.21", 47 | "react-virtuoso": "^4.4.0", 48 | "redux": "^4.2.1", 49 | "tailwindcss": "3.3.2", 50 | "websocket": "^1.0.34" 51 | }, 52 | "devDependencies": { 53 | "eslint": "^8.43.0", 54 | "eslint-plugin-react": "^7.32.2" 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /backend/tests/test_working_context.py: -------------------------------------------------------------------------------- 1 | # import unittest 2 | # from unittest.mock import Mock 3 | # from memory.memory_manager import WorkingContext 4 | 5 | 6 | # class TestWorkingContext1(unittest.TestCase): 7 | # def setUp(self): 8 | # self.db_connection = Mock() 9 | # self.db_cursor = self.db_connection.cursor.return_value 10 | # self.project_directory = "./" 11 | # self.working_context = WorkingContext( 12 | # self.db_connection, self.project_directory 13 | # ) 14 | 15 | # def test_create_tables(self): 16 | # self.working_context.create_tables() 17 | # self.db_cursor.execute.assert_called() 18 | 19 | # def test_add_context(self): 20 | # test_context = "Additional context" 21 | # self.working_context.add_context(test_context) 22 | # self.db_cursor.execute.assert_called() 23 | # self.db_connection.commit.assert_called() 24 | 25 | # def test_get_context(self): 26 | # self.db_cursor.fetchall.return_value = [("Context 1",), ("Context 2",)] 27 | # context = self.working_context.get_context() 28 | # self.db_cursor.execute.assert_called() 29 | # self.assertIn("Context 1", context) 30 | # self.assertIn("Context 2", context) 31 | 32 | # def test_remove_context(self): 33 | # test_context = "Remove this context" 34 | # self.working_context.remove_context(test_context) 35 | # self.db_cursor.execute.assert_called() 36 | # self.db_connection.commit.assert_called() 37 | 38 | # def test_str_representation(self): 39 | # self.db_cursor.fetchall.return_value = [("Context 1",), ("Context 2",)] 40 | # self.working_context.get_context() 41 | # str_representation = str(self.working_context) 42 | # self.assertIn("Context 1", str_representation) 43 | # self.assertIn("Context 2", str_representation) 44 | -------------------------------------------------------------------------------- /backend/agent/agent_functions/file_ops.py: -------------------------------------------------------------------------------- 1 | import json 2 | import uuid 3 | from instructor import OpenAISchema 4 | from pydantic import Field 5 | from agent.agent_functions.function_ops import ( 6 | AddFunction, 7 | DeleteFunction, 8 | ModifyFunction, 9 | ) 10 | from agent.agent_functions.class_ops import AddClass, DeleteClass, ModifyClass 11 | from agent.agent_functions.method_ops import AddMethod, DeleteMethod, ModifyMethod 12 | from agent.agent_functions.import_ops import AddImport, DeleteImport, ModifyImport 13 | 14 | # Export all the entities 15 | __all__ = [ 16 | "AddFunction", 17 | "DeleteFunction", 18 | "ModifyFunction", 19 | "AddClass", 20 | "DeleteClass", 21 | "ModifyClass", 22 | "AddMethod", 23 | "DeleteMethod", 24 | "ModifyMethod", 25 | "AddImport", 26 | "DeleteImport", 27 | "ModifyImport", 28 | "VariableNameChange", 29 | ] 30 | 31 | 32 | class VariableNameChange(OpenAISchema): 33 | """ 34 | Represents a request to change the name of a variable throughout the entire codebase. This operation replaces all instances of the original variable name with a new name. 35 | """ 36 | 37 | original_name: str = Field(..., description="The original name of the variable.") 38 | new_name: str = Field(..., description="The new name of the variable.") 39 | id: str = str(uuid.uuid4()) 40 | 41 | def to_json(self): 42 | out = dict(id=self.id, original_name=self.original_name, new_name=self.new_name) 43 | return "\n\n```json\n" + json.dumps(out, indent=4) + "\n```\n" 44 | 45 | 46 | _OP_LIST = [ 47 | AddImport, 48 | DeleteImport, 49 | AddFunction, 50 | DeleteFunction, 51 | AddClass, 52 | DeleteClass, 53 | AddMethod, 54 | DeleteMethod, 55 | ModifyFunction, 56 | ModifyClass, 57 | ModifyMethod, 58 | ModifyImport, 59 | VariableNameChange, 60 | ] 61 | 62 | _OP_LIST = {cls.__name__: cls for cls in _OP_LIST} 63 | -------------------------------------------------------------------------------- /frontend/store/messages/messagesSlice.js: -------------------------------------------------------------------------------- 1 | import { createSlice, createAsyncThunk } from '@reduxjs/toolkit'; 2 | 3 | export const fetchMessages = createAsyncThunk('messages/fetchMessages', async () => { 4 | const response = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/get_messages?chatbox=true`); 5 | const historicalMessages = await response.json(); 6 | const formattedMessages = historicalMessages.messages.map(message => ({ 7 | text: message.full_content, 8 | user: message.role === 'user' ? 'human' : 'ai' 9 | })); 10 | return formattedMessages; 11 | }); 12 | 13 | 14 | export const messageSlice = createSlice({ 15 | name: 'messages', 16 | initialState: [], 17 | reducers: { 18 | addMessage: (state, action) => { 19 | state.push(action.payload); 20 | }, 21 | addAIResponse: (state, action) => { 22 | state.push(action.payload); 23 | }, 24 | addAIPartResponse: (state, action) => { 25 | if (state.length > 0) { 26 | console.log("State:", state); 27 | const lastMessage = { ...state[state.length - 1] }; 28 | lastMessage.text = lastMessage.text + action.payload.text; 29 | state[state.length - 1] = lastMessage; 30 | } 31 | console.log(state); 32 | // setMessages(prevMessages => { 33 | // // console.log(prevMessages); 34 | // const lastMessage = { ...prevMessages[prevMessages.length - 1] }; 35 | // lastMessage.text = lastMessage.text + content; 36 | // return [...prevMessages.slice(0, prevMessages.length - 1), lastMessage]; 37 | // }) 38 | }, 39 | }, 40 | extraReducers: (builder) => { 41 | builder.addCase(fetchMessages.fulfilled, (state, action) => { 42 | state.push(...action.payload); 43 | }); 44 | }, 45 | }); 46 | 47 | export const { addMessage, addAIResponse, addAIPartResponse } = messageSlice.actions; 48 | 49 | export default messageSlice.reducer; 50 | -------------------------------------------------------------------------------- /backend/agent/agent_functions/teacher.txt: -------------------------------------------------------------------------------- 1 | Date: 5/1/2024 2 | Topic: 3 | Central Question: The question should be open-ended, typically starting with "why" or "how" to encourage deep thinking and discussion. 4 | 5 | 6 | 1. Engage with Initial Answers 7 | Encourage Responses: Allow participants to provide their initial thoughts or answers to the question. 8 | Listen Actively: Understand where each participant is coming from in their reasoning. 9 | 2. Begin the Socratic Questioning 10 | Clarification Questions: Ask for elaboration or clarification to understand the reasoning behind their answers. ("What do you mean by...?") 11 | Probing Assumptions: Challenge the assumptions that underlie their statements. ("What are we assuming here?") 12 | Reason and Evidence: Probe the reasons and evidence behind their thoughts. ("Why do you think this is true?") 13 | Implications and Consequences: Explore the consequences of an answer being true. ("What happens if we accept this as true?") 14 | 3. Deepen the Inquiry 15 | Counterexamples: Present scenarios or counterexamples to test the consistency of the participants' views. ("Can you think of an instance where this wouldn't hold true?") 16 | Alternative Perspectives: Encourage consideration of different perspectives. ("How would someone with an opposing view see this?") 17 | 4. Reflect and Synthesize 18 | Summary of Insights: Periodically summarize the discussion to synthesize insights and clarify where the group has reached. 19 | Encourage Reflection: Ask participants to reflect on how their views might have changed or been reinforced by the discussion. 20 | 5. Conclude with Further Questioning 21 | Final Thoughts: Allow participants to share their final thoughts and any lingering questions. 22 | Further Inquiry: End with additional questions that arise from the dialogue, setting the stage for further exploration. 23 | 6. Evaluate the Process 24 | Feedback: Gather feedback on the effectiveness of the dialogue and the comfort level of participants with the process. 25 | Self-Assessment: Reflect on your own role in guiding the dialogue and areas for improvement. 26 | -------------------------------------------------------------------------------- /backend/test.py: -------------------------------------------------------------------------------- 1 | import logging 2 | import sys 3 | import time 4 | import os 5 | import traceback 6 | from logging.handlers import TimedRotatingFileHandler 7 | 8 | 9 | class PrintLogger: 10 | def __init__(self, logger, original_stdout, original_stderr): 11 | self.logger = logger 12 | self.original_stdout = original_stdout 13 | self.original_stderr = original_stderr 14 | 15 | def write(self, message): 16 | # Check if the message is an error (stderr) 17 | if message.startswith("Traceback"): 18 | # Log the traceback 19 | self.logger.error(message) 20 | # Print the traceback to stderr 21 | self.original_stderr.write(message) 22 | elif message != "\n": 23 | # Log the normal message 24 | self.logger.info(message) 25 | # Print the normal message to stdout 26 | self.original_stdout.write(message) 27 | 28 | def flush(self): 29 | pass 30 | 31 | 32 | def cleanup_logs(directory, retention_duration_secs): 33 | for filename in os.listdir(directory): 34 | filepath = os.path.join(directory, filename) 35 | if os.path.isfile(filepath): 36 | file_creation_time = os.path.getctime(filepath) 37 | if time.time() - file_creation_time > retention_duration_secs: 38 | os.remove(filepath) 39 | print(f"Deleted old log file: {filepath}") 40 | 41 | 42 | # Save the original stdout and stderr 43 | original_stdout = sys.stdout 44 | original_stderr = sys.stderr 45 | 46 | 47 | # Create a logger 48 | logger = logging.getLogger("MyLogger") 49 | logger.setLevel(logging.INFO) 50 | 51 | # Create handlers 52 | handler = TimedRotatingFileHandler("app.log", when="M", interval=1, backupCount=0) 53 | console_handler = logging.StreamHandler() 54 | 55 | # Create formatters and add it to handlers 56 | log_format = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s") 57 | handler.setFormatter(log_format) 58 | console_handler.setFormatter(log_format) 59 | 60 | # Add handlers to the logger 61 | logger.addHandler(handler) 62 | logger.addHandler(console_handler) 63 | 64 | try: 65 | 1 / 0 66 | except Exception: 67 | # Log exception with traceback 68 | logger.error("An exception occurred", exc_info=True) 69 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # 🎉🎉 Welcome to Our Project! 🎉🎉 2 | 3 | First off, thank you for considering contributing to our project. It's people like you that make this project such a great one. We welcome any type of contribution, not only code. You can help with everything from documentation to testing to artwork and more! 4 | 5 | ## 🌈 How Can I Contribute? 🌈 6 | 7 | ### 🐞 Reporting Bugs 🐞 8 | 9 | If you found something that doesn't work as expected, please open an issue in the issue tracker. Oh, and remember, a bug not reported is a bug not fixed! 10 | 11 | ### 🆕 Suggesting Features 🆕 12 | 13 | If you're into this project, chances are you've got ideas. Don't be shy! We love innovative new ideas. Open an issue if you have a feature idea or suggestion. 14 | 15 | ### 📝 Documentation 📝 16 | 17 | Can't find what you're looking for in the documentation? Or maybe you found a mistake? Let us know! We strive to make our documentation clear, concise, and helpful, but sometimes we need a fresh pair of eyes. 18 | 19 | ### 💻 Code Contributions 💻 20 | 21 | Ready to dive into the code? Awesome! We've got a list of issues that could use some help. If you're new to coding, look for issues labeled `good first issue`. If you're an experienced coder, we've got challenges for you too! 22 | 23 | ## 🚀 Getting Started 🚀 24 | 25 | If you're ready to contribute, that's great! Here's how you can set up the project for development: 26 | 27 | 1. Fork the project. 28 | 2. Clone your fork (`git clone https://github.com/yourname/projectname.git`). 29 | 3. Create a branch (`git checkout -b my-branch`). 30 | 4. Make your changes. 31 | 5. Test your changes. 32 | 6. Commit your changes (`git commit -m 'Add my awesome feature'`). 33 | 7. Push to your branch (`git push origin my-branch`). 34 | 8. Open a Pull Request. 35 | 36 | ## 🎈 Code of Conduct 🎈 37 | 38 | We want to foster an inclusive and friendly community. Please follow our [Code of Conduct](CODE_OF_CONDUCT.md). 39 | 40 | ## 🎁 What's Next? 🎁 41 | 42 | Once you open a pull request, we will review your contribution and provide feedback. If everything looks good, we'll merge your changes into our project. And then... Congratulations! You will have just made this project even better! 43 | 44 | Remember, the best way to learn is to do. So, let's get started! We can't wait to see what amazing things you'll bring to this project. 🚀🌟 -------------------------------------------------------------------------------- /backend/tests/test_codebase.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import os 3 | from unittest.mock import Mock 4 | from database.my_codebase import MyCodebase 5 | from unittest.mock import patch 6 | 7 | IGNORE_DIRS = ["node_modules", ".next", ".venv", "__pycache__", ".git"] 8 | FILE_EXTENSIONS = [".js", ".py", ".md"] 9 | 10 | 11 | class MyCodebaseTests(unittest.TestCase): 12 | DIRECTORY = os.path.dirname(os.path.abspath(__file__)) 13 | DIRECTORY = os.path.join(DIRECTORY, "..", "..") 14 | print(DIRECTORY) 15 | 16 | def setUp(self): 17 | # Create a mock connection object 18 | conn = Mock() 19 | 20 | # Create a mock cursor object 21 | cursor = Mock() 22 | 23 | # Configure the mock connection to return the mock cursor when cursor() is called 24 | conn.cursor.return_value = cursor 25 | 26 | # Configure the mock cursor to return an empty list when fetchall() is called 27 | cursor.fetchall.return_value = [] 28 | 29 | self.codebase = MyCodebase( 30 | self.DIRECTORY, 31 | db_connection=conn, 32 | ignore_dirs=IGNORE_DIRS, 33 | file_extensions=FILE_EXTENSIONS, 34 | ) 35 | 36 | @patch( 37 | "database.my_codebase.ENCODER.encode", return_value=list(range(10)) 38 | ) # mocks ENCODER.encode to always return a list of length 10 39 | def test_set_directory(self, mock_encode): 40 | new_directory = os.path.abspath("../") 41 | self.codebase.set_directory(new_directory) 42 | self.assertEqual(self.codebase.directory, os.path.abspath(new_directory)) 43 | 44 | @patch( 45 | "database.my_codebase.ENCODER.encode", return_value=list(range(10)) 46 | ) # mocks ENCODER.encode to always return a list of length 10 47 | def test_is_valid_file(self, mock_encode): 48 | self.assertTrue(self.codebase._is_valid_file("valid_file.py")) 49 | self.assertFalse(self.codebase._is_valid_file(".invalid_file.py")) 50 | self.assertFalse(self.codebase._is_valid_file("invalid_file.json")) 51 | self.assertFalse(self.codebase._is_valid_file("package-lock.json")) 52 | 53 | @patch( 54 | "database.my_codebase.ENCODER.encode", return_value=list(range(10)) 55 | ) # mocks ENCODER.encode to always return a list of length 10 56 | def test_tree(self, mock_encode): 57 | tree = self.codebase.tree() 58 | self.assertIsInstance(tree, str) 59 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Project Code of Conduct 2 | 3 | Welcome to our awesome project! We're thrilled to have you as a part of our community. To ensure a positive and inclusive environment, we have established this Code of Conduct that applies to everyone participating in our project. By contributing to this project, you agree to abide by this Code of Conduct. 4 | 5 | ## Our Pledge 6 | 7 | In the spirit of fostering an open and welcoming community, we pledge to: 8 | 9 | - Be friendly, respectful, and supportive towards all contributors. 10 | - Embrace diversity and inclusivity, and treat everyone with kindness and empathy. 11 | - Listen to and consider different perspectives and ideas. 12 | - Be patient and understanding, especially with those who are new to the project. 13 | - Encourage and empower others to participate and contribute. 14 | 15 | ## Our Standards 16 | 17 | To create a fun and exciting environment, we have set the following standards for behavior within our community: 18 | 19 | - Be positive and constructive in your interactions with others. 20 | - Use welcoming and inclusive language. 21 | - Be respectful of differing opinions and experiences. 22 | - Accept and provide constructive feedback gracefully. 23 | - Focus on collaboration and teamwork. 24 | - Be mindful of your words and actions, as they have an impact on others. 25 | - Be open to learning from others and sharing your knowledge. 26 | 27 | ## Our Responsibilities 28 | 29 | As project maintainers, we are responsible for maintaining a safe and inclusive environment. We will: 30 | 31 | - Enforce this Code of Conduct consistently and fairly. 32 | - Address any reported issues promptly and with confidentiality. 33 | - Provide guidance and support to those who seek help. 34 | - Make decisions in the best interest of the community. 35 | 36 | ## Scope 37 | 38 | This Code of Conduct applies to all project-related spaces, including but not limited to: 39 | 40 | - GitHub repositories 41 | - Issue trackers 42 | - Pull request discussions 43 | - Project meetings 44 | - Project events 45 | 46 | ## Enforcement 47 | 48 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at [insert contact email address]. All complaints will be reviewed and investigated promptly and fairly. The project team is obligated to maintain the confidentiality of the reporter of an incident. 49 | 50 | ## Attribution 51 | 52 | This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org), version 2.0, available at [https://www.contributor-covenant.org/version/2/0/code_of_conduct.html](https://www.contributor-covenant.org/version/2/0/code_of_conduct.html). 53 | 54 | Let's make this project an amazing place where everyone feels welcome and excited to contribute! 55 | -------------------------------------------------------------------------------- /frontend/components/modal_bar_modals/ContextViewerModal.js: -------------------------------------------------------------------------------- 1 | // frontend/components/modal_bar_modals/ContextViewerModal.js 2 | import React, { useEffect, useState } from 'react'; 3 | import ReactModal from 'react-modal'; 4 | import { useDispatch, useSelector } from 'react-redux'; 5 | import { setIsContextModalOpen, setWorkingContext } from '../../store/modal_bar_modals/contextViewerSlice'; 6 | 7 | ReactModal.setAppElement('#__next'); 8 | 9 | const ContextViewerModal = () => { 10 | const dispatch = useDispatch(); 11 | const isOpen = useSelector(state => state.contextViewer.isModalOpen); 12 | const workingContext = useSelector(state => state.contextViewer.workingContext); 13 | 14 | // const currentDirectory = useSelector(state => state.sidebar.currentDirectory); 15 | const fetchContext = async () => { 16 | try { 17 | const response = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/get_context`); 18 | if (!response.ok) { 19 | throw new Error('Network response was not ok'); 20 | } 21 | const data = await response.json(); 22 | // Do something with the context data, e.g., store in state, display in a modal, etc. 23 | dispatch(setWorkingContext(data.context)); 24 | console.log(data.context); 25 | } catch (error) { 26 | console.error('There has been a problem with your fetch operation:', error); 27 | } 28 | }; 29 | 30 | useEffect(() => { 31 | if (isOpen) { 32 | fetchContext(); 33 | } 34 | }, [isOpen]); 35 | 36 | 37 | return ( 38 | dispatch(setIsContextModalOpen(false))} 41 | shouldCloseOnOverlayClick={true} 42 | className="fixed inset-0 flex items-center justify-center m-96 bg-gray-800 text-white border-blue-500" 43 | overlayClassName="fixed inset-0 bg-gray-800 bg-opacity-50" 44 | > 45 |
46 |

Working Context

47 |