merhaba arkadaşlar bugün sizlere google geminiyi python requests yani api ile kullnabileceğiniiz anlatacağım.
ilk etapta siteye giriyoruz tüm şartlari kabul ediyoruz
https://makersuite.google.com/
daha sonra sol tarafta menüde create api deyip bir tane token key aliyoruz ardından aşağıda verdiğim python koduna api keyini giriyorsunuz.
kurulacak kütüphaneler "pip install google-generativeai" && "pip install requests" """
At the command line, only need to run once to install the package via pip:
$ pip install google-generativeai
"""
import google.generativeai as genai
sor = input("Sana Nasıl yardımcı olabilirim. ?")
genai.configure(api_key="aldıgınız api keyi buraya yapiştirin..")
# Set up the model
generation_config = {
"temperature": 0.9,
"top_p": 1,
"top_k": 1,
"max_output_tokens": 2048,
}
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"
},
]
model = genai.GenerativeModel(model_name="gemini-pro",
generation_config=generation_config,
safety_settings=safety_settings)
prompt_parts = [
sor,
]
response = model.generate_content(prompt_parts)
print(response.text)api keyinizi yazdıktan sonra python dosyasını çalıştırıp dilediginiz soru sorabilirsiniz.