This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from typing import Any | |
| from langchain.agents import create_agent, AgentState | |
| from langchain.agents.middleware import before_agent | |
| from langchain.messages import HumanMessage, SystemMessage | |
| from langgraph.runtime import Runtime | |
| QUESTION = HumanMessage(content="What's the capital of the Moon?") | |
| SYSTEM_PROMPT = """" | |
| You are a science fiction writer, create a capital city at the users request. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from langchain.agents import create_agent | |
| from langchain.agents.middleware import SummarizationMiddleware | |
| from langchain.messages import HumanMessage, AIMessage | |
| from langgraph.checkpoint.memory import InMemorySaver | |
| CONFIG = {"configurable": {"thread_id": "1"}} | |
| CONVERSATION = [ | |
| HumanMessage(content="What is the capital of the moon?"), | |
| AIMessage(content="The capital of the moon is Lunapolis."), | |
| HumanMessage(content="What is the weather in Lunapolis?"), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import asyncio | |
| from langchain.agents import create_agent, AgentState | |
| from langchain.messages import HumanMessage, ToolMessage | |
| from langchain.tools import tool, ToolRuntime | |
| from langchain_community.utilities import SQLDatabase | |
| from langchain_mcp_adapters.client import MultiServerMCPClient | |
| from langgraph.types import Command | |
| from tavily import TavilyClient |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from langchain.agents import create_agent | |
| from langchain.messages import HumanMessage | |
| from langchain.tools import tool | |
| QUESTION = HumanMessage(content="What's the square root of 456?") | |
| @tool | |
| def square_root(x: float) -> float: | |
| """ | |
| Calculate the square root of a number. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from langchain.agents import AgentState, create_agent | |
| from langchain.messages import ToolMessage, HumanMessage | |
| from langchain.tools import tool, ToolRuntime | |
| from langgraph.checkpoint.memory import InMemorySaver | |
| from langgraph.types import Command | |
| CONFIG = {"configurable": {"thread_id": "1"}} | |
| QUESTION_1 = HumanMessage(content="My favorite color is green.") | |
| QUESTION_2 = HumanMessage(content="What is my favorite color?") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from dataclasses import dataclass; | |
| from langchain.agents import create_agent | |
| from langchain.messages import HumanMessage | |
| from langchain.tools import tool, ToolRuntime | |
| QUESTION = HumanMessage(content="What is my favorite color?") | |
| @dataclass | |
| class ColorContext: | |
| favorite_color: str = "blue" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import asyncio | |
| from langchain.agents import create_agent | |
| from langchain.messages import HumanMessage | |
| from langchain_mcp_adapters.client import MultiServerMCPClient | |
| QUESTION = HumanMessage(content="What's the weather in San Francisco?") | |
| client = MultiServerMCPClient( | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from langchain.agents import create_agent | |
| from langgraph.checkpoint.memory import InMemorySaver | |
| from langchain.messages import HumanMessage | |
| from langchain.tools import tool | |
| from tavily import TavilyClient | |
| tavily_client = TavilyClient(); | |
| CONFIG = {"configurable": {"thread_id": "1"}} | |
| QUESTION = HumanMessage(content="I have some leftover chicken and rice in my fridge. What can I make?") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from langchain.agents import create_agent | |
| from langgraph.checkpoint.memory import InMemorySaver | |
| from langchain.messages import HumanMessage | |
| from langchain.tools import tool | |
| CONFIG = {"configurable": {"thread_id": "1"}} | |
| QUESTION_1 = HumanMessage(content="Hello my name is Sean and my favorite color is green.") | |
| QUESTION_2 = HumanMessage(content="What is my favorite color?") | |
| agent = create_agent( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from langchain.agents import create_agent | |
| from langchain.messages import HumanMessage | |
| from langchain.tools import tool | |
| from tavily import TavilyClient | |
| tavily_client = TavilyClient(); | |
| QUESTION = HumanMessage(content="Who is the current mayor of San Francisco?") | |
| @tool |
NewerOlder