| 1234567891011121314151617181920212223242526 |
- """
- 第 0 步:先写一个普通 Python 函数。
- 这一文件不涉及 MCP、不涉及 Agent,只是为了让你先理解:
- 工具的本质 = 一个有输入、有输出的函数。
- 运行:
- python step0_plain_function.py
- """
- def search_hotels(city: str, nights: int = 2, budget_per_night: int = 400) -> str:
- """
- 查询目的地住宿区域建议。
- Args:
- city: 目的地城市,比如 重庆、杭州、西安。
- nights: 入住晚数,默认 2 晚。
- budget_per_night: 每晚住宿预算,单位元,默认 400 元。
- """
- return f"{city} 住 {nights} 晚,建议预算 {budget_per_night} 元/晚。"
- if __name__ == "__main__":
- result = search_hotels(city="重庆", nights=2, budget_per_night=400)
- print(result)
|