cbsajan commited on
Commit
fa76b17
·
1 Parent(s): 376fdcb

security: remove hardcoded API keys and harden secret hygiene

- Scrub hardcoded HuggingFace tokens and OpenAI keys from LLM_Intro.ipynb
(source lines rewritten to load from .env; cell outputs redacted)
- Delete scratch notebooks (Untitled.ipynb) and stale checkpoints that
also contained keys
- Harden .gitignore (.env*, data/, *.duckdb, .ipynb_checkpoints/, __pycache__)
- Add .env.example template (placeholders, no real secrets)

Note: exposed keys must still be rotated/revoked by the account owner.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@

.env.example ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copy this file to `.env` and fill in your own values. NEVER commit `.env`.
2
+
3
+ # ---- Secrets (API keys) ----
4
+ HUGGINGFACEHUB_API_TOKEN=your_hf_token_here
5
+ OPENAI_API_KEY=your_openai_key_here
6
+ GOOGLE_API_KEY=your_google_key_here
7
+
8
+ # ---- DuckDB ----
9
+ DUCKDB_PATH=data/complaints.duckdb
10
+ TABLE=complaints
11
+
12
+ # ---- Embedding backend ----
13
+ # hf -> EMBED_MODEL=sentence-transformers/all-MiniLM-L6-v2 EMBED_DIM=384
14
+ # google -> EMBED_MODEL=models/gemini-embedding-001 EMBED_DIM=768
15
+ EMBED_PROVIDER=hf
16
+ EMBED_MODEL=sentence-transformers/all-MiniLM-L6-v2
17
+ EMBED_DIM=384
18
+
19
+ # ---- Backfill throttling (Gemini free tier ~100 req/min) ----
20
+ EMBED_MAX_ROWS=500
21
+ EMBED_CHUNK=50
22
+ EMBED_SLEEP=1.0
23
+
24
+ # ---- Chat LLMs ----
25
+ HF_MODEL=Qwen/Qwen2.5-72B-Instruct
26
+ HF_PROVIDER=novita
27
+ OPENAI_MODEL=gpt-4o
28
+ GOOGLE_CHAT_MODEL=gemini-2.0-flash
29
+
30
+ # ---- NHTSA data source APIs ----
31
+ VPIC_URL=https://vpic.nhtsa.dot.gov/api/vehicles
32
+ COMPLAINTS_URL=https://api.nhtsa.gov/complaints/complaintsByVehicle
.gitignore ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Secrets / environment
2
+ .env
3
+ .env.*
4
+ !.env.example
5
+
6
+ # DuckDB data + local datasets
7
+ data/
8
+ *.duckdb
9
+ *.duckdb.wal
10
+ my_dataset/
11
+
12
+ # Notebook checkpoints
13
+ .ipynb_checkpoints/
14
+
15
+ # Python
16
+ __pycache__/
17
+ *.py[cod]
18
+ .venv/
19
+ venv/
20
+ *.egg-info/
21
+
22
+ # OS / editor
23
+ .DS_Store
24
+ Thumbs.db
.ipynb_checkpoints/Untitled-checkpoint.ipynb DELETED
@@ -1,6 +0,0 @@
1
- {
2
- "cells": [],
3
- "metadata": {},
4
- "nbformat": 4,
5
- "nbformat_minor": 5
6
- }
 
 
 
 
 
 
 
