Update app.py
Browse files
app.py
CHANGED
@@ -27,7 +27,7 @@ password_placeholder = st.empty()
|
|
27 |
password = password_placeholder.text_input("пасскод", type="password")
|
28 |
if password == st.secrets["real_password"]:
|
29 |
password_placeholder.empty()
|
30 |
-
st.success("тебе позволено войти, хорошо")
|
31 |
|
32 |
with st.sidebar:
|
33 |
st.title("Gemini Pro")
|
@@ -47,9 +47,12 @@ if password == st.secrets["real_password"]:
|
|
47 |
|
48 |
|
49 |
def get_response(messages, model="gemini-pro"):
|
50 |
-
|
51 |
-
|
52 |
-
|
|
|
|
|
|
|
53 |
|
54 |
|
55 |
if "messages" not in st.session_state:
|
@@ -77,7 +80,6 @@ if password == st.secrets["real_password"]:
|
|
77 |
vision_message = [{"role": "user", "parts": [chat_message]}]
|
78 |
res = get_response(vision_message)
|
79 |
|
80 |
-
|
81 |
res_text = ""
|
82 |
for chunk in res:
|
83 |
res_text += chunk.text
|
|
|
27 |
password = password_placeholder.text_input("пасскод", type="password")
|
28 |
if password == st.secrets["real_password"]:
|
29 |
password_placeholder.empty()
|
30 |
+
# st.success("тебе позволено войти, хорошо")
|
31 |
|
32 |
with st.sidebar:
|
33 |
st.title("Gemini Pro")
|
|
|
47 |
|
48 |
|
49 |
def get_response(messages, model="gemini-pro"):
|
50 |
+
try:
|
51 |
+
model = genai.GenerativeModel(model)
|
52 |
+
res = model.generate_content(messages, stream=True, safety_settings=safety_settings)
|
53 |
+
return res
|
54 |
+
except:
|
55 |
+
return "Извини, но запрос не прошел цензуру."
|
56 |
|
57 |
|
58 |
if "messages" not in st.session_state:
|
|
|
80 |
vision_message = [{"role": "user", "parts": [chat_message]}]
|
81 |
res = get_response(vision_message)
|
82 |
|
|
|
83 |
res_text = ""
|
84 |
for chunk in res:
|
85 |
res_text += chunk.text
|