liveBook · Manning

Gemini

As explained in Data Analysis with LLMs

Gemini is Google's family of multimodal generative AI models for processing and generating content.

Gemini is Google’s language model, usable through a chat interface or a Python library. Try it as an alternative when choosing a model for a task. section 8.0 section 8.3

You can use Gemini to:

  • Ask questions in the web interface, including questions about uploaded pictures. section 8.3.1
  • Enable Google tool integrations, such as access to email, to help find information in your inbox. section 8.3.1
  • Send a question from Python using an API key and the generate_content method. section 8.3.2

Ask Gemini a question from Python

Provide an API key and a question, configure the library with the key, generate a Gemini model, and print its reply. The example uses the question “What is the meaning of life?” section 8.3.2

Listing 8.3 Answering questions using Google’s Gemini model
import argparse
import google.generativeai as genai

if __name__ == '__main__':
     #1
    parser = argparse.ArgumentParser()
    parser.add_argument('api_key', type=str, help='Google API key')
    parser.add_argument('question', type=str, help='Question to answer')
    args = parser.parse_args()
     #2
    genai.configure(api_key=args.api_key)
     #3
    model = genai.GenerativeModel('gemini-1.5-flash')
    reply = model.generate_content(args.question)
     #4
    print(reply.text)

See the complete Python example for configuring the API key and generating a reply. section 8.3.2

How Data Analysis with LLMs covers it

How deep it goes
Shows chat features and a working Python call, but defers a full overview of the API.
Examples
Uses picture questions, inbox searches, and a Python prompt asking about the meaning of life.
What it assumes
Requires a Google account for chat or an API key for Python access.
What you can do after
Apply Gemini through its chat interface or Python library to generate answers to questions.
How it connects
Connects Gemini to Google, language models, and the Transformer architecture.

Also explained in

Compare how 7 books explain Gemini →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Data Analysis with LLMs. The section links point to the parts of the book it draws on.