Spaces:
Sleeping
Sleeping
koolaidfiction
commited on
Commit
•
f525ee8
1
Parent(s):
ef38c60
Update app.py
Browse files
app.py
CHANGED
@@ -101,6 +101,25 @@ def bot(
|
|
101 |
"GOOGLE_API_KEY is not set. "
|
102 |
"Please follow the instructions in the README to set it up.")
|
103 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
104 |
genai.configure(api_key=google_key)
|
105 |
generation_config = genai.types.GenerationConfig(
|
106 |
temperature=temperature,
|
@@ -118,14 +137,14 @@ def bot(
|
|
118 |
response = model.generate_content(
|
119 |
text_prompt + image_prompt,
|
120 |
stream=True,
|
121 |
-
generation_config=generation_config)
|
122 |
else:
|
123 |
messages = preprocess_chat_history(chatbot)
|
124 |
model = genai.GenerativeModel('gemini-pro')
|
125 |
response = model.generate_content(
|
126 |
messages,
|
127 |
stream=True,
|
128 |
-
generation_config=generation_config)
|
129 |
|
130 |
# streaming effect
|
131 |
chatbot[-1][1] = ""
|
|
|
101 |
"GOOGLE_API_KEY is not set. "
|
102 |
"Please follow the instructions in the README to set it up.")
|
103 |
|
104 |
+
SAFETY_SETTINGS = [
|
105 |
+
{
|
106 |
+
"category": "HARM_CATEGORY_DANGEROUS_CONTENT",
|
107 |
+
"threshold": "BLOCK_NONE",
|
108 |
+
},
|
109 |
+
{
|
110 |
+
"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
|
111 |
+
"threshold": "BLOCK_NONE",
|
112 |
+
},
|
113 |
+
{
|
114 |
+
"category": "HARM_CATEGORY_HATE_SPEECH",
|
115 |
+
"threshold": "BLOCK_NONE",
|
116 |
+
},
|
117 |
+
{
|
118 |
+
"category": "HARM_CATEGORY_HARASSMENT",
|
119 |
+
"threshold": "BLOCK_NONE",
|
120 |
+
},
|
121 |
+
]
|
122 |
+
|
123 |
genai.configure(api_key=google_key)
|
124 |
generation_config = genai.types.GenerationConfig(
|
125 |
temperature=temperature,
|
|
|
137 |
response = model.generate_content(
|
138 |
text_prompt + image_prompt,
|
139 |
stream=True,
|
140 |
+
generation_config=generation_config, safety_settings=SAFETY_SETTINGS)
|
141 |
else:
|
142 |
messages = preprocess_chat_history(chatbot)
|
143 |
model = genai.GenerativeModel('gemini-pro')
|
144 |
response = model.generate_content(
|
145 |
messages,
|
146 |
stream=True,
|
147 |
+
generation_config=generation_config, safety_settings=SAFETY_SETTINGS)
|
148 |
|
149 |
# streaming effect
|
150 |
chatbot[-1][1] = ""
|