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/text-bison-001', 'temperature': 0.7, 'candidate_count': 1, 'top_k': 40, 'top_p': 0.95, 'max_output_tokens': 1024, } prompt = """Generate some thoughtful and creative questions from the text provided. Structure your questions as creative speculations for where the story could go. Text: Three people walk into a laundromat. The likely parent, a woman enters first, ushering the other two. Next, a young girl jogs to catch up, a grin on her face and holding a strange alien-like purple plushy. Lagging behind, a cloaked teenager in an oversized hoodie waddles back and forth, awkwardly stiff in their gate as to pass the time. The oldest rushes to the back, looking ready to speak to someone. Questions: 1. Is this a family? 2. What is the reason they are in the laundromat? 3. Why is the teenager so annoyed? 4. Who else may be in this scene? Text: A brittle and brisk morning, where everything feels weirdly washed out and slightly powder blue. Sarah steps over the threshold, tugging a tan and brown flannel, as she walks out into the tall grass still dripping in morning dew. Questions: 1. Who is Sarah? 2. Why did she leave the house? 3. Where is she heading? 4. What kind of place is this? A farm? Text: An empty room, barely any light other than a thin vertical strip where the slightly uneven steel door meets up awkwardly with its frame. As your eyes adjust, you can see that the walls are simple panels and the floors a standard linoleum faux tile look of a federal office building. Suddenly a harsh overhead light flashes on, casting you in a dynamic shadows. Questions:""" response = genai.generate_text( **defaults, prompt=prompt ) print(response.result)