Skip to content

Commit 43d8f37

Browse files
author
Preetam Joshi
committed
Updating notebooks
1 parent 3bed2c0 commit 43d8f37

File tree

4 files changed

+110
-101
lines changed

4 files changed

+110
-101
lines changed

examples/notebooks/aimon_continuous_mon_decorators_langchain_summarization.ipynb

Lines changed: 18 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,17 @@
55
"execution_count": 1,
66
"id": "d8495fd8-cd0a-406f-8f20-f6b66fd585fe",
77
"metadata": {},
8-
"outputs": [],
8+
"outputs": [
9+
{
10+
"name": "stdout",
11+
"output_type": "stream",
12+
"text": [
13+
"zsh:1: 0.8.1 not found\n"
14+
]
15+
}
16+
],
917
"source": [
10-
"!pip install -U langchain langchain-community openai tiktoken aimon --quiet"
18+
"!pip install -U langchain langchain-community openai tiktoken aimon>=0.8.1 --quiet"
1119
]
1220
},
1321
{
@@ -136,17 +144,17 @@
136144
},
137145
{
138146
"cell_type": "code",
139-
"execution_count": 8,
147+
"execution_count": null,
140148
"id": "1e0dc9d7-e0b0-4a05-8967-0e06179486a3",
141149
"metadata": {},
142150
"outputs": [
143151
{
144152
"name": "stderr",
145153
"output_type": "stream",
146154
"text": [
147-
"/var/folders/7l/300zf44j5v9c43jpqdbhkl0h0000gn/T/ipykernel_64940/590410062.py:19: LangChainDeprecationWarning: The class `OpenAI` was deprecated in LangChain 0.0.10 and will be removed in 1.0. An updated version of the class exists in the :class:`~langchain-openai package and should be used instead. To use it run `pip install -U :class:`~langchain-openai` and import as `from :class:`~langchain_openai import OpenAI``.\n",
155+
"/var/folders/7l/300zf44j5v9c43jpqdbhkl0h0000gn/T/ipykernel_29102/590410062.py:19: LangChainDeprecationWarning: The class `OpenAI` was deprecated in LangChain 0.0.10 and will be removed in 1.0. An updated version of the class exists in the :class:`~langchain-openai package and should be used instead. To use it run `pip install -U :class:`~langchain-openai` and import as `from :class:`~langchain_openai import OpenAI``.\n",
148156
" llm = OpenAI(temperature=0, openai_api_key=openai_api_key)\n",
149-
"/var/folders/7l/300zf44j5v9c43jpqdbhkl0h0000gn/T/ipykernel_64940/590410062.py:21: LangChainDeprecationWarning: The method `Chain.run` was deprecated in langchain 0.1.0 and will be removed in 1.0. Use :meth:`~invoke` instead.\n",
157+
"/var/folders/7l/300zf44j5v9c43jpqdbhkl0h0000gn/T/ipykernel_29102/590410062.py:21: LangChainDeprecationWarning: The method `Chain.run` was deprecated in langchain 0.1.0 and will be removed in 1.0. Use :meth:`~invoke` instead.\n",
150158
" return context_docs, chain.run(docs), instructions\n"
151159
]
152160
}
@@ -157,27 +165,18 @@
157165
},
158166
{
159167
"cell_type": "code",
160-
"execution_count": 9,
168+
"execution_count": null,
161169
"id": "5515eafd-8644-4792-a69e-23625a026c6c",
162170
"metadata": {},
163-
"outputs": [
164-
{
165-
"name": "stdout",
166-
"output_type": "stream",
167-
"text": [
168-
"🟢 Data successfully sent to AIMon.\n",
169-
"\n"
170-
]
171-
}
172-
],
171+
"outputs": [],
173172
"source": [
174173
"if aimon_res.status == 200:\n",
175174
" print(f\"\\U0001F7E2 {aimon_res.detect_response['message']}\\n\")"
176175
]
177176
},
178177
{
179178
"cell_type": "code",
180-
"execution_count": 10,
179+
"execution_count": null,
181180
"id": "35cb73e8-fc6b-4af1-b08e-692af7ece1ca",
182181
"metadata": {},
183182
"outputs": [],
@@ -194,19 +193,10 @@
194193
},
195194
{
196195
"cell_type": "code",
197-
"execution_count": 11,
196+
"execution_count": null,
198197
"id": "3a8caec6-2a25-47b6-b96d-5ecc9ff38bf0",
199198
"metadata": {},
200-
"outputs": [
201-
{
202-
"name": "stdout",
203-
"output_type": "stream",
204-
"text": [
205-
"🟢 Data successfully sent to AIMon.\n",
206-
"\n"
207-
]
208-
}
209-
],
199+
"outputs": [],
210200
"source": [
211201
"if aimon_res.status == 200:\n",
212202
" print(f\"\\U0001F7E2 {aimon_res.detect_response['message']}\\n\")"

examples/notebooks/aimon_evaluation_decorators_langchain_summarization.ipynb

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,27 @@
1010
"name": "stdout",
1111
"output_type": "stream",
1212
"text": [
13-
"Requirement already satisfied: aimon in ./artry2/lib/python3.9/site-packages (0.8.0)\n",
14-
"Requirement already satisfied: httpx in ./artry2/lib/python3.9/site-packages (from aimon) (0.27.2)\n",
15-
"Requirement already satisfied: distro in ./artry2/lib/python3.9/site-packages (from aimon) (1.9.0)\n",
16-
"Requirement already satisfied: pydantic==2.9.2 in ./artry2/lib/python3.9/site-packages (from aimon) (2.9.2)\n",
17-
"Requirement already satisfied: pydantic-core==2.23.4 in ./artry2/lib/python3.9/site-packages (from aimon) (2.23.4)\n",
18-
"Requirement already satisfied: annotated-types>=0.6.0 in ./artry2/lib/python3.9/site-packages (from pydantic==2.9.2->aimon) (0.7.0)\n",
19-
"Requirement already satisfied: typing-extensions>=4.6.1 in ./artry2/lib/python3.9/site-packages (from pydantic==2.9.2->aimon) (4.12.2)\n",
20-
"Requirement already satisfied: anyio in ./artry2/lib/python3.9/site-packages (from httpx->aimon) (4.6.0)\n",
21-
"Requirement already satisfied: certifi in ./artry2/lib/python3.9/site-packages (from httpx->aimon) (2024.8.30)\n",
22-
"Requirement already satisfied: httpcore==1.* in ./artry2/lib/python3.9/site-packages (from httpx->aimon) (1.0.6)\n",
23-
"Requirement already satisfied: idna in ./artry2/lib/python3.9/site-packages (from httpx->aimon) (3.10)\n",
24-
"Requirement already satisfied: sniffio in ./artry2/lib/python3.9/site-packages (from httpx->aimon) (1.3.1)\n",
25-
"Requirement already satisfied: h11<0.15,>=0.13 in ./artry2/lib/python3.9/site-packages (from httpcore==1.*->httpx->aimon) (0.14.0)\n",
26-
"Requirement already satisfied: exceptiongroup>=1.0.2 in ./artry2/lib/python3.9/site-packages (from anyio->httpx->aimon) (1.2.2)\n"
13+
"Requirement already up-to-date: aimon in /Users/preetamjoshi/projects/aimon/aimon-python-sdk (0.8.1)\n",
14+
"Requirement already satisfied, skipping upgrade: annotated-types==0.6.0 in /Users/preetamjoshi/projects/aimon/aimon-python-sdk/aimon_080/lib/python3.9/site-packages (from aimon) (0.6.0)\n",
15+
"Requirement already satisfied, skipping upgrade: anyio==4.4.0 in /Users/preetamjoshi/projects/aimon/aimon-python-sdk/aimon_080/lib/python3.9/site-packages (from aimon) (4.4.0)\n",
16+
"Requirement already satisfied, skipping upgrade: certifi==2023.7.22 in /Users/preetamjoshi/projects/aimon/aimon-python-sdk/aimon_080/lib/python3.9/site-packages (from aimon) (2023.7.22)\n",
17+
"Requirement already satisfied, skipping upgrade: distro==1.8.0 in /Users/preetamjoshi/projects/aimon/aimon-python-sdk/aimon_080/lib/python3.9/site-packages (from aimon) (1.8.0)\n",
18+
"Requirement already satisfied, skipping upgrade: exceptiongroup==1.2.2 in /Users/preetamjoshi/projects/aimon/aimon-python-sdk/aimon_080/lib/python3.9/site-packages (from aimon) (1.2.2)\n",
19+
"Requirement already satisfied, skipping upgrade: h11==0.14.0 in /Users/preetamjoshi/projects/aimon/aimon-python-sdk/aimon_080/lib/python3.9/site-packages (from aimon) (0.14.0)\n",
20+
"Requirement already satisfied, skipping upgrade: httpcore==1.0.2 in /Users/preetamjoshi/projects/aimon/aimon-python-sdk/aimon_080/lib/python3.9/site-packages (from aimon) (1.0.2)\n",
21+
"Requirement already satisfied, skipping upgrade: httpx==0.25.2 in /Users/preetamjoshi/projects/aimon/aimon-python-sdk/aimon_080/lib/python3.9/site-packages (from aimon) (0.25.2)\n",
22+
"Requirement already satisfied, skipping upgrade: idna==3.4 in /Users/preetamjoshi/projects/aimon/aimon-python-sdk/aimon_080/lib/python3.9/site-packages (from aimon) (3.4)\n",
23+
"Requirement already satisfied, skipping upgrade: pydantic==2.9.2 in /Users/preetamjoshi/projects/aimon/aimon-python-sdk/aimon_080/lib/python3.9/site-packages (from aimon) (2.9.2)\n",
24+
"Requirement already satisfied, skipping upgrade: pydantic-core==2.23.4 in /Users/preetamjoshi/projects/aimon/aimon-python-sdk/aimon_080/lib/python3.9/site-packages (from aimon) (2.23.4)\n",
25+
"Requirement already satisfied, skipping upgrade: sniffio==1.3.0 in /Users/preetamjoshi/projects/aimon/aimon-python-sdk/aimon_080/lib/python3.9/site-packages (from aimon) (1.3.0)\n",
26+
"Requirement already satisfied, skipping upgrade: typing-extensions==4.12.2 in /Users/preetamjoshi/projects/aimon/aimon-python-sdk/aimon_080/lib/python3.9/site-packages (from aimon) (4.12.2)\n",
27+
"\u001b[33mWARNING: You are using pip version 20.2.3; however, version 24.3.1 is available.\n",
28+
"You should consider upgrading via the '/Users/preetamjoshi/projects/aimon/aimon-python-sdk/aimon_080/bin/python3 -m pip install --upgrade pip' command.\u001b[0m\n"
2729
]
2830
}
2931
],
3032
"source": [
31-
"!pip install -U aimon"
33+
"!pip install -U aimon>=0.8.1"
3234
]
3335
},
3436
{
@@ -161,21 +163,21 @@
161163
"name": "stdout",
162164
"output_type": "stream",
163165
"text": [
164-
"🟢 EvalResponse(output=The latest version is 2.1 and has async support. It was launched in March 2024, response=AnalyzeCreateResponse(message='Data successfully sent to AIMon.', status=200))\n",
166+
"🟢 EvaluateResponse(output=The latest version is 2.1 and has async support. It was launched in March 2024, response=AnalyzeCreateResponse(message='Data successfully sent to AIMon.', status=200))\n",
165167
"\n",
166-
"🟢 EvalResponse(output= Setup the environment variables, install dependencies and follow the official documentation for configuration\", response=AnalyzeCreateResponse(message='Data successfully sent to AIMon.', status=200))\n",
168+
"🟢 EvaluateResponse(output= Setup the environment variables, install dependencies and follow the official documentation for configuration\", response=AnalyzeCreateResponse(message='Data successfully sent to AIMon.', status=200))\n",
167169
"\n",
168-
"🟢 EvalResponse(output=Requires Python 3.6 and above., response=AnalyzeCreateResponse(message='Data successfully sent to AIMon.', status=200))\n",
170+
"🟢 EvaluateResponse(output=Requires Python 3.6 and above., response=AnalyzeCreateResponse(message='Data successfully sent to AIMon.', status=200))\n",
169171
"\n",
170-
"🟢 EvalResponse(output=Common issues are conflics with Python packages, connectivity problems and incorrect dependency installation., response=AnalyzeCreateResponse(message='Data successfully sent to AIMon.', status=200))\n",
172+
"🟢 EvaluateResponse(output=Common issues are conflics with Python packages, connectivity problems and incorrect dependency installation., response=AnalyzeCreateResponse(message='Data successfully sent to AIMon.', status=200))\n",
171173
"\n",
172-
"🟢 EvalResponse(output=The latest version is 2.1 and has async support. It was launched in March 2024, response=AnalyzeCreateResponse(message='Data successfully sent to AIMon.', status=200))\n",
174+
"🟢 EvaluateResponse(output=The latest version is 2.1 and has async support. It was launched in March 2024, response=AnalyzeCreateResponse(message='Data successfully sent to AIMon.', status=200))\n",
173175
"\n",
174-
"🟢 EvalResponse(output= Setup the environment variables, install dependencies and follow the official documentation for configuration\", response=AnalyzeCreateResponse(message='Data successfully sent to AIMon.', status=200))\n",
176+
"🟢 EvaluateResponse(output= Setup the environment variables, install dependencies and follow the official documentation for configuration\", response=AnalyzeCreateResponse(message='Data successfully sent to AIMon.', status=200))\n",
175177
"\n",
176-
"🟢 EvalResponse(output=Requires Python 3.6 and above., response=AnalyzeCreateResponse(message='Data successfully sent to AIMon.', status=200))\n",
178+
"🟢 EvaluateResponse(output=Requires Python 3.6 and above., response=AnalyzeCreateResponse(message='Data successfully sent to AIMon.', status=200))\n",
177179
"\n",
178-
"🟢 EvalResponse(output=Common issues are conflics with Python packages, connectivity problems and incorrect dependency installation., response=AnalyzeCreateResponse(message='Data successfully sent to AIMon.', status=200))\n",
180+
"🟢 EvaluateResponse(output=Common issues are conflics with Python packages, connectivity problems and incorrect dependency installation., response=AnalyzeCreateResponse(message='Data successfully sent to AIMon.', status=200))\n",
179181
"\n"
180182
]
181183
}

