Update 1_Gemini_Pro.py
Browse files- 1_Gemini_Pro.py +3 -7
1_Gemini_Pro.py
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
import google.generativeai as genai
|
2 |
-
from google.generativeai import SafetySettings
|
3 |
import streamlit as st
|
4 |
import time
|
5 |
import random
|
|
|
6 |
|
7 |
|
8 |
st.set_page_config(
|
@@ -54,8 +54,7 @@ if "app_key" in st.session_state:
|
|
54 |
message_placeholder.markdown("Thinking...")
|
55 |
try:
|
56 |
full_response = ""
|
57 |
-
safety_settings =
|
58 |
-
for chunk in chat.send_message(prompt, stream=True, safety_settings=safety_settings):
|
59 |
word_count = 0
|
60 |
random_int = random.randint(5, 10)
|
61 |
for word in chunk.text:
|
@@ -67,11 +66,8 @@ if "app_key" in st.session_state:
|
|
67 |
word_count = 0
|
68 |
random_int = random.randint(5, 10)
|
69 |
message_placeholder.markdown(full_response)
|
70 |
-
|
71 |
except genai.types.generation_types.BlockedPromptException as e:
|
72 |
-
st.
|
73 |
-
|
74 |
except Exception as e:
|
75 |
st.exception(e)
|
76 |
-
|
77 |
st.session_state.history = chat.history
|
|
|
1 |
import google.generativeai as genai
|
|
|
2 |
import streamlit as st
|
3 |
import time
|
4 |
import random
|
5 |
+
from utils import SAFETY_SETTINGS
|
6 |
|
7 |
|
8 |
st.set_page_config(
|
|
|
54 |
message_placeholder.markdown("Thinking...")
|
55 |
try:
|
56 |
full_response = ""
|
57 |
+
for chunk in chat.send_message(prompt, stream=True, safety_settings = SAFETY_SETTINGS):
|
|
|
58 |
word_count = 0
|
59 |
random_int = random.randint(5, 10)
|
60 |
for word in chunk.text:
|
|
|
66 |
word_count = 0
|
67 |
random_int = random.randint(5, 10)
|
68 |
message_placeholder.markdown(full_response)
|
|
|
69 |
except genai.types.generation_types.BlockedPromptException as e:
|
70 |
+
st.exception(e)
|
|
|
71 |
except Exception as e:
|
72 |
st.exception(e)
|
|
|
73 |
st.session_state.history = chat.history
|