Skip to content

Update examples in legal assistant #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add comment explaining how to load API keys from a .env file
  • Loading branch information
Khalid Rajan committed Jun 7, 2024
commit 0adbdd41306562c860601d5f4f42dc4894ad00a4
Binary file modified .DS_Store
Binary file not shown.
89 changes: 45 additions & 44 deletions cpi_pdf_langchain_chatbot.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"metadata": {},
"outputs": [],
"source": [
"# Insert your APIs here or alternatively, add them in a .env file and load the API keys from the .env file in the cell below\n",
"os.environ[\"YDC_API_KEY\"] = \"<Insert your YDC API key here>\"\n",
"os.environ[\"OPENAI_API_KEY\"] = \"<Insert your Open AI API key here>\""
]
Expand Down Expand Up @@ -98,7 +99,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -109,7 +110,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 6,
"metadata": {},
"outputs": [
{
Expand All @@ -120,7 +121,7 @@
" Document(page_content='Prices of store-bought food rose 3.4% - the slowest pace since August 2021 - also putting downward pressure on headline inflation. Excluding volatile food and energy, prices rose 3.1% compared with a 3.4% rise in December. The Canadian dollar reversed an early morning trend and weakened 0.25% to 1.3522 against the U.S. dollar at 1915 GMT. The two-year government bond yield dropped 13.9 basis points to 4.163%.', metadata={'url': 'https://www.reuters.com/world/americas/canadas-inflation-rate-drops-more-than-expected-29-january-2024-02-20/', 'thumbnail_url': None, 'title': \"Canada's inflation rate slows and bolsters bets on early rate cut | Reuters\", 'description': \"Canada's annual inflation rate slowed significantly more than expected to 2.9% in January and core price measures also eased, data showed on Tuesday, bringing forward bets for an early interest rate cut.\"})]"
]
},
"execution_count": 13,
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
Expand Down Expand Up @@ -162,7 +163,7 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -179,7 +180,7 @@
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": 9,
"metadata": {},
"outputs": [
{
Expand All @@ -188,7 +189,7 @@
"'(excluding fish, seafood, and other marine products) \\n(+2.1%). At the same time, fruit, fruit preparations, \\nand nut s was the only major food category to \\ndecrease in price (- 0.1%) \\nBritish Columbians paid more for both health (+2.7%) \\nand personal (+ 2.0%) care when compared to \\n12-months ago. Services, instead of items within \\nthese categories, had the largest price increase. Personal services (such a hairdressing) cost 4.8% \\nmore when compared to 12 -months ago, while the \\ncost of health care services (such as eye and dental \\ncare) increased by 4.3%. Consumer Price \\nIndex \\n \\n \\nReference date: April 2024 Issue: #24-04 Released: May 21 , 2024 \\n \\n-5.8-1.91.92.22.32.62.82.96.8\\nClothing & FootwearHouseholdRecreationAlc., Tob., & CannabisHealth & PersonalFoodTransportationAll-itemsShelterInflation by Category\\n% change, same month previous year'"
]
},
"execution_count": 18,
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -202,7 +203,7 @@
},
{
"cell_type": "code",
"execution_count": 19,
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -226,7 +227,7 @@
},
{
"cell_type": "code",
"execution_count": 20,
"execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -246,7 +247,7 @@
},
{
"cell_type": "code",
"execution_count": 21,
"execution_count": 12,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -263,7 +264,7 @@
},
{
"cell_type": "code",
"execution_count": 22,
"execution_count": 13,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -278,7 +279,7 @@
},
{
"cell_type": "code",
"execution_count": 23,
"execution_count": 14,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -308,7 +309,7 @@
},
{
"cell_type": "code",
"execution_count": 24,
"execution_count": 15,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -321,7 +322,7 @@
},
{
"cell_type": "code",
"execution_count": 25,
"execution_count": 16,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -330,16 +331,16 @@
},
{
"cell_type": "code",
"execution_count": 26,
"execution_count": 17,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"\"In April 2024, the Consumer Price Index (CPI) in British Columbia increased by 2.9% compared to April 2023. Nationally, Canada's CPI was up 2.7% over the same period. Therefore, the CPI increase in British Columbia was slightly higher than the national average.\""
"\"In April 2024, the Consumer Price Index (CPI) in British Columbia increased by 2.9% compared to April 2023. Nationally, Canada's CPI was up by 2.7% over the same period. Therefore, the CPI in British Columbia rose slightly more than the national average.\""
]
},
"execution_count": 26,
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -364,7 +365,7 @@
},
{
"cell_type": "code",
"execution_count": 27,
"execution_count": 18,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -387,7 +388,7 @@
},
{
"cell_type": "code",
"execution_count": 28,
"execution_count": 19,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -397,7 +398,7 @@
},
{
"cell_type": "code",
"execution_count": 29,
"execution_count": 20,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -413,7 +414,7 @@
},
{
"cell_type": "code",
"execution_count": 30,
"execution_count": 21,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -432,7 +433,7 @@
},
{
"cell_type": "code",
"execution_count": 31,
"execution_count": 22,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -443,7 +444,7 @@
},
{
"cell_type": "code",
"execution_count": 32,
"execution_count": 23,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -469,7 +470,7 @@
},
{
"cell_type": "code",
"execution_count": 33,
"execution_count": 24,
"metadata": {},
"outputs": [
{
Expand All @@ -478,7 +479,7 @@
"'In April 2024, food prices in British Columbia increased by 2.6% compared to April 2023.'"
]
},
"execution_count": 33,
"execution_count": 24,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -489,16 +490,16 @@
},
{
"cell_type": "code",
"execution_count": 34,
"execution_count": 25,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'In April 2024, food prices in British Columbia increased by 2.6% compared to April 2023. Nationally, food prices in Canada increased by 2.3% over the same period. Therefore, the increase in food prices in British Columbia was slightly higher than the national average.'"
"'In April 2024, food prices in British Columbia increased by 2.6% compared to April 2023. Nationally, food prices increased by 2.3% over the same period. Therefore, the increase in food prices in British Columbia was slightly higher than the national average.'"
]
},
"execution_count": 34,
"execution_count": 25,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -509,16 +510,16 @@
},
{
"cell_type": "code",
"execution_count": 35,
"execution_count": 26,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'Several factors contributed to the rising food prices in British Columbia in April 2024:\\n\\n1. **Beef and Veal Prices**: Beef and veal prices rose by 0.8% in April 2024 and were 7.0% higher than in April 2023 due to tight supplies and strong demand. This category experienced the fastest price increases among all food categories.\\n\\n2. **Pork Prices**: Wholesale pork prices increased by 2.9% in April 2024 and were 18.3% higher than in April 2023, driven by higher demand.\\n\\n3. **General Inflation**: The overall inflation rate in British Columbia was 2.9% in April 2024 compared to April 2023, which also contributed to the rise in food prices.\\n\\n4. **Supply Chain Issues**: Ongoing supply chain disruptions, labor costs, and other economic factors continued to exert upward pressure on food prices.\\n\\n5. **Global Events**: Factors such as climate events, including wildfires and flooding, affected harvests and contributed to higher food prices.\\n\\nThese combined factors led to an overall increase in food prices in British Columbia in April 2024.'"
"'Several factors contributed to the rising food prices in British Columbia in April 2024:\\n\\n1. **Beef and Veal Prices**: Beef and veal prices rose significantly, increasing by 7.0% from April 2023 due to tight supplies and strong demand.\\n2. **Pork Prices**: Wholesale pork prices saw an 18.3% increase compared to April 2023, driven by higher demand.\\n3. **General Food Inflation**: The overall food price index in British Columbia climbed by 5.4% over the past 12 months, indicating a general trend of rising food costs.\\n4. **Supply Chain Disruptions**: Ongoing supply chain issues, including those exacerbated by global events, have continued to impact food prices.\\n5. **Energy Costs**: Although energy prices decreased by 3.9%, the overall cost of production and transportation, which are heavily influenced by energy prices, still contributed to the rising food prices.\\n\\nThese factors combined to drive the increase in food prices observed in April 2024.'"
]
},
"execution_count": 35,
"execution_count": 26,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -529,16 +530,16 @@
},
{
"cell_type": "code",
"execution_count": 36,
"execution_count": 27,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"\"In April 2024, the Consumer Price Index (CPI) in British Columbia increased by 2.9% compared to April 2023. Nationally, Canada's CPI increased by 2.7% over the same period. Therefore, the CPI in British Columbia rose slightly more than the national average.\""
"\"In April 2024, the Consumer Price Index (CPI) in British Columbia increased by 2.9% compared to April 2023. Nationally, Canada's CPI increased by 2.7% over the same period. Therefore, the CPI increase in British Columbia was slightly higher than the national average.\""
]
},
"execution_count": 36,
"execution_count": 27,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -563,7 +564,7 @@
},
{
"cell_type": "code",
"execution_count": 37,
"execution_count": 28,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -676,7 +677,7 @@
},
{
"cell_type": "code",
"execution_count": 38,
"execution_count": 29,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -688,16 +689,16 @@
},
{
"cell_type": "code",
"execution_count": 39,
"execution_count": 30,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'In British Columbia, food prices increased by 2.6% in April 2024 compared to April 2023.'"
"'In April 2024, food prices in British Columbia increased by 2.6% compared to April 2023.'"
]
},
"execution_count": 39,
"execution_count": 30,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -708,7 +709,7 @@
},
{
"cell_type": "code",
"execution_count": 40,
"execution_count": 31,
"metadata": {},
"outputs": [
{
Expand All @@ -717,7 +718,7 @@
"'In April 2024, food prices in British Columbia increased by 2.6% compared to April 2023. Nationally, food prices in Canada increased by 2.3% over the same period. Therefore, the increase in food prices in British Columbia was slightly higher than the national average.'"
]
},
"execution_count": 40,
"execution_count": 31,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -728,16 +729,16 @@
},
{
"cell_type": "code",
"execution_count": 41,
"execution_count": 32,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'Several factors contributed to the rising food prices in British Columbia in April 2024:\\n\\n1. **Meat Prices:** Beef and veal prices rose by 7.0% compared to April 2023 due to tight supplies and strong demand. Wholesale pork prices also increased significantly by 18.3% over the year due to higher demand.\\n\\n2. **Climate Events:** Adverse climate events such as wildfires and flooding affected harvests and supply chains, contributing to higher food prices.\\n\\n3. **Geopolitical Conflicts:** Ongoing geopolitical conflicts, particularly in Ukraine and the Middle East, impacted global supply chains and commodity prices, indirectly affecting food prices.\\n\\n4. **Energy Costs:** While energy prices decreased overall, the cost of transportation increased by 2.8%, which can impact the cost of food distribution and logistics.\\n\\n5. **General Inflation:** Overall inflationary pressures also played a role, with the Consumer Price Index for all items in British Columbia increasing by 2.9% from April 2023 to April 2024.\\n\\nThese factors collectively contributed to the rise in food prices in British Columbia.'"
"'Several factors contributed to the rising food prices in British Columbia in April 2024:\\n\\n1. **Increased Costs for Specific Food Categories**: Beef and veal prices rose by 7.0% from April 2023 due to tight supplies and strong demand. Wholesale pork prices also saw a significant increase of 18.3% over the same period.\\n\\n2. **General Inflation**: The overall Consumer Price Index (CPI) in British Columbia increased by 2.9% from April 2023 to April 2024, with food prices specifically rising by 2.6%.\\n\\n3. **Supply Chain Issues**: Ongoing supply chain disruptions and higher production costs, including labor and transportation, contributed to the increase in food prices.\\n\\n4. **Global Events**: Factors such as climate events affecting harvests and geopolitical tensions have also played a role in driving up food prices.\\n\\nThese combined factors led to the overall increase in food prices in the region.'"
]
},
"execution_count": 41,
"execution_count": 32,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -763,7 +764,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.1.-1"
"version": "3.10.14"
}
},
"nbformat": 4,
Expand Down
Loading