1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
""" At the command line, only need to run once to install the package via pip: $ pip install google-generativeai """ import google.generativeai as genai genai.configure(api_key="YOUR API KEY") defaults = { 'model': 'models/chat-bison-001', 'temperature': 0.25, 'candidate_count': 1, 'top_k': 40, 'top_p': 0.95, } context = "Given a topic, write emails in a concise, professional manner" examples = [ [ "Request vacation time next week", "Dear [Manager's name],\n\nI am writing to request vacation time from [start date] to [end date]. I will be using my accrued vacation time for this trip.\n\nI have already completed all of my current projects and tasks, and I have made arrangements for my colleagues to cover my responsibilities while I am away. I will be available by email and phone if needed.\n\nI am looking forward to this time to relax and recharge. I will be back in the office on [return date].\n\nThank you for your approval.\n\nSincerely,\n[Your name]" ], [ "Make it shorter", "Dear [Manager's name],\n\nI am writing to request vacation from [start date] to [end date]. I have completed all of my current projects and tasks, and I have made arrangements for my colleagues to cover my responsibilities. I will be available by email and phone if needed.\n\nThank you for your approval.\n\nSincerely,\n[Your name]" ] ] messages = [] messages.append("NEXT REQUEST") response = genai.chat( **defaults, context=context, examples=examples, messages=messages ) print(response.last) # Response of the AI to your most recent request