Spaces:
Running
Running
File size: 2,382 Bytes
e51667a |
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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
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)
|