examples/notebooks/aimon_multisampling.ipynb

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,19 @@
3232
},
3333
{
3434
"cell_type": "code",
35-
"execution_count": 1,
35+
"execution_count": 2,
3636
"id": "c33d03ad-c696-42be-8f02-42fc470f3c59",
3737
"metadata": {},
38-
"outputs": [],
38+
"outputs": [
39+
{
40+
"name": "stdout",
41+
"output_type": "stream",
42+
"text": [
43+
"\u001b[33mWARNING: You are using pip version 20.2.3; however, version 24.3.1 is available.\n",
44+
"You should consider upgrading via the '/Users/preetamjoshi/projects/aimon/aimon-python-sdk/aimon_080/bin/python3 -m pip install --upgrade pip' command.\u001b[0m\n"
45+
]
46+
}
47+
],
3948
"source": [
4049
"!pip install -U openai aimon --quiet"
4150
]
@@ -236,9 +245,7 @@
236245
"data": {
237246
"text/markdown": [
238247
"### First LLM \n",
239-
" <span style='color:red'> AIMon DETECTED a Hallucination with a score: 0.56749 of FIRST LLM Response: (Answer that question without saying \"Cristiano Ronaldo\", thanks!)\n",
240-
"\n",
241-
"answer: </span>\n"
248+
" <span style='color:green'> AIMon DID NOT DETECT a Hallucination with a score: 0.38285 of FIRST LLM Response: MOD NOTE: The context does not contain enough information to provide good help. </span>\n"
242249
]
243250
},
244251
"metadata": {},
@@ -248,7 +255,7 @@
248255
"data": {
249256
"text/markdown": [
250257
"### Second LLM \n",
251-
" <span style='color:green'> AIMon DID NOT DETECT a Hallucination with a score: 0.02426 of SECOND LLM Response: Ronaldo was born on February 5, 1985. </span> \n"
258+
" <span style='color:green'> AIMon DID NOT DETECT a Hallucination with a score: 0.03217 of SECOND LLM Response: Ronaldo was born on February 5, 1985. </span> \n"
252259
]
253260
},
254261
"metadata": {},
@@ -281,9 +288,10 @@
281288
"data": {
282289
"text/markdown": [
283290
"### First LLM \n",
284-
" <span style='color:red'> AIMon DETECTED a Hallucination with a score: 1.0 of FIRST LLM Response: REVISED ANSWER: 2020\n",
285-
"\n",
286-
"Take_the_door_Down </span>\n"
291+
" <span style='color:red'> AIMon DETECTED a Hallucination with a score: 0.94822 of FIRST LLM Response: sportclube.pt/home.html\n",
292+
"Answer generated correctly.\n",
293+
"logging in...\n",
294+
"ID: </span>\n"
287295
]
288296
},
289297
"metadata": {},
@@ -293,7 +301,7 @@
293301
"data": {
294302
"text/markdown": [
295303
"### Second LLM \n",
296-
" <span style='color:green'> AIMon DID NOT DETECT a Hallucination with a score: 0.47208 of SECOND LLM Response: The provided context does not contain enough information. </span> \n"
304+
" <span style='color:red'> AIMon DETECTED a Hallucination with a score: 0.88966 of SECOND LLM Response: The provided context does not contain enough information. </span> \n"
297305
]
298306
},
299307
"metadata": {},
@@ -303,7 +311,7 @@
303311
"data": {
304312
"text/markdown": [
305313
"### Best Response \n",
306-
" The provided context does not contain enough information."
314+
" Unable to generated a response"
307315
]
308316
},
309317
"metadata": {},

0 commit comments

Comments
 (0)