Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
app.py
CHANGED
|
@@ -582,28 +582,10 @@ temperature = 0.9
|
|
| 582 |
top_p = 1.0
|
| 583 |
top_k = 1
|
| 584 |
max_output_tokens = 1024
|
| 585 |
-
|
| 586 |
-
"temperature": temperature,
|
| 587 |
-
"top_p": top_p,
|
| 588 |
-
"top_k": top_k,
|
| 589 |
-
"max_output_tokens": max_output_tokens,
|
| 590 |
-
}
|
| 591 |
-
st.sidebar.subheader("Selected Values")
|
| 592 |
-
st.sidebar.write(f"Temperature: {temperature}")
|
| 593 |
-
st.sidebar.write(f"Top P: {top_p}")
|
| 594 |
-
st.sidebar.write(f"Top K: {top_k}")
|
| 595 |
-
st.sidebar.write(f"Max Output Tokens: {max_output_tokens}")
|
| 596 |
|
| 597 |
#------------------------------------------------------------
|
| 598 |
-
SAFETY_SETTINGS = [
|
| 599 |
-
{"category": "HARM_CATEGORY_HARASSMENT", "threshold": "BLOCK_NONE"},
|
| 600 |
-
{"category": "HARM_CATEGORY_HATE_SPEECH", "threshold": "BLOCK_NONE"},
|
| 601 |
-
{"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT", "threshold": "BLOCK_NONE"},
|
| 602 |
-
{"category": "HARM_CATEGORY_DANGEROUS_CONTENT", "threshold": "BLOCK_NONE"},
|
| 603 |
-
]
|
| 604 |
|
| 605 |
-
|
| 606 |
-
|
| 607 |
#HEADER
|
| 608 |
st.markdown('''
|
| 609 |
Powered by Hk4crprasad <img src="https://i.ibb.co/BVJ2tCG/OIG-47-modified.png" width="20" height="20">
|
|
@@ -787,7 +769,21 @@ if pdf_mode:
|
|
| 787 |
text_chunks = get_text_chunks(raw_text)
|
| 788 |
get_vector_store(text_chunks)
|
| 789 |
st.success("Done")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 790 |
else:
|
|
|
|
| 791 |
with st.sidebar:
|
| 792 |
st.subheader("Settings")
|
| 793 |
temperature1 = st.slider("Temperature", 0.1, 1.0, temperature)
|
|
@@ -795,23 +791,39 @@ else:
|
|
| 795 |
top_k1 = st.slider("Top K", 1, 30, top_k)
|
| 796 |
max_output_tokens1 = st.slider("Max Output Tokens", 100, 2048, max_output_tokens)
|
| 797 |
apply_button = st.button("Apply")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 798 |
|
| 799 |
-
|
|
|
|
|
|
|
| 800 |
if apply_button:
|
| 801 |
# Update generation_config based on user input
|
| 802 |
temperature = temperature1
|
| 803 |
top_p = top_p1
|
| 804 |
top_k = top_k1
|
| 805 |
max_output_tokens = max_output_tokens1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 806 |
|
| 807 |
-
|
| 808 |
-
|
| 809 |
-
|
| 810 |
-
category
|
| 811 |
-
|
| 812 |
-
|
| 813 |
-
# Update safety settings based on user input
|
| 814 |
-
setting["threshold"] = threshold
|
| 815 |
|
| 816 |
if pdf_mode:
|
| 817 |
prompt = None
|
|
|
|
| 582 |
top_p = 1.0
|
| 583 |
top_k = 1
|
| 584 |
max_output_tokens = 1024
|
| 585 |
+
threshold_options = ["BLOCK_NONE", "BLOCK_ONLY_HIGH", "BLOCK_MEDIUM_AND_ABOVE", "BLOCK_LOW_AND_ABOVE"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 586 |
|
| 587 |
#------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 588 |
|
|
|
|
|
|
|
| 589 |
#HEADER
|
| 590 |
st.markdown('''
|
| 591 |
Powered by Hk4crprasad <img src="https://i.ibb.co/BVJ2tCG/OIG-47-modified.png" width="20" height="20">
|
|
|
|
| 769 |
text_chunks = get_text_chunks(raw_text)
|
| 770 |
get_vector_store(text_chunks)
|
| 771 |
st.success("Done")
|
| 772 |
+
|
| 773 |
+
generation_config = {
|
| 774 |
+
"temperature": temperature,
|
| 775 |
+
"top_p": top_p,
|
| 776 |
+
"top_k": top_k,
|
| 777 |
+
"max_output_tokens": max_output_tokens,
|
| 778 |
+
}
|
| 779 |
+
SAFETY_SETTINGS = [
|
| 780 |
+
{"category": "HARM_CATEGORY_HARASSMENT", "threshold": 0}, # Default to BLOCK_NONE
|
| 781 |
+
{"category": "HARM_CATEGORY_HATE_SPEECH", "threshold": 0},
|
| 782 |
+
{"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT", "threshold": 0},
|
| 783 |
+
{"category": "HARM_CATEGORY_DANGEROUS_CONTENT", "threshold": 0},
|
| 784 |
+
]
|
| 785 |
else:
|
| 786 |
+
|
| 787 |
with st.sidebar:
|
| 788 |
st.subheader("Settings")
|
| 789 |
temperature1 = st.slider("Temperature", 0.1, 1.0, temperature)
|
|
|
|
| 791 |
top_k1 = st.slider("Top K", 1, 30, top_k)
|
| 792 |
max_output_tokens1 = st.slider("Max Output Tokens", 100, 2048, max_output_tokens)
|
| 793 |
apply_button = st.button("Apply")
|
| 794 |
+
|
| 795 |
+
st.subheader("Safety Settings")
|
| 796 |
+
for setting in SAFETY_SETTINGS:
|
| 797 |
+
category = setting["category"]
|
| 798 |
+
index = st.selectbox(f"{category} Threshold", range(len(threshold_options)))
|
| 799 |
|
| 800 |
+
# Update safety settings based on user input
|
| 801 |
+
setting["threshold"] = index
|
| 802 |
+
|
| 803 |
if apply_button:
|
| 804 |
# Update generation_config based on user input
|
| 805 |
temperature = temperature1
|
| 806 |
top_p = top_p1
|
| 807 |
top_k = top_k1
|
| 808 |
max_output_tokens = max_output_tokens1
|
| 809 |
+
generation_config = {
|
| 810 |
+
"temperature": temperature,
|
| 811 |
+
"top_p": top_p,
|
| 812 |
+
"top_k": top_k,
|
| 813 |
+
"max_output_tokens": max_output_tokens,
|
| 814 |
+
}
|
| 815 |
+
st.sidebar.subheader("Selected Values")
|
| 816 |
+
st.sidebar.write(f"Temperature: {temperature}")
|
| 817 |
+
st.sidebar.write(f"Top P: {top_p}")
|
| 818 |
+
st.sidebar.write(f"Top K: {top_k}")
|
| 819 |
+
st.sidebar.write(f"Max Output Tokens: {max_output_tokens}")
|
| 820 |
|
| 821 |
+
SAFETY_SETTINGS = [
|
| 822 |
+
{"category": "HARM_CATEGORY_HARASSMENT", "threshold": index}, # Default to BLOCK_NONE
|
| 823 |
+
{"category": "HARM_CATEGORY_HATE_SPEECH", "threshold": index},
|
| 824 |
+
{"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT", "threshold": index},
|
| 825 |
+
{"category": "HARM_CATEGORY_DANGEROUS_CONTENT", "threshold": index},
|
| 826 |
+
]
|
|
|
|
|
|
|
| 827 |
|
| 828 |
if pdf_mode:
|
| 829 |
prompt = None
|