协作头脑风暴
brainstorming
在实现前澄清需求、探索设计选择,并形成清晰的开发方向。
tools-and-integrations【开发与工程】Use this sub-skill when defining, validating, sharing, loading, or troubleshooting smolagents tools, built-in/default tools, Hub/Space/LangChain integrations, or MCP tool collections.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Tool subclass or the @tool decorator.inputs, output_type, optional output_schema, and runtime argument validation.DuckDuckGoSearchTool, VisitWebpageTool, UserInputTool, or FinalAnswerTool to an agent.max_steps, or toolbox composition strategy across agents: use ../agent-workflows/SKILL.md.../model-providers/SKILL.md.smolagent, webagent, Gradio UI, CLI commands, and app launching: use ../cli-and-ui/SKILL.md.../execution-and-safety/SKILL.md.@tool for a simple stateless function; choose a Tool subclass when you need class attributes, setup(), helper methods, lazy model/client initialization, or serialization control.agent.tools is a dict keyed by tool.name.python scripts/validate_tool_schema.py path/to/tool_file.py --object tool_or_class_name.trust_remote_code=True) only after code/server review, and document optional extras.Tool, @tool, schemas, validation, serialization, and helper APIs.Decorator tools must have type hints, a return type, and an Args: docstring section for every argument:
from smolagents import tool
@tool
def normalize_label(label: str, lowercase: bool = True) -> str:
"""Normalize a user-facing label.
Args:
label: Label text to normalize.
lowercase: Whether to lowercase before replacing spaces.
"""
cleaned = label.strip().replace(" ", "_")
return cleaned.lower() if lowercase else cleaned
Subclass tools must define name, description, inputs, output_type, and forward:
from smolagents import Tool
class ReceiptLookupTool(Tool):
name = "receipt_lookup"
description = "Looks up a receipt summary by integer receipt id."
inputs = {"receipt_id": {"type": "integer", "description": "Receipt id to retrieve."}}
output_type = "string"
def forward(self, receipt_id: int) -> str:
return f"Receipt {receipt_id}: not connected to a database in this example."
save(), to_dict(), and push_to_hub() can reconstruct self-contained code.forward type hints and inputs; mismatches raise validation errors.output_schema as prompt/schema guidance for structured outputs; it does not replace testing the actual return value.