File size: 1,554 Bytes
c8fb072
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
47
48
49
50
51
import streamlit as st
from src.sdlc.graph.graph_builder import GraphBuilder
from src.sdlc.LLMS.groqllm import GroqLLM
from src.sdlc.LLMS.openaillm import OpenAILLM
from src.sdlc.ui.uiconfigfile import Config
import base64


def get_cached_graph():
    """Cache the model so it persists across reruns."""
    user_input=st.session_state.get('user_input','')
    if user_input['selected_llm'] == 'Groq':
        obj_llm_config = GroqLLM(user_controls_input=user_input)
    elif user_input['selected_llm'] == 'OpenAI':
        obj_llm_config = OpenAILLM(user_controls_input=user_input)
    else:
        st.error("Invalid LLM selection.")
        return
    model = obj_llm_config.get_llm_model()
    graph_builder = GraphBuilder(model)
    return graph_builder.setup_graph()


@st.cache_data
def get_cached_sdlc_nodes():
    sdlc_nodes = Config().get_sdlc_nodes()
    sdlc_nodes = sdlc_nodes.split(",")
    return sdlc_nodes

def clear_cache_data():
    st.session_state.clear()
    st.cache_data.clear()  # Clear all cached data
    st.cache_resource.clear()  # Clear all cached resources
    st.session_state.page = "home"

def display_states(curr_state,response):
    state=curr_state.replace('_', ' ')
    b64_docs = base64.b64encode(response.encode()).decode()
    href = f'''
        <a href="data:text/markdown;base64,{b64_docs}" 
        download="{curr_state}.md"
        style="text-decoration: none; color: inherit; font-weight: bold;">
            ⬇️ Download {state}
        </a>
    '''
    st.markdown(href, unsafe_allow_html=True)