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 |
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 467?") | |
| SYSTEM_PROMPT = "You are an arithmetic wizard." | |
| @tool | |
| def square_root(x: float) -> float: | |
| """ |
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 pydantic import BaseModel | |
| 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." | |
| class CapitalCity(BaseModel): | |
| name: str | |
| location: str |
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 | |
| SYSTEM_PROMPT = """" | |
| You are a science fiction writer, create a capital city at the users request. | |
| User: What is the capital of Mars? | |
| Agent: Marsialias | |
| User: What is the capital of Venus? |
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 | |
| agent = create_agent(model="gpt-5-nano") | |
| response = agent.invoke({ | |
| "messages": [HumanMessage(content="What's the capital of the Moon?")], | |
| }) | |
| print(response["messages"][-1].content) |
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 pprint import pprint | |
| from langchain.chat_models import init_chat_model | |
| def main(): | |
| model = init_chat_model(model="gpt-5-nano") | |
| response = model.invoke("What's the capital of the Moon?") | |
| print(response.content) | |
| pprint(response.response_metadata) |
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
| package com.example; | |
| import io.grpc.ManagedChannel; | |
| import io.grpc.ManagedChannelBuilder; | |
| import io.grpc.StatusRuntimeException; | |
| public class GreeterClient { | |
| public static void main(String[] args) { | |
| String host = "localhost"; | |
| int port = 50051; |