Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
108 changes: 51 additions & 57 deletions notebooks/1_scoping.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 35,
"execution_count": 2,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -80,7 +80,7 @@
},
{
"cell_type": "code",
"execution_count": 36,
"execution_count": 3,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -216,7 +216,7 @@
},
{
"cell_type": "code",
"execution_count": 37,
"execution_count": 4,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -314,7 +314,7 @@
},
{
"cell_type": "code",
"execution_count": 38,
"execution_count": 12,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -345,15 +345,18 @@
"from langchain_core.messages import HumanMessage, AIMessage, get_buffer_string\n",
"from langgraph.graph import StateGraph, START, END\n",
"from langgraph.types import Command\n",
"import platform\n",
"\n",
"from deep_research_from_scratch.prompts import clarify_with_user_instructions, transform_messages_into_research_topic_prompt\n",
"from deep_research_from_scratch.state_scope import AgentState, ClarifyWithUser, ResearchQuestion, AgentInputState\n",
"\n",
"# ===== UTILITY FUNCTIONS =====\n",
"\n",
"\n",
"def get_today_str() -> str:\n",
" \"\"\"Get current date in a human-readable format.\"\"\"\n",
" return datetime.now().strftime(\"%a %b %-d, %Y\")\n",
" day_format = \"%-d\" if platform.system() != \"Windows\" else \"%#d\"\n",
" return datetime.now().strftime(f\"%a %b {day_format}, %Y\")\n",
"\n",
"\n",
"# ===== CONFIGURATION =====\n",
"\n",
Expand Down Expand Up @@ -435,7 +438,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 13,
"metadata": {},
"outputs": [
{
Expand All @@ -462,8 +465,10 @@
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"execution_count": 14,
"metadata": {
"scrolled": true
},
"outputs": [
{
"data": {
Expand All @@ -486,14 +491,14 @@
"data": {
"text/html": [
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">╭───────────────────────────────────────────────────── 📝 AI ─────────────────────────────────────────────────────╮</span>\n",
"<span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span> Could you please specify what criteria are most important to you when determining the 'best' coffee shops? For <span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>\n",
"<span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span> Could you clarify what criteria are most important to you when determining the 'best' coffee shops? For <span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>\n",
"<span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span> example, are you interested in coffee quality, ambiance, Wi-Fi availability, food options, or something else? <span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>\n",
"<span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯</span>\n",
"</pre>\n"
],
"text/plain": [
"\u001b[37m╭─\u001b[0m\u001b[37m────────────────────────────────────────────────────\u001b[0m\u001b[37m 📝 AI \u001b[0m\u001b[37m────────────────────────────────────────────────────\u001b[0m\u001b[37m─╮\u001b[0m\n",
"\u001b[37m│\u001b[0m Could you please specify what criteria are most important to you when determining the 'best' coffee shops? For \u001b[37m│\u001b[0m\n",
"\u001b[37m│\u001b[0m Could you clarify what criteria are most important to you when determining the 'best' coffee shops? For \u001b[37m│\u001b[0m\n",
"\u001b[37m│\u001b[0m example, are you interested in coffee quality, ambiance, Wi-Fi availability, food options, or something else? \u001b[37m│\u001b[0m\n",
"\u001b[37m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
]
Expand All @@ -513,7 +518,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 15,
"metadata": {},
"outputs": [
{
Expand All @@ -537,14 +542,14 @@
"data": {
"text/html": [
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">╭───────────────────────────────────────────────────── 📝 AI ─────────────────────────────────────────────────────╮</span>\n",
"<span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span> Could you please specify what criteria are most important to you when determining the 'best' coffee shops? For <span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>\n",
"<span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span> Could you clarify what criteria are most important to you when determining the 'best' coffee shops? For <span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>\n",
"<span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span> example, are you interested in coffee quality, ambiance, Wi-Fi availability, food options, or something else? <span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>\n",
"<span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯</span>\n",
"</pre>\n"
],
"text/plain": [
"\u001b[37m╭─\u001b[0m\u001b[37m────────────────────────────────────────────────────\u001b[0m\u001b[37m 📝 AI \u001b[0m\u001b[37m────────────────────────────────────────────────────\u001b[0m\u001b[37m─╮\u001b[0m\n",
"\u001b[37m│\u001b[0m Could you please specify what criteria are most important to you when determining the 'best' coffee shops? For \u001b[37m│\u001b[0m\n",
"\u001b[37m│\u001b[0m Could you clarify what criteria are most important to you when determining the 'best' coffee shops? For \u001b[37m│\u001b[0m\n",
"\u001b[37m│\u001b[0m example, are you interested in coffee quality, ambiance, Wi-Fi availability, food options, or something else? \u001b[37m│\u001b[0m\n",
"\u001b[37m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
]
Expand Down Expand Up @@ -598,34 +603,36 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 17,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">I want to identify the best coffee shops in San Francisco, focusing specifically on coffee quality as the primary \n",
"criterion. In my research, I would like to consider factors that contribute to coffee quality, such as bean \n",
"sourcing, roasting methods, brewing techniques, and taste as evaluated by expert reviews and customer feedback. \n",
"Other aspects like ambiance, Wi-Fi availability, food options, and price are not specified as important for this \n",
"research and can be treated as flexible or open considerations. Please prioritize information from official coffee \n",
"shop websites, reputable specialty coffee publications, and platforms with credible user reviews (such as Google \n",
"Reviews or Yelp), but do not rely solely on aggregator or SEO-driven blogs. The goal is to compile a list of top \n",
"San Francisco coffee shops distinguished by the quality of their coffee, as of August 2025. \n",
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">I want to identify and evaluate the best coffee shops in San Francisco, focusing specifically on coffee quality as \n",
"the primary criterion. In my research, I will consider factors that contribute to coffee quality, such as bean \n",
"sourcing, roasting methods, brewing techniques, and taste as reflected in expert reviews and customer feedback. I \n",
"have not specified preferences regarding ambiance, Wi-Fi availability, food options, price range, or location \n",
"within San Francisco, so these aspects should be treated as open considerations and not prioritized unless they \n",
"directly impact coffee quality. I prefer to reference official coffee shop websites, reputable review platforms \n",
"(such as Yelp, Google Reviews, or Coffee Review), and expert sources for information on coffee quality. The goal is\n",
"to compile a list of top San Francisco coffee shops distinguished by the quality of their coffee, as of August \n",
"2025. \n",
"</pre>\n"
],
"text/plain": [
"I want to identify the best coffee shops in San Francisco, focusing specifically on coffee quality as the primary \n",
"criterion. In my research, I would like to consider factors that contribute to coffee quality, such as bean \n",
"sourcing, roasting methods, brewing techniques, and taste as evaluated by expert reviews and customer feedback. \n",
"Other aspects like ambiance, Wi-Fi availability, food options, and price are not specified as important for this \n",
"research and can be treated as flexible or open considerations. Please prioritize information from official coffee \n",
"shop websites, reputable specialty coffee publications, and platforms with credible user reviews (such as Google \n",
"Reviews or Yelp), but do not rely solely on aggregator or SEO-driven blogs. The goal is to compile a list of top \n",
"San Francisco coffee shops distinguished by the quality of their coffee, as of August 2025. \n"
"I want to identify and evaluate the best coffee shops in San Francisco, focusing specifically on coffee quality as \n",
"the primary criterion. In my research, I will consider factors that contribute to coffee quality, such as bean \n",
"sourcing, roasting methods, brewing techniques, and taste as reflected in expert reviews and customer feedback. I \n",
"have not specified preferences regarding ambiance, Wi-Fi availability, food options, price range, or location \n",
"within San Francisco, so these aspects should be treated as open considerations and not prioritized unless they \n",
"directly impact coffee quality. I prefer to reference official coffee shop websites, reputable review platforms \n",
"(such as Yelp, Google Reviews, or Coffee Review), and expert sources for information on coffee quality. The goal is\n",
"to compile a list of top San Francisco coffee shops distinguished by the quality of their coffee, as of August \n",
"2025. \n"
]
},
"execution_count": 7,
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
Expand Down Expand Up @@ -688,7 +695,7 @@
},
{
"cell_type": "code",
"execution_count": 23,
"execution_count": 18,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -716,7 +723,7 @@
},
{
"cell_type": "code",
"execution_count": 24,
"execution_count": 19,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -767,7 +774,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 20,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -848,7 +855,7 @@
},
{
"cell_type": "code",
"execution_count": 26,
"execution_count": 21,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -1014,7 +1021,7 @@
},
{
"cell_type": "code",
"execution_count": 27,
"execution_count": 22,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -1109,7 +1116,7 @@
},
{
"cell_type": "code",
"execution_count": 28,
"execution_count": 23,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -1271,7 +1278,7 @@
},
{
"cell_type": "code",
"execution_count": 29,
"execution_count": 24,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -1335,23 +1342,23 @@
},
{
"cell_type": "code",
"execution_count": 31,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"View the evaluation results for experiment: 'Deep Research Scoping-0256c122' at:\n",
"https://smith.langchain.com/o/ebbaf2eb-769b-4505-aca2-d11de10372a4/datasets/2b9a1e38-3967-4bcc-a392-f4ca242cdd02/compare?selectedSessions=8b0e39ae-d8ed-448c-81bd-9f9d824366e2\n",
"View the evaluation results for experiment: 'Deep Research Scoping-3f0466d3' at:\n",
"https://smith.langchain.com/o/ea6bee4b-d859-4526-9f9f-9864ca86fcf3/datasets/a5b469ca-f394-4eb1-ab5e-0053f9250507/compare?selectedSessions=df1a31c7-2d1d-4713-984a-aed2b9b32749\n",
"\n",
"\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "ebd9fd0be3db4f26964382ae770e7b6d",
"model_id": "70bf16d1f2964ce9abd0d404e52f2140",
"version_major": 2,
"version_minor": 0
},
Expand All @@ -1361,19 +1368,6 @@
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<ExperimentResults Deep Research Scoping-0256c122>"
],
"text/plain": [
"<ExperimentResults Deep Research Scoping-0256c122>"
]
},
"execution_count": 31,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
Expand Down Expand Up @@ -1423,7 +1417,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.13.1"
"version": "3.12.6"
}
},
"nbformat": 4,
Expand Down
Loading