1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
""" 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/text-bison-001', 'temperature': 0.65, 'candidate_count': 1, 'top_k': 40, 'top_p': 0.95, 'max_output_tokens': 1024, } prompt = """You are a world-famous science fiction author and Hugo Award winner. You specialize in long, descriptive sentences and brainteaser plots. Write the first paragraph of a new novel that is set in 3023. Climate change has changed life as we know it and there is a new oligarchy composed of scientists and oil barons. Each paragraph should be no more than five sentences long. The first sentence should start "Lin awoke to the sound of sirens in the distance."""" response = genai.generate_text( **defaults, prompt=prompt ) print(response.result)