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
""" 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.3, 'candidate_count': 1, 'top_k': 40, 'top_p': 0.95, 'max_output_tokens': 1024, } prompt = """Transform sentence into a list of nouns, verbs, and adjectives. Sentence: The heavy rain caused the river to overflow its banks, flooding the nearby town. Nouns: rain, river, banks, town, flooding Verbs: caused, overflowed Adjectives: heavy, nearby Sentence: I once went to a movie with some friends, only to find out later they really didn't like it Nouns: I, movie, friends, it Verbs: went, found Adjectives: once, later Sentence: The large building I walked into was full of synthetic plants, and turned out to be a fake tree factory. Nouns:""" response = genai.generate_text( **defaults, prompt=prompt ) print(response.result)