From 930cd8a85ca2e12e710cb10c55769099421a5bca Mon Sep 17 00:00:00 2001 From: AshishChoudhary Date: Wed, 23 Jul 2025 16:08:18 +0530 Subject: [PATCH] New Changes --- .gitignore | 1 + tool_calling.ipynb | 22 +++++++++++++++++----- 2 files changed, 18 insertions(+), 5 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2eea525 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.env \ No newline at end of file diff --git a/tool_calling.ipynb b/tool_calling.ipynb index 74bf2cb..c5ef68d 100644 --- a/tool_calling.ipynb +++ b/tool_calling.ipynb @@ -121,7 +121,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 2, "id": "b4e899c4-f512-4ec9-a941-cef28bbef237", "metadata": {}, "outputs": [], @@ -129,7 +129,16 @@ "from openai import OpenAI\n", "import json\n", "\n", - "client = OpenAI()\n", + "from dotenv import load_dotenv\n", + "import os\n", + "\n", + "# Load environment variables from .env file\n", + "load_dotenv()\n", + "\n", + "# Read the API key from the .env file\n", + "api_key = os.getenv('OPENAI_API_KEY')\n", + "\n", + "client = OpenAI(api_key=api_key)\n", "\n", "messages = [{\"role\": \"user\", \n", " \"content\": \"How much is a dollar worth in Japan? How about poland? Whats the current news in Argentina?\"}]\n", @@ -140,7 +149,8 @@ " messages=messages,\n", " tools=first_tools,\n", " tool_choice=\"auto\", # auto is default, but we'll be explicit\n", - " )" + " )\n", + "\t" ] }, { @@ -229,6 +239,8 @@ "metadata": {}, "outputs": [], "source": [ + "# Please note below API sometime doesn't work due to Company firewall, please switch to personal mobile data or \n", + "# Broadband and try\n", "from duckduckgo_search import DDGS\n", "import requests\n", "\n", @@ -1235,7 +1247,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "Python 3", "language": "python", "name": "python3" }, @@ -1249,7 +1261,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.12.1" + "version": "3.12.6" } }, "nbformat": 4,