From beeb0c6493fc23c948241a8fa9b466b8874efecb Mon Sep 17 00:00:00 2001 From: Franziska Gerold Date: Fri, 29 May 2026 23:13:07 +0200 Subject: [PATCH] changed description slightly --- project_description.md | 96 ++++++++++++++++++++++-------------------- 1 file changed, 51 insertions(+), 45 deletions(-) diff --git a/project_description.md b/project_description.md index bf27941..84f37ce 100644 --- a/project_description.md +++ b/project_description.md @@ -1,32 +1,32 @@ -###**Lightweight Code Editor with AI integration** +#**Lightweight Code Editor with AI integration** -##1. Introduction +## 1. Introduction This code editor was made as a project for the course Artificial Intelligence in Software Engineering I at FH Graubuenden. Its purpose is to help with coding questions and debugging. -##2. Requirements +## 2. Requirements streamlit openai ddgs dotenv -##3. Installation +## 3. Installation - install requirements through pip - aquire the environment variables thourgh FHGR - connect to the FHGR VPN to get access to the AI model. - run the app via terminal with "streamlit run app.py". A browser window will open. -##4. Architecture +## 4. Architecture The code is split up into frontend (app.py) and backend modules (FileManager, ChatManager, SystemPrompter, ExecutionEngine, DebugLogger and SearchManager). A lot of functionality is realized through the use of the session_state from streamlit. Since the streamlit app is rerun after each action the session_state is used to keep track of relevant information. -# 4.1 app.py +### 4.1 app.py This module is the entrypoint for the streamlit functionality. It contains all elements that are visible when the program is run. @@ -48,19 +48,19 @@ This module is the entrypoint for the streamlit functionality. It contains all e With this feedback the AI can help with a more focused approach to find and fix bugs in the code. The user has to implement the fixes themself since the AI cannot change the contents of the file. Interacts with ChatManager, Debuglogger -# 4.2 FileManager.py +### 4.2 FileManager.py This module manages the access to the working directory. It uses Path objects. The open_file function is only used as a helper function to save the file path and contents to the session_state. -# 4.3 ChatManager.py +### 4.3 ChatManager.py The environment variables are located in a .env file which is excluded from the gitea upload. The qwen AI is accessed through the openai API client. While this module sends the messages to the AI it is heavily dependend on the SystemPrompter to supply the relevant context for the finished prompt. Interacts with SystemPrompter -# 4.4 SystemPrompter.py +### 4.4 SystemPrompter.py This module handles all the context to add to the user message sent via the ChatManager. The instructions for the AI are structured with xml tags. There are two modes which are chosen with a toggle. Both modes differ in the system component and sent context. @@ -69,67 +69,73 @@ With the toggle on the output is structured with json and focussed on finding bu This means that subsequent messages to the AI keep its own responses therefore having the ability to iterate on them. Interacts with SearchManager -# 4.5 ExecutionEngine.py +### 4.5 ExecutionEngine.py With this module the program can execute the opened file after clicking the corresponding button in the streamlit app. There is a safety check before the subprocess is called to make sure no malicious actions can be made from within the program. Interacts with Debuglogger -# 4.6 DebugLogger.py +### 4.6 DebugLogger.py This module handles making all outputs from various other module more readable and useable. It saves the AI's response in the session_state to be able to send it with the next prompt when using the debug toggle. -# 4.7 SearchManager.py +### 4.7 SearchManager.py This modules uses the duckduckgosearch API to make searching the internet possible. The user does not directly see the search, but the result is sent with the prompt to the AI. -##5. Usage +## 5. Usage The following examples illustrate how to use this program. *I want to ask the AI about something in my file* - **user actions**: + click on button with name of the file - + write message to AI - + wait for response - + implement suggestions from AI + **user actions**: + + click on button with name of the file + + write message to AI + + it for response + + implement suggestions from AI - **interaction flow**: + st.sidebar uses list_files() to generate Buttons - + on_click uses open_file() to load content and file Path into session_state - + send_message() uses generate_prompt() to add system_prompt and context = file_content to the user_message - + response is displayed by st.session_state.messages + **interaction flow**: + + st.sidebar uses list_files() to generate Buttons + + on_click uses open_file() to load content and file Path into session_state + + send_message() uses generate_prompt() to add system_prompt and context = file_content to the user_message + + response is displayed by st.session_state.messages *I want to ask the AI about somehting in my file, but the AI has outdated info about the topic* - **user actions**: + click on button with name of the file - + activate "enable internet search" toggle - + write message to AI - + wait for response - + implement suggestions from AI + **user actions**: + + click on button with name of the file + + activate "enable internet search" toggle + + write message to AI + + wait for response + + implement suggestions from AI - **interaction flow**: + st.sidebar uses list_files() to generate Buttons - + on_click uses open_file() to load content and file Path into session_state - + send_message() uses generate_prompt() to add system_prompt and context = file_content and results from perform_search() to the user_message - + response is displayed by st.session_state.messages + **interaction flow**: + + st.sidebar uses list_files() to generate Buttons + + on_click uses open_file() to load content and file Path into session_state + + send_message() uses generate_prompt() to add system_prompt and context = file_content and results from perform_search() to the user_message + + response is displayed by st.session_state.messages *I want to debug my code* - **user actions**: + click on button with name of the file - + click the "execute code" button - + write message to AI - + wait for response - + implement suggestions from AI - + write message to AI - + implement suggestions from AI + **user actions**: + + click on button with name of the file + + click the "execute code" button + + write message to AI + + wait for response + + implement suggestions from AI + + write message to AI + + implement suggestions from AI - **interaction flow**: + st.sidebar uses list_files() to generate Buttons - + on_click uses open_file() to load content and file Path into session_state - + on_click uses run_code() to execute the file, results are formatted by format_output() or format_error() - + code_output or code_error are loaded into seassion_state - + send_message() uses generate_prompt() to add system_prompt which detects the "debug" toggle and adds context = file_content and code_output / code_error to the user_message - + response is displayed by st.session_state.messages - + send_message() uses generate_prompt() to add system_prompt which detects the "debug" toggle and adds context = file_content and code_output / code_error and debug response to the user_message - + response is displayed by st.session_state.messages + **interaction flow**: + + st.sidebar uses list_files() to generate Buttons + + on_click uses open_file() to load content and file Path into session_state + + on_click uses run_code() to execute the file, results are formatted by format_output() or format_error() + + code_output or code_error are loaded into seassion_state + + send_message() uses generate_prompt() to add system_prompt which detects the "debug" toggle and adds context = file_content and code_output / code_error to the user_message + + response is displayed by st.session_state.messages + + send_message() uses generate_prompt() to add system_prompt which detects the "debug" toggle and adds context = file_content and code_output / code_error and debug response to the user_message + + response is displayed by st.session_state.messages