old_price) * 100}get_current_stock_price("MSFT")    {'price': 334.57000732421875, 'currency': 'USD'}get_stock_performance("MSFT", 30)    {'percent_change': 1.014466941163018}Make custom tools‚Äãfrom typing import Typefrom pydantic import BaseModel, Fieldfrom langchain.tools import BaseToolclass CurrentStockPriceInput(BaseModel):    """Inputs for get_current_stock_price"""    ticker: str = Field(description="Ticker symbol of the stock")class CurrentStockPriceTool(BaseTool):    name = "get_current_stock_price"    description = """        Useful when you want to get current stock price.        You should enter the stock ticker symbol recognized by the yahoo finance        """    args_schema: Type[BaseModel] = CurrentStockPriceInput    def _run(self, ticker: str):        price_response = get_current_stock_price(ticker)        return price_response    def _arun(self, ticker: str):        raise NotImplementedError("get_current_stock_price does not support async")class StockPercentChangeInput(BaseModel):    """Inputs for get_stock_performance"""    ticker: str = Field(description="Ticker symbol of the stock")    days: int = Field(description="Timedelta days to get past date from current date")class StockPerformanceTool(BaseTool):    name = "get_stock_performance"    description = """        Useful when you want to check performance of the stock.        You should enter the stock ticker symbol recognized by the yahoo finance.        You should enter days as number of days from today from which performance needs to be check.        output will be the change in the stock price represented as a percentage.        """    args_schema: Type[BaseModel] = StockPercentChangeInput    def _run(self, ticker: str, days: int):        response = get_stock_performance(ticker, days)        return response    def _arun(self, ticker: str):        raise NotImplementedError("get_stock_performance does not support async")Create Agent‚Äãfrom langchain.agents import AgentTypefrom
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. ->: old_price) * 100}get_current_stock_price("MSFT")    {'price': 334.57000732421875, 'currency': 'USD'}get_stock_performance("MSFT", 30)    {'percent_change': 1.014466941163018}Make custom tools‚Äãfrom typing import Typefrom pydantic import BaseModel, Fieldfrom langchain.tools import BaseToolclass CurrentStockPriceInput(BaseModel):    """Inputs for get_current_stock_price"""    ticker: str = Field(description="Ticker symbol of the stock")class CurrentStockPriceTool(BaseTool):    name = "get_current_stock_price"    description = """        Useful when you want to get current stock price.        You should enter the stock ticker symbol recognized by the yahoo finance        """    args_schema: Type[BaseModel] = CurrentStockPriceInput    def _run(self, ticker: str):        price_response = get_current_stock_price(ticker)        return price_response    def _arun(self, ticker: str):        raise NotImplementedError("get_current_stock_price does not support async")class StockPercentChangeInput(BaseModel):    """Inputs for get_stock_performance"""    ticker: str = Field(description="Ticker symbol of the stock")    days: int = Field(description="Timedelta days to get past date from current date")class StockPerformanceTool(BaseTool):    name = "get_stock_performance"    description = """        Useful when you want to check performance of the stock.        You should enter the stock ticker symbol recognized by the yahoo finance.        You should enter days as number of days from today from which performance needs to be check.        output will be the change in the stock price represented as a percentage.        """    args_schema: Type[BaseModel] = StockPercentChangeInput    def _run(self, ticker: str, days: int):        response = get_stock_performance(ticker, days)        return response    def _arun(self, ticker: str):        raise NotImplementedError("get_stock_performance does not support async")Create Agent‚Äãfrom langchain.agents import AgentTypefrom