Close Menu
  • Home
  • Opinion
  • Region
    • Africa
    • Asia
    • Europe
    • Middle East
    • North America
    • Oceania
    • South America
  • AI & Machine Learning
  • Robotics & Automation
  • Space & Deep Tech
  • Web3 & Digital Economies
  • Climate & Sustainability Tech
  • Biotech & Future Health
  • Mobility & Smart Cities
  • Global Tech Pulse
  • Cybersecurity & Digital Rights
  • Future of Work & Education
  • Trend Radar & Startup Watch
  • Creator Economy & Culture
What's Hot

Artemis II Astronauts Circle the Moon and Carry Again Views That Change Every part

April 8, 2026

Los Angeles to open subway extension Might 8

April 8, 2026

Huawei Teases Pura X2, Its Most Highly effective Vast Foldable But with HarmonyOS 6

April 8, 2026
Facebook X (Twitter) Instagram LinkedIn RSS
NextTech NewsNextTech News
Facebook X (Twitter) Instagram LinkedIn RSS
  • Home
  • Africa
  • Asia
  • Europe
  • Middle East
  • North America
  • Oceania
  • South America
  • Opinion
Trending
  • Artemis II Astronauts Circle the Moon and Carry Again Views That Change Every part
  • Los Angeles to open subway extension Might 8
  • Huawei Teases Pura X2, Its Most Highly effective Vast Foldable But with HarmonyOS 6
  • How meals producers in Europe are automating palletizing with out including headcount
  • The Artemis 2 area rest room is definitely working advantageous. However there’s one other drawback
  • Skip companions with Loblaws for its grocery supply service
  • With 74% of companies planning agentic AI deployment, Trent AI secures €11 million in Seed funding
  • Wall Road Journal Editorial Submissions
Wednesday, April 8
NextTech NewsNextTech News
Home - AI & Machine Learning - Easy methods to Mix Google Search, Google Maps, and Customized Capabilities in a Single Gemini API Name With Context Circulation, Parallel Instrument IDs, and Multi-Step Agentic Chains
AI & Machine Learning

Easy methods to Mix Google Search, Google Maps, and Customized Capabilities in a Single Gemini API Name With Context Circulation, Parallel Instrument IDs, and Multi-Step Agentic Chains

NextTechBy NextTechApril 8, 2026No Comments3 Mins Read
Share Facebook Twitter Pinterest LinkedIn Tumblr Telegram Email Copy Link
Follow Us
Google News Flipboard
Easy methods to Mix Google Search, Google Maps, and Customized Capabilities in a Single Gemini API Name With Context Circulation, Parallel Instrument IDs, and Multi-Step Agentic Chains
Share
Facebook Twitter LinkedIn Pinterest Email


import subprocess, sys


subprocess.check_call(
   [sys.executable, "-m", "pip", "install", "-qU", "google-genai"],
   stdout=subprocess.DEVNULL,
   stderr=subprocess.DEVNULL,
)


import getpass, json, textwrap, os, time
from google import genai
from google.genai import sorts


if "GOOGLE_API_KEY" not in os.environ:
   os.environ["GOOGLE_API_KEY"] = getpass.getpass("Enter your Gemini API key: ")


consumer = genai.Consumer(api_key=os.environ["GOOGLE_API_KEY"])


TOOL_COMBO_MODEL = "gemini-3-flash-preview"
MAPS_MODEL       = "gemini-2.5-flash"


DIVIDER = "=" * 72


def heading(title: str):
   print(f"n{DIVIDER}")
   print(f"  {title}")
   print(DIVIDER)


def wrap(textual content: str, width: int = 80):
   for line in textual content.splitlines():
       print(textwrap.fill(line, width=width) if line.strip() else "")


def describe_parts(response):
   elements = response.candidates[0].content material.elements
   fc_ids = {}
   for i, half in enumerate(elements):
       prefix = f"   Half {i:second}:"
       if hasattr(half, "tool_call") and half.tool_call:
           tc = half.tool_call
           print(f"{prefix} [toolCall]        kind={tc.tool_type}  id={tc.id}")
       if hasattr(half, "tool_response") and half.tool_response:
           tr = half.tool_response
           print(f"{prefix} [toolResponse]    kind={tr.tool_type}  id={tr.id}")
       if hasattr(half, "executable_code") and half.executable_code:
           code = half.executable_code.code[:90].change("n", " ↵ ")
           print(f"{prefix} [executableCode]  {code}...")
       if hasattr(half, "code_execution_result") and half.code_execution_result:
           out = (half.code_execution_result.output or "")[:90]
           print(f"{prefix} [codeExecResult]  {out}")
       if hasattr(half, "function_call") and half.function_call:
           fc = half.function_call
           fc_ids[fc.name] = fc.id
           print(f"{prefix} [functionCall]    title={fc.title}  id={fc.id}")
           print(f"              └─ args: {dict(fc.args)}")
       if hasattr(half, "textual content") and half.textual content:
           snippet = half.textual content[:110].change("n", " ")
           print(f"{prefix} [text]            {snippet}...")
       if hasattr(half, "thought_signature") and half.thought_signature:
           print(f"              └─ thought_signature current ✓")
   return fc_ids




heading("DEMO 1: Mix Google Search + Customized Perform in One Request")


print("""
This demo exhibits the flagship new function: passing BOTH a built-in device
(Google Search) and a customized operate declaration in a single API name.


Gemini will:
 Flip 1 → Search the online for real-time information, then request our customized
          operate to get climate knowledge.
 Flip 2 → We provide the operate response; Gemini synthesizes the whole lot.


Key factors:
 • google_search and function_declarations go within the SAME Instrument object
 • include_server_side_tool_invocations have to be True (on ToolConfig)
 • Return ALL elements (incl. thought_signatures) in subsequent turns
""")


