Add city parameter to weather tool (#1303)
This commit is contained in:
+35
-11
@@ -107,9 +107,21 @@
|
||||
"\n",
|
||||
"# Create a custom tool \n",
|
||||
"@tool\n",
|
||||
"def weather():\n",
|
||||
" \"\"\" Get weather \"\"\" # Dummy implementation\n",
|
||||
" return \"sunny\"\n",
|
||||
"def weather(city:str):\n",
|
||||
" \"\"\"Get weather information.\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",
|
||||
"model_id = \"global.anthropic.claude-haiku-4-5-20251001-v1:0\"\n",
|
||||
@@ -157,7 +169,7 @@
|
||||
},
|
||||
"outputs": [],
|
||||
"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",
|
||||
"# Create a custom tool \n",
|
||||
"@tool\n",
|
||||
"def weather():\n",
|
||||
" \"\"\" Get weather \"\"\" # Dummy implementation\n",
|
||||
" return \"sunny\"\n",
|
||||
"def weather(city:str):\n",
|
||||
" \"\"\"Get weather information.\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",
|
||||
"model_id = \"global.anthropic.claude-haiku-4-5-20251001-v1:0\"\n",
|
||||
@@ -369,7 +393,7 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"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"
|
||||
]
|
||||
},
|
||||
@@ -676,9 +700,9 @@
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3 (ipykernel)",
|
||||
"display_name": "conda_python3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
"name": "conda_python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
@@ -690,7 +714,7 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.10.18"
|
||||
"version": "3.10.20"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
|
||||
Reference in New Issue
Block a user