Add city parameter to weather tool (#1303)
This commit is contained in:
+35
-11
@@ -107,9 +107,21 @@
|
|||||||
"\n",
|
"\n",
|
||||||
"# Create a custom tool \n",
|
"# Create a custom tool \n",
|
||||||
"@tool\n",
|
"@tool\n",
|
||||||
"def weather():\n",
|
"def weather(city:str):\n",
|
||||||
" \"\"\" Get weather \"\"\" # Dummy implementation\n",
|
" \"\"\"Get weather information.\n",
|
||||||
" return \"sunny\"\n",
|
"\n",
|
||||||
|
" Args:\n",
|
||||||
|
" city: City for which weather will be returned\n",
|
||||||
|
"\n",
|
||||||
|
" Returns:\n",
|
||||||
|
" Weather of provided city as a string.\n",
|
||||||
|
" \"\"\"\n",
|
||||||
|
" print(city)\n",
|
||||||
|
" if city.lower() == \"athens\":\n",
|
||||||
|
" weather = \"very sunny\"\n",
|
||||||
|
" else:\n",
|
||||||
|
" weather = \"sunny\"\n",
|
||||||
|
" return weather\n",
|
||||||
"\n",
|
"\n",
|
||||||
"\n",
|
"\n",
|
||||||
"model_id = \"global.anthropic.claude-haiku-4-5-20251001-v1:0\"\n",
|
"model_id = \"global.anthropic.claude-haiku-4-5-20251001-v1:0\"\n",
|
||||||
@@ -157,7 +169,7 @@
|
|||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"!python strands_claude.py '{\"prompt\": \"What is the weather now?\"}'"
|
"!python strands_claude.py '{\"prompt\": \"What is the weather now in Athens ?\"}'"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -196,9 +208,21 @@
|
|||||||
"\n",
|
"\n",
|
||||||
"# Create a custom tool \n",
|
"# Create a custom tool \n",
|
||||||
"@tool\n",
|
"@tool\n",
|
||||||
"def weather():\n",
|
"def weather(city:str):\n",
|
||||||
" \"\"\" Get weather \"\"\" # Dummy implementation\n",
|
" \"\"\"Get weather information.\n",
|
||||||
" return \"sunny\"\n",
|
"\n",
|
||||||
|
" Args:\n",
|
||||||
|
" city: City for which weather will be returned\n",
|
||||||
|
"\n",
|
||||||
|
" Returns:\n",
|
||||||
|
" Weather of provided city as a string.\n",
|
||||||
|
" \"\"\"\n",
|
||||||
|
" print(city)\n",
|
||||||
|
" if city.lower() == \"athens\":\n",
|
||||||
|
" weather = \"very sunny\"\n",
|
||||||
|
" else:\n",
|
||||||
|
" weather = \"sunny\"\n",
|
||||||
|
" return weather\n",
|
||||||
"\n",
|
"\n",
|
||||||
"\n",
|
"\n",
|
||||||
"model_id = \"global.anthropic.claude-haiku-4-5-20251001-v1:0\"\n",
|
"model_id = \"global.anthropic.claude-haiku-4-5-20251001-v1:0\"\n",
|
||||||
@@ -369,7 +393,7 @@
|
|||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"invoke_response = agentcore_runtime.invoke({\"prompt\": \"How is the weather now?\"})\n",
|
"invoke_response = agentcore_runtime.invoke({\"prompt\": \"How is the weather now in Athens ?\"})\n",
|
||||||
"invoke_response"
|
"invoke_response"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -676,9 +700,9 @@
|
|||||||
],
|
],
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"kernelspec": {
|
"kernelspec": {
|
||||||
"display_name": "Python 3 (ipykernel)",
|
"display_name": "conda_python3",
|
||||||
"language": "python",
|
"language": "python",
|
||||||
"name": "python3"
|
"name": "conda_python3"
|
||||||
},
|
},
|
||||||
"language_info": {
|
"language_info": {
|
||||||
"codemirror_mode": {
|
"codemirror_mode": {
|
||||||
@@ -690,7 +714,7 @@
|
|||||||
"name": "python",
|
"name": "python",
|
||||||
"nbconvert_exporter": "python",
|
"nbconvert_exporter": "python",
|
||||||
"pygments_lexer": "ipython3",
|
"pygments_lexer": "ipython3",
|
||||||
"version": "3.10.18"
|
"version": "3.10.20"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nbformat": 4,
|
"nbformat": 4,
|
||||||
|
|||||||
Reference in New Issue
Block a user