

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 架構原生工具
<a name="framework-native-tools-detailed"></a>

雖然[模型內容通訊協定 (MCP)](https://modelcontextprotocol.io/) 提供最靈活的基礎，但架構原生工具可為特定使用案例提供優勢。

[Strands Agents 開發套件](https://strandsagents.com)提供以 Python為基礎的工具，其輕量型設計為特徵，只需最少的負荷即可進行簡單的操作。它們可以快速實作，並允許開發人員使用幾行程式碼來建立工具。此外，它們已緊密整合，可在Strands Agents架構內順暢運作。

下列範例示範如何使用 建立簡單的天氣工具Strands Agents。開發人員可以將Python函數快速轉換為客服人員可存取的工具，並將程式碼額外負荷降至最低，並自動從函數的 Docstring 產生適當的文件。

`#Example of a simple Strands native tool`

`@tool`

`def weather(location: str) -> str:`

`"""Get the current weather for a location""" #`

`Implementation here`

`return f"The weather in {location} is sunny."`

對於快速原型或簡單的使用案例，架構原生工具可以加速開發。不過，對於生產系統，MCP 工具提供比架構原生工具更好的互通性和未來彈性。

下表提供其他架構特定工具的概觀。


| 
| 
| **架構** | **工具類型** | **優點** | **考量** | 
| --- |--- |--- |--- |
| [https://microsoft.github.io/autogen/docs/Use-Cases/agent_chat](https://microsoft.github.io/autogen/docs/Use-Cases/agent_chat) | 函數定義 | 強大的多代理程式支援 | Microsoft 生態系統 | 
| [https://python.langchain.com/docs/concepts/tools/](https://python.langchain.com/docs/concepts/tools/) | Python 類別 | 預先建置工具的大型生態系統 | 架構鎖定 | 
| [https://docs.llamaindex.ai/en/stable/getting_started/starter_tools/](https://docs.llamaindex.ai/en/stable/getting_started/starter_tools/) | Python 函式 | 針對資料操作進行最佳化 | 限制為 LlamaIndex | 