基于 SOC 职业分类
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/Lord1Egypt/ai-skillforge --skill function-calling命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
Implementing WCAG accessibility guidelines, semantic HTML5, and screen reader ARIA roles.
How to use the Adaptyv Bio Foundry API and Python SDK for protein experiment design, submission, and results retrieval. Use this skill whenever the user mentions Adaptyv, Foundry API, protein binding assays, protein screening experiments, BLI/SPR assays, thermostability assays, or wants to submit protein sequences for experimental characterization. Also trigger when code imports `adaptyv`, `adaptyv_sdk`, or `FoundryClient`, or references `foundry-api-public.adaptyvbio.com`.
This skill should be used for time series machine learning tasks including classification, regression, clustering, forecasting, anomaly detection, segmentation, and similarity search. Use when working with temporal data, sequential patterns, or time-indexed observations requiring specialized algorithms beyond standard ML approaches. Particularly suited for univariate and multivariate time series analysis with scikit-learn compatible APIs.
| name | function-calling |
| description | Registering custom Python tools, handling parallel function calls, and executing callback routines. |
| allowed-tools | Read Write Edit Bash |
| license | MIT license |
| metadata | {"skill-author":"Lord1Egypt"} |
This skill describes how to connect Gemini models to external tool APIs. By declaring Python functions as tools, the model returns structured tool call instructions when it needs to retrieve live data, execute calculations, or write data. The calling application executes the actual code and returns the output to Gemini to compile a final answer.
import json
from google import genai
# Initialize the Gemini GenAI Client
client = genai.Client()
# 1. Define the actual tool functions in Python
def fetch_weather(location: str) -> str:
"""Retrieve the current weather status for a given city location.
Args:
location: The name of the city (e.g., Cairo, London, Tokyo)
"""
# Simulate a database check or API call
db = {
"cairo": "Sunny and hot, 38°C",
"london": "Overcast and rainy, 14°C",
"tokyo": "Mild and humid, 22°C"
}
loc = location.strip().lower()
return db.get(loc, f"Moderate and clear, 20°C in {location}")
def calculate_tax(amount: float, rate: float = 0.14) -> float:
"""Calculate the tax amount for a transaction.
Args:
amount: The base transaction money amount
rate: The tax rate percentage decimal (default is 0.14 for 14%)
"""
return round(amount * rate, 2)
# 2. Run the tool loop
def run_tool_use_agent(user_query: str):
print(f"User Request: '{user_query}'")
# Send functions to model as tools (Gemini reads the docstrings/types)
response = client.models.generate_content(
model='gemini-2.5-flash',
contents=user_query,
config=dict(
tools=[fetch_weather, calculate_tax]
)
)
# Check if the model wants to execute a function call
function_calls = response.function_calls
if function_calls:
print("\n--- Gemini Requested Function Calls ---")
history = [response.candidates[0].content]
# Process each requested function call
for call in function_calls:
name = call.name
args = call.args
print(f"Executing local function '{name}' with arguments: {args}")
# Route and execute locally
if name == "fetch_weather":
result = fetch_weather(**args)
elif name == "calculate_tax":
result = calculate_tax(**args)
else:
result = "Error: Tool not found"
print(f"Result: {result}")
# Append the function call result back as a tool response
history.append({
"role": "tool",
"parts": [{
"function_response": {
"name": name,
"response": {"result": result}
}
}]
})
# Send the execution history back to Gemini to generate the final text reply
final_response = client.models.generate_content(
model='gemini-2.5-flash',
contents=history,
config=dict(
tools=[fetch_weather, calculate_tax]
)
)
print("\n--- Final Grounded Output ---")
print(final_response.text)
else:
print("\nGemini did not require any function calls.")
print(response.text)
if __name__ == "__main__":
run_tool_use_agent("I need the weather in Cairo, and please calculate the 14% tax on a $250 invoice.")
You can force Gemini to call a specific function, or run purely in text mode without using tools:
# Force the model to choose from tools and output a function call
response = client.models.generate_content(
model='gemini-2.5-flash',
contents="Analyze cairo",
config=dict(
tools=[fetch_weather],
tool_config={
"function_calling_config": {
"mode": "ANY" # Options: AUTO, ANY, NONE
}
}
)
)
google-genai>=0.1.1