Spaces:
Paused
Paused
Debug safety config
Browse files- Tabs/Gemini_Chabot_Nightly.py +5 -5
- app.py +11 -9
Tabs/Gemini_Chabot_Nightly.py
CHANGED
@@ -47,10 +47,10 @@ def chatbot_stable(message, history):
|
|
47 |
model = genai.GenerativeModel(
|
48 |
model_name,
|
49 |
safety_settings={
|
50 |
-
HarmCategory.HARM_CATEGORY_HARASSMENT: HarmBlockThreshold.
|
51 |
-
HarmCategory.HARM_CATEGORY_HATE_SPEECH: HarmBlockThreshold.
|
52 |
-
HarmCategory.HARM_CATEGORY_SEXUALLY_EXPLICIT: HarmBlockThreshold.
|
53 |
-
HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT: HarmBlockThreshold.
|
54 |
},
|
55 |
generation_config={
|
56 |
"temperature": 1,
|
@@ -64,7 +64,7 @@ def chatbot_stable(message, history):
|
|
64 |
global chat
|
65 |
chat = model.start_chat(history=[])
|
66 |
chat.history = transform_history(history)
|
67 |
-
response = chat.send_message(message_content)
|
68 |
response.resolve()
|
69 |
|
70 |
return response.text
|
|
|
47 |
model = genai.GenerativeModel(
|
48 |
model_name,
|
49 |
safety_settings={
|
50 |
+
HarmCategory.HARM_CATEGORY_HARASSMENT: HarmBlockThreshold.BLOCK_ONLY_HIGH,
|
51 |
+
HarmCategory.HARM_CATEGORY_HATE_SPEECH: HarmBlockThreshold.BLOCK_ONLY_HIGH,
|
52 |
+
HarmCategory.HARM_CATEGORY_SEXUALLY_EXPLICIT: HarmBlockThreshold.BLOCK_ONLY_HIGH,
|
53 |
+
HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT: HarmBlockThreshold.BLOCK_ONLY_HIGH,
|
54 |
},
|
55 |
generation_config={
|
56 |
"temperature": 1,
|
|
|
64 |
global chat
|
65 |
chat = model.start_chat(history=[])
|
66 |
chat.history = transform_history(history)
|
67 |
+
response = chat.send_message(message_content, stream=True)
|
68 |
response.resolve()
|
69 |
|
70 |
return response.text
|
app.py
CHANGED
@@ -87,21 +87,23 @@ def bot(
|
|
87 |
)
|
88 |
|
89 |
model_name = "gemini-1.5-flash"
|
90 |
-
model = genai.GenerativeModel(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
inputs = [text_prompt] if image_prompt is None else [
|
92 |
text_prompt, preprocess_image(image_prompt)
|
93 |
]
|
94 |
|
95 |
response = model.generate_content(
|
96 |
inputs,
|
97 |
-
stream=True
|
98 |
-
generation_config=generation_config,
|
99 |
-
safety_settings={
|
100 |
-
HarmCategory.HARM_CATEGORY_HARASSMENT: HarmBlockThreshold.BLOCK_MEDIUM_AND_ABOVE,
|
101 |
-
HarmCategory.HARM_CATEGORY_HATE_SPEECH: HarmBlockThreshold.BLOCK_MEDIUM_AND_ABOVE,
|
102 |
-
HarmCategory.HARM_CATEGORY_SEXUALLY_EXPLICIT: HarmBlockThreshold.BLOCK_MEDIUM_AND_ABOVE,
|
103 |
-
HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT: HarmBlockThreshold.BLOCK_MEDIUM_AND_ABOVE,
|
104 |
-
},
|
105 |
)
|
106 |
response.resolve()
|
107 |
|
|
|
87 |
)
|
88 |
|
89 |
model_name = "gemini-1.5-flash"
|
90 |
+
model = genai.GenerativeModel(
|
91 |
+
model_name,
|
92 |
+
safety_settings={
|
93 |
+
HarmCategory.HARM_CATEGORY_HARASSMENT: HarmBlockThreshold.BLOCK_ONLY_HIGH,
|
94 |
+
HarmCategory.HARM_CATEGORY_HATE_SPEECH: HarmBlockThreshold.BLOCK_ONLY_HIGH,
|
95 |
+
HarmCategory.HARM_CATEGORY_SEXUALLY_EXPLICIT: HarmBlockThreshold.BLOCK_ONLY_HIGH,
|
96 |
+
HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT: HarmBlockThreshold.BLOCK_ONLY_HIGH,
|
97 |
+
},
|
98 |
+
generation_config=generation_config
|
99 |
+
)
|
100 |
inputs = [text_prompt] if image_prompt is None else [
|
101 |
text_prompt, preprocess_image(image_prompt)
|
102 |
]
|
103 |
|
104 |
response = model.generate_content(
|
105 |
inputs,
|
106 |
+
stream=True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
107 |
)
|
108 |
response.resolve()
|
109 |
|