get_weather_func = sorts.FunctionDeclaration(
   title="getWeather",
   description="Will get the present climate for a requested metropolis.",
   parameters=sorts.Schema(
       kind="OBJECT",
       properties={
           "metropolis": sorts.Schema(
               kind="STRING",
               description="The town and state, e.g. Utqiagvik, Alaska",
           ),
       },
       required=["city"],
   ),
)


print("▶  Flip 1: Sending immediate with Google Search + getWeather instruments...n")


response_1 = consumer.fashions.generate_content(
   mannequin=TOOL_COMBO_MODEL,
   contents=(
       "What's the northernmost metropolis in the US? "
       "What is the climate like there at this time?"
   ),
   config=sorts.GenerateContentConfig(
       instruments=[
           types.Tool(
               google_search=types.GoogleSearch(),
               function_declarations=[get_weather_func],
           ),
       ],
       tool_config=sorts.ToolConfig(
           include_server_side_tool_invocations=True,
       ),
   ),
)


print("   Elements returned by the mannequin:n")
fc_ids = describe_parts(response_1)


function_call_id = fc_ids.get("getWeather")
print(f"n   ✅ Captured function_call id for getWeather: {function_call_id}")


print("n▶  Flip 2: Returning operate consequence & requesting ultimate synthesis...n")


historical past = [
   types.Content(
       role="user",
       parts=[
           types.Part(
               text=(
                   "What is the northernmost city in the United States? "
                   "What's the weather like there today?"
               )
           )
       ],
   ),
   response_1.candidates[0].content material,
   sorts.Content material(
       position="consumer",
       elements=[
           types.Part(
               function_response=types.FunctionResponse(
                   name="getWeather",
                   response={"response": "Very cold. 22°F / -5.5°C with strong Arctic winds."},
                   id=function_call_id,
               )
           )
       ],
   ),
]


response_2 = consumer.fashions.generate_content(
   mannequin=TOOL_COMBO_MODEL,
   contents=historical past,
   config=sorts.GenerateContentConfig(
       instruments=[
           types.Tool(
               google_search=types.GoogleSearch(),
               function_declarations=[get_weather_func],
           ),
       ],
       tool_config=sorts.ToolConfig(
           include_server_side_tool_invocations=True,
       ),
   ),
)


print("   ✅ Ultimate synthesized response:n")
for half in response_2.candidates[0].content material.elements:
   if hasattr(half, "textual content") and half.textual content:
       wrap(half.textual content)

Elevate your perspective with NextTech Information, the place innovation meets perception.
Uncover the most recent breakthroughs, get unique updates, and join with a worldwide community of future-focused thinkers.
Unlock tomorrow’s tendencies at this time: learn extra, subscribe to our e-newsletter, and turn into a part of the NextTech group at NextTech-news.com

Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
NextTech
  • Website

Related Posts

Tips on how to Deploy Open WebUI with Safe OpenAI API Integration, Public Tunneling, and Browser-Primarily based Chat Entry

April 8, 2026

Meta AI Releases EUPE: A Compact Imaginative and prescient Encoder Household Below 100M Parameters That Rivals Specialist Fashions Throughout Picture Understanding, Dense Prediction, and VLM Duties

April 7, 2026

An Implementation Information to Working NVIDIA Transformer Engine with Blended Precision, FP8 Checks, Benchmarking, and Fallback Execution

April 7, 2026
Add A Comment
Leave A Reply Cancel Reply

Economy News

Artemis II Astronauts Circle the Moon and Carry Again Views That Change Every part

By NextTechApril 8, 2026

Photograph credit score: NASAOn April 6, 4 Artemis II astronauts within the Orion spacecraft sailed…

Los Angeles to open subway extension Might 8

April 8, 2026

Huawei Teases Pura X2, Its Most Highly effective Vast Foldable But with HarmonyOS 6

April 8, 2026
Top Trending

Artemis II Astronauts Circle the Moon and Carry Again Views That Change Every part

By NextTechApril 8, 2026

Photograph credit score: NASAOn April 6, 4 Artemis II astronauts within the…

Los Angeles to open subway extension Might 8

By NextTechApril 8, 2026

The practically 4-mile extension is the primary of three that may present…

Huawei Teases Pura X2, Its Most Highly effective Vast Foldable But with HarmonyOS 6

By NextTechApril 8, 2026

Huawei has formally teased the upcoming launch of its new foldable flagship,…

Subscribe to News

Get the latest sports news from NewsSite about world, sports and politics.

NEXTTECH-LOGO
Facebook X (Twitter) Instagram YouTube

AI & Machine Learning

Robotics & Automation

Space & Deep Tech

Web3 & Digital Economies

Climate & Sustainability Tech

Biotech & Future Health

Mobility & Smart Cities

Global Tech Pulse

Cybersecurity & Digital Rights

Future of Work & Education

Creator Economy & Culture

Trend Radar & Startup Watch

News By Region

Africa

Asia

Europe

Middle East

North America

Oceania

South America

2025 © NextTech-News. All Rights Reserved
  • About Us
  • Contact Us
  • Privacy Policy
  • Terms Of Service
  • Advertise With Us
  • Write For Us
  • Submit Article & Press Release

Type above and press Enter to search. Press Esc to cancel.

Subscribe For Latest Updates

Sign up to best of Tech news, informed analysis and opinions on what matters to you.

Invalid email address
 We respect your inbox and never send spam. You can unsubscribe from our newsletter at any time.     
Thanks for subscribing!