gemini API を wsl2で使う
import google.generativeai as genai
import os
api_key="googleからもらったAPIキー"
genai.configure(api_key=api_key)
safety_settings = [
{
"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"
}
]
model = genai.GenerativeModel("gemini-1.5-flash")
response = model.generate_content("犬はブタですか?",safety_settings=safety_settings)
#response = genai.generate_text(model="gemini-1.5-flash",prompt="犬はブタですか?")
print(response.text)