• bitcoinBitcoin(BTC)$77,796.00-0.17%
  • ethereumEthereum(ETH)$2,313.14-0.91%
  • tetherTether(USDT)$1.00-0.01%
  • rippleXRP(XRP)$1.40-1.59%
  • binancecoinBNB(BNB)$625.38-0.96%
  • usd-coinUSDC(USDC)$1.000.01%
  • solanaSolana(SOL)$85.13-1.11%
  • tronTRON(TRX)$0.3256440.64%
  • Figure HelocFigure Heloc(FIGR_HELOC)$1.020.00%
  • dogecoinDogecoin(DOGE)$0.098166-0.28%
  • whitebitWhiteBIT Coin(WBT)$54.86-0.56%
  • USDSUSDS(USDS)$1.000.00%
  • HyperliquidHyperliquid(HYPE)$42.312.85%
  • leo-tokenLEO Token(LEO)$10.360.66%
  • cardanoCardano(ADA)$0.246863-2.02%
  • bitcoin-cashBitcoin Cash(BCH)$451.640.15%
  • moneroMonero(XMR)$389.170.18%
  • chainlinkChainlink(LINK)$9.29-1.46%
  • zcashZcash(ZEC)$356.441.05%
  • CantonCanton(CC)$0.148273-1.69%
  • stellarStellar(XLM)$0.167590-1.85%
  • MemeCoreMemeCore(M)$3.95-9.34%
  • daiDai(DAI)$1.000.02%
  • USD1USD1(USD1)$1.00-0.03%
  • litecoinLitecoin(LTC)$55.68-0.53%
  • avalanche-2Avalanche(AVAX)$9.23-1.91%
  • hedera-hashgraphHedera(HBAR)$0.090924-1.39%
  • Ethena USDeEthena USDe(USDE)$1.000.00%
  • suiSui(SUI)$0.93-1.41%
  • shiba-inuShiba Inu(SHIB)$0.000006-1.18%
  • RainRain(RAIN)$0.007455-0.32%
  • paypal-usdPayPal USD(PYUSD)$1.000.00%
  • the-open-networkToncoin(TON)$1.30-0.59%
  • crypto-com-chainCronos(CRO)$0.069830-0.48%
  • Circle USYCCircle USYC(USYC)$1.120.00%
  • tether-goldTether Gold(XAUT)$4,680.65-0.46%
  • Global DollarGlobal Dollar(USDG)$1.00-0.01%
  • BittensorBittensor(TAO)$248.701.08%
  • World Liberty FinancialWorld Liberty Financial(WLFI)$0.073475-1.95%
  • BlackRock USD Institutional Digital Liquidity FundBlackRock USD Institutional Digital Liquidity Fund(BUIDL)$1.000.00%
  • pax-goldPAX Gold(PAXG)$4,683.12-0.37%
  • mantleMantle(MNT)$0.64-2.06%
  • polkadotPolkadot(DOT)$1.23-2.43%
  • uniswapUniswap(UNI)$3.24-0.69%
  • SkySky(SKY)$0.087097-0.23%
  • Pi NetworkPi Network(PI)$0.1840401.59%
  • Falcon USDFalcon USD(USDF)$1.000.08%
  • nearNEAR Protocol(NEAR)$1.37-1.40%
  • okbOKB(OKB)$83.75-0.72%
  • HTX DAOHTX DAO(HTX)$0.0000020.47%
TradePoint.io
  • Main
  • AI & Technology
  • Stock Charts
  • Market & News
  • Business
  • Finance Tips
  • Trade Tube
  • Blog
  • Shop
No Result
View All Result
TradePoint.io
No Result
View All Result

How to Combine Google Search, Google Maps, and Custom Functions in a Single Gemini API Call With Context Circulation, Parallel Tool IDs, and Multi-Step Agentic Chains

April 8, 2026
in AI & Technology
Reading Time: 3 mins read
A A
How to Combine Google Search, Google Maps, and Custom Functions in a Single Gemini API Call With Context Circulation, Parallel Tool IDs, and Multi-Step Agentic Chains
ShareShareShareShareShare

YOU MAY ALSO LIKE

Ford’s Mustang Cobra Jet sets a new EV quarter mile record at 6.87 seconds

Meta AI Releases Sapiens2: A High-Resolution Human-Centric Vision Model for Pose, Segmentation, Normals, Pointmap, and Albedo

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 types


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


