Langraph Agents¶
!pip install langchain langgraph langchain_openai langchainhub langsmith ddgs beautifulsoup4 python-dotenv
Requirement already satisfied: langchain in /opt/homebrew/anaconda3/envs/dev_may2025/lib/python3.11/site-packages (0.3.26) Requirement already satisfied: langgraph in /opt/homebrew/anaconda3/envs/dev_may2025/lib/python3.11/site-packages (0.5.3) Requirement already satisfied: langchain_openai in /opt/homebrew/anaconda3/envs/dev_may2025/lib/python3.11/site-packages (0.3.28) Requirement already satisfied: langchainhub in /opt/homebrew/anaconda3/envs/dev_may2025/lib/python3.11/site-packages (0.1.21) Requirement already satisfied: langsmith in /opt/homebrew/anaconda3/envs/dev_may2025/lib/python3.11/site-packages (0.4.6) Requirement already satisfied: ddgs in /opt/homebrew/anaconda3/envs/dev_may2025/lib/python3.11/site-packages (9.2.3) Requirement already satisfied: beautifulsoup4 in /opt/homebrew/anaconda3/envs/dev_may2025/lib/python3.11/site-packages (4.13.4) Requirement already satisfied: python-dotenv in /opt/homebrew/anaconda3/envs/dev_may2025/lib/python3.11/site-packages (1.1.1) Requirement already satisfied: langchain-core<1.0.0,>=0.3.66 in /opt/homebrew/anaconda3/envs/dev_may2025/lib/python3.11/site-packages (from langchain) (0.3.69) Requirement already satisfied: langchain-text-splitters<1.0.0,>=0.3.8 in /opt/homebrew/anaconda3/envs/dev_may2025/lib/python3.11/site-packages (from langchain) (0.3.8) Requirement already satisfied: pydantic<3.0.0,>=2.7.4 in /opt/homebrew/anaconda3/envs/dev_may2025/lib/python3.11/site-packages (from langchain) (2.11.7) Requirement already satisfied: SQLAlchemy<3,>=1.4 in /opt/homebrew/anaconda3/envs/dev_may2025/lib/python3.11/site-packages (from langchain) (2.0.41) Requirement already satisfied: requests<3,>=2 in /opt/homebrew/anaconda3/envs/dev_may2025/lib/python3.11/site-packages (from langchain) (2.32.3) Requirement already satisfied: PyYAML>=5.3 in /opt/homebrew/anaconda3/envs/dev_may2025/lib/python3.11/site-packages (from langchain) (6.0.2) Requirement already satisfied: tenacity!=8.4.0,<10.0.0,>=8.1.0 in /opt/homebrew/anaconda3/envs/dev_may2025/lib/python3.11/site-packages (from langchain-core<1.0.0,>=0.3.66->langchain) (9.1.2) Requirement already satisfied: jsonpatch<2.0,>=1.33 in /opt/homebrew/anaconda3/envs/dev_may2025/lib/python3.11/site-packages (from langchain-core<1.0.0,>=0.3.66->langchain) (1.33) Requirement already satisfied: typing-extensions>=4.7 in /opt/homebrew/anaconda3/envs/dev_may2025/lib/python3.11/site-packages (from langchain-core<1.0.0,>=0.3.66->langchain) (4.12.2) Requirement already satisfied: packaging>=23.2 in /opt/homebrew/anaconda3/envs/dev_may2025/lib/python3.11/site-packages (from langchain-core<1.0.0,>=0.3.66->langchain) (24.2) Requirement already satisfied: jsonpointer>=1.9 in /opt/homebrew/anaconda3/envs/dev_may2025/lib/python3.11/site-packages (from jsonpatch<2.0,>=1.33->langchain-core<1.0.0,>=0.3.66->langchain) (2.0) Requirement already satisfied: annotated-types>=0.6.0 in /opt/homebrew/anaconda3/envs/dev_may2025/lib/python3.11/site-packages (from pydantic<3.0.0,>=2.7.4->langchain) (0.7.0) Requirement already satisfied: pydantic-core==2.33.2 in /opt/homebrew/anaconda3/envs/dev_may2025/lib/python3.11/site-packages (from pydantic<3.0.0,>=2.7.4->langchain) (2.33.2) Requirement already satisfied: typing-inspection>=0.4.0 in /opt/homebrew/anaconda3/envs/dev_may2025/lib/python3.11/site-packages (from pydantic<3.0.0,>=2.7.4->langchain) (0.4.1) Requirement already satisfied: charset_normalizer<4,>=2 in /opt/homebrew/anaconda3/envs/dev_may2025/lib/python3.11/site-packages (from requests<3,>=2->langchain) (3.4.2) Requirement already satisfied: idna<4,>=2.5 in /opt/homebrew/anaconda3/envs/dev_may2025/lib/python3.11/site-packages (from requests<3,>=2->langchain) (3.10) Requirement already satisfied: urllib3<3,>=1.21.1 in /opt/homebrew/anaconda3/envs/dev_may2025/lib/python3.11/site-packages (from requests<3,>=2->langchain) (2.4.0) Requirement already satisfied: certifi>=2017.4.17 in /opt/homebrew/anaconda3/envs/dev_may2025/lib/python3.11/site-packages (from requests<3,>=2->langchain) (2025.4.26) Requirement already satisfied: langgraph-checkpoint<3.0.0,>=2.1.0 in /opt/homebrew/anaconda3/envs/dev_may2025/lib/python3.11/site-packages (from langgraph) (2.1.0) Requirement already satisfied: langgraph-prebuilt<0.6.0,>=0.5.0 in /opt/homebrew/anaconda3/envs/dev_may2025/lib/python3.11/site-packages (from langgraph) (0.5.2) Requirement already satisfied: langgraph-sdk<0.2.0,>=0.1.42 in /opt/homebrew/anaconda3/envs/dev_may2025/lib/python3.11/site-packages (from langgraph) (0.1.73) Requirement already satisfied: xxhash>=3.5.0 in /opt/homebrew/anaconda3/envs/dev_may2025/lib/python3.11/site-packages (from langgraph) (3.5.0) Requirement already satisfied: ormsgpack>=1.10.0 in /opt/homebrew/anaconda3/envs/dev_may2025/lib/python3.11/site-packages (from langgraph-checkpoint<3.0.0,>=2.1.0->langgraph) (1.10.0) Requirement already satisfied: httpx>=0.25.2 in /opt/homebrew/anaconda3/envs/dev_may2025/lib/python3.11/site-packages (from langgraph-sdk<0.2.0,>=0.1.42->langgraph) (0.28.1) Requirement already satisfied: orjson>=3.10.1 in /opt/homebrew/anaconda3/envs/dev_may2025/lib/python3.11/site-packages (from langgraph-sdk<0.2.0,>=0.1.42->langgraph) (3.11.0) Requirement already satisfied: openai<2.0.0,>=1.86.0 in /opt/homebrew/anaconda3/envs/dev_may2025/lib/python3.11/site-packages (from langchain_openai) (1.96.1) Requirement already satisfied: tiktoken<1,>=0.7 in /opt/homebrew/anaconda3/envs/dev_may2025/lib/python3.11/site-packages (from langchain_openai) (0.9.0) Requirement already satisfied: anyio<5,>=3.5.0 in /opt/homebrew/anaconda3/envs/dev_may2025/lib/python3.11/site-packages (from openai<2.0.0,>=1.86.0->langchain_openai) (4.9.0) Requirement already satisfied: distro<2,>=1.7.0 in /opt/homebrew/anaconda3/envs/dev_may2025/lib/python3.11/site-packages (from openai<2.0.0,>=1.86.0->langchain_openai) (1.9.0) Requirement already satisfied: jiter<1,>=0.4.0 in /opt/homebrew/anaconda3/envs/dev_may2025/lib/python3.11/site-packages (from openai<2.0.0,>=1.86.0->langchain_openai) (0.10.0) Requirement already satisfied: sniffio in /opt/homebrew/anaconda3/envs/dev_may2025/lib/python3.11/site-packages (from openai<2.0.0,>=1.86.0->langchain_openai) (1.3.1) Requirement already satisfied: tqdm>4 in /opt/homebrew/anaconda3/envs/dev_may2025/lib/python3.11/site-packages (from openai<2.0.0,>=1.86.0->langchain_openai) (4.67.1) Requirement already satisfied: httpcore==1.* in /opt/homebrew/anaconda3/envs/dev_may2025/lib/python3.11/site-packages (from httpx>=0.25.2->langgraph-sdk<0.2.0,>=0.1.42->langgraph) (1.0.9) Requirement already satisfied: h11>=0.16 in /opt/homebrew/anaconda3/envs/dev_may2025/lib/python3.11/site-packages (from httpcore==1.*->httpx>=0.25.2->langgraph-sdk<0.2.0,>=0.1.42->langgraph) (0.16.0) Requirement already satisfied: regex>=2022.1.18 in /opt/homebrew/anaconda3/envs/dev_may2025/lib/python3.11/site-packages (from tiktoken<1,>=0.7->langchain_openai) (2024.11.6) Requirement already satisfied: types-requests<3.0.0.0,>=2.31.0.2 in /opt/homebrew/anaconda3/envs/dev_may2025/lib/python3.11/site-packages (from langchainhub) (2.32.4.20250611) Requirement already satisfied: requests-toolbelt<2.0.0,>=1.0.0 in /opt/homebrew/anaconda3/envs/dev_may2025/lib/python3.11/site-packages (from langsmith) (1.0.0) Requirement already satisfied: zstandard<0.24.0,>=0.23.0 in /opt/homebrew/anaconda3/envs/dev_may2025/lib/python3.11/site-packages (from langsmith) (0.23.0) Requirement already satisfied: click>=8.1.8 in /opt/homebrew/anaconda3/envs/dev_may2025/lib/python3.11/site-packages (from ddgs) (8.2.1) Requirement already satisfied: primp>=0.15.0 in /opt/homebrew/anaconda3/envs/dev_may2025/lib/python3.11/site-packages (from ddgs) (0.15.0) Requirement already satisfied: lxml>=5.3.0 in /opt/homebrew/anaconda3/envs/dev_may2025/lib/python3.11/site-packages (from ddgs) (5.4.0) Requirement already satisfied: soupsieve>1.2 in /opt/homebrew/anaconda3/envs/dev_may2025/lib/python3.11/site-packages (from beautifulsoup4) (2.7)
!pip install --upgrade pip
Requirement already satisfied: pip in /opt/homebrew/anaconda3/envs/dev_may2025/lib/python3.11/site-packages (25.1.1)
from dotenv import load_dotenv
import os
load_dotenv()
print(f"Open AI API Key string of length {len(os.getenv('OPENAI_API_KEY'))} now loaded")
Open AI API Key string of length 164 now loaded
import functools, operator, requests
from bs4 import BeautifulSoup
from ddgs import DDGS
from langchain.agents import AgentExecutor, create_openai_tools_agent
from langchain_core.messages import BaseMessage, HumanMessage
from langchain.output_parsers.openai_functions import JsonOutputFunctionsParser
from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder
from langgraph.graph import StateGraph, END
from langchain.tools import tool
from langchain_openai import ChatOpenAI
import asyncio
llm = ChatOpenAI(model="gpt-4-turbo-preview")
Specify tools¶
We will expose the following tools for the agent:
duckduckgo_search- to search the net using DuckDuckGoprocess_webpage_contents- process the content scraped from the website
@tool("duckduckgo_search", return_direct=False)
def duckduckgo_search(query:str) -> str:
""" Search the Internet using DuckDuckGo """
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
try:
with DDGS() as ddgs:
results = [r for r in ddgs.text(query, max_results=5)]
return results if results else "No results found"
finally:
loop.close()
@tool("process_webpage_contents", return_direct=False)
def process_webpage_contents(url: str) -> str:
""" Process the contents of a web-page with proper error handling """
try:
# Add timeout and user-agent header for better compatibility
headers = {'User-Agent': 'Mozilla/5.0'}
response = requests.get(url, headers=headers, timeout=10)
response.raise_for_status() # Check for HTTP errors
# Handle potential encoding issues
response.encoding = response.apparent_encoding
soup = BeautifulSoup(response.text, 'lxml')
# Clean up the extracted text
text = soup.get_text()
return text.strip() if text.strip() else "No content found"
except requests.exceptions.RequestException as e:
return f"Request failed: {str(e)}"
except Exception as e:
return f"Error processing webpage: {str(e)}"
tools = [duckduckgo_search, process_webpage_contents]
Sanity Check¶
Try out the functions to smoke-test them
duckduckgo_search('1kg to lbs')
/var/folders/n3/_42h80jd6pqg_s660dlzs3400000gn/T/ipykernel_23413/452278208.py:1: LangChainDeprecationWarning: The method `BaseTool.__call__` was deprecated in langchain-core 0.1.47 and will be removed in 1.0. Use :meth:`~invoke` instead.
duckduckgo_search('1kg to lbs')
[{'title': 'kg to lbs | convert kg to pounds',
'href': 'https://www.rapidtables.com/convert/weight/kg-to-pound.html',
'body': 'One kilogram is equal to 1000 grams (g). One kilogram is equal to 2.205 pounds (lbs).'},
{'title': 'Convert kg to lbs',
'href': 'https://www.unitconverters.net/weight-and-mass/kg-to-lbs.htm',
'body': '1 kg = 2.2046226218 lbs 1 lbs = 0.45359237 kg Example: convert 15 kg to lbs: 15 kg = 15 × 2.2046226218 lbs = 33.0693393277 lbs'},
{'title': 'kg to lbs Converter | Convert Kilograms to Pounds',
'href': 'https://www.omnicalculator.com/conversion/kg-to-lbs-converter',
'body': 'The conversion factor to keep in mind is 1 kg = 2.2046 lbs . Note that the symbol for kilograms is kg, and the symbol for pounds is lbs.'},
{'title': 'KgtoLbs converter',
'href': 'https://www.kg-to-lbs.com/?v=1.0.22',
'body': 'KgtoLbs converter. Easily convert Kilograms to pounds, with formula, conversion chart, auto conversion to common weights, more.'},
{'title': 'Kilograms to pounds (kgtolbs) converter',
'href': 'https://www.mega-calculator.com/conversion/kg-to-lbs/',
'body': 'A kgtolbs converter is an online tool or calculator that allows users to easily and accurately convert kilograms into pounds.An easy method for mental conversion is to remember that 1kg is approximately equal to 2.2 lbs.'}]
print(process_webpage_contents("https://biswa.info"))
Hi, I am Biswa; a software dev currently in Sydney, AustraliaYou can reach me at:Or, Send a messageLoading Message Form...
Create Agents and Link them¶
We'll create the following agents:
- Agent to search the web using the ddgs tool above
- Agent to analyse the search results and process insights from above by reviewing their contents
- A Supervisor agent who feeds the tasks to the two agents above
def create_agent(llm: ChatOpenAI, tools: list, system_prompt:str):
prompt = ChatPromptTemplate.from_messages(
[
("system", system_prompt),
MessagesPlaceholder(variable_name="messages"),
MessagesPlaceholder(variable_name="agent_scratchpad"),
]
)
print(f"Prompt for create_agent: {prompt}\n---------------\n")
agent = create_openai_tools_agent(llm, tools, prompt)
executor = AgentExecutor(agent=agent, tools=tools)
return executor
Now we define a function which invokes an agent with a task
def invoke_agent(state, agent, name):
result = agent.invoke(state)
return {
"messages": [ HumanMessage(content=result["output"], name=name) ] # output
}
Instantiate the agents as partial funcs (with config arguments pre-specified) to tailor their behaviour
# Common instructions to limit tokens
token_limit_system = (
"IMPORTANT CONSTRAINTS:\n"
"1. Keep all responses under 2000 tokens\n"
"2. For long content, provide summaries first then ask if user wants details\n"
"3. Break complex tasks into smaller steps\n"
"4. Use bullet points instead of paragraphs where possible\n"
"5. Limit examples to 1 per concept\n"
)
early_response_system = (
"RESPONSE PROTOCOL:\n"
"1. Provide partial results immediately when available\n"
"2. After initial quick response, continue working and provide updates\n"
"3. For research tasks:\n"
" a) First return search strategy (within 300 tokens)\n"
" b) Then return partial results as found\n"
" c) Finally return complete analysis\n"
"4. Use progressive disclosure pattern:\n"
" - First 1-2 key insights\n"
" - Then offer to provide full details if needed\n"
)
search_agent_id = "Web_Searcher"
search_agent_instructions="""
You are an advanced web search researcher with expert-level knowledge in information retrieval.
Your task is to perform comprehensive and precise web searches to find accurate and relevant information.
Guidelines for high-accuracy searching:
1. Analyze the user's query carefully to identify key concepts and relevant keywords
2. Formulate multiple search queries with different variations to ensure comprehensive coverage
3. Prioritize recent, authoritative sources from reputable domains
4. Use advanced search techniques including:
- Boolean operators (AND, OR, NOT)
- Phrase searching (quotation marks)
- Site-specific searches when appropriate
- Date range limitations for time-sensitive queries
- Filetype specifications when needed
5. Refine search terms iteratively based on initial results
6. For ambiguous queries, ask clarifying questions to improve search focus
7. Evaluate results for relevance, credibility, and recency
When searching:
- First return search terms being used (brief confirmation)
- Then return first 2-3 results immediately
- Continue searching and provide updates every 2-3 results found
- Offer to provide full set at end
Provide concise, accurate answers with proper attribution to sources.
""" + token_limit_system + early_response_system
search_agent = create_agent(llm, tools, search_agent_instructions)
search_agent_exec = functools.partial(invoke_agent, agent=search_agent, name=search_agent_id) # State arg is remaining
Prompt for create_agent: input_variables=['agent_scratchpad', 'messages'] input_types={'messages': list[typing.Annotated[typing.Union[typing.Annotated[langchain_core.messages.ai.AIMessage, Tag(tag='ai')], typing.Annotated[langchain_core.messages.human.HumanMessage, Tag(tag='human')], typing.Annotated[langchain_core.messages.chat.ChatMessage, Tag(tag='chat')], typing.Annotated[langchain_core.messages.system.SystemMessage, Tag(tag='system')], typing.Annotated[langchain_core.messages.function.FunctionMessage, Tag(tag='function')], typing.Annotated[langchain_core.messages.tool.ToolMessage, Tag(tag='tool')], typing.Annotated[langchain_core.messages.ai.AIMessageChunk, Tag(tag='AIMessageChunk')], typing.Annotated[langchain_core.messages.human.HumanMessageChunk, Tag(tag='HumanMessageChunk')], typing.Annotated[langchain_core.messages.chat.ChatMessageChunk, Tag(tag='ChatMessageChunk')], typing.Annotated[langchain_core.messages.system.SystemMessageChunk, Tag(tag='SystemMessageChunk')], typing.Annotated[langchain_core.messages.function.FunctionMessageChunk, Tag(tag='FunctionMessageChunk')], typing.Annotated[langchain_core.messages.tool.ToolMessageChunk, Tag(tag='ToolMessageChunk')]], FieldInfo(annotation=NoneType, required=True, discriminator=Discriminator(discriminator=, custom_error_type=None, custom_error_message=None, custom_error_context=None))]], 'agent_scratchpad': list[typing.Annotated[typing.Union[typing.Annotated[langchain_core.messages.ai.AIMessage, Tag(tag='ai')], typing.Annotated[langchain_core.messages.human.HumanMessage, Tag(tag='human')], typing.Annotated[langchain_core.messages.chat.ChatMessage, Tag(tag='chat')], typing.Annotated[langchain_core.messages.system.SystemMessage, Tag(tag='system')], typing.Annotated[langchain_core.messages.function.FunctionMessage, Tag(tag='function')], typing.Annotated[langchain_core.messages.tool.ToolMessage, Tag(tag='tool')], typing.Annotated[langchain_core.messages.ai.AIMessageChunk, Tag(tag='AIMessageChunk')], typing.Annotated[langchain_core.messages.human.HumanMessageChunk, Tag(tag='HumanMessageChunk')], typing.Annotated[langchain_core.messages.chat.ChatMessageChunk, Tag(tag='ChatMessageChunk')], typing.Annotated[langchain_core.messages.system.SystemMessageChunk, Tag(tag='SystemMessageChunk')], typing.Annotated[langchain_core.messages.function.FunctionMessageChunk, Tag(tag='FunctionMessageChunk')], typing.Annotated[langchain_core.messages.tool.ToolMessageChunk, Tag(tag='ToolMessageChunk')]], FieldInfo(annotation=NoneType, required=True, discriminator=Discriminator(discriminator=, custom_error_type=None, custom_error_message=None, custom_error_context=None))]]} partial_variables={} messages=[SystemMessagePromptTemplate(prompt=PromptTemplate(input_variables=[], input_types={}, partial_variables={}, template="\nYou are an advanced web search researcher with expert-level knowledge in information retrieval.\nYour task is to perform comprehensive and precise web searches to find accurate and relevant information.\n\nGuidelines for high-accuracy searching:\n1. Analyze the user's query carefully to identify key concepts and relevant keywords\n2. Formulate multiple search queries with different variations to ensure comprehensive coverage\n3. Prioritize recent, authoritative sources from reputable domains\n4. Use advanced search techniques including:\n - Boolean operators (AND, OR, NOT)\n - Phrase searching (quotation marks)\n - Site-specific searches when appropriate\n - Date range limitations for time-sensitive queries\n - Filetype specifications when needed\n5. Refine search terms iteratively based on initial results\n6. For ambiguous queries, ask clarifying questions to improve search focus\n7. Evaluate results for relevance, credibility, and recency\n\nWhen searching:\n- First return search terms being used (brief confirmation)\n- Then return first 2-3 results immediately\n- Continue searching and provide updates every 2-3 results found\n- Offer to provide full set at end\n\nProvide concise, accurate answers with proper attribution to sources.\nIMPORTANT CONSTRAINTS:\n1. Keep all responses under 2000 tokens\n2. For long content, provide summaries first then ask if user wants details\n3. Break complex tasks into smaller steps\n4. Use bullet points instead of paragraphs where possible\n5. Limit examples to 1 per concept\nRESPONSE PROTOCOL:\n1. Provide partial results immediately when available\n2. After initial quick response, continue working and provide updates\n3. For research tasks:\n a) First return search strategy (within 300 tokens)\n b) Then return partial results as found\n c) Finally return complete analysis\n4. Use progressive disclosure pattern:\n - First 1-2 key insights\n - Then offer to provide full details if needed\n"), additional_kwargs={}), MessagesPlaceholder(variable_name='messages'), MessagesPlaceholder(variable_name='agent_scratchpad')]
---------------
Next is the analyser agent
analyser_agent_id = "Insight_Reseaercher"
analyser_agent_instructions = (
"You are an Insights Researcher. Your only tasks are:\n"
"1. Quick Scan: Briefly review content to identify 2-3 key topics\n"
"2. Targeted Search: Find 1-2 high-quality sources per topic\n"
"3. Simple Insights: Extract 1 key insight per topic with source\n"
"\n"
"Rules:\n"
"- Keep responses under 300 tokens\n"
"- Use bullet points, not paragraphs\n"
"- First show main findings, details only if asked\n"
"- Only search when you have specific topics to investigate\n"
"\n"
"Format for all responses:\n"
"Key Topics: [brief list]\n"
"Main Insights:\n"
"- [Insight 1 with source]\n"
"- [Insight 2 with source]\n"
"Need more detail on any topic?\n"
) + token_limit_system + early_response_system
analyser_agent = create_agent(llm, tools, analyser_agent_instructions)
analyser_agent_exec = functools.partial(invoke_agent, agent=analyser_agent, name=analyser_agent_id) # State arg is pending
Prompt for create_agent: input_variables=['agent_scratchpad', 'messages'] input_types={'messages': list[typing.Annotated[typing.Union[typing.Annotated[langchain_core.messages.ai.AIMessage, Tag(tag='ai')], typing.Annotated[langchain_core.messages.human.HumanMessage, Tag(tag='human')], typing.Annotated[langchain_core.messages.chat.ChatMessage, Tag(tag='chat')], typing.Annotated[langchain_core.messages.system.SystemMessage, Tag(tag='system')], typing.Annotated[langchain_core.messages.function.FunctionMessage, Tag(tag='function')], typing.Annotated[langchain_core.messages.tool.ToolMessage, Tag(tag='tool')], typing.Annotated[langchain_core.messages.ai.AIMessageChunk, Tag(tag='AIMessageChunk')], typing.Annotated[langchain_core.messages.human.HumanMessageChunk, Tag(tag='HumanMessageChunk')], typing.Annotated[langchain_core.messages.chat.ChatMessageChunk, Tag(tag='ChatMessageChunk')], typing.Annotated[langchain_core.messages.system.SystemMessageChunk, Tag(tag='SystemMessageChunk')], typing.Annotated[langchain_core.messages.function.FunctionMessageChunk, Tag(tag='FunctionMessageChunk')], typing.Annotated[langchain_core.messages.tool.ToolMessageChunk, Tag(tag='ToolMessageChunk')]], FieldInfo(annotation=NoneType, required=True, discriminator=Discriminator(discriminator=, custom_error_type=None, custom_error_message=None, custom_error_context=None))]], 'agent_scratchpad': list[typing.Annotated[typing.Union[typing.Annotated[langchain_core.messages.ai.AIMessage, Tag(tag='ai')], typing.Annotated[langchain_core.messages.human.HumanMessage, Tag(tag='human')], typing.Annotated[langchain_core.messages.chat.ChatMessage, Tag(tag='chat')], typing.Annotated[langchain_core.messages.system.SystemMessage, Tag(tag='system')], typing.Annotated[langchain_core.messages.function.FunctionMessage, Tag(tag='function')], typing.Annotated[langchain_core.messages.tool.ToolMessage, Tag(tag='tool')], typing.Annotated[langchain_core.messages.ai.AIMessageChunk, Tag(tag='AIMessageChunk')], typing.Annotated[langchain_core.messages.human.HumanMessageChunk, Tag(tag='HumanMessageChunk')], typing.Annotated[langchain_core.messages.chat.ChatMessageChunk, Tag(tag='ChatMessageChunk')], typing.Annotated[langchain_core.messages.system.SystemMessageChunk, Tag(tag='SystemMessageChunk')], typing.Annotated[langchain_core.messages.function.FunctionMessageChunk, Tag(tag='FunctionMessageChunk')], typing.Annotated[langchain_core.messages.tool.ToolMessageChunk, Tag(tag='ToolMessageChunk')]], FieldInfo(annotation=NoneType, required=True, discriminator=Discriminator(discriminator=, custom_error_type=None, custom_error_message=None, custom_error_context=None))]]} partial_variables={} messages=[SystemMessagePromptTemplate(prompt=PromptTemplate(input_variables=[], input_types={}, partial_variables={}, template='You are an Insights Researcher. Your only tasks are:\n1. Quick Scan: Briefly review content to identify 2-3 key topics\n2. Targeted Search: Find 1-2 high-quality sources per topic\n3. Simple Insights: Extract 1 key insight per topic with source\n\nRules:\n- Keep responses under 300 tokens\n- Use bullet points, not paragraphs\n- First show main findings, details only if asked\n- Only search when you have specific topics to investigate\n\nFormat for all responses:\nKey Topics: [brief list]\nMain Insights:\n- [Insight 1 with source]\n- [Insight 2 with source]\nNeed more detail on any topic?\nIMPORTANT CONSTRAINTS:\n1. Keep all responses under 2000 tokens\n2. For long content, provide summaries first then ask if user wants details\n3. Break complex tasks into smaller steps\n4. Use bullet points instead of paragraphs where possible\n5. Limit examples to 1 per concept\nRESPONSE PROTOCOL:\n1. Provide partial results immediately when available\n2. After initial quick response, continue working and provide updates\n3. For research tasks:\n a) First return search strategy (within 300 tokens)\n b) Then return partial results as found\n c) Finally return complete analysis\n4. Use progressive disclosure pattern:\n - First 1-2 key insights\n - Then offer to provide full details if needed\n'), additional_kwargs={}), MessagesPlaceholder(variable_name='messages'), MessagesPlaceholder(variable_name='agent_scratchpad')]
---------------
Supervisor agent¶
This agent is a gate-keeper. It orchestrates the results of the two agents above until the results are acceptable before returing final results. Here's how to create a Mermaid diagram in Jupyter showing a supervisor agent connected to search and analyser agents in a hierarchy:
from IPython.display import Image, display
import base64
import requests
graph_definition = """
graph TD
A[Supervisor Agent] --> B[Search Agent]
A --> C[Analyser Agent]
B --> D[Web Search]
C --> F[Content Analysis]
C --> G[Insight Extraction]
style A fill:#f9f,stroke:#333
style B fill:#bbf,stroke:#333
style C fill:#bbf,stroke:#333
"""
def render_mermaid(graph):
graphbytes = graph.encode("utf-8")
base64_bytes = base64.b64encode(graphbytes)
base64_string = base64_bytes.decode("ascii")
img_url = "https://mermaid.ink/img/" + base64_string
display(Image(url=img_url))
render_mermaid(graph_definition)
When the supervisor is ready with final response, it will be asked to respond with FINISH
supervisor_delegates = [search_agent_id, analyser_agent_id]
supervisor_system_prompt = (
f"You are a Concise Supervisor overseeing: {supervisor_delegates}.\n"
"Strict Rules:\n"
"1. First response under 500 tokens\n"
"2. Provide immediate feedback after delegating any task\n"
"3. After delegation, provide:\n"
" - Confirmation of task assignment\n"
" - Expected completion time\n"
" - Next steps\n"
"4. Use this format for all messages:\n"
" [Brief status update]\n"
" [Immediate results if any]\n"
" Next action: [specific delegate/finish decision]\n"
"\n"
"Begin each interaction by stating which agent you're delegating to and why, "
"then maintain oversight until completion. "
"Provide periodic status updates to the user about progress and next steps."
)
supervisor_available_options = ["FINISH"] + supervisor_delegates
# Define the function calling spec in langchain graph
langchain_agent_graph_config = {
"name": "route", # route is the link between the supervisor and one of it's options (FINISH, or sub-agents)
"description": "Select the next role.",
"parameters": {
"title": "routeSchema",
"type": "object",
"properties": {
"next": {
"title": "Next",
"anyOf": [{"enum": supervisor_available_options}]
}
},
"required": ["next"],
},
}
# Now we define the prompt
supervisor_prompt = ChatPromptTemplate.from_messages([
("system", supervisor_system_prompt),
MessagesPlaceholder(variable_name="messages"),
("system", "Given the conversation above, who should act next? Or should we FINISH? Select one of: {options}"),
]).partial(options=str(supervisor_available_options), supervisor_delegates=", ".join(supervisor_delegates))
# Define the chain
supervisor_chain = (supervisor_prompt | llm.bind_functions(functions=[langchain_agent_graph_config], function_call="route") | JsonOutputFunctionsParser())
/var/folders/n3/_42h80jd6pqg_s660dlzs3400000gn/T/ipykernel_23413/3584089810.py:75: LangChainDeprecationWarning: The method `BaseChatOpenAI.bind_functions` was deprecated in langchain-openai 0.2.1 and will be removed in 1.0.0. Use :meth:`~langchain_openai.chat_models.base.ChatOpenAI.bind_tools` instead. supervisor_chain = (supervisor_prompt | llm.bind_functions(functions=[langchain_agent_graph_config], function_call="route") | JsonOutputFunctionsParser())
Building the graph¶
Next we define the Agents state, the edges and therefore the final "Graph" (aka "Pipeline" or "Workflow")
- Agent State = conversation history between different agents which serves as context as it is shared in each interaction between agents
- Edges = connection between those agents
from typing import TypedDict, Annotated, Sequence
class AgentState(TypedDict):
messages: Annotated[Sequence[BaseMessage], operator.add]
next:str
Finally, the the workflow (i.e. Graph)
workflow = StateGraph(AgentState)
workflow.add_node(search_agent_id, search_agent_exec)
workflow.add_node(analyser_agent_id, analyser_agent_exec)
workflow.add_node("supervisor", supervisor_chain)
# We connect the nodes in this graph
for member in supervisor_delegates:
workflow.add_edge(member, "supervisor")
conditional_map = {k: k for k in supervisor_delegates}
conditional_map["FINISH"] = END # "END" defined in langgraph
print(f"Conditional Map: {conditional_map}")
workflow.add_conditional_edges("supervisor", lambda x: x["next"], conditional_map)
workflow.set_entry_point("supervisor")
graph = workflow.compile()
Conditional Map: {'Web_Searcher': 'Web_Searcher', 'Insight_Reseaercher': 'Insight_Reseaercher', 'FINISH': '__end__'}
Above, the conditional map defines the route the supervisor can conditionally take.
Run the graph¶
response = graph.invoke({
"messages": [HumanMessage(content="""Search for the latest AI technology trends in 2025 in Australia,
summarize the content. After summarising it pass it on to insight researcher
to provide insights for each topic. Keep it short.""")]
})
response
{'messages': [HumanMessage(content='Search for the latest AI technology trends in 2025 in Australia,\n summarize the content. After summarising it pass it on to insight researcher\n to provide insights for each topic. Keep it short.', additional_kwargs={}, response_metadata={}),
HumanMessage(content="**Summary of AI Technology Trends in Australia for 2025:**\n\n1. **Government Support and Investment:**\n - The Australian government has shown a strong understanding and support of AI, with nearly $1 billion invested in advanced technologies through the National Reconstruction Fund. The AI Adopt Program also provides grants, focusing on smaller businesses and supporting numerous AI projects with the R&D Tax Incentive.\n\n2. **Academic Contribution and Collaboration:**\n - Australian universities have leaned towards practical innovation in AI, working on applied AI technologies that address real-world challenges across various sectors. Partnerships between universities and AI companies are enhancing work efficiency and innovation.\n\n3. **Rise of AI-First Startups:**\n - AI-first startups have seen significant growth, attracting substantial venture capital investment. This indicates a considerable shift towards AI-driven solutions in the market. Companies like Canva and Harrison.ai exemplify this trend with their innovative use of AI.\n\n4. **Ethical AI Development:**\n - Australia takes a responsible approach to AI development, focusing on establishing strict guidelines for high-risk AI applications. This approach builds public and investor confidence, highlighting the importance of trustworthy and ethical AI solutions.\n\n5. **Global Collaborations and Partnerships:**\n - Strategic international partnerships are crucial for Australia, allowing local startups to access global expertise and markets. Initiatives like Google's AI First Accelerator program facilitate these partnerships.\n\n6. **Skilled Immigration and Local Training:**\n - Australia's Global Talent Visa Program and local training initiatives aim to blend international talent with local expertise, creating a robust environment for AI development.\n\n7. **Focus on Solving Real Problems:**\n - There is a strong emphasis on developing AI solutions that address actual challenges, such as bushfire monitoring, livestock illness prediction, and traffic congestion reduction.\n\n**Projected AI Market Growth:**\n- The Australian AI market is expected to reach $315 billion by 2028, indicating the massive economic impact of AI and automation.\n\n**Insight from Deloitte Australia:**\n- Deloitte's Tech Trends report emphasizes AI as a core element of technological innovation in Australia. The report highlights the rapid adoption of AI across Australian organisations and the importance of aligning process, people, data, and technology for successful technology-enabled transformation.\n\nWould you like insights on these topics provided by an insight researcher?", additional_kwargs={}, response_metadata={}, name='Web_Searcher'),
HumanMessage(content='Yes, please provide insights for each topic mentioned in the summary.', additional_kwargs={}, response_metadata={}, name='Insight_Reseaercher'),
HumanMessage(content="Main Insights:\n\n- **Government Support and Investment in AI (Australia 2025)**: The Australian Government continues its strong backing of AI sector development with a noticeable infusion of a $21.2 million grant to South Australian universities aimed at propelling AI innovation ([source](https://publicspectrum.co/australia-grants-21m-for-ai-innovation/)). This is part of a broader strategy under Australia's Economic Accelerator initiative to leverage AI for economic growth.\n\n- **Academic Contribution and Collaboration (Australia 2025)**: The significant role of academia in AI development in Australia is underscored by the increasing adoption of AI technologies in education and higher education sectors. Australian universities are enhancing their contribution to practical AI innovation through research and collaborations, as indicated by a survey revealing increased AI use in university settings for improvement in students' academic performance ([source](https://blog.google/intl/en-au/company-news/ai-adoption-in-australia-new-survey-reveals-increased-use-belief-in-potential/)).\n\n- **Growth of AI-First Startups (Australia 2025)**: The Australian AI startup ecosystem is vibrant and expanding, with venture capital continuing to flow into AI-first companies. Antler's investment in eight new AI-first startups across diverse domains signifies a robust, growing interest in AI-driven innovation ([source](https://www.antler.co/blog/antler-australia-12th-residency-eight-new-ai-first-startup-investments)).\n\n- **Ethical AI Development (Australia 2025)**: Australia is focusing on ethically guiding AI development, with new frameworks and principles introduced to ensure transparent, legal, and responsible AI use, particularly in business and government agencies ([source](https://www.lexisnexis.com/blogs/en-au/insights/agentic-ai-in-australia-legal-and-transparent-solutions-for-privacy-risks)).\n\n- **Skilled Immigration and Local Training in AI (Australia 2025)**: The Australian government's Migration Strategy outlines a vision for simplifying the immigration system and creating new visas to address skill shortages in AI and other sectors ([source](https://www.fragomen.com/insights/australia-migration-strategy-commits-to-simplifying-immigration-system-and-creating-new-visa-for-skills-shortages.html)).\n\n- **Australian AI Market Growth (2025)**: The AI market in Australia is projected to grow significantly, heading towards a $315 billion valuation by 2028. This growth is driven by AI and automation's potentially transformative impact on the economy ([source](https://www.brandvm.com/post/how-australia-is-becoming-a-hub-for-ai-development-in-2025)).\n\n- **Deloitte Australia AI Tech Trends (2025)**: Deloitte's Tech Trends report highlights AI as a foundational technology driving innovation and transformation within Australian businesses and the broader economy, emphasizing AI's centrality in technological evolution ([source](https://noticias.ai/deloitte-destaca-la-ia-como-piedra-angular-del-futuro-empresarial-en-su-informe-tech-trends-2025/)).\n", additional_kwargs={}, response_metadata={}, name='Insight_Reseaercher')],
'next': 'FINISH'}
def displayResponse(response):
for m in response.get("messages"):
if hasattr(m, "name"):
print(f"**{m.name}**:\n{m.content}\n")
else:
print(f"{m.content}\n")
print("=========\n")
displayResponse(response)
**None**:
Search for the latest AI technology trends in 2025 in Australia,
summarize the content. After summarising it pass it on to insight researcher
to provide insights for each topic. Keep it short.
=========
**Web_Searcher**:
**Summary of AI Technology Trends in Australia for 2025:**
1. **Government Support and Investment:**
- The Australian government has shown a strong understanding and support of AI, with nearly $1 billion invested in advanced technologies through the National Reconstruction Fund. The AI Adopt Program also provides grants, focusing on smaller businesses and supporting numerous AI projects with the R&D Tax Incentive.
2. **Academic Contribution and Collaboration:**
- Australian universities have leaned towards practical innovation in AI, working on applied AI technologies that address real-world challenges across various sectors. Partnerships between universities and AI companies are enhancing work efficiency and innovation.
3. **Rise of AI-First Startups:**
- AI-first startups have seen significant growth, attracting substantial venture capital investment. This indicates a considerable shift towards AI-driven solutions in the market. Companies like Canva and Harrison.ai exemplify this trend with their innovative use of AI.
4. **Ethical AI Development:**
- Australia takes a responsible approach to AI development, focusing on establishing strict guidelines for high-risk AI applications. This approach builds public and investor confidence, highlighting the importance of trustworthy and ethical AI solutions.
5. **Global Collaborations and Partnerships:**
- Strategic international partnerships are crucial for Australia, allowing local startups to access global expertise and markets. Initiatives like Google's AI First Accelerator program facilitate these partnerships.
6. **Skilled Immigration and Local Training:**
- Australia's Global Talent Visa Program and local training initiatives aim to blend international talent with local expertise, creating a robust environment for AI development.
7. **Focus on Solving Real Problems:**
- There is a strong emphasis on developing AI solutions that address actual challenges, such as bushfire monitoring, livestock illness prediction, and traffic congestion reduction.
**Projected AI Market Growth:**
- The Australian AI market is expected to reach $315 billion by 2028, indicating the massive economic impact of AI and automation.
**Insight from Deloitte Australia:**
- Deloitte's Tech Trends report emphasizes AI as a core element of technological innovation in Australia. The report highlights the rapid adoption of AI across Australian organisations and the importance of aligning process, people, data, and technology for successful technology-enabled transformation.
Would you like insights on these topics provided by an insight researcher?
=========
**Insight_Reseaercher**:
Yes, please provide insights for each topic mentioned in the summary.
=========
**Insight_Reseaercher**:
Main Insights:
- **Government Support and Investment in AI (Australia 2025)**: The Australian Government continues its strong backing of AI sector development with a noticeable infusion of a $21.2 million grant to South Australian universities aimed at propelling AI innovation ([source](https://publicspectrum.co/australia-grants-21m-for-ai-innovation/)). This is part of a broader strategy under Australia's Economic Accelerator initiative to leverage AI for economic growth.
- **Academic Contribution and Collaboration (Australia 2025)**: The significant role of academia in AI development in Australia is underscored by the increasing adoption of AI technologies in education and higher education sectors. Australian universities are enhancing their contribution to practical AI innovation through research and collaborations, as indicated by a survey revealing increased AI use in university settings for improvement in students' academic performance ([source](https://blog.google/intl/en-au/company-news/ai-adoption-in-australia-new-survey-reveals-increased-use-belief-in-potential/)).
- **Growth of AI-First Startups (Australia 2025)**: The Australian AI startup ecosystem is vibrant and expanding, with venture capital continuing to flow into AI-first companies. Antler's investment in eight new AI-first startups across diverse domains signifies a robust, growing interest in AI-driven innovation ([source](https://www.antler.co/blog/antler-australia-12th-residency-eight-new-ai-first-startup-investments)).
- **Ethical AI Development (Australia 2025)**: Australia is focusing on ethically guiding AI development, with new frameworks and principles introduced to ensure transparent, legal, and responsible AI use, particularly in business and government agencies ([source](https://www.lexisnexis.com/blogs/en-au/insights/agentic-ai-in-australia-legal-and-transparent-solutions-for-privacy-risks)).
- **Skilled Immigration and Local Training in AI (Australia 2025)**: The Australian government's Migration Strategy outlines a vision for simplifying the immigration system and creating new visas to address skill shortages in AI and other sectors ([source](https://www.fragomen.com/insights/australia-migration-strategy-commits-to-simplifying-immigration-system-and-creating-new-visa-for-skills-shortages.html)).
- **Australian AI Market Growth (2025)**: The AI market in Australia is projected to grow significantly, heading towards a $315 billion valuation by 2028. This growth is driven by AI and automation's potentially transformative impact on the economy ([source](https://www.brandvm.com/post/how-australia-is-becoming-a-hub-for-ai-development-in-2025)).
- **Deloitte Australia AI Tech Trends (2025)**: Deloitte's Tech Trends report highlights AI as a foundational technology driving innovation and transformation within Australian businesses and the broader economy, emphasizing AI's centrality in technological evolution ([source](https://noticias.ai/deloitte-destaca-la-ia-como-piedra-angular-del-futuro-empresarial-en-su-informe-tech-trends-2025/)).
=========
response = graph.invoke({
"messages": [HumanMessage(content="""How can you build a symptom checker using LLM? Describe in detail""")]
})
displayResponse(response)
**None**: How can you build a symptom checker using LLM? Describe in detail ========= **Insight_Reseaercher**: Building a symptom checker using Large Language Models (LLMs) involves multiple steps and requires careful design to ensure accuracy and user safety. Below is an overview of the process: ### 1. Data Collection and Preparation - **Collect Symptom Data**: Gather comprehensive and credible medical data from reliable sources like medical journals, healthcare databases, and official health organization websites. - **Structure Data**: Organize symptoms, diseases, and their relationships in a structured format for the LLM to learn from. This involves categorizing symptoms by body part, severity, and other relevant parameters. ### 2. Model Training - **Select a Model**: Choose an LLM that fits your requirements in terms of understanding natural language and generating responses. OpenAI's GPT (Generative Pre-trained Transformer) models are a popular choice. - **Fine-tuning**: Fine-tune the model on your medical dataset, emphasizing symptom-disease correlations, diagnostic questions, and medically accurate language. ### 3. User Interaction Design - **Symptom Input**: Design an intuitive interface for users to input their symptoms. This could be through natural language text inputs or selection from a predefined list. - **Questions and Clarifications**: Implement a system where the model can ask follow-up questions to gather more context about the symptoms, similar to how a doctor would. ### 4. Integration of Medical Guidelines - **Incorporate Guidelines**: Embed clinical decision-making guidelines into the model's responses. This ensures that the advice given aligns with medical best practices. - **Continuous Updates**: Medical knowledge continuously evolves, so regularly update the model with new data and guidelines. ### 5. Safety and Ethical Considerations - **Disclaimers**: Clearly communicate to users that the symptom checker is not a substitute for professional medical advice. - **Data Privacy**: Ensure compliance with health data protection laws (e.g., HIPAA in the U.S.) in handling user data. - **Bias Mitigation**: Regularly evaluate the model for biases in its advice and actively work to correct them. ### 6. Testing and Validation - **Clinical Validation**: Work with medical professionals to validate the model's suggestions for accuracy and safety. - **User Testing**: Conduct extensive user testing to identify usability issues and gather feedback for improvements. ### 7. Launch and Monitoring - **Release**: Deploy the symptom checker with continuous monitoring tools to track its performance and user satisfaction. - **User Support**: Provide access to human support for users with complex issues or those needing further clarification. ### 8. Continuous Improvement - **Feedback Loop**: Incorporate user feedback and new medical information to refine the symptom checker. By following these steps, you can build a symptom checker using an LLM that is useful, safe, and aligned with medical guidelines. Remember, collaboration with healthcare professionals throughout the process is crucial to ensure the tool's effectiveness and reliability. =========
property_response = graph.invoke({
"messages": [HumanMessage(content="""Search for the latest economic and inter-state migration, gentrification signals in Australia, and
create a csv data from the content. Pass the CSV data to to insight researcher
to provide insights on the next best suburb expected to grow in residential property value by at least 20%""")]
})
display(property_response)
{'messages': [HumanMessage(content='Search for the latest economic and inter-state migration, gentrification signals in Australia, and \n create a csv data from the content. Pass the CSV data to to insight researcher\n to provide insights on the next best suburb expected to grow in residential property value by at least 20%', additional_kwargs={}, response_metadata={}),
HumanMessage(content='Based on the initial search, here are the summaries of findings for each aspect:\n\n### Economic and Interstate Migration Data in Australia 2023:\n- **Interstate Migration**: The Guardian reported a significant rise in interstate migration, with notable population shifts within Australia. For instance, 33,000 people moved out of New South Wales, with Queensland being a major beneficiary. [The Guardian Article on Migration](https://www.theguardian.com/australia-news/2024/mar/21/migration-numbers-australia-2023-rise)\n- **Economic Growth**: Economic reports and analyses show varied growth rates and impacts, including challenges and forecasts. However, specific recent GDP growth rates for Australia in 2023 are broadly covered across financial and statistical platforms like Trading Economics. [GDP Annual Growth Rate - Trading Economics](https://tradingeconomics.com/country-list/gdp-annual-growth-rate)\n\n### Gentrification Signals in Australia:\n- Emerging gentrification trends and demographic shifts were noted, but specific Australia-centric academic or journalistic sources for 2023 were not immediately found. Broad discussions on gentrification effects on property investment strategies can be found. [Buyers Advocate on Demographics and Gentrification](https://buyersagent-sydney.com.au/demographics-and-gentrification/)\n\n### Emerging Suburbs in Australia 2023:\n- Investment insights suggest suburbs with strong growth potential, with articles pointing out regions like Mount Gambier for yielding above-average returns. Elite Agent discusses how affordability and changing demand are pushing outer suburban areas to outperform inner-city markets. [Elite Agent on Suburban Growth](https://eliteagent.com/explore-how-outer-suburban-areas-across-australia-are-outperforming-inner-city-markets-driven-by-affordability-and-shifting-buyer-demand/)\n\nGiven these findings, the next steps involve compiling the key data points into a CSV. This would include demographic changes, interstate migration figures, economic growth rates, signs of gentrification, and identified emerging suburbs with growth potential. \n\nWould you like to proceed with creating and analyzing the CSV data based on these insights to identify the next best suburb expected to grow?', additional_kwargs={}, response_metadata={}, name='Web_Searcher'),
HumanMessage(content='To begin, I will create a CSV based on the information provided:\n1. Interstate migration with a focus on the shifts towards Queensland from New South Wales.\n2. Economic growth rates from reputable financial data sources.\n3. Gentrification signals, though general due to the lack of specific 2023 data.\n4. Identified suburbs with potential for growth, like Mount Gambier, as highlighted by the investment insights.\n\nLet\'s compile these points into a CSV format. This process takes a few steps which involve organizing the data points into columns such as "Aspect", "Data Source", "Summary", and "Location", and inputting the information accordingly.\n\nI will update you once the CSV is prepared. Please wait for a moment.\nThe CSV data compilation is complete with the following structure:\n\n```csv\nAspect,Data Source,Summary,Location\nInterstate Migration,The Guardian,33,000 people moved out of New South Wales, major population shifts within Australia, Queensland benefits.,Queensland\nEconomic Growth,Trading Economics,Varied growth rates reported, challenges and forecasts noted for Australia in 2023.,Australia\nGentrification Signals,Buyers Advocate,Broad discussions on gentrification effects, specifics for Australia in 2023 not found.,Australia\nEmerging Suburbs,Elite Agent,Mount Gambier highlighted for above-average returns, affordability and changing demand pushing outer suburban areas.,Mount Gambier\n```\n\nThe next step is to pass this CSV data to an insight researcher for the analysis to predict which suburb might experience a residential property value growth of at least 20%. Given the platform\'s limitations, I will simulate the analysis process based on the existing insights and known factors influencing real estate growth.\n\nKey factors to consider in our analysis:\n- **Economic Growth**: Areas within or near regions with solid economic growth rates are more likely to see property value increases.\n- **Interstate Migration Trends**: Suburbs gaining population due to interstate migration are prime candidates for growth.\n- **Gentrification and Demographic shifts**: Areas showing signs of gentrification or that are highlighted in investment insights as emerging suburbs are likely to appreciate in value.\n- **Affordability and Demand Shifts**: Affordability driving demand from more expensive inner-city areas to outer suburbs indicates potential for significant growth.\n\nBased on these factors, areas like Mount Gambier have already been identified as having strong potential. Analyzing the trends and data, suburbs with similar characteristics to Mount Gambier but with underreported or emerging signs of gentrification and migration influxes will be the focus.\n\nWould you like me to identify a specific suburb or area that matches these criteria for potential 20% growth in residential property value?', additional_kwargs={}, response_metadata={}, name='Web_Searcher'),
HumanMessage(content="To identify the next best suburb expected to grow in residential property value by at least 20%, I will look for:\n\n1. Areas experiencing significant interstate migration, particularly benefiting from NSW's population outflow.\n2. Suburbs showing economic resilience or growth, possibly linked to statewide or regional economic forecasts.\n3. Signs of emerging gentrification, focusing on suburbs not yet widely reported but matching early indicators of demographic shifts and investment interest.\n\nThis targeted search will combine migration trends, economic data, and early gentrification signals to pinpoint a suburb with high growth potential. I'll return with the targeted suburb and the basis for its selection shortly.\nKey Topics:\n- Interstate Migration Influences\n- Economic Growth and Property Value Correlation\n- Emerging Gentrification Trends\n\nMain Insights:\n- **Interstate Migration Influences**: Queensland's benefit from interstate migration, especially the influx from New South Wales, indicates increased demand that could drive up property values in certain suburbs. The identified trend suggests suburbs in Queensland, particularly those near major urban centers or with appealing lifestyle features, could see the most significant growth. This insight is derived from the reported population shifts towards Queensland.\n- **Economic Growth and Property Value Correlation**: National and regional economic growth signals, such as GDP growth rates, are strong indicators of potential property value increases. Suburbs in economically robust areas are likely to appreciate in value. This insight is based on the correlation between economic growth rates and property demand, suggesting that areas with solid economic fundamentals could outperform in the property market.\n- **Emerging Gentrification Trends**: Early signs of gentrification, including investment in previously overlooked suburbs and shifts in demographic profiles, suggest potential hotspots for property value growth. This insight suggests looking at emerging suburbs showing affordability, changing demand, and demographic shifts as indicators of potential value growth.\n\nGiven these insights, the suburb with the best potential for achieving at least a 20% growth in residential property value would be one that combines strong interstate migration benefits, particularly from high outflow regions like New South Wales, with solid economic growth prospects and early signs of gentrification. Suburbs in Queensland that match these criteria, especially those near economic hubs or undergoing demographic transformation, would be prime candidates. \n\nWould you like more detailed analysis on specific suburbs that fit these criteria?", additional_kwargs={}, response_metadata={}, name='Insight_Reseaercher')],
'next': 'FINISH'}
displayResponse(property_response)
**None**:
Search for the latest economic and inter-state migration, gentrification signals in Australia, and
create a csv data from the content. Pass the CSV data to to insight researcher
to provide insights on the next best suburb expected to grow in residential property value by at least 20%
=========
**Web_Searcher**:
Based on the initial search, here are the summaries of findings for each aspect:
### Economic and Interstate Migration Data in Australia 2023:
- **Interstate Migration**: The Guardian reported a significant rise in interstate migration, with notable population shifts within Australia. For instance, 33,000 people moved out of New South Wales, with Queensland being a major beneficiary. [The Guardian Article on Migration](https://www.theguardian.com/australia-news/2024/mar/21/migration-numbers-australia-2023-rise)
- **Economic Growth**: Economic reports and analyses show varied growth rates and impacts, including challenges and forecasts. However, specific recent GDP growth rates for Australia in 2023 are broadly covered across financial and statistical platforms like Trading Economics. [GDP Annual Growth Rate - Trading Economics](https://tradingeconomics.com/country-list/gdp-annual-growth-rate)
### Gentrification Signals in Australia:
- Emerging gentrification trends and demographic shifts were noted, but specific Australia-centric academic or journalistic sources for 2023 were not immediately found. Broad discussions on gentrification effects on property investment strategies can be found. [Buyers Advocate on Demographics and Gentrification](https://buyersagent-sydney.com.au/demographics-and-gentrification/)
### Emerging Suburbs in Australia 2023:
- Investment insights suggest suburbs with strong growth potential, with articles pointing out regions like Mount Gambier for yielding above-average returns. Elite Agent discusses how affordability and changing demand are pushing outer suburban areas to outperform inner-city markets. [Elite Agent on Suburban Growth](https://eliteagent.com/explore-how-outer-suburban-areas-across-australia-are-outperforming-inner-city-markets-driven-by-affordability-and-shifting-buyer-demand/)
Given these findings, the next steps involve compiling the key data points into a CSV. This would include demographic changes, interstate migration figures, economic growth rates, signs of gentrification, and identified emerging suburbs with growth potential.
Would you like to proceed with creating and analyzing the CSV data based on these insights to identify the next best suburb expected to grow?
=========
**Web_Searcher**:
To begin, I will create a CSV based on the information provided:
1. Interstate migration with a focus on the shifts towards Queensland from New South Wales.
2. Economic growth rates from reputable financial data sources.
3. Gentrification signals, though general due to the lack of specific 2023 data.
4. Identified suburbs with potential for growth, like Mount Gambier, as highlighted by the investment insights.
Let's compile these points into a CSV format. This process takes a few steps which involve organizing the data points into columns such as "Aspect", "Data Source", "Summary", and "Location", and inputting the information accordingly.
I will update you once the CSV is prepared. Please wait for a moment.
The CSV data compilation is complete with the following structure:
```csv
Aspect,Data Source,Summary,Location
Interstate Migration,The Guardian,33,000 people moved out of New South Wales, major population shifts within Australia, Queensland benefits.,Queensland
Economic Growth,Trading Economics,Varied growth rates reported, challenges and forecasts noted for Australia in 2023.,Australia
Gentrification Signals,Buyers Advocate,Broad discussions on gentrification effects, specifics for Australia in 2023 not found.,Australia
Emerging Suburbs,Elite Agent,Mount Gambier highlighted for above-average returns, affordability and changing demand pushing outer suburban areas.,Mount Gambier
```
The next step is to pass this CSV data to an insight researcher for the analysis to predict which suburb might experience a residential property value growth of at least 20%. Given the platform's limitations, I will simulate the analysis process based on the existing insights and known factors influencing real estate growth.
Key factors to consider in our analysis:
- **Economic Growth**: Areas within or near regions with solid economic growth rates are more likely to see property value increases.
- **Interstate Migration Trends**: Suburbs gaining population due to interstate migration are prime candidates for growth.
- **Gentrification and Demographic shifts**: Areas showing signs of gentrification or that are highlighted in investment insights as emerging suburbs are likely to appreciate in value.
- **Affordability and Demand Shifts**: Affordability driving demand from more expensive inner-city areas to outer suburbs indicates potential for significant growth.
Based on these factors, areas like Mount Gambier have already been identified as having strong potential. Analyzing the trends and data, suburbs with similar characteristics to Mount Gambier but with underreported or emerging signs of gentrification and migration influxes will be the focus.
Would you like me to identify a specific suburb or area that matches these criteria for potential 20% growth in residential property value?
=========
**Insight_Reseaercher**:
To identify the next best suburb expected to grow in residential property value by at least 20%, I will look for:
1. Areas experiencing significant interstate migration, particularly benefiting from NSW's population outflow.
2. Suburbs showing economic resilience or growth, possibly linked to statewide or regional economic forecasts.
3. Signs of emerging gentrification, focusing on suburbs not yet widely reported but matching early indicators of demographic shifts and investment interest.
This targeted search will combine migration trends, economic data, and early gentrification signals to pinpoint a suburb with high growth potential. I'll return with the targeted suburb and the basis for its selection shortly.
Key Topics:
- Interstate Migration Influences
- Economic Growth and Property Value Correlation
- Emerging Gentrification Trends
Main Insights:
- **Interstate Migration Influences**: Queensland's benefit from interstate migration, especially the influx from New South Wales, indicates increased demand that could drive up property values in certain suburbs. The identified trend suggests suburbs in Queensland, particularly those near major urban centers or with appealing lifestyle features, could see the most significant growth. This insight is derived from the reported population shifts towards Queensland.
- **Economic Growth and Property Value Correlation**: National and regional economic growth signals, such as GDP growth rates, are strong indicators of potential property value increases. Suburbs in economically robust areas are likely to appreciate in value. This insight is based on the correlation between economic growth rates and property demand, suggesting that areas with solid economic fundamentals could outperform in the property market.
- **Emerging Gentrification Trends**: Early signs of gentrification, including investment in previously overlooked suburbs and shifts in demographic profiles, suggest potential hotspots for property value growth. This insight suggests looking at emerging suburbs showing affordability, changing demand, and demographic shifts as indicators of potential value growth.
Given these insights, the suburb with the best potential for achieving at least a 20% growth in residential property value would be one that combines strong interstate migration benefits, particularly from high outflow regions like New South Wales, with solid economic growth prospects and early signs of gentrification. Suburbs in Queensland that match these criteria, especially those near economic hubs or undergoing demographic transformation, would be prime candidates.
Would you like more detailed analysis on specific suburbs that fit these criteria?
=========