forked from UKZN-GroupProjs/Python-Code-Assistant
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
46 lines (36 loc) · 1.52 KB
/
app.py
File metadata and controls
46 lines (36 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import streamlit as st
from view.components import user_input_area, mode_selector
from view.sidebar import draw_sidebar as sidebar
from view.model_selector import model_selector
from controller.orchestrator import Orchestrator
from utils.session_manager import SessionManager
from utils.request_handler import RequestHandler
from view.page_config import setup_page
# =================================
# MODEL + ORCHESTRATOR SETUP
# =================================
@st.cache_resource
def get_orchestrator(selected_model: str):
"""Create or retrieve cached orchestrator instance."""
return Orchestrator(selected_model, "llama3.2:1b")
def setup_orchestrator():
"""Handle model selection and orchestrator initialization."""
selected_model = model_selector() or "Deepseek-coder:6.7b"
orchestrator = get_orchestrator(selected_model)
return orchestrator
# ============================
# MAIN DASHBOARD ENTRY
# ============================
def show_dashboard(username: str):
"""Main entry point for the dashboard — orchestrates all components."""
setup_page(username)
sidebar(username)
orchestrator = setup_orchestrator()
mode_raw, use_planner = mode_selector()
mode = "tutor" if "Tutor" in mode_raw else "fix-it"
user_input = user_input_area()
SessionManager.initialize()
request_handler = RequestHandler(orchestrator)
request_handler.handle_run_button(user_input, use_planner, mode)
if use_planner:
request_handler.handle_planner_stage(user_input, mode)