client = genai.Client(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(text: str, width: int = 80):
   for line in text.splitlines():
       print(textwrap.fill(line, width=width) if line.strip() else "")


def describe_parts(response):
   parts = response.candidates[0].content.parts
   fc_ids = {}
   for i, part in enumerate(parts):
       prefix = f"   Part {i:2d}:"
       if hasattr(part, "tool_call") and part.tool_call:
           tc = part.tool_call
           print(f"{prefix} [toolCall]        type={tc.tool_type}  id={tc.id}")
       if hasattr(part, "tool_response") and part.tool_response:
           tr = part.tool_response
           print(f"{prefix} [toolResponse]    type={tr.tool_type}  id={tr.id}")
       if hasattr(part, "executable_code") and part.executable_code:
           code = part.executable_code.code[:90].replace("\n", " ↵ ")
           print(f"{prefix} [executableCode]  {code}...")
       if hasattr(part, "code_execution_result") and part.code_execution_result:
           out = (part.code_execution_result.output or "")[:90]
           print(f"{prefix} [codeExecResult]  {out}")
       if hasattr(part, "function_call") and part.function_call:
           fc = part.function_call
           fc_ids[fc.name] = fc.id
           print(f"{prefix} [functionCall]    name={fc.name}  id={fc.id}")
           print(f"              └─ args: {dict(fc.args)}")
       if hasattr(part, "text") and part.text:
           snippet = part.text[:110].replace("\n", " ")
           print(f"{prefix} [text]            {snippet}...")
       if hasattr(part, "thought_signature") and part.thought_signature:
           print(f"              └─ thought_signature present ✓")
   return fc_ids




heading("DEMO 1: Combine Google Search + Custom Function in One Request")


print("""
This demo shows the flagship new feature: passing BOTH a built-in tool
(Google Search) and a custom function declaration in a single API call.


Gemini will:
 Turn 1 → Search the web for real-time info, then request our custom
          function to get weather data.
 Turn 2 → We supply the function response; Gemini synthesizes everything.


Key points:
 • google_search and function_declarations go in the SAME Tool object
 • include_server_side_tool_invocations must be True (on ToolConfig)
 • Return ALL parts (incl. thought_signatures) in subsequent turns
""")


get_weather_func = types.FunctionDeclaration(
   name="getWeather",
   description="Gets the current weather for a requested city.",
   parameters=types.Schema(
       type="OBJECT",
       properties={
           "city": types.Schema(
               type="STRING",
               description="The city and state, e.g. Utqiagvik, Alaska",
           ),
       },
       required=["city"],
   ),
)


print("▶  Turn 1: Sending prompt with Google Search + getWeather tools...\n")


response_1 = client.models.generate_content(
   model=TOOL_COMBO_MODEL,
   contents=(
       "What is the northernmost city in the United States? "
       "What's the weather like there today?"
   ),
   config=types.GenerateContentConfig(
       tools=[
           types.Tool(
               google_search=types.GoogleSearch(),
               function_declarations=[get_weather_func],
           ),
       ],
       tool_config=types.ToolConfig(
           include_server_side_tool_invocations=True,
       ),
   ),
)


print("   Parts returned by the model:\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▶  Turn 2: Returning function result & requesting final synthesis...\n")


history = [
   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,
   types.Content(
       role="user",
       parts=[
           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 = client.models.generate_content(
   model=TOOL_COMBO_MODEL,
   contents=history,
   config=types.GenerateContentConfig(
       tools=[
           types.Tool(
               google_search=types.GoogleSearch(),
               function_declarations=[get_weather_func],
           ),
       ],
       tool_config=types.ToolConfig(
           include_server_side_tool_invocations=True,
       ),
   ),
)


print("   ✅ Final synthesized response:\n")
for part in response_2.candidates[0].content.parts:
   if hasattr(part, "text") and part.text:
       wrap(part.text)

Credit: Source link

ShareTweetSendSharePin

Related Posts

Ford’s Mustang Cobra Jet sets a new EV quarter mile record at 6.87 seconds
AI & Technology

Ford’s Mustang Cobra Jet sets a new EV quarter mile record at 6.87 seconds

April 27, 2026
Meta AI Releases Sapiens2: A High-Resolution Human-Centric Vision Model for Pose, Segmentation, Normals, Pointmap, and Albedo
AI & Technology

Meta AI Releases Sapiens2: A High-Resolution Human-Centric Vision Model for Pose, Segmentation, Normals, Pointmap, and Albedo

April 27, 2026
The LoRA Assumption That Breaks in Production 
AI & Technology

The LoRA Assumption That Breaks in Production 

April 27, 2026
How to Build Smarter Multilingual Text Wrapping with BudouX Through Parsing, HTML Rendering, Model Introspection, and Toy Training
AI & Technology

How to Build Smarter Multilingual Text Wrapping with BudouX Through Parsing, HTML Rendering, Model Introspection, and Toy Training

April 26, 2026
Next Post
NCAA director reveals how sports betting can be manipulated

NCAA director reveals how sports betting can be manipulated

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Search

No Result
View All Result
Trump says price of oil may rise after peace talks between the U.S. and Iran collapse

Trump says price of oil may rise after peace talks between the U.S. and Iran collapse

April 26, 2026
North Korea commemorates its late founder’s birthday

North Korea commemorates its late founder’s birthday

April 24, 2026
UAE airlines the first to resume flights to Israel since beginning of Operation Epic Fury in Iran

UAE airlines the first to resume flights to Israel since beginning of Operation Epic Fury in Iran

April 21, 2026

About

Learn more

Our Services

Legal

Privacy Policy

Terms of Use

Bloggers

Learn more

Article Links

Contact

Advertise

Ask us anything

©2020- TradePoint.io - All rights reserved!

Tradepoint.io, being just a publishing and technology platform, is not a registered broker-dealer or investment adviser. So we do not provide investment advice. Rather, brokerage services are provided to clients of Tradepoint.io by independent SEC-registered broker-dealers and members of FINRA/SIPC. Every form of investing carries some risk and past performance is not a guarantee of future results. “Tradepoint.io“, “Instant Investing” and “My Trading Tools” are registered trademarks of Apperbuild, LLC.

This website is operated by Apperbuild, LLC. We have no link to any brokerage firm and we do not provide investment advice. Every information and resource we provide is solely for the education of our readers. © 2020 Apperbuild, LLC. All rights reserved.

No Result
View All Result
  • Main
  • AI & Technology
  • Stock Charts
  • Market & News
  • Business
  • Finance Tips
  • Trade Tube
  • Blog
  • Shop

© 2023 - TradePoint.io - All Rights Reserved!