From 2fb9f44664a7c4eb848cd07445f726fff53e52fc Mon Sep 17 00:00:00 2001 From: Kartik Date: Sat, 30 Aug 2025 15:45:59 +0530 Subject: [PATCH] clear outputs --- .../day5_stock-assistant-with-tools.ipynb | 186 ++++++------------ 1 file changed, 64 insertions(+), 122 deletions(-) diff --git a/week2/community-contributions/day5_stock-assistant-with-tools.ipynb b/week2/community-contributions/day5_stock-assistant-with-tools.ipynb index 8848482..f0acfd3 100644 --- a/week2/community-contributions/day5_stock-assistant-with-tools.ipynb +++ b/week2/community-contributions/day5_stock-assistant-with-tools.ipynb @@ -10,7 +10,7 @@ }, { "cell_type": "code", - "execution_count": 170, + "execution_count": 1, "id": "b7bd1bd7-19d9-4c4b-bc4b-9bc9cca8bd0f", "metadata": {}, "outputs": [ @@ -33,7 +33,7 @@ }, { "cell_type": "code", - "execution_count": 171, + "execution_count": 2, "id": "8b50bbe2-c0b1-49c3-9a5c-1ba7efa2bcb4", "metadata": {}, "outputs": [], @@ -52,7 +52,7 @@ }, { "cell_type": "code", - "execution_count": 172, + "execution_count": 3, "id": "ba0ddc1a-c775-4ed3-9531-ed0c5799e87f", "metadata": {}, "outputs": [ @@ -60,7 +60,7 @@ "name": "stderr", "output_type": "stream", "text": [ - "2025-08-30 15:05:58,159 [INFO] Logger initialized!\n" + "2025-08-30 15:23:48,810 [INFO] Logger initialized!\n" ] } ], @@ -80,7 +80,7 @@ }, { "cell_type": "code", - "execution_count": 173, + "execution_count": 4, "id": "747e8786-9da8-4342-b6c9-f5f69c2e22ae", "metadata": {}, "outputs": [ @@ -88,8 +88,8 @@ "name": "stderr", "output_type": "stream", "text": [ - "2025-08-30 15:05:58,164 [INFO] OpenAI API Key exists and begins sk-proj-\n", - "2025-08-30 15:05:58,164 [INFO] FINNHUB_API_KEY exists!\n" + "2025-08-30 15:23:48,813 [INFO] OpenAI API Key exists and begins sk-proj-\n", + "2025-08-30 15:23:48,814 [INFO] FINNHUB_API_KEY exists!\n" ] } ], @@ -118,7 +118,7 @@ }, { "cell_type": "code", - "execution_count": 174, + "execution_count": 5, "id": "ee3aaa9a-5495-42fd-a382-803fbfa92eaf", "metadata": {}, "outputs": [], @@ -204,7 +204,7 @@ }, { "cell_type": "code", - "execution_count": 175, + "execution_count": 6, "id": "fdf1a2b0-07be-47a0-9ce3-14d21b48c8f2", "metadata": {}, "outputs": [], @@ -226,7 +226,7 @@ }, { "cell_type": "code", - "execution_count": 176, + "execution_count": 7, "id": "12d912fc-91fb-469e-9572-2876a099f5aa", "metadata": {}, "outputs": [], @@ -245,7 +245,7 @@ }, { "cell_type": "code", - "execution_count": 177, + "execution_count": 8, "id": "61a2a15d-b559-4844-b377-6bd5cb4949f6", "metadata": {}, "outputs": [], @@ -287,7 +287,7 @@ }, { "cell_type": "code", - "execution_count": 178, + "execution_count": 9, "id": "173010e3-dfef-4611-8b68-d11256bd5fba", "metadata": {}, "outputs": [], @@ -314,7 +314,7 @@ }, { "cell_type": "code", - "execution_count": 179, + "execution_count": 10, "id": "448bb4ce-8e86-4ceb-ab52-96bddfd33337", "metadata": {}, "outputs": [], @@ -409,7 +409,7 @@ }, { "cell_type": "code", - "execution_count": 180, + "execution_count": 11, "id": "9df7b74e-fec8-4e75-92a9-31acc75e6e97", "metadata": {}, "outputs": [], @@ -437,7 +437,7 @@ }, { "cell_type": "code", - "execution_count": 181, + "execution_count": 12, "id": "cfeeb200-3f30-4855-82b9-cc8b2a950f80", "metadata": {}, "outputs": [], @@ -483,7 +483,7 @@ }, { "cell_type": "code", - "execution_count": 182, + "execution_count": 13, "id": "3724d92a-4515-4267-af6f-2c1ec2b6ed36", "metadata": {}, "outputs": [], @@ -508,7 +508,7 @@ }, { "cell_type": "code", - "execution_count": 183, + "execution_count": 14, "id": "62f5d477-6626-428f-b8eb-d763e736ef5b", "metadata": {}, "outputs": [], @@ -573,7 +573,7 @@ }, { "cell_type": "code", - "execution_count": 184, + "execution_count": 15, "id": "5150ecb6-e3f1-46dc-94fa-2a9abe5165f6", "metadata": {}, "outputs": [], @@ -610,7 +610,7 @@ }, { "cell_type": "code", - "execution_count": 185, + "execution_count": 16, "id": "26dd7375-626f-4235-b4a2-f1926f62cc5e", "metadata": {}, "outputs": [], @@ -657,7 +657,7 @@ }, { "cell_type": "code", - "execution_count": 186, + "execution_count": 17, "id": "5bd1aa28-119c-4c7a-bdc0-161a582ab1cc", "metadata": {}, "outputs": [], @@ -682,7 +682,7 @@ }, { "cell_type": "code", - "execution_count": 187, + "execution_count": 18, "id": "fbe8ef6c-2d88-43a2-94dc-70b507fe9cd2", "metadata": {}, "outputs": [], @@ -761,7 +761,7 @@ }, { "cell_type": "code", - "execution_count": 188, + "execution_count": 19, "id": "9eaeae75-d68f-4160-a26e-c13e40cf756b", "metadata": {}, "outputs": [], @@ -797,7 +797,7 @@ }, { "cell_type": "code", - "execution_count": 189, + "execution_count": 20, "id": "bdca8679-935f-4e7f-97e6-e71a4d4f228c", "metadata": {}, "outputs": [], @@ -831,7 +831,7 @@ }, { "cell_type": "code", - "execution_count": 190, + "execution_count": 21, "id": "86f76f57-76c4-4dc7-94a8-cfe7816a39f1", "metadata": {}, "outputs": [], @@ -861,7 +861,7 @@ }, { "cell_type": "code", - "execution_count": 191, + "execution_count": 22, "id": "ce9b0744-9c78-408d-b9df-9f6fd9ed78cf", "metadata": {}, "outputs": [], @@ -949,7 +949,7 @@ }, { "cell_type": "code", - "execution_count": 192, + "execution_count": 23, "id": "f4be8a71-b19e-4c2f-80df-f59ff2661f14", "metadata": {}, "outputs": [ @@ -957,22 +957,45 @@ "name": "stderr", "output_type": "stream", "text": [ - "2025-08-30 15:06:02,319 [INFO] HTTP Request: GET http://127.0.0.1:7871/gradio_api/startup-events \"HTTP/1.1 200 OK\"\n", - "2025-08-30 15:06:02,322 [INFO] HTTP Request: HEAD http://127.0.0.1:7871/ \"HTTP/1.1 200 OK\"\n" + "2025-08-30 15:23:51,219 [INFO] HTTP Request: GET http://127.0.0.1:7860/gradio_api/startup-events \"HTTP/1.1 200 OK\"\n", + "2025-08-30 15:23:51,226 [INFO] HTTP Request: HEAD http://127.0.0.1:7860/ \"HTTP/1.1 200 OK\"\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ - "* Running on local URL: http://127.0.0.1:7871\n", - "* To create a public link, set `share=True` in `launch()`.\n" + "* Running on local URL: http://127.0.0.1:7860\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2025-08-30 15:23:52,534 [INFO] HTTP Request: GET https://api.gradio.app/pkg-version \"HTTP/1.1 200 OK\"\n", + "2025-08-30 15:23:52,536 [INFO] HTTP Request: GET https://api.gradio.app/v3/tunnel-request \"HTTP/1.1 200 OK\"\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "* Running on public URL: https://8532ed0b314508005c.gradio.live\n", + "\n", + "This share link expires in 1 week. For free permanent hosting and GPU upgrades, run `gradio deploy` from the terminal in the working directory to deploy to Hugging Face Spaces (https://huggingface.co/spaces)\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2025-08-30 15:23:56,230 [INFO] HTTP Request: HEAD https://8532ed0b314508005c.gradio.live \"HTTP/1.1 200 OK\"\n" ] }, { "data": { "text/html": [ - "
" + "
" ], "text/plain": [ "" @@ -985,7 +1008,7 @@ "data": { "text/plain": [] }, - "execution_count": 192, + "execution_count": 23, "metadata": {}, "output_type": "execute_result" }, @@ -993,102 +1016,21 @@ "name": "stderr", "output_type": "stream", "text": [ - "2025-08-30 15:06:03,572 [INFO] HTTP Request: GET https://api.gradio.app/pkg-version \"HTTP/1.1 200 OK\"\n", - "2025-08-30 15:06:07,415 [INFO] \n", + "2025-08-30 15:26:10,184 [INFO] \n", "Messages:\n", - "{'role': 'user', 'content': 'apple stock earnings?'}\n", + "{'role': 'user', 'content': 'Tell me the performance of eli lilly'}\n", "\n", - "2025-08-30 15:06:07,971 [INFO] HTTP Request: POST https://api.openai.com/v1/chat/completions \"HTTP/1.1 200 OK\"\n", - "2025-08-30 15:06:07,979 [INFO] Executing tool: get_current_time with args: {}\n", - "2025-08-30 15:06:08,580 [INFO] HTTP Request: POST https://api.openai.com/v1/chat/completions \"HTTP/1.1 200 OK\"\n", - "2025-08-30 15:06:08,782 [INFO] Executing tool: get_earnings_calendar with args: {'symbol': 'AAPL', '_from': '2025-07-30', 'to': '2025-08-30'}\n", - "2025-08-30 15:06:08,785 [INFO] Tool get_earnings_calendar called for AAPL from 2025-07-30 to 2025-08-30\n", - "2025-08-30 15:06:10,398 [INFO] HTTP Request: POST https://api.openai.com/v1/chat/completions \"HTTP/1.1 200 OK\"\n", - "2025-08-30 15:06:16,366 [INFO] \n", - "Messages:\n", - "{'role': 'user', 'metadata': None, 'content': 'apple stock earnings?', 'options': None}\n", - "{'role': 'assistant', 'metadata': None, 'content': 'Apple (AAPL) reported its Q3 2025 earnings on July 31, 2025, after market close. \\n- Actual EPS: $1.57 (estimate was $1.46) \\n- Actual Revenue: $94.04 billion (estimate was about $91.3 billion)', 'options': None}\n", - "{'role': 'user', 'content': 'nvidia q1 earnings'}\n", - "\n", - "2025-08-30 15:06:17,205 [INFO] HTTP Request: POST https://api.openai.com/v1/chat/completions \"HTTP/1.1 200 OK\"\n", - "2025-08-30 15:06:17,221 [INFO] Executing tool: get_current_time with args: {}\n", - "2025-08-30 15:06:17,775 [INFO] HTTP Request: POST https://api.openai.com/v1/chat/completions \"HTTP/1.1 200 OK\"\n", - "2025-08-30 15:06:18,023 [INFO] Executing tool: get_earnings_calendar with args: {'symbol': 'NVDA', '_from': '2025-05-01', 'to': '2025-08-30'}\n", - "2025-08-30 15:06:18,026 [INFO] Tool get_earnings_calendar called for NVDA from 2025-05-01 to 2025-08-30\n", - "2025-08-30 15:06:18,842 [INFO] HTTP Request: POST https://api.openai.com/v1/chat/completions \"HTTP/1.1 200 OK\"\n", - "2025-08-30 15:06:28,656 [INFO] \n", - "Messages:\n", - "{'role': 'user', 'metadata': None, 'content': 'apple stock earnings?', 'options': None}\n", - "{'role': 'assistant', 'metadata': None, 'content': 'Apple (AAPL) reported its Q3 2025 earnings on July 31, 2025, after market close. \\n- Actual EPS: $1.57 (estimate was $1.46) \\n- Actual Revenue: $94.04 billion (estimate was about $91.3 billion)', 'options': None}\n", - "{'role': 'user', 'metadata': None, 'content': 'nvidia q1 earnings', 'options': None}\n", - "{'role': 'assistant', 'metadata': None, 'content': \"NVIDIA's most recent earnings were for Q2 2026, reported on August 27, 2025: \\n- EPS: $1.05 (estimate was about $1.03) \\n- Revenue: $46.7 billion (estimate was about $46.98 billion) \\n\\nQ1 2026 earnings data is not in the recent range. Would you like details for a different quarter or time frame?\", 'options': None}\n", - "{'role': 'user', 'content': 'q1 2025'}\n", - "\n", - "2025-08-30 15:06:29,790 [INFO] HTTP Request: POST https://api.openai.com/v1/chat/completions \"HTTP/1.1 200 OK\"\n", - "2025-08-30 15:06:29,805 [INFO] Executing tool: get_earnings_calendar with args: {'symbol': 'NVDA', '_from': '2025-01-01', 'to': '2025-03-31'}\n", - "2025-08-30 15:06:29,807 [INFO] Tool get_earnings_calendar called for NVDA from 2025-01-01 to 2025-03-31\n", - "2025-08-30 15:06:29,808 [INFO] Executing tool: get_current_time with args: {}\n", - "2025-08-30 15:06:30,404 [INFO] HTTP Request: POST https://api.openai.com/v1/chat/completions \"HTTP/1.1 200 OK\"\n", - "2025-08-30 15:06:38,997 [INFO] \n", - "Messages:\n", - "{'role': 'user', 'metadata': None, 'content': 'apple stock earnings?', 'options': None}\n", - "{'role': 'assistant', 'metadata': None, 'content': 'Apple (AAPL) reported its Q3 2025 earnings on July 31, 2025, after market close. \\n- Actual EPS: $1.57 (estimate was $1.46) \\n- Actual Revenue: $94.04 billion (estimate was about $91.3 billion)', 'options': None}\n", - "{'role': 'user', 'metadata': None, 'content': 'nvidia q1 earnings', 'options': None}\n", - "{'role': 'assistant', 'metadata': None, 'content': \"NVIDIA's most recent earnings were for Q2 2026, reported on August 27, 2025: \\n- EPS: $1.05 (estimate was about $1.03) \\n- Revenue: $46.7 billion (estimate was about $46.98 billion) \\n\\nQ1 2026 earnings data is not in the recent range. Would you like details for a different quarter or time frame?\", 'options': None}\n", - "{'role': 'user', 'metadata': None, 'content': 'q1 2025', 'options': None}\n", - "{'role': 'assistant', 'metadata': None, 'content': \"I cannot retrieve NVIDIA's Q1 2025 earnings because the data must be from within the last month. I can help with more recent earnings or other stock info if you want.\", 'options': None}\n", - "{'role': 'user', 'content': 'microsoft?'}\n", - "\n", - "2025-08-30 15:06:40,071 [INFO] HTTP Request: POST https://api.openai.com/v1/chat/completions \"HTTP/1.1 200 OK\"\n", - "2025-08-30 15:06:40,327 [INFO] Executing tool: get_current_time with args: {}\n", - "2025-08-30 15:06:40,328 [INFO] Executing tool: get_company_financials with args: {'symbol': 'MSFT'}\n", - "2025-08-30 15:06:40,330 [INFO] Tool get_company_financials called for MSFT\n", - "2025-08-30 15:06:41,437 [INFO] Executing tool: get_earnings_calendar with args: {'symbol': 'MSFT', '_from': '2025-08-01', 'to': '2025-08-29'}\n", - "2025-08-30 15:06:41,439 [INFO] Tool get_earnings_calendar called for MSFT from 2025-08-01 to 2025-08-29\n", - "2025-08-30 15:06:42,284 [INFO] HTTP Request: POST https://api.openai.com/v1/chat/completions \"HTTP/1.1 200 OK\"\n", - "2025-08-30 15:06:47,742 [INFO] \n", - "Messages:\n", - "{'role': 'user', 'metadata': None, 'content': 'apple stock earnings?', 'options': None}\n", - "{'role': 'assistant', 'metadata': None, 'content': 'Apple (AAPL) reported its Q3 2025 earnings on July 31, 2025, after market close. \\n- Actual EPS: $1.57 (estimate was $1.46) \\n- Actual Revenue: $94.04 billion (estimate was about $91.3 billion)', 'options': None}\n", - "{'role': 'user', 'metadata': None, 'content': 'nvidia q1 earnings', 'options': None}\n", - "{'role': 'assistant', 'metadata': None, 'content': \"NVIDIA's most recent earnings were for Q2 2026, reported on August 27, 2025: \\n- EPS: $1.05 (estimate was about $1.03) \\n- Revenue: $46.7 billion (estimate was about $46.98 billion) \\n\\nQ1 2026 earnings data is not in the recent range. Would you like details for a different quarter or time frame?\", 'options': None}\n", - "{'role': 'user', 'metadata': None, 'content': 'q1 2025', 'options': None}\n", - "{'role': 'assistant', 'metadata': None, 'content': \"I cannot retrieve NVIDIA's Q1 2025 earnings because the data must be from within the last month. I can help with more recent earnings or other stock info if you want.\", 'options': None}\n", - "{'role': 'user', 'metadata': None, 'content': 'microsoft?', 'options': None}\n", - "{'role': 'assistant', 'metadata': None, 'content': 'Microsoft (MSFT) key financials: \\n- Market Cap: $3.79 trillion \\n- P/E Ratio (TTM): 37.23 \\n- EPS (TTM): $13.64 \\n- Dividend Yield: 0.65% \\n- 52-Week Range: $344.79 – $555.45 \\n\\nNo Q1 2025 or recent earnings releases found within August 2025. Would you like info on a different date or other details?', 'options': None}\n", - "{'role': 'user', 'content': 'latest earnings'}\n", - "\n", - "2025-08-30 15:06:48,343 [INFO] HTTP Request: POST https://api.openai.com/v1/chat/completions \"HTTP/1.1 200 OK\"\n", - "2025-08-30 15:06:48,368 [INFO] Executing tool: get_current_time with args: {}\n", - "2025-08-30 15:06:48,985 [INFO] HTTP Request: POST https://api.openai.com/v1/chat/completions \"HTTP/1.1 200 OK\"\n", - "2025-08-30 15:06:49,242 [INFO] Executing tool: get_earnings_calendar with args: {'symbol': 'MSFT', '_from': '2025-07-30', 'to': '2025-08-30'}\n", - "2025-08-30 15:06:49,243 [INFO] Tool get_earnings_calendar called for MSFT from 2025-07-30 to 2025-08-30\n", - "2025-08-30 15:06:49,956 [INFO] HTTP Request: POST https://api.openai.com/v1/chat/completions \"HTTP/1.1 200 OK\"\n", - "2025-08-30 15:06:59,770 [INFO] \n", - "Messages:\n", - "{'role': 'user', 'metadata': None, 'content': 'apple stock earnings?', 'options': None}\n", - "{'role': 'assistant', 'metadata': None, 'content': 'Apple (AAPL) reported its Q3 2025 earnings on July 31, 2025, after market close. \\n- Actual EPS: $1.57 (estimate was $1.46) \\n- Actual Revenue: $94.04 billion (estimate was about $91.3 billion)', 'options': None}\n", - "{'role': 'user', 'metadata': None, 'content': 'nvidia q1 earnings', 'options': None}\n", - "{'role': 'assistant', 'metadata': None, 'content': \"NVIDIA's most recent earnings were for Q2 2026, reported on August 27, 2025: \\n- EPS: $1.05 (estimate was about $1.03) \\n- Revenue: $46.7 billion (estimate was about $46.98 billion) \\n\\nQ1 2026 earnings data is not in the recent range. Would you like details for a different quarter or time frame?\", 'options': None}\n", - "{'role': 'user', 'metadata': None, 'content': 'q1 2025', 'options': None}\n", - "{'role': 'assistant', 'metadata': None, 'content': \"I cannot retrieve NVIDIA's Q1 2025 earnings because the data must be from within the last month. I can help with more recent earnings or other stock info if you want.\", 'options': None}\n", - "{'role': 'user', 'metadata': None, 'content': 'microsoft?', 'options': None}\n", - "{'role': 'assistant', 'metadata': None, 'content': 'Microsoft (MSFT) key financials: \\n- Market Cap: $3.79 trillion \\n- P/E Ratio (TTM): 37.23 \\n- EPS (TTM): $13.64 \\n- Dividend Yield: 0.65% \\n- 52-Week Range: $344.79 – $555.45 \\n\\nNo Q1 2025 or recent earnings releases found within August 2025. Would you like info on a different date or other details?', 'options': None}\n", - "{'role': 'user', 'metadata': None, 'content': 'latest earnings', 'options': None}\n", - "{'role': 'assistant', 'metadata': None, 'content': 'Microsoft has not reported any earnings releases in the last month up to August 30, 2025. Would you like me to check a different date range or provide recent earnings for another company?', 'options': None}\n", - "{'role': 'user', 'content': 'nvidia'}\n", - "\n", - "2025-08-30 15:07:00,871 [INFO] HTTP Request: POST https://api.openai.com/v1/chat/completions \"HTTP/1.1 200 OK\"\n", - "2025-08-30 15:07:00,901 [INFO] Executing tool: get_current_time with args: {}\n", - "2025-08-30 15:07:01,680 [INFO] HTTP Request: POST https://api.openai.com/v1/chat/completions \"HTTP/1.1 200 OK\"\n", - "2025-08-30 15:07:01,944 [INFO] Executing tool: get_earnings_calendar with args: {'symbol': 'NVDA', '_from': '2025-07-30', 'to': '2025-08-30'}\n", - "2025-08-30 15:07:01,947 [INFO] Tool get_earnings_calendar called for NVDA from 2025-07-30 to 2025-08-30\n", - "2025-08-30 15:07:02,980 [INFO] HTTP Request: POST https://api.openai.com/v1/chat/completions \"HTTP/1.1 200 OK\"\n" + "2025-08-30 15:26:11,569 [INFO] HTTP Request: POST https://api.openai.com/v1/chat/completions \"HTTP/1.1 200 OK\"\n", + "2025-08-30 15:26:11,592 [INFO] Executing tool: get_stock_quote with args: {'symbol': 'LLY'}\n", + "2025-08-30 15:26:11,594 [INFO] Tool get_stock_quote called for LLY\n", + "2025-08-30 15:26:12,419 [INFO] Executing tool: get_company_financials with args: {'symbol': 'LLY'}\n", + "2025-08-30 15:26:12,420 [INFO] Tool get_company_financials called for LLY\n", + "2025-08-30 15:26:14,097 [INFO] HTTP Request: POST https://api.openai.com/v1/chat/completions \"HTTP/1.1 200 OK\"\n" ] } ], "source": [ - "gr.ChatInterface(fn=chat, type=\"messages\", title=\"TickerBot\", description=\"Ask about stock prices, company financials and market news!\").launch()" + "gr.ChatInterface(fn=chat, type=\"messages\", title=\"TickerBot\", description=\"Ask about stock prices, company financials and market news!\").launch(share=True)" ] }, {