Skip to content

Commit 303b1b0

Browse files
committed
Updates
1 parent a90f3b0 commit 303b1b0

File tree

1 file changed

+19
-43
lines changed

1 file changed

+19
-43
lines changed

tutorials/47_HiTL_Agent.ipynb

Lines changed: 19 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -68,18 +68,10 @@
6868
},
6969
{
7070
"cell_type": "code",
71-
"execution_count": 3,
71+
"execution_count": null,
7272
"id": "82bdb67e-7187-45d8-8408-49102c8432c4",
7373
"metadata": {},
74-
"outputs": [
75-
{
76-
"name": "stdin",
77-
"output_type": "stream",
78-
"text": [
79-
"Enter your OpenAI API key: ········\n"
80-
]
81-
}
82-
],
74+
"outputs": [],
8375
"source": [
8476
"from getpass import getpass\n",
8577
"import os\n",
@@ -142,30 +134,27 @@
142134
" \"\"\"Add two numbers.\"\"\"\n",
143135
" return a + b\n",
144136
"\n",
145-
"addition_tool = create_tool_from_function(\n",
146-
" function=addition,\n",
147-
" name=\"addition\",\n",
148-
" description=\"Add two floats together.\",\n",
149-
")\n",
137+
"\n",
138+
"addition_tool = create_tool_from_function(function=addition, name=\"addition\", description=\"Add two floats together.\")\n",
139+
"\n",
150140
"\n",
151141
"def get_bank_balance(account_id: str) -> str:\n",
152142
" \"\"\"Simulate fetching a bank balance.\"\"\"\n",
153143
" return f\"Balance for account {account_id} is $1,234.56\"\n",
154144
"\n",
145+
"\n",
155146
"balance_tool = create_tool_from_function(\n",
156-
" function=get_bank_balance,\n",
157-
" name=\"get_bank_balance\",\n",
158-
" description=\"Get the bank balance for a given account ID.\",\n",
147+
" function=get_bank_balance, name=\"get_bank_balance\", description=\"Get the bank balance for a given account ID.\"\n",
159148
")\n",
160149
"\n",
150+
"\n",
161151
"def get_phone_number(name: str) -> str:\n",
162152
" \"\"\"Simulate fetching a phone number.\"\"\"\n",
163153
" return f\"The phone number for {name} is (123) 456-7890\"\n",
164154
"\n",
155+
"\n",
165156
"phone_tool = create_tool_from_function(\n",
166-
" function=get_phone_number,\n",
167-
" name=\"get_phone_number\",\n",
168-
" description=\"Get the phone number for a given name.\",\n",
157+
" function=get_phone_number, name=\"get_phone_number\", description=\"Get the phone number for a given name.\"\n",
169158
")"
170159
]
171160
},
@@ -194,16 +183,13 @@
194183
" system_prompt=\"You are a helpful financial assistant. Use the provided tools to answer user questions.\",\n",
195184
" confirmation_strategies={\n",
196185
" balance_tool.name: BlockingConfirmationStrategy(\n",
197-
" confirmation_policy=AlwaysAskPolicy(),\n",
198-
" confirmation_ui=RichConsoleUI(console=cons),\n",
186+
" confirmation_policy=AlwaysAskPolicy(), confirmation_ui=RichConsoleUI(console=cons)\n",
199187
" ),\n",
200188
" addition_tool.name: BlockingConfirmationStrategy(\n",
201-
" confirmation_policy=NeverAskPolicy(),\n",
202-
" confirmation_ui=RichConsoleUI(console=cons),\n",
189+
" confirmation_policy=NeverAskPolicy(), confirmation_ui=RichConsoleUI(console=cons)\n",
203190
" ),\n",
204191
" phone_tool.name: BlockingConfirmationStrategy(\n",
205-
" confirmation_policy=AskOncePolicy(),\n",
206-
" confirmation_ui=RichConsoleUI(console=cons),\n",
192+
" confirmation_policy=AskOncePolicy(), confirmation_ui=RichConsoleUI(console=cons)\n",
207193
" ),\n",
208194
" },\n",
209195
")"
@@ -232,7 +218,7 @@
232218
"\n",
233219
"- **y**: Proceed with the tool execution as planned\n",
234220
"- **n**: Cancel the tool execution; agent will try alternative approaches\n",
235-
"- **m**: Edit the tool parameters before execution (advanced)\n",
221+
"- **m**: Edit the tool parameters before execution\n",
236222
"\n",
237223
"**NOTE**: Custom UIs and Policies can also be implemented by following the respective `ConfirmationUI` and `ConfirmationPolicy` protocols. This allows full flexibility for domain-specific workflows."
238224
]
@@ -559,13 +545,12 @@
559545
"source": [
560546
"def expense(cost: float, description: str) -> float:\n",
561547
" \"\"\"Submit an expense report that has a `cost` and `description`\"\"\"\n",
562-
" # This is where we would add a real submission request \n",
548+
" # This is where we would add a real submission request\n",
563549
" return \"Expense report submitted successfully!\"\n",
564550
"\n",
551+
"\n",
565552
"expense_tool = create_tool_from_function(\n",
566-
" function=expense,\n",
567-
" name=\"expense\",\n",
568-
" description=\"Submit an expense report that has a `cost` and `description`\",\n",
553+
" function=expense, name=\"expense\", description=\"Submit an expense report that has a `cost` and `description`\"\n",
569554
")\n",
570555
"\n",
571556
"cons = Console()\n",
@@ -580,9 +565,8 @@
580565
" ),\n",
581566
" confirmation_strategies={\n",
582567
" expense_tool.name: BlockingConfirmationStrategy(\n",
583-
" confirmation_policy=BudgetBasedPolicy(cost_threshold=100.0),\n",
584-
" confirmation_ui=RichConsoleUI(console=cons),\n",
585-
" ),\n",
568+
" confirmation_policy=BudgetBasedPolicy(cost_threshold=100.0), confirmation_ui=RichConsoleUI(console=cons)\n",
569+
" )\n",
586570
" },\n",
587571
")"
588572
]
@@ -751,14 +735,6 @@
751735
"\n",
752736
"(*Notebook by [Sebastian Husch Lee](https://github.com/sjrl)*)"
753737
]
754-
},
755-
{
756-
"cell_type": "code",
757-
"execution_count": null,
758-
"id": "27655802-50e2-44aa-904e-78ba1f9b77b8",
759-
"metadata": {},
760-
"outputs": [],
761-
"source": []
762738
}
763739
],
764740
"metadata": {

0 commit comments

Comments
 (0)