LLM_Intro.ipynb ADDED
@@ -0,0 +1,659 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "id": "b947c78e",
6
+ "metadata": {},
7
+ "source": [
8
+ "<font color='green'>\n",
9
+ "Pip install is the command you use to install Python packages with the help of a tool called Pip package manager.\n",
10
+ "<br><br>Installing LangChain package\n",
11
+ "</font>"
12
+ ]
13
+ },
14
+ {
15
+ "cell_type": "code",
16
+ "execution_count": 2,
17
+ "id": "3d4a481b-60ed-4177-93ea-a234186eb787",
18
+ "metadata": {},
19
+ "outputs": [
20
+ {
21
+ "name": "stdout",
22
+ "output_type": "stream",
23
+ "text": [
24
+ "d:\\2026\\July\\Agentic-RAG-with-LangGraph-and-Ollama\\.venv\\Scripts\\python.exe\n"
25
+ ]
26
+ }
27
+ ],
28
+ "source": [
29
+ "import sys\n",
30
+ "print(sys.executable)"
31
+ ]
32
+ },
33
+ {
34
+ "cell_type": "code",
35
+ "execution_count": 3,
36
+ "id": "6347bffa-cd6e-4fab-b987-e91c21d353ac",
37
+ "metadata": {},
38
+ "outputs": [
39
+ {
40
+ "name": "stdout",
41
+ "output_type": "stream",
42
+ "text": [
43
+ "✅ Installed into: d:\\2026\\July\\Agentic-RAG-with-LangGraph-and-Ollama\\.venv\\Scripts\\python.exe\n"
44
+ ]
45
+ }
46
+ ],
47
+ "source": [
48
+ "import sys\n",
49
+ "!{sys.executable} -m pip install -q \"huggingface_hub<1.0,>=0.34.0\"\n",
50
+ "\n",
51
+ "print(f\"✅ Installed into: {sys.executable}\")"
52
+ ]
53
+ },
54
+ {
55
+ "cell_type": "code",
56
+ "execution_count": 4,
57
+ "id": "8236fd59",
58
+ "metadata": {},
59
+ "outputs": [],
60
+ "source": [
61
+ "#!pip install langchain"
62
+ ]
63
+ },
64
+ {
65
+ "cell_type": "markdown",
66
+ "id": "2f9c241d",
67
+ "metadata": {},
68
+ "source": [
69
+ "## Let's use open-source LLM hosted on Hugging Face"
70
+ ]
71
+ },
72
+ {
73
+ "cell_type": "code",
74
+ "execution_count": 5,
75
+ "id": "78a5b3f2",
76
+ "metadata": {},
77
+ "outputs": [],
78
+ "source": [
79
+ "# huggingface_hub pinned <1.0 — 1.x drops the InferenceClient(api_key=...) arg\n",
80
+ "# that langchain_huggingface uses, and breaks transformers.\n",
81
+ "#!pip install langchain-huggingface langchain \"huggingface_hub<1.0,>=0.34.0\""
82
+ ]
83
+ },
84
+ {
85
+ "cell_type": "markdown",
86
+ "id": "1a2152cf",
87
+ "metadata": {},
88
+ "source": [
89
+ "<font color='green'>Imports the Python built-in module called \"os.\"\n",
90
+ "This module provides a way to interact with the operating system, such as accessing environment variables, working with files and directories, executing shell commands, etc\n",
91
+ "<br><br>\n",
92
+ "The environ attribute is a dictionary-like object that contains the environment variables of the current operating system session\n",
93
+ "<br><br>\n",
94
+ "By accessing os.environ, you can retrieve and manipulate environment variables within your Python program. For example, you can retrieve the value of a specific environment variable using the syntax os.environ['VARIABLE_NAME'], where \"VARIABLE_NAME\" is the name of the environment variable you want to access.\n",
95
+ "</font>"
96
+ ]
97
+ },
98
+ {
99
+ "cell_type": "code",
100
+ "execution_count": 6,
101
+ "id": "6ea1b4d2",
102
+ "metadata": {},
103
+ "outputs": [],
104
+ "source": [
105
+ "import os\n",
106
+ "# HUGGINGFACEHUB_API_TOKEN is loaded from .env (see load_dotenv); never hardcode it here"
107
+ ]
108
+ },
109
+ {
110
+ "cell_type": "markdown",
111
+ "id": "2dfc23e4",
112
+ "metadata": {},
113
+ "source": [
114
+ "<font color='green'>\n",
115
+ "LangChain has built a Wrapper around HuggingFace APIs, using which we can get access to all the services HuggingFace provides.\n",
116
+ "<br>\n",
117
+ "The code snippet below imports a specific class called 'HuggingFaceEndpoint'(Wrapper around HuggingFace large language models) from 'langchain_huggingface' library.\n",
118
+ "\n",
119
+ "<font>"
120
+ ]
121
+ },
122
+ {
123
+ "cell_type": "code",
124
+ "execution_count": 7,
125
+ "id": "4c808209",
126
+ "metadata": {},
127
+ "outputs": [],
128
+ "source": [
129
+ "from langchain_huggingface import HuggingFaceEndpoint"
130
+ ]
131
+ },
132
+ {
133
+ "cell_type": "markdown",
134
+ "id": "e8cdfdbb",
135
+ "metadata": {},
136
+ "source": [
137
+ "<font color='green'>Here we are instantiating a language model object called HuggingFaceEndpoint, for our natural language processing tasks.\n",
138
+ "<br><br>\n",
139
+ "The parameter repo_id is provided\n",
140
+ "<font>"
141
+ ]
142
+ },
143
+ {
144
+ "cell_type": "code",
145
+ "execution_count": 8,
146
+ "id": "8a492cf3-15f3-4bd2-b602-29b702c6e1b0",
147
+ "metadata": {},
148
+ "outputs": [
149
+ {
150
+ "name": "stdout",
151
+ "output_type": "stream",
152
+ "text": [
153
+ "huggingface_hub: 0.36.2\n",
154
+ "langchain_huggingface: 1.2.2\n",
155
+ "langchain: 1.3.11\n"
156
+ ]
157
+ }
158
+ ],
159
+ "source": [
160
+ "from importlib.metadata import version\n",
161
+ "\n",
162
+ "print(f\"huggingface_hub: {version('huggingface_hub')}\")\n",
163
+ "print(f\"langchain_huggingface: {version('langchain-huggingface')}\")\n",
164
+ "print(f\"langchain: {version('langchain')}\")"
165
+ ]
166
+ },
167
+ {
168
+ "cell_type": "code",
169
+ "execution_count": 9,
170
+ "id": "a12912cc-10a9-4e13-8aae-be96267261c3",
171
+ "metadata": {},
172
+ "outputs": [
173
+ {
174
+ "name": "stdout",
175
+ "output_type": "stream",
176
+ "text": [
177
+ "The currency of India is the Indian Rupee (INR).\n",
178
+ "\n",
179
+ "To convert 1 Malaysian Ringgit (MYR) to Indian Rupee (INR), you can use a currency converter or check the current exchange rate from a reliable financial source, as exchange rates fluctuate frequently.\n",
180
+ "\n",
181
+ "As of the latest available data, 1 MYR is approximately 18.50 INR. However, for the most accurate and up-to-date conversion, please refer to a current financial news source or a reliable currency converter online.\n"
182
+ ]
183
+ }
184
+ ],
185
+ "source": [
186
+ "from dotenv import load_dotenv\n",
187
+ "import os\n",
188
+ "from langchain_huggingface import HuggingFaceEndpoint, ChatHuggingFace\n",
189
+ "\n",
190
+ "# Load keys from .env file\n",
191
+ "load_dotenv()\n",
192
+ "\n",
193
+ "# Notes on why this shape:\n",
194
+ "# - task=\"conversational\": instruct/chat models on HF Inference are served\n",
195
+ "# as chat-completions, NOT \"text-generation\".\n",
196
+ "# - provider=\"novita\": route to a provider that actually hosts the model\n",
197
+ "# and is live (featherless-ai was returning 503).\n",
198
+ "# - ChatHuggingFace wraps the endpoint so it calls the chat API correctly.\n",
199
+ "llm = HuggingFaceEndpoint(\n",
200
+ " repo_id=\"Qwen/Qwen2.5-72B-Instruct\",\n",
201
+ " task=\"conversational\",\n",
202
+ " provider=\"novita\",\n",
203
+ " huggingfacehub_api_token=os.getenv(\"HUGGINGFACEHUB_API_TOKEN\"),\n",
204
+ ")\n",
205
+ "chat = ChatHuggingFace(llm=llm)\n",
206
+ "\n",
207
+ "completion = chat.invoke(\"What is the currency of India and convert one MYR to INR?\")\n",
208
+ "print(completion.content)"
209
+ ]
210
+ },
211
+ {
212
+ "cell_type": "code",
213
+ "execution_count": 10,
214
+ "id": "5432711b",
215
+ "metadata": {},
216
+ "outputs": [
217
+ {
218
+ "name": "stdout",
219
+ "output_type": "stream",
220
+ "text": [
221
+ "The currency of India is the Indian Rupee (INR). As an AI language model, I don't have real-time data access, so I can't provide you with the current exchange rate between MYR and INR. However, you can easily find this information on various financial websites or mobile apps that offer currency conversion services.\n"
222
+ ]
223
+ }
224
+ ],
225
+ "source": [
226
+ "from dotenv import load_dotenv\n",
227
+ "import os\n",
228
+ "from huggingface_hub import InferenceClient\n",
229
+ "\n",
230
+ "load_dotenv()\n",
231
+ "\n",
232
+ "client = InferenceClient(\n",
233
+ " api_key=os.getenv(\"HUGGINGFACEHUB_API_TOKEN\"),\n",
234
+ ")\n",
235
+ "\n",
236
+ "response = client.chat.completions.create(\n",
237
+ " model=\"Qwen/Qwen2.5-1.5B-Instruct\", # ← free, works on free tier\n",
238
+ " messages=[\n",
239
+ " {\"role\": \"user\", \"content\": \"What is the currency of India and convert one MYR to INR today's rate?\"}\n",
240
+ " ],\n",
241
+ " max_tokens=200,\n",
242
+ ")\n",
243
+ "\n",
244
+ "print(response.choices[0].message.content)"
245
+ ]
246
+ },
247
+ {
248
+ "cell_type": "markdown",
249
+ "id": "32c225b4",
250
+ "metadata": {},
251
+ "source": [
252
+ "## Let's use Proprietary LLM from - OpenAI"
253
+ ]
254
+ },
255
+ {
256
+ "cell_type": "markdown",
257
+ "id": "2a0e925c",
258
+ "metadata": {},
259
+ "source": [
260
+ "<font color='green'>\n",
261
+ "Installing Openai package, which includes the classes that we can use to communicate with Openai services\n",
262
+ "<font>"
263
+ ]
264
+ },
265
+ {
266
+ "cell_type": "code",
267
+ "execution_count": 11,
268
+ "id": "5cb5a1a7",
269
+ "metadata": {},
270
+ "outputs": [],
271
+ "source": [
272
+ "# !pip install langchain-openai"
273
+ ]
274
+ },
275
+ {
276
+ "cell_type": "markdown",
277
+ "id": "f274e9c5",
278
+ "metadata": {},
279
+ "source": [
280
+ "<font color='green'>\n",
281
+ "Imports the Python built-in module called \"os.\"\n",
282
+ "<br>This module provides a way to interact with the operating system, such as accessing environment variables, working with files and directories, executing shell commands, etc\n",
283
+ "<br><br>\n",
284
+ "The environ attribute is a dictionary-like object that contains the environment variables of the current operating system session\n",
285
+ "<br><br>\n",
286
+ "By accessing os.environ, you can retrieve and manipulate environment variables within your Python program. For example, you can retrieve the value of a specific environment variable using the syntax os.environ['VARIABLE_NAME'], where \"VARIABLE_NAME\" is the name of the environment variable you want to access.\n",
287
+ "<font>"
288
+ ]
289
+ },
290
+ {
291
+ "cell_type": "code",
292
+ "execution_count": 12,
293
+ "id": "a4d278e8",
294
+ "metadata": {},
295
+ "outputs": [],
296
+ "source": [
297
+ "import os\n",
298
+ "# OPENAI_API_KEY is loaded from .env (see load_dotenv); never hardcode it here"
299
+ ]
300
+ },
301
+ {
302
+ "cell_type": "markdown",
303
+ "id": "5aef06cb",
304
+ "metadata": {},
305
+ "source": [
306
+ "<font color='green'>\n",
307
+ "LangChain has built a Wrapper around OpenAI APIs, using which we can get access to all the services OpenAI provides.\n",
308
+ "<br>\n",
309
+ "The code snippet below imports a specific class called 'OpenAI'(Wrapper around OpenAI large language models) from 'langchain-openai' library.\n",
310
+ "\n",
311
+ "<font>"
312
+ ]
313
+ },
314
+ {
315
+ "cell_type": "code",
316
+ "execution_count": 13,
317
+ "id": "db64eaa7",
318
+ "metadata": {},
319
+ "outputs": [],
320
+ "source": [
321
+ "from langchain_openai import ChatOpenAI"
322
+ ]
323
+ },
324
+ {
325
+ "cell_type": "markdown",
326
+ "id": "6a9d124f",
327
+ "metadata": {},
328
+ "source": [
329
+ "<font color='green'>Here we are instantiating a language model object called OpenAI, for our natural language processing tasks.\n",
330
+ "<br><br>\n",
331
+ "The parameter model_name is provided with the value \"gpt-3.5-turbo-instruct\" which is a specific version or variant of a language model (examples - gpt-3.5-turbo, text-ada-001 and more).\n",
332
+ "<font>"
333
+ ]
334
+ },
335
+ {
336
+ "cell_type": "code",
337
+ "execution_count": 14,
338
+ "id": "9a3be989",
339
+ "metadata": {},
340
+ "outputs": [],
341
+ "source": [
342
+ "llm = ChatOpenAI(model=\"gpt-4o\")"
343
+ ]
344
+ },
345
+ {
346
+ "cell_type": "markdown",
347
+ "id": "396c7904",
348
+ "metadata": {},
349
+ "source": [
350
+ "<font color='green'>\n",
351
+ "Here language model is represented by the object \"llm,\" which is being utilized to generate a completion or response based on a specific query. \n",
352
+ "<br><br>\n",
353
+ "The query, stored in the \"our_query\" variable is bieng passed to the model through llm object.\n",
354
+ "<font>"
355
+ ]
356
+ },
357
+ {
358
+ "cell_type": "code",
359
+ "execution_count": 15,
360
+ "id": "a2e267f6",
361
+ "metadata": {},
362
+ "outputs": [],
363
+ "source": [
364
+ "our_query = \"What is the currency of India and convert one MYR to INR today's rate?\"\n",
365
+ "\n",
366
+ "completion = llm.invoke(our_query)"
367
+ ]
368
+ },
369
+ {
370
+ "cell_type": "code",
371
+ "execution_count": 16,
372
+ "id": "39f1b87e",
373
+ "metadata": {},
374
+ "outputs": [
375
+ {
376
+ "name": "stdout",
377
+ "output_type": "stream",
378
+ "text": [
379
+ "The currency of India is the Indian Rupee (INR). Exchange rates fluctuate frequently, so to get the most accurate and up-to-date rate for converting Malaysian Ringgit (MYR) to Indian Rupees (INR), you should check a reliable financial news source, a bank, or a currency conversion website. As of my last update, I don't have access to real-time data, so it's best to look up the current exchange rate online or through a financial service.\n"
380
+ ]
381
+ }
382
+ ],
383
+ "source": [
384
+ "print(completion.content)"
385
+ ]
386
+ },
387
+ {
388
+ "cell_type": "code",
389
+ "execution_count": 17,
390
+ "id": "d0d8a94b",
391
+ "metadata": {},
392
+ "outputs": [
393
+ {
394
+ "name": "stdout",
395
+ "output_type": "stream",
396
+ "text": [
397
+ "The currency of India is the Indian Rupee (INR). Exchange rates fluctuate frequently, so to get the most accurate and up-to-date rate for converting Malaysian Ringgit (MYR) to Indian Rupees (INR), you should check a reliable financial news source, a bank, or a currency conversion website. As of my last update, I don't have access to real-time data, so it's best to look up the current exchange rate online or through a financial service.\n"
398
+ ]
399
+ }
400
+ ],
401
+ "source": [
402
+ "print(completion.content)"
403
+ ]
404
+ },
405
+ {
406
+ "cell_type": "code",
407
+ "execution_count": null,
408
+ "id": "65a783d6",
409
+ "metadata": {},
410
+ "outputs": [
411
+ {
412
+ "name": "stdout",
413
+ "output_type": "stream",
414
+ "text": [
415
+ "Collecting datasets\n",
416
+ " Using cached datasets-5.0.0-py3-none-any.whl.metadata (23 kB)\n",
417
+ "Requirement already satisfied: filelock in d:\\2026\\July\\Agentic-RAG-with-LangGraph-and-Ollama\\.venv\\Lib\\site-packages (from datasets) (3.29.6)\n",
418
+ "Requirement already satisfied: numpy>=1.17 in d:\\2026\\July\\Agentic-RAG-with-LangGraph-and-Ollama\\.venv\\Lib\\site-packages (from datasets) (2.5.1)\n",
419
+ "Requirement already satisfied: pyarrow>=21.0.0 in d:\\2026\\July\\Agentic-RAG-with-LangGraph-and-Ollama\\.venv\\Lib\\site-packages (from datasets) (24.0.0)\n",
420
+ "Requirement already satisfied: dill<0.4.2,>=0.3.0 in d:\\2026\\July\\Agentic-RAG-with-LangGraph-and-Ollama\\.venv\\Lib\\site-packages (from datasets) (0.4.1)\n",
421
+ "Requirement already satisfied: pandas in d:\\2026\\July\\Agentic-RAG-with-LangGraph-and-Ollama\\.venv\\Lib\\site-packages (from datasets) (2.3.3)\n",
422
+ "Requirement already satisfied: requests>=2.32.2 in d:\\2026\\July\\Agentic-RAG-with-LangGraph-and-Ollama\\.venv\\Lib\\site-packages (from datasets) (2.34.2)\n",
423
+ "Requirement already satisfied: httpx<1.0.0 in d:\\2026\\July\\Agentic-RAG-with-LangGraph-and-Ollama\\.venv\\Lib\\site-packages (from datasets) (0.28.1)\n",
424
+ "Requirement already satisfied: tqdm>=4.66.3 in d:\\2026\\July\\Agentic-RAG-with-LangGraph-and-Ollama\\.venv\\Lib\\site-packages (from datasets) (4.68.4)\n",
425
+ "Requirement already satisfied: xxhash in d:\\2026\\July\\Agentic-RAG-with-LangGraph-and-Ollama\\.venv\\Lib\\site-packages (from datasets) (3.8.1)\n",
426
+ "Requirement already satisfied: multiprocess<0.70.20 in d:\\2026\\July\\Agentic-RAG-with-LangGraph-and-Ollama\\.venv\\Lib\\site-packages (from datasets) (0.70.19)\n",
427
+ "Collecting fsspec<=2026.4.0,>=2023.1.0 (from fsspec[http]<=2026.4.0,>=2023.1.0->datasets)\n",
428
+ " Using cached fsspec-2026.4.0-py3-none-any.whl.metadata (10 kB)\n",
429
+ "Requirement already satisfied: huggingface-hub<2.0,>=0.25.0 in d:\\2026\\July\\Agentic-RAG-with-LangGraph-and-Ollama\\.venv\\Lib\\site-packages (from datasets) (0.36.2)\n",
430
+ "Requirement already satisfied: packaging in d:\\2026\\July\\Agentic-RAG-with-LangGraph-and-Ollama\\.venv\\Lib\\site-packages (from datasets) (26.2)\n",
431
+ "Requirement already satisfied: pyyaml>=5.1 in d:\\2026\\July\\Agentic-RAG-with-LangGraph-and-Ollama\\.venv\\Lib\\site-packages (from datasets) (6.0.3)\n",
432
+ "Requirement already satisfied: aiohttp!=4.0.0a0,!=4.0.0a1 in d:\\2026\\July\\Agentic-RAG-with-LangGraph-and-Ollama\\.venv\\Lib\\site-packages (from fsspec[http]<=2026.4.0,>=2023.1.0->datasets) (3.14.1)\n",
433
+ "Requirement already satisfied: anyio in d:\\2026\\July\\Agentic-RAG-with-LangGraph-and-Ollama\\.venv\\Lib\\site-packages (from httpx<1.0.0->datasets) (4.14.1)\n",
434
+ "Requirement already satisfied: certifi in d:\\2026\\July\\Agentic-RAG-with-LangGraph-and-Ollama\\.venv\\Lib\\site-packages (from httpx<1.0.0->datasets) (2026.6.17)\n",
435
+ "Requirement already satisfied: httpcore==1.* in d:\\2026\\July\\Agentic-RAG-with-LangGraph-and-Ollama\\.venv\\Lib\\site-packages (from httpx<1.0.0->datasets) (1.0.9)\n",
436
+ "Requirement already satisfied: idna in d:\\2026\\July\\Agentic-RAG-with-LangGraph-and-Ollama\\.venv\\Lib\\site-packages (from httpx<1.0.0->datasets) (3.18)\n",
437
+ "Requirement already satisfied: h11>=0.16 in d:\\2026\\July\\Agentic-RAG-with-LangGraph-and-Ollama\\.venv\\Lib\\site-packages (from httpcore==1.*->httpx<1.0.0->datasets) (0.16.0)\n",
438
+ "Requirement already satisfied: typing-extensions>=3.7.4.3 in d:\\2026\\July\\Agentic-RAG-with-LangGraph-and-Ollama\\.venv\\Lib\\site-packages (from huggingface-hub<2.0,>=0.25.0->datasets) (4.16.0)\n",
439
+ "Requirement already satisfied: aiohappyeyeballs>=2.5.0 in d:\\2026\\July\\Agentic-RAG-with-LangGraph-and-Ollama\\.venv\\Lib\\site-packages (from aiohttp!=4.0.0a0,!=4.0.0a1->fsspec[http]<=2026.4.0,>=2023.1.0->datasets) (2.7.1)\n",
440
+ "Requirement already satisfied: aiosignal>=1.4.0 in d:\\2026\\July\\Agentic-RAG-with-LangGraph-and-Ollama\\.venv\\Lib\\site-packages (from aiohttp!=4.0.0a0,!=4.0.0a1->fsspec[http]<=2026.4.0,>=2023.1.0->datasets) (1.4.0)\n",
441
+ "Requirement already satisfied: attrs>=17.3.0 in d:\\2026\\July\\Agentic-RAG-with-LangGraph-and-Ollama\\.venv\\Lib\\site-packages (from aiohttp!=4.0.0a0,!=4.0.0a1->fsspec[http]<=2026.4.0,>=2023.1.0->datasets) (26.1.0)\n",
442
+ "Requirement already satisfied: frozenlist>=1.1.1 in d:\\2026\\July\\Agentic-RAG-with-LangGraph-and-Ollama\\.venv\\Lib\\site-packages (from aiohttp!=4.0.0a0,!=4.0.0a1->fsspec[http]<=2026.4.0,>=2023.1.0->datasets) (1.8.0)\n",
443
+ "Requirement already satisfied: multidict<7.0,>=4.5 in d:\\2026\\July\\Agentic-RAG-with-LangGraph-and-Ollama\\.venv\\Lib\\site-packages (from aiohttp!=4.0.0a0,!=4.0.0a1->fsspec[http]<=2026.4.0,>=2023.1.0->datasets) (6.7.1)\n",
444
+ "Requirement already satisfied: propcache>=0.2.0 in d:\\2026\\July\\Agentic-RAG-with-LangGraph-and-Ollama\\.venv\\Lib\\site-packages (from aiohttp!=4.0.0a0,!=4.0.0a1->fsspec[http]<=2026.4.0,>=2023.1.0->datasets) (0.5.2)\n",
445
+ "Requirement already satisfied: yarl<2.0,>=1.17.0 in d:\\2026\\July\\Agentic-RAG-with-LangGraph-and-Ollama\\.venv\\Lib\\site-packages (from aiohttp!=4.0.0a0,!=4.0.0a1->fsspec[http]<=2026.4.0,>=2023.1.0->datasets) (1.24.2)\n",
446
+ "Requirement already satisfied: charset_normalizer<4,>=2 in d:\\2026\\July\\Agentic-RAG-with-LangGraph-and-Ollama\\.venv\\Lib\\site-packages (from requests>=2.32.2->datasets) (3.4.9)\n",
447
+ "Requirement already satisfied: urllib3<3,>=1.26 in d:\\2026\\July\\Agentic-RAG-with-LangGraph-and-Ollama\\.venv\\Lib\\site-packages (from requests>=2.32.2->datasets) (2.7.0)\n",
448
+ "Requirement already satisfied: colorama in d:\\2026\\July\\Agentic-RAG-with-LangGraph-and-Ollama\\.venv\\Lib\\site-packages (from tqdm>=4.66.3->datasets) (0.4.6)\n",
449
+ "Requirement already satisfied: python-dateutil>=2.8.2 in d:\\2026\\July\\Agentic-RAG-with-LangGraph-and-Ollama\\.venv\\Lib\\site-packages (from pandas->datasets) (2.9.0.post0)\n",
450
+ "Requirement already satisfied: pytz>=2020.1 in d:\\2026\\July\\Agentic-RAG-with-LangGraph-and-Ollama\\.venv\\Lib\\site-packages (from pandas->datasets) (2026.2)\n",
451
+ "Requirement already satisfied: tzdata>=2022.7 in d:\\2026\\July\\Agentic-RAG-with-LangGraph-and-Ollama\\.venv\\Lib\\site-packages (from pandas->datasets) (2026.2)\n",
452
+ "Requirement already satisfied: six>=1.5 in d:\\2026\\July\\Agentic-RAG-with-LangGraph-and-Ollama\\.venv\\Lib\\site-packages (from python-dateutil>=2.8.2->pandas->datasets) (1.17.0)\n",
453
+ "Using cached datasets-5.0.0-py3-none-any.whl (555 kB)\n",
454
+ "Using cached fsspec-2026.4.0-py3-none-any.whl (203 kB)\n",
455
+ "Installing collected packages: fsspec, datasets\n",
456
+ "\n",
457
+ " Attempting uninstall: fsspec\n",
458
+ "\n",
459
+ " Found existing installation: fsspec 2026.6.0\n",
460
+ "\n",
461
+ " Uninstalling fsspec-2026.6.0:\n",
462
+ "\n",
463
+ " Successfully uninstalled fsspec-2026.6.0\n",
464
+ "\n",
465
+ " ---------------------------------------- 0/2 [fsspec]\n",
466
+ " ---------------------------------------- 0/2 [fsspec]\n",
467
+ " ---------------------------------------- 0/2 [fsspec]\n",
468
+ " -------------------- ------------------- 1/2 [datasets]\n",
469
+ " -------------------- ------------------- 1/2 [datasets]\n",
470
+ " -------------------- ------------------- 1/2 [datasets]\n",
471
+ " -------------------- ------------------- 1/2 [datasets]\n",
472
+ " -------------------- ------------------- 1/2 [datasets]\n",
473
+ " -------------------- ------------------- 1/2 [datasets]\n",
474
+ " -------------------- ------------------- 1/2 [datasets]\n",
475
+ " -------------------- ------------------- 1/2 [datasets]\n",
476
+ " -------------------- ------------------- 1/2 [datasets]\n",
477
+ " ---------------------------------------- 2/2 [datasets]\n",
478
+ "\n",
479
+ "Successfully installed datasets-5.0.0 fsspec-2026.4.0\n"
480
+ ]
481
+ }
482
+ ],
483
+ "source": [
484
+ "#!pip install datasets"
485
+ ]
486
+ },
487
+ {
488
+ "cell_type": "code",
489
+ "execution_count": null,
490
+ "id": "97e2464f",
491
+ "metadata": {},
492
+ "outputs": [
493
+ {
494
+ "name": "stdout",
495
+ "output_type": "stream",
496
+ "text": [
497
+ "Dataset({\n",
498
+ " features: ['text', 'label'],\n",
499
+ " num_rows: 2\n",
500
+ "})\n",
501
+ "Value('string')\n",
502
+ "Column([1, 1])\n"
503
+ ]
504
+ }
505
+ ],
506
+ "source": [
507
+ "import pandas as pd\n",
508
+ "from datasets import Dataset\n",
509
+ "\n",
510
+ "# Define your raw structured data\n",
511
+ "raw_data = {\n",
512
+ " \"text\": [\"I love machine learning\", \"Hugging Face makes AI easy\"],\n",
513
+ " \"label\": [1, 1]\n",
514
+ "}\n",
515
+ "\n",
516
+ "# Convert to a Hugging Face Dataset object\n",
517
+ "dataset = Dataset.from_pandas(pd.DataFrame(raw_data))\n",
518
+ "print(dataset)\n",
519
+ "print(dataset[\"text\"])\n",
520
+ "print(dataset[\"label\"])"
521
+ ]
522
+ },
523
+ {
524
+ "cell_type": "code",
525
+ "execution_count": 28,
526
+ "id": "4ea59a37",
527
+ "metadata": {},
528
+ "outputs": [
529
+ {
530
+ "name": "stdout",
531
+ "output_type": "stream",
532
+ "text": [
533
+ "Dataset({\n",
534
+ " features: ['text', 'label'],\n",
535
+ " num_rows: 10\n",
536
+ "})\n"
537
+ ]
538
+ }
539
+ ],
540
+ "source": [
541
+ "data = {\n",
542
+ " \"text\": [\n",
543
+ " \"I love machine learning\",\n",
544
+ " \"Hugging Face makes AI easy\",\n",
545
+ " \"Natural language processing is interesting\",\n",
546
+ " \"Deep learning models are powerful\",\n",
547
+ " \"AI is transforming industries\",\n",
548
+ " \"Data science is exciting\",\n",
549
+ " \"Python is widely used in AI\",\n",
550
+ " \"Models require good datasets\",\n",
551
+ " \"Learning AI step by step is helpful\",\n",
552
+ " \"Custom datasets improve performance\"\n",
553
+ " ],\n",
554
+ " \"label\": [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n",
555
+ "}\n",
556
+ "df = pd.DataFrame(data)\n",
557
+ "dataset = Dataset.from_pandas(df)\n",
558
+ "print(dataset)"
559
+ ]
560
+ },
561
+ {
562
+ "cell_type": "code",
563
+ "execution_count": 29,
564
+ "id": "7c13f568",
565
+ "metadata": {},
566
+ "outputs": [
567
+ {
568
+ "data": {
569
+ "application/vnd.jupyter.widget-view+json": {
570
+ "model_id": "09acd1375a0d4365a564944c8bd94a23",
571
+ "version_major": 2,
572
+ "version_minor": 0
573
+ },
574
+ "text/plain": [
575
+ "Saving the dataset (0/1 shards): 0%| | 0/10 [00:00<?, ? examples/s]"
576
+ ]
577
+ },
578
+ "metadata": {},
579
+ "output_type": "display_data"
580
+ }
581
+ ],
582
+ "source": [
583
+ "dataset.save_to_disk(\"my_dataset\")"
584
+ ]
585
+ },
586
+ {
587
+ "cell_type": "code",
588
+ "execution_count": 30,
589
+ "id": "46c552ea",
590
+ "metadata": {},
591
+ "outputs": [
592
+ {
593
+ "name": "stdout",
594
+ "output_type": "stream",
595
+ "text": [
596
+ "Status: 200\n",
597
+ "URL: https://api.nhtsa.gov/complaints/complaintsByVehicle?make=Tesla&model=Model+3&modelYear=2020\n",
598
+ "\n",
599
+ "Total complaints found: 435\n",
600
+ "Message: Results returned successfully\n",
601
+ "\n",
602
+ "--- First Complaint ---\n",
603
+ "ODI Number: 11751847\n",
604
+ "Component: UNKNOWN OR OTHER,FORWARD COLLISION AVOIDANCE\n",
605
+ "Date: 07/16/2026\n",
606
+ "Description: ...\n"
607
+ ]
608
+ }
609
+ ],
610
+ "source": [
611
+ "import requests\n",
612
+ "\n",
613
+ "url = \"https://api.nhtsa.gov/complaints/complaintsByVehicle\"\n",
614
+ "params = {\"make\": \"Tesla\", \"model\": \"Model 3\", \"modelYear\": \"2020\"}\n",
615
+ "\n",
616
+ "r = requests.get(url, params=params)\n",
617
+ "\n",
618
+ "print(\"Status:\", r.status_code)\n",
619
+ "print(\"URL:\", r.url)\n",
620
+ "\n",
621
+ "# Parse JSON properly\n",
622
+ "data = r.json()\n",
623
+ "\n",
624
+ "print(f\"\\nTotal complaints found: {data['count']}\")\n",
625
+ "print(f\"Message: {data['message']}\")\n",
626
+ "\n",
627
+ "# Show first complaint\n",
628
+ "if data['results']:\n",
629
+ " first = data['results'][0]\n",
630
+ " print(\"\\n--- First Complaint ---\")\n",
631
+ " print(f\"ODI Number: {first.get('odiNumber')}\")\n",
632
+ " print(f\"Component: {first.get('components')}\")\n",
633
+ " print(f\"Date: {first.get('dateOfIncident')}\")\n",
634
+ " print(f\"Description: {first.get('description', '')[:200]}...\")"
635
+ ]
636
+ }
637
+ ],
638
+ "metadata": {
639
+ "kernelspec": {
640
+ "display_name": ".venv (3.12.8.final.0)",
641
+ "language": "python",
642
+ "name": "python3"
643
+ },
644
+ "language_info": {
645
+ "codemirror_mode": {
646
+ "name": "ipython",
647
+ "version": 3
648
+ },
649
+ "file_extension": ".py",
650
+ "mimetype": "text/x-python",
651
+ "name": "python",
652
+ "nbconvert_exporter": "python",
653
+ "pygments_lexer": "ipython3",
654
+ "version": "3.12.8"
655
+ }
656
+ },
657
+ "nbformat": 4,
658
+ "nbformat_minor": 5
659
+ }
Untitled.ipynb DELETED
@@ -1,72 +0,0 @@
1
- {
2
- "cells": [
3
- {
4
- "cell_type": "code",
5
- "execution_count": 4,
6
- "id": "e4271b05-0ca4-4cc9-b534-e4ac8d74ef07",
7
- "metadata": {},
8
- "outputs": [
9
- {
10
- "data": {
11
- "text/plain": [
12
- "24"
13
- ]
14
- },
15
- "execution_count": 4,
16
- "metadata": {},
17
- "output_type": "execute_result"
18
- }
19
- ],
20
- "source": [
21
- "12 + 12"
22
- ]
23
- },
24
- {
25
- "cell_type": "code",
26
- "execution_count": 3,
27
- "id": "9fdb7b0c-b3a9-492e-8c45-6d15fd288da9",
28
- "metadata": {},
29
- "outputs": [
30
- {
31
- "name": "stdout",
32
- "output_type": "stream",
33
- "text": [
34
- "Hello World\n"
35
- ]
36
- }
37
- ],
38
- "source": [
39
- "print('Hello World')"
40
- ]
41
- },
42
- {
43
- "cell_type": "code",
44
- "execution_count": null,
45
- "id": "aa2e4e6b-9803-4733-9b2f-9b4dbd19aa73",
46
- "metadata": {},
47
- "outputs": [],
48
- "source": []
49
- }
50
- ],
51
- "metadata": {
52
- "kernelspec": {
53
- "display_name": "Agentic RAG (Python 3.12.8)",
54
- "language": "python",
55
- "name": "agentic-rag"
56
- },
57
- "language_info": {
58
- "codemirror_mode": {
59
- "name": "ipython",
60
- "version": 3
61
- },
62
- "file_extension": ".py",
63
- "mimetype": "text/x-python",
64
- "name": "python",
65
- "nbconvert_exporter": "python",
66
- "pygments_lexer": "ipython3",
67
- "version": "3.12.8"
68
- }
69
- },
70
- "nbformat": 4,
71
- "nbformat_minor": 5
72
- }