Spaces:
Runtime error
Runtime error
prabinpanta0
commited on
Commit
·
ca3d6f1
1
Parent(s):
cc3c90a
Update app.py
Browse files
app.py
CHANGED
@@ -36,10 +36,10 @@ def generate(text):
|
|
36 |
'top_p': 0.32,
|
37 |
}
|
38 |
safety_settings = {
|
39 |
-
generative_models.HarmCategory.HARM_CATEGORY_HATE_SPEECH: generative_models.HarmBlockThreshold.
|
40 |
-
generative_models.HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT: generative_models.HarmBlockThreshold.
|
41 |
-
generative_models.HarmCategory.HARM_CATEGORY_SEXUALLY_EXPLICIT: generative_models.HarmBlockThreshold.
|
42 |
-
generative_models.HarmCategory.HARM_CATEGORY_HARASSMENT: generative_models.HarmBlockThreshold.
|
43 |
}
|
44 |
responses = model.generate_content(
|
45 |
[text],
|
@@ -52,7 +52,7 @@ def generate(text):
|
|
52 |
for response in responses:
|
53 |
response_text += response.text
|
54 |
|
55 |
-
return response_text if response_text else "No valid response generated."
|
56 |
|
57 |
except Exception as e:
|
58 |
return str(e)
|
|
|
36 |
'top_p': 0.32,
|
37 |
}
|
38 |
safety_settings = {
|
39 |
+
generative_models.HarmCategory.HARM_CATEGORY_HATE_SPEECH: generative_models.HarmBlockThreshold.BLOCK_NONE,
|
40 |
+
generative_models.HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT: generative_models.HarmBlockThreshold.BLOCK_NONE,
|
41 |
+
generative_models.HarmCategory.HARM_CATEGORY_SEXUALLY_EXPLICIT: generative_models.HarmBlockThreshold.BLOCK_NONE,
|
42 |
+
generative_models.HarmCategory.HARM_CATEGORY_HARASSMENT: generative_models.HarmBlockThreshold.BLOCK_NONE,
|
43 |
}
|
44 |
responses = model.generate_content(
|
45 |
[text],
|
|
|
52 |
for response in responses:
|
53 |
response_text += response.text
|
54 |
|
55 |
+
return response_text if response_text else "No valid response generated or response was blocked."
|
56 |
|
57 |
except Exception as e:
|
58 |
return str(e)
|