import ChatOpenAIfrom langchain.tools import DuckDuckGoSearchResultsfrom langchain.tools.render import format_tool_to_openai_function# Fetches the latest version of this promptprompt = hub.pull("wfh/langsmith-agent-prompt:latest")llm = ChatOpenAI(    model="gpt-3.5-turbo-16k",    temperature=0,)tools = [    DuckDuckGoSearchResults(        name="duck_duck_go"    ),  # General internet search using DuckDuckGo]llm_with_tools = llm.bind(functions=[format_tool_to_openai_function(t) for t in tools])runnable_agent = (    {        "input": lambda x: x["input"],        "agent_scratchpad": lambda x: format_to_openai_functions(            x["intermediate_steps"]        ),    }    | prompt    | llm_with_tools    | OpenAIFunctionsAgentOutputParser())agent_executor = AgentExecutor(    agent=runnable_agent, tools=tools, handle_parsing_errors=True)We are running the agent concurrently on multiple inputs to reduce latency. Runs get logged to LangSmith in the background so execution latency is unaffected.inputs = [    "What is LangChain?",    "What's LangSmith?",    "When was Llama-v2 released?",    "Who trained Llama-v2?",    "What is the langsmith cookbook?",    "When did langchain first announce the hub?",]results = agent_executor.batch([{"input": x} for x in inputs], return_exceptions=True)results[:2]    [{'input': 'What is LangChain?',      'output': 'I\'m sorry, but I couldn\'t find any information about "LangChain". Could you please provide more context or clarify your question?'},     {'input': "What's LangSmith?",      'output': 'I\'m sorry, but I couldn\'t find any information about "LangSmith". It could be a specific term or a company that is not widely known. Can you provide more context or clarify what you are referring to?'}]Assuming you've successfully set up your environment, your agent traces should show up in the Projects section in the app. Congrats!It looks like the agent isn't effectively using the tools though. Let's evaluate this so we have a baseline.Evaluate
Open In Colab
Open In Colab ->: import ChatOpenAIfrom langchain.tools import DuckDuckGoSearchResultsfrom langchain.tools.render import format_tool_to_openai_function# Fetches the latest version of this promptprompt = hub.pull("wfh/langsmith-agent-prompt:latest")llm = ChatOpenAI(    model="gpt-3.5-turbo-16k",    temperature=0,)tools = [    DuckDuckGoSearchResults(        name="duck_duck_go"    ),  # General internet search using DuckDuckGo]llm_with_tools = llm.bind(functions=[format_tool_to_openai_function(t) for t in tools])runnable_agent = (    {        "input": lambda x: x["input"],        "agent_scratchpad": lambda x: format_to_openai_functions(            x["intermediate_steps"]        ),    }    | prompt    | llm_with_tools    | OpenAIFunctionsAgentOutputParser())agent_executor = AgentExecutor(    agent=runnable_agent, tools=tools, handle_parsing_errors=True)We are running the agent concurrently on multiple inputs to reduce latency. Runs get logged to LangSmith in the background so execution latency is unaffected.inputs = [    "What is LangChain?",    "What's LangSmith?",    "When was Llama-v2 released?",    "Who trained Llama-v2?",    "What is the langsmith cookbook?",    "When did langchain first announce the hub?",]results = agent_executor.batch([{"input": x} for x in inputs], return_exceptions=True)results[:2]    [{'input': 'What is LangChain?',      'output': 'I\'m sorry, but I couldn\'t find any information about "LangChain". Could you please provide more context or clarify your question?'},     {'input': "What's LangSmith?",      'output': 'I\'m sorry, but I couldn\'t find any information about "LangSmith". It could be a specific term or a company that is not widely known. Can you provide more context or clarify what you are referring to?'}]Assuming you've successfully set up your environment, your agent traces should show up in the Projects section in the app. Congrats!It looks like the agent isn't effectively using the tools though. Let's evaluate this so we have a baseline.Evaluate