Spaces:
Sleeping
Sleeping
prototype edits
Browse files- notebooks/01_data_ingestion.ipynb +0 -0
- notebooks/structure_data.ipynb +7 -7
- notebooks/test_demo.ipynb +43 -111
notebooks/01_data_ingestion.ipynb
CHANGED
|
The diff for this file is too large to render.
See raw diff
|
|
|
notebooks/structure_data.ipynb
CHANGED
|
@@ -791,7 +791,7 @@
|
|
| 791 |
},
|
| 792 |
{
|
| 793 |
"cell_type": "code",
|
| 794 |
-
"execution_count":
|
| 795 |
"id": "30e68bef-c053-465a-9efe-fe728468435e",
|
| 796 |
"metadata": {},
|
| 797 |
"outputs": [],
|
|
@@ -803,7 +803,7 @@
|
|
| 803 |
},
|
| 804 |
{
|
| 805 |
"cell_type": "code",
|
| 806 |
-
"execution_count":
|
| 807 |
"id": "0335a6cd-032e-49d2-855e-e7ab1d41b80c",
|
| 808 |
"metadata": {},
|
| 809 |
"outputs": [],
|
|
@@ -822,7 +822,7 @@
|
|
| 822 |
},
|
| 823 |
{
|
| 824 |
"cell_type": "code",
|
| 825 |
-
"execution_count":
|
| 826 |
"id": "3fda1317-2305-4405-8970-9ede381329c8",
|
| 827 |
"metadata": {},
|
| 828 |
"outputs": [],
|
|
@@ -839,14 +839,14 @@
|
|
| 839 |
},
|
| 840 |
{
|
| 841 |
"cell_type": "code",
|
| 842 |
-
"execution_count":
|
| 843 |
"id": "b9a4a400-d2e3-4326-b053-0bb649661c64",
|
| 844 |
"metadata": {},
|
| 845 |
"outputs": [
|
| 846 |
{
|
| 847 |
"data": {
|
| 848 |
"application/vnd.jupyter.widget-view+json": {
|
| 849 |
-
"model_id": "
|
| 850 |
"version_major": 2,
|
| 851 |
"version_minor": 0
|
| 852 |
},
|
|
@@ -860,7 +860,7 @@
|
|
| 860 |
{
|
| 861 |
"data": {
|
| 862 |
"application/vnd.jupyter.widget-view+json": {
|
| 863 |
-
"model_id": "
|
| 864 |
"version_major": 2,
|
| 865 |
"version_minor": 0
|
| 866 |
},
|
|
@@ -1409,7 +1409,7 @@
|
|
| 1409 |
" \n",
|
| 1410 |
" for t in tables_to_drop:\n",
|
| 1411 |
" conn.execute(text(f'DROP TABLE IF EXISTS \"{t}\"'))\n",
|
| 1412 |
-
" print(f\" 🗑️ Dropped table: {t}\")\n",
|
| 1413 |
" \n",
|
| 1414 |
" conn.commit()\n",
|
| 1415 |
"\n",
|
|
|
|
| 791 |
},
|
| 792 |
{
|
| 793 |
"cell_type": "code",
|
| 794 |
+
"execution_count": 7,
|
| 795 |
"id": "30e68bef-c053-465a-9efe-fe728468435e",
|
| 796 |
"metadata": {},
|
| 797 |
"outputs": [],
|
|
|
|
| 803 |
},
|
| 804 |
{
|
| 805 |
"cell_type": "code",
|
| 806 |
+
"execution_count": 8,
|
| 807 |
"id": "0335a6cd-032e-49d2-855e-e7ab1d41b80c",
|
| 808 |
"metadata": {},
|
| 809 |
"outputs": [],
|
|
|
|
| 822 |
},
|
| 823 |
{
|
| 824 |
"cell_type": "code",
|
| 825 |
+
"execution_count": 9,
|
| 826 |
"id": "3fda1317-2305-4405-8970-9ede381329c8",
|
| 827 |
"metadata": {},
|
| 828 |
"outputs": [],
|
|
|
|
| 839 |
},
|
| 840 |
{
|
| 841 |
"cell_type": "code",
|
| 842 |
+
"execution_count": 10,
|
| 843 |
"id": "b9a4a400-d2e3-4326-b053-0bb649661c64",
|
| 844 |
"metadata": {},
|
| 845 |
"outputs": [
|
| 846 |
{
|
| 847 |
"data": {
|
| 848 |
"application/vnd.jupyter.widget-view+json": {
|
| 849 |
+
"model_id": "7954405dd6174df3b37aaf12fe923dc3",
|
| 850 |
"version_major": 2,
|
| 851 |
"version_minor": 0
|
| 852 |
},
|
|
|
|
| 860 |
{
|
| 861 |
"data": {
|
| 862 |
"application/vnd.jupyter.widget-view+json": {
|
| 863 |
+
"model_id": "25987682e2644f9a96c09557c722bb43",
|
| 864 |
"version_major": 2,
|
| 865 |
"version_minor": 0
|
| 866 |
},
|
|
|
|
| 1409 |
" \n",
|
| 1410 |
" for t in tables_to_drop:\n",
|
| 1411 |
" conn.execute(text(f'DROP TABLE IF EXISTS \"{t}\"'))\n",
|
| 1412 |
+
" print(The total value of commodity tea exports in 1998 was 2,774.28 million.'f\" 🗑️ Dropped table: {t}\")\n",
|
| 1413 |
" \n",
|
| 1414 |
" conn.commit()\n",
|
| 1415 |
"\n",
|
notebooks/test_demo.ipynb
CHANGED
|
@@ -10,7 +10,7 @@
|
|
| 10 |
},
|
| 11 |
{
|
| 12 |
"cell_type": "code",
|
| 13 |
-
"execution_count":
|
| 14 |
"id": "ae890231-b53d-451b-912c-ad84bd1f3360",
|
| 15 |
"metadata": {},
|
| 16 |
"outputs": [],
|
|
@@ -20,7 +20,7 @@
|
|
| 20 |
},
|
| 21 |
{
|
| 22 |
"cell_type": "code",
|
| 23 |
-
"execution_count":
|
| 24 |
"id": "ed3dafc1-5641-42ee-94e4-299295939a8f",
|
| 25 |
"metadata": {},
|
| 26 |
"outputs": [],
|
|
@@ -32,7 +32,7 @@
|
|
| 32 |
},
|
| 33 |
{
|
| 34 |
"cell_type": "code",
|
| 35 |
-
"execution_count":
|
| 36 |
"id": "25b50f89-d265-42b1-a97b-8e7790856595",
|
| 37 |
"metadata": {},
|
| 38 |
"outputs": [],
|
|
@@ -46,7 +46,7 @@
|
|
| 46 |
},
|
| 47 |
{
|
| 48 |
"cell_type": "code",
|
| 49 |
-
"execution_count":
|
| 50 |
"id": "dea362be-192d-4929-b140-3778cba1df25",
|
| 51 |
"metadata": {},
|
| 52 |
"outputs": [],
|
|
@@ -57,7 +57,7 @@
|
|
| 57 |
},
|
| 58 |
{
|
| 59 |
"cell_type": "code",
|
| 60 |
-
"execution_count":
|
| 61 |
"id": "333e0906-23f5-4836-8beb-188d2155e879",
|
| 62 |
"metadata": {},
|
| 63 |
"outputs": [],
|
|
@@ -67,7 +67,7 @@
|
|
| 67 |
},
|
| 68 |
{
|
| 69 |
"cell_type": "code",
|
| 70 |
-
"execution_count":
|
| 71 |
"id": "d8f69073-a21a-4b9d-89c5-d7554d7ac605",
|
| 72 |
"metadata": {},
|
| 73 |
"outputs": [
|
|
@@ -75,8 +75,8 @@
|
|
| 75 |
"name": "stdout",
|
| 76 |
"output_type": "stream",
|
| 77 |
"text": [
|
| 78 |
-
"
|
| 79 |
-
"
|
| 80 |
]
|
| 81 |
}
|
| 82 |
],
|
|
@@ -87,7 +87,7 @@
|
|
| 87 |
},
|
| 88 |
{
|
| 89 |
"cell_type": "code",
|
| 90 |
-
"execution_count":
|
| 91 |
"id": "7a607e94-d378-4127-9c97-1d0a5a3e629f",
|
| 92 |
"metadata": {},
|
| 93 |
"outputs": [],
|
|
@@ -101,12 +101,14 @@
|
|
| 101 |
"query7 = \"summarize recent loan default trends in microfinance institutions.\"\n",
|
| 102 |
"query8 = \"What was the total public debt for 1999?\"\n",
|
| 103 |
"query9 = \"Is the Kenyan economy improving? Considering the quality of life of its citizens\"\n",
|
| 104 |
-
"query10 = \"Why did the shilling depreciate?\""
|
|
|
|
|
|
|
| 105 |
]
|
| 106 |
},
|
| 107 |
{
|
| 108 |
"cell_type": "code",
|
| 109 |
-
"execution_count":
|
| 110 |
"id": "5d5a7ff3-aa69-4083-81cf-d6e34c41be6f",
|
| 111 |
"metadata": {},
|
| 112 |
"outputs": [],
|
|
@@ -116,7 +118,7 @@
|
|
| 116 |
},
|
| 117 |
{
|
| 118 |
"cell_type": "code",
|
| 119 |
-
"execution_count":
|
| 120 |
"id": "dc20cc1d-da64-4394-85d5-7b77ad0e88c5",
|
| 121 |
"metadata": {},
|
| 122 |
"outputs": [
|
|
@@ -124,9 +126,9 @@
|
|
| 124 |
"name": "stdout",
|
| 125 |
"output_type": "stream",
|
| 126 |
"text": [
|
| 127 |
-
"
|
| 128 |
-
"
|
| 129 |
-
"
|
| 130 |
]
|
| 131 |
},
|
| 132 |
{
|
|
@@ -135,7 +137,7 @@
|
|
| 135 |
"True"
|
| 136 |
]
|
| 137 |
},
|
| 138 |
-
"execution_count":
|
| 139 |
"metadata": {},
|
| 140 |
"output_type": "execute_result"
|
| 141 |
}
|
|
@@ -147,7 +149,7 @@
|
|
| 147 |
},
|
| 148 |
{
|
| 149 |
"cell_type": "code",
|
| 150 |
-
"execution_count":
|
| 151 |
"id": "e3942375-e589-4469-94ef-b0bae5e0684f",
|
| 152 |
"metadata": {},
|
| 153 |
"outputs": [
|
|
@@ -156,124 +158,46 @@
|
|
| 156 |
"output_type": "stream",
|
| 157 |
"text": [
|
| 158 |
"\n",
|
| 159 |
-
"
|
| 160 |
"----------------------------------------\n",
|
| 161 |
-
"
|
| 162 |
-
"\n",
|
| 163 |
-
"🧠 Step 1: Thought: I need to determine the reasons behind the Kenyan shilling's depreciation. This requires analyzing economic factors like inflation, trade deficits, political stability, or global market trends. I'll first check the database for relevant quantitative data, then use financial reports/news if needed.\n",
|
| 164 |
"\n",
|
|
|
|
| 165 |
"Action: sql_db_list_tables \n",
|
| 166 |
"Action Input:\n",
|
| 167 |
"🛠️ Calling 'sql_db_list_tables' with: \n",
|
| 168 |
"\n",
|
| 169 |
-
"🧠 Step 2: Thought:
|
| 170 |
-
"\n",
|
| 171 |
-
"Action: sql_db_schema \n",
|
| 172 |
-
"Action Input: foreign_trade_summary, cbk_indicative_rates\n",
|
| 173 |
-
"🛠️ Calling 'sql_db_schema' with: foreign_trade_summary, cbk_indicative_rates\n",
|
| 174 |
-
"\n",
|
| 175 |
-
"🧠 Step 3: Thought: I need to analyze trade deficits and exchange rate trends. First, check recent trade balances and exchange rates.\n",
|
| 176 |
-
"\n",
|
| 177 |
-
"Action: sql_db_query_checker \n",
|
| 178 |
-
"Action Input: SELECT year, month, trade_balance FROM foreign_trade_summary ORDER BY year DESC, month DESC LIMIT 12\n",
|
| 179 |
-
"🛠️ Calling 'sql_db_query_checker' with: SELECT year, month, trade_balance FROM foreign_trade_summary ORDER BY year DESC, month DESC LIMIT 12\n",
|
| 180 |
-
"\n",
|
| 181 |
-
"🧠 Step 4: Action: sql_db_query \n",
|
| 182 |
-
"Action Input: SELECT year, month, trade_balance FROM foreign_trade_summary ORDER BY year DESC, month DESC LIMIT 12\n",
|
| 183 |
-
"🛠️ Calling 'sql_db_query' with: SELECT year, month, trade_balance FROM foreign_trade_summary ORDER BY year DESC, month DESC LIMIT 12\n",
|
| 184 |
-
"\n",
|
| 185 |
-
"🧠 Step 5: Thought: The trade balance data shows a consistent deficit, indicating higher imports than exports, which increases demand for foreign currency. This likely contributes to shilling depreciation. To confirm, check exchange rate trends over time.\n",
|
| 186 |
-
"\n",
|
| 187 |
-
"Action: sql_db_query_checker \n",
|
| 188 |
-
"Action Input: SELECT date, mean_rate FROM cbk_indicative_rates WHERE currency = 'US DOLLAR' ORDER BY date DESC LIMIT 12\n",
|
| 189 |
-
"🛠️ Calling 'sql_db_query_checker' with: SELECT date, mean_rate FROM cbk_indicative_rates WHERE currency = 'US DOLLAR' ORDER BY date DESC LIMIT 12\n",
|
| 190 |
-
"\n",
|
| 191 |
-
"🧠 Step 6: Thought: The trade balance data shows persistent deficits, increasing demand for foreign currency. Exchange rate trends for the US dollar (mean rate rising) confirm shilling depreciation. To fully answer \"why,\" I should also check for inflation data or policy changes, but since the database lacks an inflation table, I'll rely on available data and external sources.\n",
|
| 192 |
-
"\n",
|
| 193 |
"Action: search_financial_reports_and_news \n",
|
| 194 |
-
"Action Input:
|
| 195 |
-
"🛠️ Calling 'search_financial_reports_and_news' with:
|
| 196 |
-
]
|
| 197 |
-
},
|
| 198 |
-
{
|
| 199 |
-
"name": "stderr",
|
| 200 |
-
"output_type": "stream",
|
| 201 |
-
"text": [
|
| 202 |
-
"/users/tligawa/mshauri-fedha/notebooks/mshauri_demo.py:159: LangChainDeprecationWarning: The class `OllamaEmbeddings` was deprecated in LangChain 0.3.1 and will be removed in 1.0.0. An updated version of the class exists in the `langchain-ollama package and should be used instead. To use it run `pip install -U `langchain-ollama` and import as `from `langchain_ollama import OllamaEmbeddings``.\n",
|
| 203 |
-
" embeddings = OllamaEmbeddings(model=DEFAULT_EMBED_MODEL, base_url=ollama_url)\n",
|
| 204 |
-
"/users/tligawa/mshauri-fedha/notebooks/mshauri_demo.py:160: LangChainDeprecationWarning: The class `Chroma` was deprecated in LangChain 0.2.9 and will be removed in 1.0. An updated version of the class exists in the `langchain-chroma package and should be used instead. To use it run `pip install -U `langchain-chroma` and import as `from `langchain_chroma import Chroma``.\n",
|
| 205 |
-
" vectorstore = Chroma(persist_directory=vector_db_path, embedding_function=embeddings)\n"
|
| 206 |
-
]
|
| 207 |
-
},
|
| 208 |
-
{
|
| 209 |
-
"name": "stdout",
|
| 210 |
-
"output_type": "stream",
|
| 211 |
-
"text": [
|
| 212 |
"\n",
|
| 213 |
-
"🧠 Step
|
| 214 |
"\n",
|
| 215 |
-
"
|
| 216 |
-
"
|
| 217 |
-
"
|
| 218 |
"\n",
|
| 219 |
-
"
|
| 220 |
-
" - **CBK Policy**: News articles highlight the Central Bank of Kenya (CBK) has limited interventions in the foreign exchange market. Without active measures to stabilize the shilling (e.g., selling foreign reserves), market forces drive the currency lower. \n",
|
| 221 |
-
" - **Market Sentiment**: Analysts predict the shilling could fall below **KES 90 to the dollar** by year-end, reflecting weak confidence in sustained CBK support.\n",
|
| 222 |
"\n",
|
| 223 |
-
"
|
| 224 |
-
" - **Monetary Policy (Table 16)**: Savings deposit rates (e.g., 3.56% in 2022) and inter-bank rates (5.39% in 2022) are historically low, reducing incentives for foreign investors to hold shillings. This drives capital outflows, further pressuring the currency. \n",
|
| 225 |
-
" - **Comparison**: Overdraft and loan rates (12–12.67%) remain high for borrowers but fail to attract external investment, as returns in shillings are eroded by depreciation.\n",
|
| 226 |
-
"\n",
|
| 227 |
-
"### 4. **Weak Export Sector Growth** \n",
|
| 228 |
-
" - **Agriculture Data (Table 33)**: While tea and pyrethrum production has grown, key exports like maize and wheat show volatility. Agriculture contributes ~21% of GDP but lacks diversification or value addition to boost export earnings. \n",
|
| 229 |
-
" - **Non-Agricultural Exports**: Limited growth in manufacturing and services (e.g., tourism) exacerbates the trade deficit, reducing foreign exchange inflows.\n",
|
| 230 |
-
"\n",
|
| 231 |
-
"### 5. **Global and Regional Factors** \n",
|
| 232 |
-
" - **Commodity Prices**: Higher global fuel and food prices increase import costs, worsening the trade deficit. \n",
|
| 233 |
-
" - **Regional Currency Dynamics**: The shilling’s depreciation relative to neighbors (e.g., Uganda, Tanzania) reflects broader East African economic challenges, including inflation and weak regional trade integration.\n",
|
| 234 |
-
"\n",
|
| 235 |
-
"### Conclusion \n",
|
| 236 |
-
"The shilling’s depreciation stems from structural issues: **trade imbalances**, **limited CBK intervention**, **low interest rates**, and **stagnant export growth**. Without addressing these fundamentals (e.g., boosting exports, attracting foreign investment, or stabilizing the exchange rate), the shilling is likely to remain under pressure. Policymakers must balance short-term market interventions with long-term structural reforms to restore currency stability.\n",
|
| 237 |
"----------------------------------------\n",
|
| 238 |
-
"
|
| 239 |
-
"\n",
|
| 240 |
-
"### 1. **Persistent Trade Deficits** \n",
|
| 241 |
-
" - **Foreign Trade Data**: The *foreign_trade_summary* table reveals consistent negative trade balances (e.g., large deficits in 2022–2023). Kenya imports significantly more goods (e.g., machinery, fuel, and manufactured products) than it exports, increasing demand for foreign currency and weakening the shilling. \n",
|
| 242 |
-
" - **Impact**: A trade deficit reduces foreign exchange reserves, making the currency more vulnerable to depreciation.\n",
|
| 243 |
-
"\n",
|
| 244 |
-
"### 2. **Low Central Bank Intervention** \n",
|
| 245 |
-
" - **CBK Policy**: News articles highlight the Central Bank of Kenya (CBK) has limited interventions in the foreign exchange market. Without active measures to stabilize the shilling (e.g., selling foreign reserves), market forces drive the currency lower. \n",
|
| 246 |
-
" - **Market Sentiment**: Analysts predict the shilling could fall below **KES 90 to the dollar** by year-end, reflecting weak confidence in sustained CBK support.\n",
|
| 247 |
-
"\n",
|
| 248 |
-
"### 3. **Low Interest Rates** \n",
|
| 249 |
-
" - **Monetary Policy (Table 16)**: Savings deposit rates (e.g., 3.56% in 2022) and inter-bank rates (5.39% in 2022) are historically low, reducing incentives for foreign investors to hold shillings. This drives capital outflows, further pressuring the currency. \n",
|
| 250 |
-
" - **Comparison**: Overdraft and loan rates (12–12.67%) remain high for borrowers but fail to attract external investment, as returns in shillings are eroded by depreciation.\n",
|
| 251 |
-
"\n",
|
| 252 |
-
"### 4. **Weak Export Sector Growth** \n",
|
| 253 |
-
" - **Agriculture Data (Table 33)**: While tea and pyrethrum production has grown, key exports like maize and wheat show volatility. Agriculture contributes ~21% of GDP but lacks diversification or value addition to boost export earnings. \n",
|
| 254 |
-
" - **Non-Agricultural Exports**: Limited growth in manufacturing and services (e.g., tourism) exacerbates the trade deficit, reducing foreign exchange inflows.\n",
|
| 255 |
-
"\n",
|
| 256 |
-
"### 5. **Global and Regional Factors** \n",
|
| 257 |
-
" - **Commodity Prices**: Higher global fuel and food prices increase import costs, worsening the trade deficit. \n",
|
| 258 |
-
" - **Regional Currency Dynamics**: The shilling’s depreciation relative to neighbors (e.g., Uganda, Tanzania) reflects broader East African economic challenges, including inflation and weak regional trade integration.\n",
|
| 259 |
-
"\n",
|
| 260 |
-
"### Conclusion \n",
|
| 261 |
-
"The shilling’s depreciation stems from structural issues: **trade imbalances**, **limited CBK intervention**, **low interest rates**, and **stagnant export growth**. Without addressing these fundamentals (e.g., boosting exports, attracting foreign investment, or stabilizing the exchange rate), the shilling is likely to remain under pressure. Policymakers must balance short-term market interventions with long-term structural reforms to restore currency stability.\n"
|
| 262 |
]
|
| 263 |
},
|
| 264 |
{
|
| 265 |
"data": {
|
| 266 |
"text/plain": [
|
| 267 |
-
"'
|
| 268 |
]
|
| 269 |
},
|
| 270 |
-
"execution_count":
|
| 271 |
"metadata": {},
|
| 272 |
"output_type": "execute_result"
|
| 273 |
}
|
| 274 |
],
|
| 275 |
"source": [
|
| 276 |
-
"ask_mshauri(agent,
|
| 277 |
]
|
| 278 |
},
|
| 279 |
{
|
|
@@ -283,6 +207,14 @@
|
|
| 283 |
"metadata": {},
|
| 284 |
"outputs": [],
|
| 285 |
"source": []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 286 |
}
|
| 287 |
],
|
| 288 |
"metadata": {
|
|
|
|
| 10 |
},
|
| 11 |
{
|
| 12 |
"cell_type": "code",
|
| 13 |
+
"execution_count": 1,
|
| 14 |
"id": "ae890231-b53d-451b-912c-ad84bd1f3360",
|
| 15 |
"metadata": {},
|
| 16 |
"outputs": [],
|
|
|
|
| 20 |
},
|
| 21 |
{
|
| 22 |
"cell_type": "code",
|
| 23 |
+
"execution_count": 2,
|
| 24 |
"id": "ed3dafc1-5641-42ee-94e4-299295939a8f",
|
| 25 |
"metadata": {},
|
| 26 |
"outputs": [],
|
|
|
|
| 32 |
},
|
| 33 |
{
|
| 34 |
"cell_type": "code",
|
| 35 |
+
"execution_count": 3,
|
| 36 |
"id": "25b50f89-d265-42b1-a97b-8e7790856595",
|
| 37 |
"metadata": {},
|
| 38 |
"outputs": [],
|
|
|
|
| 46 |
},
|
| 47 |
{
|
| 48 |
"cell_type": "code",
|
| 49 |
+
"execution_count": 4,
|
| 50 |
"id": "dea362be-192d-4929-b140-3778cba1df25",
|
| 51 |
"metadata": {},
|
| 52 |
"outputs": [],
|
|
|
|
| 57 |
},
|
| 58 |
{
|
| 59 |
"cell_type": "code",
|
| 60 |
+
"execution_count": 5,
|
| 61 |
"id": "333e0906-23f5-4836-8beb-188d2155e879",
|
| 62 |
"metadata": {},
|
| 63 |
"outputs": [],
|
|
|
|
| 67 |
},
|
| 68 |
{
|
| 69 |
"cell_type": "code",
|
| 70 |
+
"execution_count": 6,
|
| 71 |
"id": "d8f69073-a21a-4b9d-89c5-d7554d7ac605",
|
| 72 |
"metadata": {},
|
| 73 |
"outputs": [
|
|
|
|
| 75 |
"name": "stdout",
|
| 76 |
"output_type": "stream",
|
| 77 |
"text": [
|
| 78 |
+
" Initializing Mshauri Fedha (Model: qwen3:32b)...\n",
|
| 79 |
+
" Mshauri Agent Ready (Zero-Dependency Mode).\n"
|
| 80 |
]
|
| 81 |
}
|
| 82 |
],
|
|
|
|
| 87 |
},
|
| 88 |
{
|
| 89 |
"cell_type": "code",
|
| 90 |
+
"execution_count": 7,
|
| 91 |
"id": "7a607e94-d378-4127-9c97-1d0a5a3e629f",
|
| 92 |
"metadata": {},
|
| 93 |
"outputs": [],
|
|
|
|
| 101 |
"query7 = \"summarize recent loan default trends in microfinance institutions.\"\n",
|
| 102 |
"query8 = \"What was the total public debt for 1999?\"\n",
|
| 103 |
"query9 = \"Is the Kenyan economy improving? Considering the quality of life of its citizens\"\n",
|
| 104 |
+
"query10 = \"Why did the shilling depreciate?\"\n",
|
| 105 |
+
"query11 = \"What was the inflation rate in 2023 and why is it rising?\"\n",
|
| 106 |
+
"query12= \"Summarize recent loan default trends in microfinance institutions\""
|
| 107 |
]
|
| 108 |
},
|
| 109 |
{
|
| 110 |
"cell_type": "code",
|
| 111 |
+
"execution_count": 8,
|
| 112 |
"id": "5d5a7ff3-aa69-4083-81cf-d6e34c41be6f",
|
| 113 |
"metadata": {},
|
| 114 |
"outputs": [],
|
|
|
|
| 118 |
},
|
| 119 |
{
|
| 120 |
"cell_type": "code",
|
| 121 |
+
"execution_count": 9,
|
| 122 |
"id": "dc20cc1d-da64-4394-85d5-7b77ad0e88c5",
|
| 123 |
"metadata": {},
|
| 124 |
"outputs": [
|
|
|
|
| 126 |
"name": "stdout",
|
| 127 |
"output_type": "stream",
|
| 128 |
"text": [
|
| 129 |
+
" Starting Ollama Server...\n",
|
| 130 |
+
" Waiting for server to boot...\n",
|
| 131 |
+
" Server started successfully.\n"
|
| 132 |
]
|
| 133 |
},
|
| 134 |
{
|
|
|
|
| 137 |
"True"
|
| 138 |
]
|
| 139 |
},
|
| 140 |
+
"execution_count": 9,
|
| 141 |
"metadata": {},
|
| 142 |
"output_type": "execute_result"
|
| 143 |
}
|
|
|
|
| 149 |
},
|
| 150 |
{
|
| 151 |
"cell_type": "code",
|
| 152 |
+
"execution_count": 16,
|
| 153 |
"id": "e3942375-e589-4469-94ef-b0bae5e0684f",
|
| 154 |
"metadata": {},
|
| 155 |
"outputs": [
|
|
|
|
| 158 |
"output_type": "stream",
|
| 159 |
"text": [
|
| 160 |
"\n",
|
| 161 |
+
" User: What was the inflation rate in 2023 and why is it rising?\n",
|
| 162 |
"----------------------------------------\n",
|
| 163 |
+
" Starting Agent Loop for: 'What was the inflation rate in 2023 and why is it rising?'\n",
|
|
|
|
|
|
|
| 164 |
"\n",
|
| 165 |
+
"🧠 Step 1: Thought: I need to find the inflation rate for 2023 and understand the reasons behind its rise. First, I'll check if the SQL database contains inflation data. \n",
|
| 166 |
"Action: sql_db_list_tables \n",
|
| 167 |
"Action Input:\n",
|
| 168 |
"🛠️ Calling 'sql_db_list_tables' with: \n",
|
| 169 |
"\n",
|
| 170 |
+
"🧠 Step 2: Thought: The SQL tables listed do not include a direct source for inflation rates. I'll use the search tool to find the 2023 inflation rate and its causes from financial reports. \n",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 171 |
"Action: search_financial_reports_and_news \n",
|
| 172 |
+
"Action Input: inflation rate 2023 Kenya\n",
|
| 173 |
+
"🛠️ Calling 'search_financial_reports_and_news' with: inflation rate 2023 Kenya\n",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 174 |
"\n",
|
| 175 |
+
"🧠 Step 3: The inflation rate in Kenya for 2023 was **7.9% in April 2023** and rose to **8.0% in May 2023**, as reported by the Consumer Price Index (CPI). The rise in inflation is primarily attributed to:\n",
|
| 176 |
"\n",
|
| 177 |
+
"1. **Food and Non-Alcoholic Beverages (10.1%–10.2% annual increase):** Driven by supply chain disruptions, climate-related impacts on agriculture, and rising global commodity prices. \n",
|
| 178 |
+
"2. **Housing, Water, Electricity, Gas, and Fuels (9.6%–9.7% annual increase):** Higher energy costs, particularly electricity tariffs, and construction material prices. \n",
|
| 179 |
+
"3. **Transport (9.8%–10.1% annual increase):** Increased fuel prices and transportation costs due to global oil price fluctuations. \n",
|
| 180 |
"\n",
|
| 181 |
+
"These categories account for over 57% of the CPI's weighted components, amplifying their impact on overall inflation. Additionally, monthly CPI increases (e.g., a 0.9% rise from April to May 2023) were driven by marginal but cumulative price hikes in essential goods and services. \n",
|
|
|
|
|
|
|
| 182 |
"\n",
|
| 183 |
+
"**Final Answer:** Kenya’s 2023 inflation rate was approximately **7.9–8.0%**, driven by rising food, energy, and transport costs linked to global price trends, local supply constraints, and energy policy adjustments.\n",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 184 |
"----------------------------------------\n",
|
| 185 |
+
" Mshauri: ** Kenya’s 2023 inflation rate was approximately **7.9–8.0%**, driven by rising food, energy, and transport costs linked to global price trends, local supply constraints, and energy policy adjustments.\n"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 186 |
]
|
| 187 |
},
|
| 188 |
{
|
| 189 |
"data": {
|
| 190 |
"text/plain": [
|
| 191 |
+
"'** Kenya’s 2023 inflation rate was approximately **7.9–8.0%**, driven by rising food, energy, and transport costs linked to global price trends, local supply constraints, and energy policy adjustments.'"
|
| 192 |
]
|
| 193 |
},
|
| 194 |
+
"execution_count": 16,
|
| 195 |
"metadata": {},
|
| 196 |
"output_type": "execute_result"
|
| 197 |
}
|
| 198 |
],
|
| 199 |
"source": [
|
| 200 |
+
"ask_mshauri(agent, query11)"
|
| 201 |
]
|
| 202 |
},
|
| 203 |
{
|
|
|
|
| 207 |
"metadata": {},
|
| 208 |
"outputs": [],
|
| 209 |
"source": []
|
| 210 |
+
},
|
| 211 |
+
{
|
| 212 |
+
"cell_type": "code",
|
| 213 |
+
"execution_count": null,
|
| 214 |
+
"id": "64dee97e-d620-4de5-be60-a7335fda4b0c",
|
| 215 |
+
"metadata": {},
|
| 216 |
+
"outputs": [],
|
| 217 |
+
"source": []
|
| 218 |
}
|
| 219 |
],
|
| 220 |
"metadata": {
|