Skip to main contentü¶úÔ∏èüîó LangChainDocsUse casesIntegrationsAPICommunityChat our docsLangSmithJS/TS DocsSearchCTRLKGet startedIntroductionInstallationQuickstartLangChain Expression LanguageInterfaceHow toCookbookLangChain Expression Language (LCEL)Why use LCEL?ModulesModel I/‚ÄãORetrievalChainsMemoryAgentsAgent TypesHow-toAdd Memory to OpenAI Functions AgentRunning Agent as an IteratorReturning Structured OutputCombine agents and vector storesAsync APICreate ChatGPT cloneCustom functions with OpenAI Functions AgentCustom agentCustom agent with tool retrievalCustom LLM agentCustom LLM Agent (with a ChatModel)Custom MRKL agentCustom multi-action agentHandle parsing errorsAccess intermediate stepsCap the max number of iterationsTimeouts for agentsReplicating MRKLShared memory across agents and toolsStreaming final agent outputUse ToolKits with OpenAI FunctionsToolsToolkitsCallbacksModulesSecurityGuidesMoreModulesAgentsHow-toCustom functions with OpenAI Functions AgentOn this pageCustom functions with OpenAI Functions AgentThis notebook goes through how to integrate custom functions with OpenAI Functions agent.Install libraries which are required to run this example notebook:pip install -q openai langchain yfinanceDefine custom functions‚Äãimport yfinance as yffrom datetime import datetime, timedeltadef get_current_stock_price(ticker):    """Method to get current stock price"""    ticker_data = yf.Ticker(ticker)    recent = ticker_data.history(period="1d")    return {"price": recent.iloc[0]["Close"], "currency": ticker_data.info["currency"]}def get_stock_performance(ticker, days):    """Method to get stock price change in percentage"""    past_date = datetime.today() - timedelta(days=days)    ticker_data = yf.Ticker(ticker)    history = ticker_data.history(start=past_date)    old_price = history.iloc[0]["Close"]    current_price = history.iloc[-1]["Close"]    return {"percent_change": ((current_price - old_price) / old_price) * 100}get_current_stock_price("MSFT")
This notebook goes through how to integrate custom functions with OpenAI Functions agent.
This notebook goes through how to integrate custom functions with OpenAI Functions agent. ->: Skip to main contentü¶úÔ∏èüîó LangChainDocsUse casesIntegrationsAPICommunityChat our docsLangSmithJS/TS DocsSearchCTRLKGet startedIntroductionInstallationQuickstartLangChain Expression LanguageInterfaceHow toCookbookLangChain Expression Language (LCEL)Why use LCEL?ModulesModel I/‚ÄãORetrievalChainsMemoryAgentsAgent TypesHow-toAdd Memory to OpenAI Functions AgentRunning Agent as an IteratorReturning Structured OutputCombine agents and vector storesAsync APICreate ChatGPT cloneCustom functions with OpenAI Functions AgentCustom agentCustom agent with tool retrievalCustom LLM agentCustom LLM Agent (with a ChatModel)Custom MRKL agentCustom multi-action agentHandle parsing errorsAccess intermediate stepsCap the max number of iterationsTimeouts for agentsReplicating MRKLShared memory across agents and toolsStreaming final agent outputUse ToolKits with OpenAI FunctionsToolsToolkitsCallbacksModulesSecurityGuidesMoreModulesAgentsHow-toCustom functions with OpenAI Functions AgentOn this pageCustom functions with OpenAI Functions AgentThis notebook goes through how to integrate custom functions with OpenAI Functions agent.Install libraries which are required to run this example notebook:pip install -q openai langchain yfinanceDefine custom functions‚Äãimport yfinance as yffrom datetime import datetime, timedeltadef get_current_stock_price(ticker):    """Method to get current stock price"""    ticker_data = yf.Ticker(ticker)    recent = ticker_data.history(period="1d")    return {"price": recent.iloc[0]["Close"], "currency": ticker_data.info["currency"]}def get_stock_performance(ticker, days):    """Method to get stock price change in percentage"""    past_date = datetime.today() - timedelta(days=days)    ticker_data = yf.Ticker(ticker)    history = ticker_data.history(start=past_date)    old_price = history.iloc[0]["Close"]    current_price = history.iloc[-1]["Close"]    return {"percent_change": ((current_price - old_price) / old_price) * 100}get_current_stock_price("MSFT")