- Add ChatManager class for OpenAI-compatible API communication (silicon.fhgr.ch:7080) - Add SystemPrompter for intelligent prompt generation with file context - Integrate ChatManager into frontend chat component - Add comprehensive pytest tests (40+ tests covering unit and integration scenarios) - Implement error handling for API failures, timeouts, and connection issues - Add environment variable-based configuration for API credentials - Update frontend state initialization to include ChatManager - All tests passing with mock/patch isolation for API calls
37 lines
1.1 KiB
Python
37 lines
1.1 KiB
Python
import streamlit as st
|
|
from backend.managers.chat_manager import ChatManager
|
|
|
|
def init_state():
|
|
# Sidebar state initialization
|
|
|
|
# Chat manager (persists across reruns)
|
|
if "chat_manager" not in st.session_state:
|
|
st.session_state.chat_manager = ChatManager()
|
|
|
|
# Editor state initialization
|
|
if "open_files" not in st.session_state:
|
|
st.session_state.open_files = []
|
|
|
|
if "files_content" not in st.session_state:
|
|
st.session_state.files_content = {}
|
|
|
|
if "active_file" not in st.session_state:
|
|
st.session_state.active_file = None
|
|
|
|
if "is_editing" not in st.session_state:
|
|
st.session_state.is_editing = False
|
|
|
|
if "code_suggestions" not in st.session_state:
|
|
st.session_state.code_suggestions = []
|
|
|
|
if "code_execution_output" not in st.session_state:
|
|
st.session_state.code_execution_output = ""
|
|
|
|
# Chat state initialization
|
|
if "chat_history" not in st.session_state:
|
|
st.session_state.chat_history = []
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
init_state() |