fix: make gemini safe to None

Signed-off-by: yihong0618 <zouzou0208@gmail.com>
This commit is contained in:
yihong0618 2024-03-17 18:30:55 +08:00
parent 9e5d5db767
commit 2952b81521
2 changed files with 4 additions and 12 deletions

View File

@ -22,16 +22,10 @@ generation_config = {
}
safety_settings = [
{"category": "HARM_CATEGORY_HARASSMENT", "threshold": "BLOCK_MEDIUM_AND_ABOVE"},
{"category": "HARM_CATEGORY_HATE_SPEECH", "threshold": "BLOCK_MEDIUM_AND_ABOVE"},
{
"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
"threshold": "BLOCK_MEDIUM_AND_ABOVE",
},
{
"category": "HARM_CATEGORY_DANGEROUS_CONTENT",
"threshold": "BLOCK_MEDIUM_AND_ABOVE",
},
{"category": "HARM_CATEGORY_HARASSMENT", "threshold": "BLOCK_NONE"},
{"category": "HARM_CATEGORY_HATE_SPEECH", "threshold": "BLOCK_NONE"},
{"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT", "threshold": "BLOCK_NONE"},
{"category": "HARM_CATEGORY_DANGEROUS_CONTENT", "threshold": "BLOCK_NONE"},
]
# Global history cache

View File

@ -53,7 +53,6 @@ def yi_handler(message: Message, bot: TeleBot) -> None:
player_message.pop()
r = client.chat.completions.create(messages=player_message, model=YI_MODEL)
content = r.choices[0].message.content.encode("utf8").decode()
print(content)
if not content:
yi_reply_text = "yi did not answer."
player_message.pop()
@ -140,7 +139,6 @@ def yi_photo_handler(message: Message, bot: TeleBot) -> None:
headers=headers,
json=payload,
).json()
print(response)
try:
text = response["choices"][0]["message"]["content"].encode("utf8").decode()
bot.reply_to(message, "yi vision answer:\n" + text)