semantic-kernel icon indicating copy to clipboard operation
semantic-kernel copied to clipboard

.Net: New Feature: Gemini Grounding with Google Search

Open scherervictor opened this issue 7 months ago • 2 comments


name: Gemini - Grouding with Google Search about: Gemini supports grouding with Google Search if configured properly on the request, would be nice to have the option to configure this param (Doc reference)


scherervictor avatar Apr 25 '25 12:04 scherervictor

@scherervictor Would you be interested in contributing this functionality to the Semantic Kernel?

markwallace-microsoft avatar Apr 25 '25 14:04 markwallace-microsoft

@markwallace-microsoft sure! I could try to do that.

scherervictor avatar Apr 25 '25 15:04 scherervictor

@markwallace-microsoft If the docs is:

curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent?key=$GOOGLE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
      "contents": [
          {
              "parts": [
                  {"text": "What is the current Google stock price?"}
              ]
          }
      ],
      "tools": [
          {
              "google_search": {}
          }
      ]
  }' > result.json

cat result.json

Would it be equivelent to this in SK?

GeminiPromptExecutionSettings settings = new()
{
    ModelId = AIModel.Google_Gemini25ProPreview.ToModelIdentifier(),
    ServiceId = AIModel.Google_Gemini25ProPreview.ToModelIdentifier(),
    MaxTokens = 32768,
    ExtensionData = new Dictionary<string, object>()
    {
        ["tools"] = new List<Dictionary<string, object>>
        {
            new() 
            {
                ["google_search"] = new Dictionary<string, object>()
            }
        }
    }
};

dmm-l-mediehus avatar Apr 29 '25 07:04 dmm-l-mediehus

@markwallace-microsoft @RogerBarreto I've created a PR implementing this, could you review it, please?

scherervictor avatar Apr 29 '25 12:04 scherervictor