用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/Lord1Egypt/ai-skillforge --skill search-grounding命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
基于 SOC 职业分类
| name | search-grounding |
| description | Real-time Google Search grounding, live web query integration, and web source citation extraction. |
| allowed-tools | Read Write Edit Bash |
| license | MIT license |
| metadata | {"skill-author":"Lord1Egypt"} |
This skill implements real-time Search Grounding using Google Search. When enabled, Gemini dynamically queries the live web to retrieve current information, ground its answers in factual web search results, and return source URLs (citations) with inline metadata.
from google import genai
# Initialize the Gemini GenAI Client
client = genai.Client()
def query_grounded_web(prompt: str):
print(f"Querying Gemini with Search Grounding: '{prompt}'...")
# Run content generation with google_search tool enabled
response = client.models.generate_content(
model='gemini-2.5-flash',
contents=prompt,
config=dict(
# Enable the Google Search tool
tools=[{'google_search': {}}]
)
)
print("\n--- Grounded Answer ---")
print(response.text)
# Extract Search Sources and Grounding Metadata
metadata = response.candidates[0].grounding_metadata
if metadata and metadata.grounding_chunks:
print("\n--- Sources Used ---")
for i, chunk in enumerate(metadata.grounding_chunks, 1):
web_info = chunk.web
if web_info:
print(f"[{i}] {web_info.title}")
print(f" URL: {web_info.uri}")
# Print web search queries Gemini actually executed
if metadata.web_search_queries:
print(f"\nExecuted Queries: {', '.join(metadata.web_search_queries)}")
else:
print("\nNo search grounding chunks used.")
if __name__ == "__main__":
query_grounded_web("What is the current stock price of Google, and what are the major news drivers today?")
You can verify and map the search queries that the model executes or use the metadata to show inline hyperlinks in chat interfaces:
response = client.models.generate_content(
model='gemini-2.5-flash',
contents="Tell me who won the latest Formula 1 Grand Prix",
config=dict(
tools=[{'google_search': {}}]
)
)
metadata = response.candidates[0].grounding_metadata
# Accessing supporting passage parts mapping to the sources
if metadata.search_entry_point:
print("Render HTML query snippets:")
print(metadata.search_entry_point.rendered_content_html)
google-genai>=0.1.1