Merge branch 'ui-setup' of https://gitea.fhgr.ch/meulilivio/AISE1_Project into feature/backend_implemation
This commit is contained in:
commit
38efd1aec2
@ -0,0 +1,49 @@
|
||||
import streamlit as st
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
# Add project root to Python path for imports
|
||||
sys.path.insert(0, str(Path(__file__).parent.parent))
|
||||
|
||||
from frontend.sidebar import render_sidebar
|
||||
from frontend.editor import render_editor
|
||||
from frontend.chat import render_chat
|
||||
|
||||
|
||||
def init_state():
|
||||
"""Initialize session state variables."""
|
||||
if "selected_file" not in st.session_state:
|
||||
st.session_state.selected_file = None
|
||||
if "file_content" not in st.session_state:
|
||||
st.session_state.file_content = ""
|
||||
if "chat_history" not in st.session_state:
|
||||
st.session_state.chat_history = []
|
||||
if "code_output" not in st.session_state:
|
||||
st.session_state.code_output = ""
|
||||
|
||||
|
||||
def main():
|
||||
st.set_page_config(
|
||||
page_title="Lightweight code editor",
|
||||
layout="wide")
|
||||
|
||||
st.title("Lightweight code editor")
|
||||
|
||||
init_state()
|
||||
|
||||
left, right = st.columns([1, 3])
|
||||
|
||||
with left:
|
||||
choice = render_sidebar()
|
||||
|
||||
with right:
|
||||
if choice == "Chat with AI Assistant":
|
||||
render_chat()
|
||||
elif choice == "Code Editor":
|
||||
render_editor()
|
||||
elif choice == "File Explorer":
|
||||
st.subheader("File Explorer")
|
||||
st.info("File Explorer functionality is not implemented yet.")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@ -0,0 +1,21 @@
|
||||
import streamlit as st
|
||||
|
||||
def render_chat():
|
||||
st.subheader("Chat with AI Assistant")
|
||||
|
||||
if st.session_state.chat_history:
|
||||
for message in st.session_state.chat_history:
|
||||
st.markdown(f"**{message['role'].capitalize()}:** {message['content']}")
|
||||
|
||||
user_input = st.text_input("Type your message here:", key="chat_input")
|
||||
|
||||
if st.button("Send", key="send_button") and user_input:
|
||||
st.session_state.chat_history.append({"role": "user", "content": user_input})
|
||||
# Here you would typically call your AI assistant to get a response
|
||||
# For demonstration, we'll just echo the user's message
|
||||
ai_response = f"Echo: {user_input}"
|
||||
st.session_state.chat_history.append({"role": "assistant", "content": ai_response})
|
||||
st.session_state.chat_input = "" # Clear input after sending
|
||||
|
||||
if __name__ == "__main__":
|
||||
render_chat()
|
||||
@ -0,0 +1,17 @@
|
||||
import streamlit as st
|
||||
|
||||
def render_editor():
|
||||
st.subheader("Code Editor")
|
||||
|
||||
if st.session_state.selected_file:
|
||||
st.text_area(
|
||||
"Edit your code here:",
|
||||
value=st.session_state.file_content,
|
||||
height=400,
|
||||
key="code_editor"
|
||||
)
|
||||
else:
|
||||
st.info("Please select a file to edit.")
|
||||
|
||||
if __name__ == "__main__":
|
||||
render_editor()
|
||||
@ -0,0 +1,13 @@
|
||||
import streamlit as st
|
||||
|
||||
def render_sidebar():
|
||||
st.sidebar.title("Navigation")
|
||||
|
||||
options = ["Chat with AI Assistant", "Code Editor", "File Explorer"]
|
||||
choice = st.sidebar.radio("Go to:", options)
|
||||
|
||||
return choice
|
||||
|
||||
if __name__ == "__main__":
|
||||
render_sidebar()
|
||||
|
||||
20
frontend/state.py
Normal file
20
frontend/state.py
Normal file
@ -0,0 +1,20 @@
|
||||
import streamlit as st
|
||||
|
||||
def init_state():
|
||||
if "selected_file" not in st.session_state:
|
||||
st.session_state.selected_file = None
|
||||
|
||||
if "file_content" not in st.session_state:
|
||||
st.session_state.file_content = ""
|
||||
|
||||
if "is_editing" not in st.session_state:
|
||||
st.session_state.is_editing = False
|
||||
|
||||
if "chat_history" not in st.session_state:
|
||||
st.session_state.chat_history = []
|
||||
|
||||
if "code_suggestions" not in st.session_state:
|
||||
st.session_state.code_suggestions = []
|
||||
|
||||
if __name__ == "__main__":
|
||||
init_state()
|
||||
Loading…
x
Reference in New Issue
Block a user