import streamlit as st def prompt_engineering_dashboard(session_state, config): inital_prompt_engineering_dict = config["PROMPT_ENGINEERING_DICT"] def engineer_prompt(): session_state.history[0] = [ session_state.system_instruction, session_state.system_response, ] with st.expander("Prompt Engineering Dashboard"): st.info( "**The input to the model follows this below template**", ) st.code( """ [SYSTEM INSTRUCTION] [SYSTEM RESPONSE] [... LIST OF PREV INPUTS] [PRE CONTEXT] [CONTEXT RETRIEVED FROM THE WEB] [POST CONTEXT] [PRE PROMPT] [PROMPT] [POST PROMPT] [PREV GENERATED INPUT] # Only if Pass previous prompt set True """ ) session_state.system_instruction = st.text_area( label="SYSTEM INSTRUCTION", value=inital_prompt_engineering_dict["SYSTEM_INSTRUCTION"], ) session_state.system_response = st.text_area( "SYSTEM RESPONSE", value=inital_prompt_engineering_dict["SYSTEM_RESPONSE"] ) col1, col2 = st.columns(2) with col1: session_state.pre_context = st.text_input( "PRE CONTEXT", value=inital_prompt_engineering_dict["PRE_CONTEXT"], disabled=not session_state.rag_enabled, ) session_state.post_context = st.text_input( "POST CONTEXT", value=inital_prompt_engineering_dict["POST_CONTEXT"], disabled=not session_state.rag_enabled, ) with col2: session_state.pre_prompt = st.text_input( "PRE PROMPT", value=inital_prompt_engineering_dict["PRE_PROMPT"] ) session_state.post_prompt = st.text_input( "POST PROMPT", value=inital_prompt_engineering_dict["POST_PROMPT"] ) col3, col4 = st.columns(2) with col3: session_state.pass_prev = st.toggle("Pass previous Output") with col4: st.button("Engineer Prompts", on_click=engineer_prompt)