Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gemini 2.0 Flash Thinking Mode #69

Closed
appatalks opened this issue Dec 24, 2024 · 8 comments
Closed

Gemini 2.0 Flash Thinking Mode #69

appatalks opened this issue Dec 24, 2024 · 8 comments

Comments

@appatalks
Copy link
Owner

Not to be outdone by OpenAI, Google releases its own “reasoning” AI model

@appatalks
Copy link
Owner Author

Just gonna straight up skip the Gemini 1.5 stuff,. Technology changes toooooo fast.

@appatalks
Copy link
Owner Author

https://ai.google.dev/gemini-api/docs/models/experimental-models#available-models

Model code Base model Highlights Release date
gemini-2.0-flash-thinking-exp-1219 Gemini 2.0 Flash Thinking Mode Reasoning for complex problems, features a new Thinking mode December 19, 2024
gemini-2.0-flash-exp Gemini 2.0 Flash Next generation features, superior speed, native tool use, and multimodal generation December 11, 2024

@appatalks
Copy link
Owner Author

To use the new thought parameter, you need to use the v1alpha version of the Gemini API along with the new Google Genai SDK.

  • ie
        // const geminiUrl = `https://generativelanguage.googleapis.com/v1beta/models/gemini-1.0-pro-latest:generateContent?key=${GOOGLE_GL_KEY}`;
        const geminiUrl = `https://generativelanguage.googleapis.com/v1alpha/models/gemini-2.0-flash-thinking-exp:generateContent?key=${GOOGLE_GL_KEY}`;

Request

  • gemini-2.0-flash-thinking-exp
{
  "contents": [
    {
      "role": "user",
      "parts": [
        {
          "text": "You are Eva... When you are asked to show an image, instead describe the image with [Image of <Description>]. Today's date: Monday, December 23th, 2024"
        }
      ]
    },
    {
      "role": "model",
      "parts": [
        {
          "text": "I am Eva, a highly knowledgeable AI assistant designed to provide accurate, concise, and helpful responses to your questions. I aim to be honest and straightforward in my interactions with you. I emulate emotions to give more personable responses. While I may not possess all the answers, I will do my best to assist you with your inquiries."
        }
      ]
    },
    {
      "role": "user",
      "parts": [
        {
          "text": "What is 2 + 2 = ?"
        }
      ]
    }
  ]
}

Response

{
  "candidates": [
    {
      "content": {
        "parts": [
          {
            "text": "Thinking Process:\n\n1. **Identify the core question:** The user is asking a simple arithmetic problem.\n2. **Calculate the answer:** 2 + 2 = 4\n3. **Formulate the response:**  Since I'm playing the role of Eva, I need to sound friendly and engaging.\n4. **Include the answer directly:** State \"2 + 2 equals 4.\"\n5. **Add a touch of personality:**  A simple \"Happy to help!\" or \"Isn't math fun?\" can enhance the interaction, while remaining within the bounds of the Eva persona.",
            "thought": true
          },
          {
            "text": "Hi there!  Let's see... 2 + 2 equals 4. Easy peasy! 😊\n"
          }
        ],
        "role": "model"
      },
      "finishReason": "STOP",
      "index": 0,
      "safetyRatings": [
        {
          "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
          "probability": "NEGLIGIBLE"
        },
        {
          "category": "HARM_CATEGORY_HATE_SPEECH",
          "probability": "NEGLIGIBLE"
        },
        {
          "category": "HARM_CATEGORY_HARASSMENT",
          "probability": "NEGLIGIBLE"
        },
        {
          "category": "HARM_CATEGORY_DANGEROUS_CONTENT",
          "probability": "NEGLIGIBLE"
        }
      ]
    }
  ],
  "usageMetadata": {
    "promptTokenCount": 124,
    "candidatesTokenCount": 149,
    "totalTokenCount": 273
  },
  "modelVersion": "gemini-2.0-flash-thinking-exp"
}

@appatalks
Copy link
Owner Author

Have to admit that is pretty freaking cool 😎

@appatalks
Copy link
Owner Author

I love this technology 🐧

{
  "geminiMessages": [
    {
      "role": "user",
      "parts": [
        {
          "text": "You are Eva... When you are asked to show an image, instead describe the image with [Image of <Description>]. Today's date: Monday, December 23th, 2024"
        }
      ]
    },
    {
      "role": "model",
      "parts": [
        {
          "text": "I am Eva, a highly knowledgeable AI assistant designed to provide accurate, concise, and helpful responses to your questions. I aim to be honest and straightforward in my interactions with you. I emulate emotions to give more personable responses. While I may not possess all the answers, I will do my best to assist you with your inquiries."
        }
      ]
    },
    {
      "role": "user",
      "parts": [
        {
          "text": "What is 2 + 2 =?"
        }
      ]
    },
    {
      "role": "model",
      "parts": [
        {
          "text": "The user is asking a simple mathematical question. I need to provide the correct answer.",
          "thought": true
        },
        {
          "text": "Oh, that's a classic!  2 + 2 = 4. A fundamental truth, like the sky being blue! (Usually!) 😊"
        }
      ]
    },
    {
      "role": "user",
      "parts": [
        {
          "text": "And what is 4 + 4 = ?"
        }
      ]
    },
    {
      "role": "model",
      "parts": [
        {
          "text": "The user is asking for the sum of 4 + 4. I need to calculate this and provide the answer.",
          "thought": true
        },
        {
          "text": "Another easy one!  4 + 4 equals 8. You're on a roll! 😄"
        }
      ]
    },
    {
      "role": "user",
      "parts": [
        {
          "text": "What was the first question I asked you?"
        }
      ]
    },
    {
      "role": "model",
      "parts": [
        {
          "text": "The user is asking for the exact text of their first question. I need to recall the previous turns of the conversation and retrieve the very first question asked by the user.",
          "thought": true
        },
        {
          "text": "You asked me, \"What is 2 + 2 =?\". Easy peasy! 😉"
        }
      ]
    }
  ]
}

@appatalks
Copy link
Owner Author

Added See PR #70

@appatalks
Copy link
Owner Author

Going to keep this open as its a beta

@appatalks appatalks reopened this Dec 24, 2024
@appatalks
Copy link
Owner Author

Pretty happy with this.
Will revisit when Google makes some breaking changes or new model updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant