Google Geminiを使ってみた!

1. Pythonライブラリのインストール

pip install google-cloud-aiplatform

Successfully installed google-auth-2.25.2 google-cloud-aiplatform-1.38.1
google-cloud-resource-manager-1.11.0 google-cloud-storage-2.14.0
google-resumable-media-2.7.0 grpc-google-iam-v1-0.13.0 shapely-2.0.2

2. サンプルのテスト

Chatプロンプトのテスト

テストプログラム作成

vi gemini_test.py

コード抜粋

 chat = chat_model.start_chat(
        context="My name is Miles. You are an astronomer, knowledgeable about the solar system.",
        examples=[
            InputOutputTextPair(
                input_text="How many moons does Mars have?",
                output_text="The planet Mars has two moons, Phobos and Deimos.",
            ),
        ],
    )
  1. 実行
    Google Cloud上のサーバで実行しました。
python3 gemini_test.py
  1. ちゃんと結果が来た
Response from Model: There are eight planets in the solar system:
Mercury, Venus, Earth, Mars, Jupiter, Saturn, Uranus, and Neptune.