Spaces:
Running
Running
File size: 6,129 Bytes
2d46f87 |
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 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
import streamlit as st
from utils2 import AvocatAI, chat_model, Guidlines
# def home():
# st.title("Home Page")
# st.write("Welcome to the multi-screen Streamlit app. Use the sidebar to navigate between different screens.")
def prompt_response_screen():
st.title("Prompt and Response Input App")
def respon(prompt, response, error):
input_data = f"""
Plase Note if user asked for the extra information information in form of text apart from coding then you should consider it as explaination and it can affect the review so plase check guidlines as well so only code can not considered as explaination.
Guidlines : {Guidlines}
User_Prompt: {prompt}
Model_Response: {response}
Problems: {error}"""
return AvocatAI(input_data)
def display_results(result):
# Unpack and format the result dictionary
instruction_following = result.get('Instruction_Following2', 'N/A')
rationale_instruction_following = result.get('Rationalefor_Instruction_Following2', 'N/A')
Truthfulness = result.get('Truthfulness2', 'N/A')
Rationale_for_Truthfulness = result.get('Rationale_for_Truthfulness2', 'N/A')
Conciseness = result.get('Conciseness2', 'N/A')
Rationale_for_Conciseness = result.get('Rationale_for_Conciseness2', 'N/A')
Content_Safety = result.get('Content_Safety2', 'N/A')
Rationale_Code_Content_Safety_Rating = result.get('Rationale_Code_Content_Safety_Rating2', 'N/A')
Overall_Satisfaction = result.get('Overall_Satisfaction2', 'N/A')
Reasoning_for_Overall_Satisfaction_Rating = result.get('Reasoning_for_Overall_Satisfaction_Rating2', 'N/A')
# Display formatted results
st.write(f"**Instruction Following:** {instruction_following}")
st.write("--------------------------")
st.write(f"**Rationale for Instruction Following:**")
st.write(rationale_instruction_following)
st.write("--------------------------")
st.write(f"**Truthfulness:** {Truthfulness}")
st.write("--------------------------")
st.write(f"**Rationale for Truthfulness:** ")
st.write(Rationale_for_Truthfulness)
st.write("--------------------------")
st.write(f"**Conciseness:** {Conciseness}")
st.write("--------------------------")
st.write(f"**Rationale for Conciseness:** ")
st.write(Rationale_for_Conciseness)
st.write("--------------------------")
st.write(f"**Content Safety:** {Content_Safety}")
st.write("--------------------------")
st.write(f"**Rationale for Content Safety:** ")
st.write(Rationale_Code_Content_Safety_Rating)
st.write("--------------------------")
st.write(f"**Overall Satisfaction:** {Overall_Satisfaction}")
st.write("--------------------------")
st.write(f"**Rationale for Overall Satisfaction:** ")
st.write(Reasoning_for_Overall_Satisfaction_Rating)
# Collecting the prompt and responses
prompt = st.text_area("Enter the user prompt:", "")
st.subheader("Input Details For Model A")
response1 = st.text_area("Enter the response for the first Response:", "")
output1 = st.text_input("Enter the first output:", "")
st.subheader("Input Details for Model B")
response2 = st.text_area("Enter the response for the second Response:", "")
output2 = st.text_input("Enter the second output:", "")
# Process and display results
if st.button("Submit"):
if all([prompt, response1, output1, response2, output2]):
# Process the responses
res1 = respon(prompt, response1, output1)
res2 = respon(prompt, response2, output2)
# Create two columns for side-by-side display
col1, col2 = st.columns(2)
# Display results in the first column
with col1:
st.subheader("Model A")
display_results(res1)
# Display results in the second column
with col2:
st.subheader("Model B")
display_results(res2)
data = f'''which model I should use chose any one and give justification why that model is better over another model and please answer in 2-3 lines only and it should looks like it was written by human and also model comparison should indicates the issues as well..
Model A: {res1}
Model B: {res2}'''
response = chat_model.invoke(data).content
st.write("---------------------------------------------------")
st.write(f'Preference: {response}')
else:
st.error("Please fill in all the fields.")
def settings():
st.title("Prompt Page")
metadata = st.text_area("Enter the metadata:", "")
if st.button("Submit"):
data = f''' generate user prompt for below meta data. prompt should looks like it was written by user and it should be easy and in 2-3 lenght.
METADATA: {metadata}'''
response = chat_model.invoke(data).content
st.write(f"**Prompt:**")
st.write(f"**----------------------------**")
st.write(f"{response}")
followup_promp = f"please generate list of easy relatable follow up question for given prompt: {response} Note: it should only be questions and it should looks like it is written by user and it's should related to the given input prompt. question length should be 3-4 lines."
response = chat_model.invoke(followup_promp).content
st.write(f"**FollowUp questions:**")
st.write(f"**----------------------------**")
st.write(f"{response}")
def main():
st.sidebar.title("Navigation")
page = st.sidebar.radio("Select a page:", ["Prompt and Response", "Prompt Page"])
# if page == "Home":
# home()
if page == "Prompt and Response":
prompt_response_screen()
elif page == "Prompt Page":
settings()
if __name__ == "__main__":
main()
|