Newer
Older
"text/plain": [
"RouteChoice(name='timezone_management', function_call=[{'function_name': 'get_time_difference', 'arguments': {'timezone1': 'America/Los_Angeles', 'timezone2': 'Europe/Istanbul'}}], similarity_score=None)"
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"response = rl2(\"What is the time difference between Los Angeles and Istanbul?\")\n",
"response"
]
},
{
"cell_type": "code",
"metadata": {
"id": "2jxAIi6rg9hv",
"outputId": "8abff974-602f-4c0d-8d21-3a275b0eee62"
},
"outputs": [
"name": "stdout",
"output_type": "stream",
"text": [
"The time difference between America/Los_Angeles and Europe/Istanbul is 11.0 hours.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"C:\\Users\\Joshu\\AppData\\Local\\Temp\\ipykernel_13320\\3683005204.py:28: DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).\n",
" now_utc = datetime.utcnow().replace(tzinfo=ZoneInfo(\"UTC\"))\n"
]
}
],
"source": [
"parse_response(response)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "14qz-ApLg9hv"
},
"source": [
"### Testing the `multi_function_route` - The `convert_time` Function"
]
},
{
"cell_type": "code",
"metadata": {
"id": "PzM1HH7Rg9hv",
"outputId": "e123c86f-9754-453a-d895-bfcce26110d4"
},
"outputs": [
"name": "stderr",
"output_type": "stream",
"text": [
"2025-01-06 12:10:55 - httpx - INFO - _client.py:1025 - _send_single_request() - HTTP Request: POST https://api.openai.com/v1/embeddings \"HTTP/1.1 200 OK\"\n",
"2025-01-06 12:10:59 - httpx - INFO - _client.py:1025 - _send_single_request() - HTTP Request: POST https://api.openai.com/v1/chat/completions \"HTTP/1.1 200 OK\"\n"
"data": {
"text/plain": [
"RouteChoice(name='timezone_management', function_call=[{'function_name': 'convert_time', 'arguments': {'time': '23:02', 'from_timezone': 'Asia/Dubai', 'to_timezone': 'Asia/Tokyo'}}], similarity_score=None)"
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"response = rl2(\"What is 23:02 Dubai time in Tokyo time? Please and thank you.\")\n",
"response"
]
},
{
"cell_type": "code",
"metadata": {
"id": "QFKZ757Pg9hv",
"outputId": "af5c1328-f6dd-4dc7-c104-e920198885fc"
},
"outputs": [
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
"name": "stdout",
"output_type": "stream",
"text": [
"04:02\n"
]
}
],
"source": [
"parse_response(response)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "TSRfC6JJg9hv"
},
"source": [
"### The Cool Bit - Testing `multi_function_route` - Multiple Functions at Once"
]
},
{
"cell_type": "code",
"metadata": {
"id": "Vnj6A3AVg9hv",
"outputId": "c8a61c3f-a504-430b-82fb-c211c0523dcb"
},
"outputs": [
"name": "stderr",
"output_type": "stream",
"text": [
"2025-01-06 12:11:03 - httpx - INFO - _client.py:1025 - _send_single_request() - HTTP Request: POST https://api.openai.com/v1/embeddings \"HTTP/1.1 200 OK\"\n",
"2025-01-06 12:11:05 - httpx - INFO - _client.py:1025 - _send_single_request() - HTTP Request: POST https://api.openai.com/v1/chat/completions \"HTTP/1.1 200 OK\"\n"
]
}
],
"source": [
"response = rl2(\n",
" \"\"\"\n",
" What is the time in Prague?\n",
" What is the time difference between Frankfurt and Beijing?\n",
" What is 5:53 Lisbon time in Bangkok time?\n",
"\"\"\"\n",
")"
]
},
{
"cell_type": "code",
"metadata": {
"id": "L9jq_Yoag9hv",
"outputId": "50fae028-4af4-46f5-f6e9-4262b8874caa"
},
"outputs": [
"data": {
"text/plain": [
"RouteChoice(name='timezone_management', function_call=[{'function_name': 'get_time', 'arguments': {'timezone': 'Europe/Prague'}}, {'function_name': 'get_time_difference', 'arguments': {'timezone1': 'Europe/Berlin', 'timezone2': 'Asia/Shanghai'}}, {'function_name': 'convert_time', 'arguments': {'time': '05:53', 'from_timezone': 'Europe/Lisbon', 'to_timezone': 'Asia/Bangkok'}}], similarity_score=None)"
],
"source": [
"response"
]
},
{
"cell_type": "code",
"metadata": {
"id": "Hw3raSVBg9hv",
"outputId": "d30b9cba-979d-4bdf-86e0-37c550c4187d"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"13:11\n",
"The time difference between Europe/Berlin and Asia/Shanghai is 7.0 hours.\n",
"12:53\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"C:\\Users\\Joshu\\AppData\\Local\\Temp\\ipykernel_13320\\3683005204.py:28: DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).\n",
" now_utc = datetime.utcnow().replace(tzinfo=ZoneInfo(\"UTC\"))\n"
],
"source": [
"parse_response(response)"
]
}
],
"metadata": {
"colab": {
"provenance": []
},
"kernelspec": {
"display_name": "decision-layer",
"language": "python",
"name": "python3"
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",