import os from langchain_together import ChatTogether from dotenv import load_dotenv load_dotenv() from langchain_community.tools import DuckDuckGoSearchRun llm = ChatTogether(model="meta-llama/Llama-3.3-70B-Instruct-Turbo-Free", api_key=os.getenv("TOGETHER_API_KEY")) search_tool = DuckDuckGoSearchRun() # Augment the LLM with tools llm_with_tools = llm.bind_tools([search_tool]) # Invoke the LLM with input that triggers the tool call response = llm_with_tools.invoke("If Eliud Kipchoge could maintain his record-making marathon pace indefinitely, how many thousand hours would it take him to run the distance between the Earth and the Moon its closest approach? Please use the minimum perigee value on the Wikipedia page for the Moon when carrying out your calculation. Round your result to the nearest 1000 hours and do not use any comma separators if necessary.") print(response) # Get the tool call print(response.tool_calls)