|
79 | 79 | }, |
80 | 80 | { |
81 | 81 | "cell_type": "code", |
82 | | - "execution_count": 9, |
| 82 | + "execution_count": 1, |
83 | 83 | "id": "e42b4a10", |
84 | 84 | "metadata": {}, |
85 | 85 | "outputs": [], |
|
118 | 118 | }, |
119 | 119 | { |
120 | 120 | "cell_type": "code", |
121 | | - "execution_count": 10, |
| 121 | + "execution_count": 2, |
122 | 122 | "id": "91fd6810", |
123 | 123 | "metadata": {}, |
124 | 124 | "outputs": [ |
|
188 | 188 | }, |
189 | 189 | { |
190 | 190 | "cell_type": "code", |
191 | | - "execution_count": 11, |
| 191 | + "execution_count": 3, |
192 | 192 | "id": "f98f31e7", |
193 | 193 | "metadata": {}, |
194 | 194 | "outputs": [ |
|
225 | 225 | }, |
226 | 226 | { |
227 | 227 | "cell_type": "code", |
228 | | - "execution_count": 12, |
| 228 | + "execution_count": 4, |
229 | 229 | "id": "fbe31e32", |
230 | 230 | "metadata": {}, |
231 | 231 | "outputs": [ |
|
281 | 281 | }, |
282 | 282 | { |
283 | 283 | "cell_type": "code", |
284 | | - "execution_count": 13, |
| 284 | + "execution_count": null, |
285 | 285 | "id": "6eb0ebd3", |
286 | 286 | "metadata": {}, |
287 | 287 | "outputs": [ |
288 | 288 | { |
289 | 289 | "data": { |
290 | 290 | "text/plain": [ |
291 | | - "{'object': 'list', 'data': [{'id': 'asst_lzafrxILzTmhdFaMMEVjuhE8', 'object': 'assistant', 'created_at': 1746940688, 'name': 'earth-search-agent', 'description': None, 'model': 'gpt-4o-mini', 'instructions': '\\nAn Q&A agent that can answer questions about the Earth at night.\\nSources have a JSON format with a ref_id that must be cited in the answer.\\nIf you do not have the answer, respond with \"I don\\'t know\".\\n', 'tools': [], 'top_p': 1.0, 'temperature': 1.0, 'tool_resources': {}, 'metadata': {}, 'response_format': 'auto'}], 'first_id': 'asst_lzafrxILzTmhdFaMMEVjuhE8', 'last_id': 'asst_lzafrxILzTmhdFaMMEVjuhE8', 'has_more': False}" |
| 291 | + "{'object': 'list', 'data': [{'id': 'asst_sXngVG4fzu0bQJNFmTxzX6h4', 'object': 'assistant', 'created_at': 1746940725, 'name': 'earth-search-agent', 'description': None, 'model': 'gpt-4o-mini', 'instructions': '\\nAn Q&A agent that can answer questions about the Earth at night.\\nSources have a JSON format with a ref_id that must be cited in the answer.\\nIf you do not have the answer, respond with \"I don\\'t know\".\\n', 'tools': [], 'top_p': 1.0, 'temperature': 1.0, 'tool_resources': {}, 'metadata': {}, 'response_format': 'auto'}, {'id': 'asst_lzafrxILzTmhdFaMMEVjuhE8', 'object': 'assistant', 'created_at': 1746940688, 'name': 'earth-search-agent', 'description': None, 'model': 'gpt-4o-mini', 'instructions': '\\nAn Q&A agent that can answer questions about the Earth at night.\\nSources have a JSON format with a ref_id that must be cited in the answer.\\nIf you do not have the answer, respond with \"I don\\'t know\".\\n', 'tools': [], 'top_p': 1.0, 'temperature': 1.0, 'tool_resources': {}, 'metadata': {}, 'response_format': 'auto'}], 'first_id': 'asst_sXngVG4fzu0bQJNFmTxzX6h4', 'last_id': 'asst_lzafrxILzTmhdFaMMEVjuhE8', 'has_more': False}" |
292 | 292 | ] |
293 | 293 | }, |
294 | | - "execution_count": 13, |
| 294 | + "execution_count": 5, |
295 | 295 | "metadata": {}, |
296 | 296 | "output_type": "execute_result" |
297 | 297 | } |
298 | 298 | ], |
299 | 299 | "source": [ |
300 | 300 | "from azure.ai.projects import AIProjectClient\n", |
301 | | - "import json\n", |
302 | 301 | "\n", |
303 | 302 | "project_client = AIProjectClient.from_connection_string(project_conn_str, credential=credential)\n", |
304 | 303 | "\n", |
|
307 | 306 | }, |
308 | 307 | { |
309 | 308 | "cell_type": "code", |
310 | | - "execution_count": 14, |
| 309 | + "execution_count": null, |
311 | 310 | "id": "aa363122", |
312 | 311 | "metadata": {}, |
313 | 312 | "outputs": [ |
|
326 | 325 | "project_client = AIProjectClient.from_connection_string(project_conn_str, credential=credential)\n", |
327 | 326 | "\n", |
328 | 327 | "instructions = \"\"\"\n", |
329 | | - "An Q&A agent that can answer questions about the Earth at night.\n", |
| 328 | + "A Q&A agent that can answer questions about the Earth at night.\n", |
330 | 329 | "Sources have a JSON format with a ref_id that must be cited in the answer.\n", |
331 | 330 | "If you do not have the answer, respond with \"I don't know\".\n", |
332 | 331 | "\"\"\"\n", |
|
351 | 350 | }, |
352 | 351 | { |
353 | 352 | "cell_type": "code", |
354 | | - "execution_count": 15, |
| 353 | + "execution_count": 7, |
355 | 354 | "id": "de2ee775", |
356 | 355 | "metadata": {}, |
357 | 356 | "outputs": [], |
|
378 | 377 | " messages.data.reverse()\n", |
379 | 378 | " retrieval_result = agent_client.knowledge_retrieval.retrieve(\n", |
380 | 379 | " retrieval_request=KnowledgeAgentRetrievalRequest(\n", |
381 | | - " messages=[KnowledgeAgentMessage(role=msg[\"role\"], content=[KnowledgeAgentMessageTextContent(text=msg.content[0].text)]) for msg in messages.data],\n", |
| 380 | + " messages=[KnowledgeAgentMessage(role=msg[\"role\"], content=[KnowledgeAgentMessageTextContent(text=msg.content[0].text)]) for msg in messages.data if msg[\"role\"] != \"system\"],\n", |
382 | 381 | " target_index_params=[KnowledgeAgentIndexParams(index_name=index_name, reranker_threshold=2.5)]\n", |
383 | 382 | " )\n", |
384 | 383 | " )\n", |
|
412 | 411 | }, |
413 | 412 | { |
414 | 413 | "cell_type": "code", |
415 | | - "execution_count": 16, |
| 414 | + "execution_count": 8, |
416 | 415 | "id": "f1fc04fc", |
417 | 416 | "metadata": {}, |
418 | 417 | "outputs": [ |
419 | 418 | { |
420 | 419 | "name": "stdout", |
421 | 420 | "output_type": "stream", |
422 | 421 | "text": [ |
423 | | - "Agent response: Suburban areas display larger December brightening than urban cores primarily due to the distribution of light sources and land use patterns\n", |
424 | | - " While urban cores may have higher absolute light levels, the suburban belt tends to have more residential areas, which are often illuminated during the darker winter months\n", |
425 | | - " These suburbs typically have street lights, homes, and other light sources that contribute to the overall brightness in the vicinity\n", |
426 | | - " In contrast, urban cores may have more concentrated lighting in commercial areas that are not uniformly distributed, making the suburban regions appear more luminous during certain times, especially in winter months when daylight is limited (ref_id: 0)\n", |
| 422 | + "Agent response: The differences in nighttime brightness between suburban belts and urban cores can be attributed to several factors:\n", |
| 423 | + "\n", |
| 424 | + "1\n", |
| 425 | + " **December Brightening**: Suburban areas tend to have a greater relative increase in brightness during December due to seasonal decorations, festive lighting, and residential activity\n", |
| 426 | + " In contrast, urban cores may have higher absolute light levels due to commercial lighting, but the types of light and their arrangement can lead to a less pronounced increase compared to the festive displays in suburban settings\n", |
| 427 | + " Urban centers often focus on commercial light sources that may not display the same wide variability in illumination as residential areas do during holidays (Source: ref_id 0)\n", |
| 428 | + "\n", |
| 429 | + "\n", |
| 430 | + "2\n", |
| 431 | + " **Visibility of Phoenix's Nighttime Grid**: The sharp visibility of the Phoenix nighttime street grid from space can be attributed to its planned urban layout, which features a grid pattern of streets and blocks that are well-illuminated\n", |
| 432 | + " This grid is a result of urban design that promotes easy navigation and access, leading to concentrated bright spots along major streets and intersections\n", |
| 433 | + " In contrast, the interstate stretches in the Midwest tend to connect larger rural areas with fewer lighted nodes due to the sparser population and fewer urban developments, making those areas appear relatively dim from space (Source: ref_id 1)\n", |
427 | 434 | "\n", |
428 | 435 | "\n", |
429 | | - "As for Phoenix, the sharp visibility of its nighttime street grid from space can be attributed to its organized urban layout and the prevalence of street lighting along major transportation corridors\n", |
430 | | - " The city is laid out in a regular grid pattern with a focus on facilitating traffic flow, leading to bright illumination along these streets\n", |
431 | | - " This contrasts with large stretches of interstate highways between Midwestern cities, where the rural nature and lower population density result in significantly less light\n", |
432 | | - " In these areas, fewer urban centers and residential developments lead to darker patches, making them less visible from space compared to densely lit urban areas like Phoenix (ref_id: 1)\n", |
| 436 | + "The differences in light patterns between urban and suburban areas, alongside the planned layouts of cities like Phoenix, significantly influence how they are perceived in nighttime satellite imagery\n", |
433 | 437 | "\n" |
434 | 438 | ] |
435 | 439 | } |
|
464 | 468 | }, |
465 | 469 | { |
466 | 470 | "cell_type": "code", |
467 | | - "execution_count": 17, |
| 471 | + "execution_count": 9, |
468 | 472 | "id": "7b90fefa", |
469 | 473 | "metadata": {}, |
470 | 474 | "outputs": [ |
|
478 | 482 | " \"id\": 0,\n", |
479 | 483 | " \"type\": \"ModelQueryPlanning\",\n", |
480 | 484 | " \"input_tokens\": 1265,\n", |
481 | | - " \"output_tokens\": 271\n", |
| 485 | + " \"output_tokens\": 277\n", |
482 | 486 | " },\n", |
483 | 487 | " {\n", |
484 | 488 | " \"id\": 1,\n", |
|
487 | 491 | " \"query\": {\n", |
488 | 492 | " \"search\": \"suburban belts December brightening urban cores comparison\"\n", |
489 | 493 | " },\n", |
490 | | - " \"query_time\": \"2025-05-11T05:19:00.563Z\",\n", |
| 494 | + " \"query_time\": \"2025-05-13T22:22:45.368Z\",\n", |
491 | 495 | " \"count\": 0,\n", |
492 | | - " \"elapsed_ms\": 354\n", |
| 496 | + " \"elapsed_ms\": 350\n", |
493 | 497 | " },\n", |
494 | 498 | " {\n", |
495 | 499 | " \"id\": 2,\n", |
|
498 | 502 | " \"query\": {\n", |
499 | 503 | " \"search\": \"Phoenix nighttime street grid visibility from space\"\n", |
500 | 504 | " },\n", |
501 | | - " \"query_time\": \"2025-05-11T05:19:00.890Z\",\n", |
| 505 | + " \"query_time\": \"2025-05-13T22:22:45.682Z\",\n", |
502 | 506 | " \"count\": 2,\n", |
503 | | - " \"elapsed_ms\": 314\n", |
| 507 | + " \"elapsed_ms\": 304\n", |
504 | 508 | " },\n", |
505 | 509 | " {\n", |
506 | 510 | " \"id\": 3,\n", |
|
509 | 513 | " \"query\": {\n", |
510 | 514 | " \"search\": \"interstate visibility from space midwestern cities\"\n", |
511 | 515 | " },\n", |
512 | | - " \"query_time\": \"2025-05-11T05:19:01.133Z\",\n", |
| 516 | + " \"query_time\": \"2025-05-13T22:22:45.977Z\",\n", |
513 | 517 | " \"count\": 2,\n", |
514 | | - " \"elapsed_ms\": 241\n", |
| 518 | + " \"elapsed_ms\": 291\n", |
515 | 519 | " },\n", |
516 | 520 | " {\n", |
517 | 521 | " \"id\": 4,\n", |
518 | 522 | " \"type\": \"AzureSearchSemanticRanker\",\n", |
519 | | - " \"input_tokens\": 74735\n", |
| 523 | + " \"input_tokens\": 74224\n", |
520 | 524 | " }\n", |
521 | 525 | "]\n", |
522 | 526 | "Retrieval results\n", |
|
571 | 575 | }, |
572 | 576 | { |
573 | 577 | "cell_type": "code", |
574 | | - "execution_count": 18, |
| 578 | + "execution_count": 10, |
575 | 579 | "id": "d9478191", |
576 | 580 | "metadata": {}, |
577 | 581 | "outputs": [ |
578 | 582 | { |
579 | 583 | "name": "stdout", |
580 | 584 | "output_type": "stream", |
581 | 585 | "text": [ |
582 | | - "Agent response: To find lava at night, you can utilize the distinct glow produced by active lava flows, which can often be visible from considerable distances, especially under sufficient moonlight\n", |
583 | | - " Here are some ways to spot lava at night:\n", |
| 586 | + "Agent response: To find lava at night, you can take advantage of various natural and technological methods:\n", |
584 | 587 | "\n", |
585 | 588 | "1\n", |
586 | | - " **Use Satellite Imagery**: Advanced satellites equipped with thermal imaging can detect the heat emitted from lava flows\n", |
587 | | - " For instance, data from the VIIRS Day/Night Band on polar-orbiting satellites can capture glowing lava, even when the only illumination is moonlight\n", |
588 | | - " Observers looking from space can distinguish the warm glow from lava flows against the cooler landscape\n", |
| 589 | + " **Natural Glow**: Active lava flows produce a significant glow, which can be visible from a distance at night\n", |
| 590 | + " Under good visibility conditions, the bright red-orange light of flowing lava can be seen against the darker landscape\n", |
| 591 | + " Observing this from higher vantage points or from areas with minimal light pollution can enhance visibility\n", |
589 | 592 | "\n", |
590 | 593 | "\n", |
591 | 594 | "2\n", |
592 | | - " **Location of Volcanoes**: Focus on areas known for volcanic activity, such as Mount Etna in Italy or Kilauea in Hawaii\n", |
593 | | - " For example, the eruption of Mount Etna has been photographed at night, showing the bright red and orange hues of flowing lava as a contrast to the surrounding darkness (ref_id: 1)\n", |
594 | | - " \n", |
| 595 | + " **Satellite Imagery**: During nighttime, satellites equipped with capabilities like the VIIRS (Visible Infrared Imaging Radiometer Suite) can capture images of areas with volcanic activity\n", |
| 596 | + " These images show the glow of active lava flows clearly against the background, which highlights volcanic eruptions and their effects\n", |
| 597 | + " For example, images of Mount Etna and Kilauea have shown their lava flows brightly illuminated at night (Source: ref_id 1, ref_id 4)\n", |
| 598 | + "\n", |
595 | 599 | "\n", |
596 | 600 | "3\n", |
597 | | - " **Monitoring for Eruptions**: Stay informed about active volcanoes through geological surveys, which often provide real-time updates on volcanic activity\n", |
598 | | - " During eruptions, lava will glow brightly, making it easier to identify at night\n", |
| 601 | + " **Infrared Imaging**: Thermal imaging can also assist in identifying hot lava spots\n", |
| 602 | + " This method utilizes infrared sensors to detect heat emitted by lava flows, making it effective even in darkness\n", |
| 603 | + " Satellites and drones equipped with thermal cameras can provide detailed imagery showing lava flows and their progression\n", |
599 | 604 | "\n", |
600 | 605 | "\n", |
601 | 606 | "4\n", |
602 | | - " **Natural Light Sources**: Look for lava flows under optimum conditions, such as on nights with a full moon, when the light can enhance visibility\n", |
603 | | - " At night, the unique glow from lava can serve as a key indicator of eruptive activity, as it stands out starkly against the dark surroundings (ref_id: 0)\n", |
| 607 | + " **Safety Considerations**: While observing lava, always prioritize safety\n", |
| 608 | + " Ensure you are at a safe distance from volcanic activity and follow any guidance from local authorities regarding volcanic eruptions\n", |
604 | 609 | "\n", |
605 | 610 | "\n", |
606 | | - "By leveraging these observations and resources, you should be able to locate lava at night effectively\n", |
| 611 | + "In summary, you can find lava at night by looking for its natural glow, using satellite imagery and infrared sensors, and ensuring a safe viewing approach\n", |
607 | 612 | "\n" |
608 | 613 | ] |
609 | 614 | } |
|
633 | 638 | }, |
634 | 639 | { |
635 | 640 | "cell_type": "code", |
636 | | - "execution_count": 19, |
| 641 | + "execution_count": 11, |
637 | 642 | "id": "c063c45e", |
638 | 643 | "metadata": {}, |
639 | 644 | "outputs": [ |
|
646 | 651 | " {\n", |
647 | 652 | " \"id\": 0,\n", |
648 | 653 | " \"type\": \"ModelQueryPlanning\",\n", |
649 | | - " \"input_tokens\": 1532,\n", |
650 | | - " \"output_tokens\": 323\n", |
| 654 | + " \"input_tokens\": 1565,\n", |
| 655 | + " \"output_tokens\": 299\n", |
651 | 656 | " },\n", |
652 | 657 | " {\n", |
653 | 658 | " \"id\": 1,\n", |
|
656 | 661 | " \"query\": {\n", |
657 | 662 | " \"search\": \"how to locate lava flows at night\"\n", |
658 | 663 | " },\n", |
659 | | - " \"query_time\": \"2025-05-11T05:19:16.473Z\",\n", |
| 664 | + " \"query_time\": \"2025-05-13T22:23:07.269Z\",\n", |
660 | 665 | " \"count\": 6,\n", |
661 | | - " \"elapsed_ms\": 528\n", |
| 666 | + " \"elapsed_ms\": 376\n", |
662 | 667 | " },\n", |
663 | 668 | " {\n", |
664 | 669 | " \"id\": 2,\n", |
665 | 670 | " \"type\": \"AzureSearchQuery\",\n", |
666 | 671 | " \"target_index\": \"earth_at_night\",\n", |
667 | 672 | " \"query\": {\n", |
668 | | - " \"search\": \"best tools for finding lava at night\"\n", |
| 673 | + " \"search\": \"best tools for viewing lava at night\"\n", |
669 | 674 | " },\n", |
670 | | - " \"query_time\": \"2025-05-11T05:19:16.766Z\",\n", |
671 | | - " \"count\": 0,\n", |
672 | | - " \"elapsed_ms\": 281\n", |
| 675 | + " \"query_time\": \"2025-05-13T22:23:07.575Z\",\n", |
| 676 | + " \"count\": 1,\n", |
| 677 | + " \"elapsed_ms\": 293\n", |
673 | 678 | " },\n", |
674 | 679 | " {\n", |
675 | 680 | " \"id\": 3,\n", |
676 | 681 | " \"type\": \"AzureSearchQuery\",\n", |
677 | 682 | " \"target_index\": \"earth_at_night\",\n", |
678 | 683 | " \"query\": {\n", |
679 | | - " \"search\": \"safety tips for finding lava at night\"\n", |
| 684 | + " \"search\": \"safety tips for exploring lava at night\"\n", |
680 | 685 | " },\n", |
681 | | - " \"query_time\": \"2025-05-11T05:19:17.037Z\",\n", |
| 686 | + " \"query_time\": \"2025-05-13T22:23:07.857Z\",\n", |
682 | 687 | " \"count\": 0,\n", |
683 | | - " \"elapsed_ms\": 269\n", |
| 688 | + " \"elapsed_ms\": 281\n", |
684 | 689 | " },\n", |
685 | 690 | " {\n", |
686 | 691 | " \"id\": 4,\n", |
687 | 692 | " \"type\": \"AzureSearchSemanticRanker\",\n", |
688 | | - " \"input_tokens\": 71937\n", |
| 693 | + " \"input_tokens\": 70920\n", |
689 | 694 | " }\n", |
690 | 695 | "]\n", |
691 | 696 | "Retrieval results\n", |
|
761 | 766 | }, |
762 | 767 | { |
763 | 768 | "cell_type": "code", |
764 | | - "execution_count": 23, |
| 769 | + "execution_count": 12, |
765 | 770 | "id": "d67f8609", |
766 | 771 | "metadata": {}, |
767 | 772 | "outputs": [ |
|
789 | 794 | }, |
790 | 795 | { |
791 | 796 | "cell_type": "code", |
792 | | - "execution_count": 24, |
| 797 | + "execution_count": 13, |
793 | 798 | "id": "d9895f27", |
794 | 799 | "metadata": {}, |
795 | 800 | "outputs": [ |
|
0 commit comments