Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
app.py
CHANGED
|
@@ -749,6 +749,7 @@ else:
|
|
| 749 |
image = None
|
| 750 |
url = ''
|
| 751 |
|
|
|
|
| 752 |
|
| 753 |
if pdf_mode:
|
| 754 |
with st.sidebar:
|
|
@@ -769,13 +770,12 @@ else:
|
|
| 769 |
max_output_tokens1 = st.slider("Max Output Tokens", 100, 2048, max_output_tokens)
|
| 770 |
|
| 771 |
st.subheader("Safety Settings")
|
| 772 |
-
safety_settings = []
|
| 773 |
for setting in SAFETY_SETTINGS:
|
| 774 |
category = setting["category"]
|
| 775 |
-
index = st.selectbox(f"{category} Threshold", range(len(threshold_options)))
|
| 776 |
-
|
| 777 |
-
#
|
| 778 |
-
|
| 779 |
|
| 780 |
# Update generation_config based on user input
|
| 781 |
temperature = temperature1
|
|
@@ -856,12 +856,7 @@ if prompt:
|
|
| 856 |
|
| 857 |
with st.spinner(spinertxt):
|
| 858 |
if len(prmt['parts']) > 1:
|
| 859 |
-
response = vision.generate_content(prmt['parts'],stream=True,safety_settings=
|
| 860 |
-
{"category": "HARM_CATEGORY_HARASSMENT", "threshold": threshold_options[index] for index in range(len(threshold_options))},
|
| 861 |
-
{"category": "HARM_CATEGORY_HATE_SPEECH", "threshold": threshold_options[index] for index in range(len(threshold_options))},
|
| 862 |
-
{"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT", "threshold": threshold_options[index] for index in range(len(threshold_options))},
|
| 863 |
-
{"category": "HARM_CATEGORY_DANGEROUS_CONTENT", "threshold": threshold_options[index] for index in range(len(threshold_options))},
|
| 864 |
-
], generation_config = {
|
| 865 |
"temperature": temperature,
|
| 866 |
"top_p": top_p,
|
| 867 |
"top_k": top_k,
|
|
@@ -924,12 +919,7 @@ if prompt:
|
|
| 924 |
"top_p": top_p,
|
| 925 |
"top_k": top_k,
|
| 926 |
"max_output_tokens": max_output_tokens,
|
| 927 |
-
},safety_settings=
|
| 928 |
-
{"category": "HARM_CATEGORY_HARASSMENT", "threshold": threshold_options[index] for index in range(len(threshold_options))},
|
| 929 |
-
{"category": "HARM_CATEGORY_HATE_SPEECH", "threshold": threshold_options[index] for index in range(len(threshold_options))},
|
| 930 |
-
{"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT", "threshold": threshold_options[index] for index in range(len(threshold_options))},
|
| 931 |
-
{"category": "HARM_CATEGORY_DANGEROUS_CONTENT", "threshold": threshold_options[index] for index in range(len(threshold_options))},
|
| 932 |
-
], stream=True)
|
| 933 |
response = st.session_state.chat.last
|
| 934 |
response.resolve()
|
| 935 |
except StopCandidateException as sce:
|
|
|
|
| 749 |
image = None
|
| 750 |
url = ''
|
| 751 |
|
| 752 |
+
safety_settings_updated = []
|
| 753 |
|
| 754 |
if pdf_mode:
|
| 755 |
with st.sidebar:
|
|
|
|
| 770 |
max_output_tokens1 = st.slider("Max Output Tokens", 100, 2048, max_output_tokens)
|
| 771 |
|
| 772 |
st.subheader("Safety Settings")
|
|
|
|
| 773 |
for setting in SAFETY_SETTINGS:
|
| 774 |
category = setting["category"]
|
| 775 |
+
index = st.selectbox(f"{category} Threshold", range(len(threshold_options)), format_func=lambda x: threshold_options[x])
|
| 776 |
+
|
| 777 |
+
# Append updated safety setting
|
| 778 |
+
safety_settings_updated.append({"category": category, "threshold": threshold_options[index]})
|
| 779 |
|
| 780 |
# Update generation_config based on user input
|
| 781 |
temperature = temperature1
|
|
|
|
| 856 |
|
| 857 |
with st.spinner(spinertxt):
|
| 858 |
if len(prmt['parts']) > 1:
|
| 859 |
+
response = vision.generate_content(prmt['parts'],stream=True,safety_settings=safety_settings_updated, generation_config = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 860 |
"temperature": temperature,
|
| 861 |
"top_p": top_p,
|
| 862 |
"top_k": top_k,
|
|
|
|
| 919 |
"top_p": top_p,
|
| 920 |
"top_k": top_k,
|
| 921 |
"max_output_tokens": max_output_tokens,
|
| 922 |
+
},safety_settings=safety_settings_updated, stream=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 923 |
response = st.session_state.chat.last
|
| 924 |
response.resolve()
|
| 925 |
except StopCandidateException as sce:
|