mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
Python: Fix Gemini client support for Gemini API and Vertex AI (#5258)
* Add Gemini and Vertex AI client support Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Address Gemini PR review feedback Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * removed sample run readme part --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Evan Mattson <35585003+moonbox3@users.noreply.github.com>
This commit is contained in:
co-authored by
Copilot
Evan Mattson
parent
c14beedb3a
commit
90a633967c
@@ -4,9 +4,9 @@
|
||||
|
||||
Allows Gemini to retrieve up-to-date information from the web before responding.
|
||||
|
||||
Requires the following environment variables to be set:
|
||||
- GEMINI_API_KEY
|
||||
- GEMINI_MODEL
|
||||
Requires ``GOOGLE_MODEL`` or ``GEMINI_MODEL`` and either Gemini Developer API credentials
|
||||
(``GEMINI_API_KEY`` or ``GOOGLE_API_KEY``) or Vertex AI settings
|
||||
(``GOOGLE_GENAI_USE_VERTEXAI``, ``GOOGLE_CLOUD_PROJECT``, and ``GOOGLE_CLOUD_LOCATION``).
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
@@ -23,6 +23,7 @@ async def main() -> None:
|
||||
"""Run the Google Search grounding example."""
|
||||
print("=== Google Search grounding ===")
|
||||
|
||||
# 1. Create the agent with Gemini and the built-in Google Search grounding tool.
|
||||
agent = Agent(
|
||||
client=GeminiChatClient(),
|
||||
name="SearchAgent",
|
||||
@@ -30,6 +31,7 @@ async def main() -> None:
|
||||
tools=[GeminiChatClient.get_web_search_tool()],
|
||||
)
|
||||
|
||||
# 2. Ask a current-events style question and stream the grounded answer.
|
||||
query = "What is the latest stable release of the .NET SDK?"
|
||||
print(f"User: {query}")
|
||||
print("Agent: ", end="", flush=True)
|
||||
@@ -41,3 +43,10 @@ async def main() -> None:
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
|
||||
"""
|
||||
Sample output:
|
||||
=== Google Search grounding ===
|
||||
User: What is the latest stable release of the .NET SDK?
|
||||
Agent: As of April 14, 2026, the latest stable release of the .NET SDK is .NET 10.0 (SDK 10.0.201).
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user