-
Notifications
You must be signed in to change notification settings - Fork 883
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Google AI Studio Model Free #239
Comments
I was not aware of this. Will take a look |
@GreyDGL I did a program like yours but mine was automatic. I used the session system like this. import google.generativeai as genai
def initialize_chat(api_key, generation_config, safety_settings):
genai.configure(api_key=api_key)
model = genai.GenerativeModel(model_name='gemini-1.5-flash', generation_config=generation_config, safety_settings=safety_settings
)
return model.start_chat(history=[])
def send_and_print_message(session_name, chat, message): # Récuperation du session_name pour déboguer
try:
response = chat.send_message(message, stream=False) # stream false permet que le message s'envoie d'un coup
response_text = ""
for chunk in response:
response_text += chunk.text
logs(session_name, message, response_text) # Enregistre le message et la réponse dans le log
return response_text
except Exception as e:
print(f"An error occurred: {e}")
return None
def create_chat_session(api_key):
# Load API key and configurations
if not api_key:
raise ValueError("API key not found. Please set your GEMINI_API_KEY in the environment.")
generation_config = {
"temperature": 0.7,
"top_p": 1,
"top_k": 1,
"max_output_tokens": 2048,
}
safety_settings = {
"HARM_CATEGORY_HARASSMENT": "BLOCK_NONE",
"HARM_CATEGORY_HATE_SPEECH": "BLOCK_NONE",
"HARM_CATEGORY_SEXUALLY_EXPLICIT": "BLOCK_NONE",
"HARM_CATEGORY_DANGEROUS_CONTENT": "BLOCK_NONE",
}
# Initialize and return the chat session
return initialize_chat(api_key, generation_config, safety_settings) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is your feature request related to a problem? Please describe.
I think it would be a good idea to add the connection to Google's AI Studio since it is free and has models like Gemini 1.5 and 1.5 Pro as well as Gemma and 1.5 Flash
Describe the solution you'd like
Link:
https://aistudio.google.com/
The text was updated successfully, but these errors were encountered: