id
stringlengths
14
17
text
stringlengths
42
2.11k
4e9727215e95-3200
run with input: "Harry Styles age"[tool/end] [1:chain:agent_executor > 7:tool:search] [632ms] Exiting Tool run with output: "29 years"[chain/start] [1:chain:agent_executor > 8:chain:llm_chain] Entering Chain run with input: { "input": "Who is Olivia Wilde's boyfriend? What is his current age raised to the 0.23 power?
4e9727215e95-3201
", "agent_scratchpad": " I need to find out who Olivia Wilde's boyfriend is and then calculate his age raised to the 0.23 power.\nAction: search\nAction Input: \"Olivia Wilde boyfriend\"\nObservation: In January 2021, Wilde began dating singer Harry Styles after meeting during the filming of Don't Worry Darling. Their relationship ended in November 2022.\nThought: I need to find out Harry Styles' age.\nAction: search\nAction Input: \"Harry Styles age\"\nObservation: 29 years\nThought:", "stop": [ "\nObservation: " ]}[llm/start] [1:chain:agent_executor > 8:chain:llm_chain > 9:llm:openai] Entering LLM run with input: { "prompts": [ "Answer the following questions as best you can. You have access to the following tools:\n\nsearch: a search engine. useful for when you need to answer questions about current events. input should be a search query.\ncalculator: Useful for getting the result of a math expression.
4e9727215e95-3202
The input to this tool should be a valid mathematical expression that could be executed by a simple calculator.\n\nUse the following format in your response:\n\nQuestion: the input question you must answer\nThought: you should always think about what to do\nAction: the action to take, should be one of [search,calculator]\nAction Input: the input to the action\nObservation: the result of the action\n... (this Thought/Action/Action Input/Observation can repeat N times)\nThought: I now know the final answer\nFinal Answer: the final answer to the original input question\n\nBegin!\n\nQuestion: Who is Olivia Wilde's boyfriend? What is his current age raised to the 0.23 power?\nThought: I need to find out who Olivia Wilde's boyfriend is and then calculate his age raised to the 0.23 power.\nAction: search\nAction Input: \"Olivia Wilde boyfriend\"\nObservation: In January 2021, Wilde began dating singer Harry Styles after meeting during the filming of Don't Worry Darling.
4e9727215e95-3203
Their relationship ended in November 2022.\nThought: I need to find out Harry Styles' age.\nAction: search\nAction Input: \"Harry Styles age\"\nObservation: 29 years\nThought:" ]}[llm/end] [1:chain:agent_executor > 8:chain:llm_chain > 9:llm:openai] [2.72s] Exiting LLM run with output: { "generations": [ [ { "text": " I need to calculate 29 raised to the 0.23 power.\nAction: calculator\nAction Input: 29^0.23", "generationInfo": { "finishReason": "stop", "logprobs": null } } ] ], "llmOutput": { "tokenUsage": { "completionTokens": 26, "promptTokens": 329, "totalTokens": 355 } }}[chain/end] [1:chain:agent_executor > 8:chain:llm_chain] [2.72s] Exiting Chain run with output: { "text": " I need to calculate 29 raised to the 0.23 power.\nAction: calculator\nAction Input: 29^0.23"}[agent/action] [1:chain:agent_executor] Agent selected action: { "tool": "calculator", "toolInput": "29^0.23", "log": " I need to calculate 29 raised to the 0.23 power.\nAction: calculator\nAction
4e9727215e95-3204
need to calculate 29 raised to the 0.23 power.\nAction: calculator\nAction Input: 29^0.23"}[tool/start] [1:chain:agent_executor > 10:tool:calculator] Entering Tool run with input: "29^0.23"[tool/end] [1:chain:agent_executor > 10:tool:calculator] [3ms] Exiting Tool run with output: "2.169459462491557"[chain/start] [1:chain:agent_executor > 11:chain:llm_chain] Entering Chain run with input: { "input": "Who is Olivia Wilde's boyfriend? What is his current age raised to the 0.23 power?
4e9727215e95-3205
", "agent_scratchpad": " I need to find out who Olivia Wilde's boyfriend is and then calculate his age raised to the 0.23 power.\nAction: search\nAction Input: \"Olivia Wilde boyfriend\"\nObservation: In January 2021, Wilde began dating singer Harry Styles after meeting during the filming of Don't Worry Darling. Their relationship ended in November 2022.\nThought: I need to find out Harry Styles' age.\nAction: search\nAction Input: \"Harry Styles age\"\nObservation: 29 years\nThought: I need to calculate 29 raised to the 0.23 power.\nAction: calculator\nAction Input: 29^0.23\nObservation: 2.169459462491557\nThought:", "stop": [ "\nObservation: " ]}[llm/start] [1:chain:agent_executor > 11:chain:llm_chain > 12:llm:openai] Entering LLM run with input: { "prompts": [ "Answer the following questions as best you can. You have access to the following tools:\n\nsearch: a search engine. useful for when you need to answer questions about current events. input should be a search query.\ncalculator: Useful for getting the result of a math expression.
4e9727215e95-3206
The input to this tool should be a valid mathematical expression that could be executed by a simple calculator.\n\nUse the following format in your response:\n\nQuestion: the input question you must answer\nThought: you should always think about what to do\nAction: the action to take, should be one of [search,calculator]\nAction Input: the input to the action\nObservation: the result of the action\n... (this Thought/Action/Action Input/Observation can repeat N times)\nThought: I now know the final answer\nFinal Answer: the final answer to the original input question\n\nBegin!\n\nQuestion: Who is Olivia Wilde's boyfriend? What is his current age raised to the 0.23 power?\nThought: I need to find out who Olivia Wilde's boyfriend is and then calculate his age raised to the 0.23 power.\nAction: search\nAction Input: \"Olivia Wilde boyfriend\"\nObservation: In January 2021, Wilde began dating singer Harry Styles after meeting during the filming of Don't Worry Darling.
4e9727215e95-3207
Their relationship ended in November 2022.\nThought: I need to find out Harry Styles' age.\nAction: search\nAction Input: \"Harry Styles age\"\nObservation: 29 years\nThought: I need to calculate 29 raised to the 0.23 power.\nAction: calculator\nAction Input: 29^0.23\nObservation: 2.169459462491557\nThought:" ]}[llm/end] [1:chain:agent_executor > 11:chain:llm_chain > 12:llm:openai] [3.51s] Exiting LLM run with output: { "generations": [ [ { "text": " I now know the final answer.\nFinal Answer: Harry Styles is Olivia Wilde's boyfriend and his current age raised to the 0.23 power is 2.169459462491557. ", "generationInfo": { "finishReason": "stop", "logprobs": null } } ] ], "llmOutput": { "tokenUsage": { "completionTokens": 39, "promptTokens": 371, "totalTokens": 410 } }}[chain/end] [1:chain:agent_executor > 11:chain:llm_chain] [3.51s] Exiting Chain run with output: { "text": " I now know the final answer.\nFinal Answer: Harry Styles is Olivia Wilde's boyfriend and his current age raised to the 0.23 power is
4e9727215e95-3208
Harry Styles is Olivia Wilde's boyfriend and his current age raised to the 0.23 power is 2.169459462491557. "}[chain/end] [1:chain:agent_executor] [14.90s] Exiting Chain run with output: { "output": "Harry Styles is Olivia Wilde's boyfriend and his current age raised to the 0.23 power is 2.169459462491557. "}PreviousCustom LLM Agent (with a ChatModel)NextAdding a timeout
4e9727215e95-3209
ModulesAgentsHow-toLogging and tracingLogging and tracingYou can pass the verbose flag when creating an agent to enable logging of all events to the console. For example:You can also enable tracing by setting the LANGCHAIN_TRACING environment variable to true.import { initializeAgentExecutorWithOptions } from "langchain/agents";import { OpenAI } from "langchain/llms/openai";import { SerpAPI } from "langchain/tools";import { Calculator } from "langchain/tools/calculator";const model = new OpenAI({ temperature: 0 });const tools = [ new SerpAPI(process.env.SERPAPI_API_KEY, { location: "Austin,Texas,United States", hl: "en", gl: "us", }), new Calculator(),];const executor = await initializeAgentExecutorWithOptions(tools, model, { agentType: "zero-shot-react-description", verbose: true,});const input = `Who is Olivia Wilde's boyfriend? What is his current age raised to the 0.23 power?`;const result = await executor.call({ input });API Reference:initializeAgentExecutorWithOptions from langchain/agentsOpenAI from langchain/llms/openaiSerpAPI from langchain/toolsCalculator from langchain/tools/calculator[chain/start] [1:chain:agent_executor] Entering Chain run with input: { "input": "Who is Olivia Wilde's boyfriend? What is his current age raised to the 0.23 power? "}[chain/start] [1:chain:agent_executor > 2:chain:llm_chain] Entering Chain run with input: { "input": "Who is Olivia Wilde's boyfriend? What is his current age raised to the 0.23 power?
4e9727215e95-3210
", "agent_scratchpad": "", "stop": [ "\nObservation: " ]}[llm/start] [1:chain:agent_executor > 2:chain:llm_chain > 3:llm:openai] Entering LLM run with input: { "prompts": [ "Answer the following questions as best you can. You have access to the following tools:\n\nsearch: a search engine. useful for when you need to answer questions about current events. input should be a search query.\ncalculator: Useful for getting the result of a math expression. The input to this tool should be a valid mathematical expression that could be executed by a simple calculator.\n\nUse the following format in your response:\n\nQuestion: the input question you must answer\nThought: you should always think about what to do\nAction: the action to take, should be one of [search,calculator]\nAction Input: the input to the action\nObservation: the result of the action\n... (this Thought/Action/Action Input/Observation can repeat N times)\nThought: I now know the final answer\nFinal Answer: the final answer to the original input question\n\nBegin!\n\nQuestion: Who is Olivia Wilde's boyfriend?
4e9727215e95-3211
What is his current age raised to the 0.23 power?\nThought:" ]}[llm/end] [1:chain:agent_executor > 2:chain:llm_chain > 3:llm:openai] [3.52s] Exiting LLM run with output: { "generations": [ [ { "text": " I need to find out who Olivia Wilde's boyfriend is and then calculate his age raised to the 0.23 power.\nAction: search\nAction Input: \"Olivia Wilde boyfriend\"", "generationInfo": { "finishReason": "stop", "logprobs": null } } ] ], "llmOutput": { "tokenUsage": { "completionTokens": 39, "promptTokens": 220, "totalTokens": 259 } }}[chain/end] [1:chain:agent_executor > 2:chain:llm_chain] [3.53s] Exiting Chain run with output: { "text": " I need to find out who Olivia Wilde's boyfriend is and then calculate his age raised to the 0.23 power.\nAction: search\nAction Input: \"Olivia Wilde boyfriend\""}[agent/action] [1:chain:agent_executor] Agent selected action: { "tool": "search", "toolInput": "Olivia Wilde boyfriend", "log": " I need to find out who Olivia Wilde's boyfriend is and then calculate his age raised to the 0.23 power.\nAction: search\nAction
4e9727215e95-3212
and then calculate his age raised to the 0.23 power.\nAction: search\nAction Input: \"Olivia Wilde boyfriend\""}[tool/start] [1:chain:agent_executor > 4:tool:search] Entering Tool run with input: "Olivia Wilde boyfriend"[tool/end] [1:chain:agent_executor > 4:tool:search] [845ms] Exiting Tool run with output: "In January 2021, Wilde began dating singer Harry Styles after meeting during the filming of Don't Worry Darling.
4e9727215e95-3213
Their relationship ended in November 2022. "[chain/start] [1:chain:agent_executor > 5:chain:llm_chain] Entering Chain run with input: { "input": "Who is Olivia Wilde's boyfriend? What is his current age raised to the 0.23 power? ", "agent_scratchpad": " I need to find out who Olivia Wilde's boyfriend is and then calculate his age raised to the 0.23 power.\nAction: search\nAction Input: \"Olivia Wilde boyfriend\"\nObservation: In January 2021, Wilde began dating singer Harry Styles after meeting during the filming of Don't Worry Darling. Their relationship ended in November 2022.\nThought:", "stop": [ "\nObservation: " ]}[llm/start] [1:chain:agent_executor > 5:chain:llm_chain > 6:llm:openai] Entering LLM run with input: { "prompts": [ "Answer the following questions as best you can. You have access to the following tools:\n\nsearch: a search engine. useful for when you need to answer questions about current events. input should be a search query.\ncalculator: Useful for getting the result of a math expression.
4e9727215e95-3214
The input to this tool should be a valid mathematical expression that could be executed by a simple calculator.\n\nUse the following format in your response:\n\nQuestion: the input question you must answer\nThought: you should always think about what to do\nAction: the action to take, should be one of [search,calculator]\nAction Input: the input to the action\nObservation: the result of the action\n... (this Thought/Action/Action Input/Observation can repeat N times)\nThought: I now know the final answer\nFinal Answer: the final answer to the original input question\n\nBegin!\n\nQuestion: Who is Olivia Wilde's boyfriend? What is his current age raised to the 0.23 power?\nThought: I need to find out who Olivia Wilde's boyfriend is and then calculate his age raised to the 0.23 power.\nAction: search\nAction Input: \"Olivia Wilde boyfriend\"\nObservation: In January 2021, Wilde began dating singer Harry Styles after meeting during the filming of Don't Worry Darling.
4e9727215e95-3215
Their relationship ended in November 2022.\nThought:" ]}[llm/end] [1:chain:agent_executor > 5:chain:llm_chain > 6:llm:openai] [3.65s] Exiting LLM run with output: { "generations": [ [ { "text": " I need to find out Harry Styles' age.\nAction: search\nAction Input: \"Harry Styles age\"", "generationInfo": { "finishReason": "stop", "logprobs": null } } ] ], "llmOutput": { "tokenUsage": { "completionTokens": 23, "promptTokens": 296, "totalTokens": 319 } }}[chain/end] [1:chain:agent_executor > 5:chain:llm_chain] [3.65s] Exiting Chain run with output: { "text": " I need to find out Harry Styles' age.\nAction: search\nAction Input: \"Harry Styles age\""}[agent/action] [1:chain:agent_executor] Agent selected action: { "tool": "search", "toolInput": "Harry Styles age", "log": " I need to find out Harry Styles' age.\nAction: search\nAction Input: \"Harry Styles age\""}[tool/start] [1:chain:agent_executor > 7:tool:search] Entering Tool run with input: "Harry Styles age"[tool/end] [1:chain:agent_executor >
4e9727215e95-3216
run with input: "Harry Styles age"[tool/end] [1:chain:agent_executor > 7:tool:search] [632ms] Exiting Tool run with output: "29 years"[chain/start] [1:chain:agent_executor > 8:chain:llm_chain] Entering Chain run with input: { "input": "Who is Olivia Wilde's boyfriend? What is his current age raised to the 0.23 power?
4e9727215e95-3217
", "agent_scratchpad": " I need to find out who Olivia Wilde's boyfriend is and then calculate his age raised to the 0.23 power.\nAction: search\nAction Input: \"Olivia Wilde boyfriend\"\nObservation: In January 2021, Wilde began dating singer Harry Styles after meeting during the filming of Don't Worry Darling. Their relationship ended in November 2022.\nThought: I need to find out Harry Styles' age.\nAction: search\nAction Input: \"Harry Styles age\"\nObservation: 29 years\nThought:", "stop": [ "\nObservation: " ]}[llm/start] [1:chain:agent_executor > 8:chain:llm_chain > 9:llm:openai] Entering LLM run with input: { "prompts": [ "Answer the following questions as best you can. You have access to the following tools:\n\nsearch: a search engine. useful for when you need to answer questions about current events. input should be a search query.\ncalculator: Useful for getting the result of a math expression.
4e9727215e95-3218
The input to this tool should be a valid mathematical expression that could be executed by a simple calculator.\n\nUse the following format in your response:\n\nQuestion: the input question you must answer\nThought: you should always think about what to do\nAction: the action to take, should be one of [search,calculator]\nAction Input: the input to the action\nObservation: the result of the action\n... (this Thought/Action/Action Input/Observation can repeat N times)\nThought: I now know the final answer\nFinal Answer: the final answer to the original input question\n\nBegin!\n\nQuestion: Who is Olivia Wilde's boyfriend? What is his current age raised to the 0.23 power?\nThought: I need to find out who Olivia Wilde's boyfriend is and then calculate his age raised to the 0.23 power.\nAction: search\nAction Input: \"Olivia Wilde boyfriend\"\nObservation: In January 2021, Wilde began dating singer Harry Styles after meeting during the filming of Don't Worry Darling.
4e9727215e95-3219
Their relationship ended in November 2022.\nThought: I need to find out Harry Styles' age.\nAction: search\nAction Input: \"Harry Styles age\"\nObservation: 29 years\nThought:" ]}[llm/end] [1:chain:agent_executor > 8:chain:llm_chain > 9:llm:openai] [2.72s] Exiting LLM run with output: { "generations": [ [ { "text": " I need to calculate 29 raised to the 0.23 power.\nAction: calculator\nAction Input: 29^0.23", "generationInfo": { "finishReason": "stop", "logprobs": null } } ] ], "llmOutput": { "tokenUsage": { "completionTokens": 26, "promptTokens": 329, "totalTokens": 355 } }}[chain/end] [1:chain:agent_executor > 8:chain:llm_chain] [2.72s] Exiting Chain run with output: { "text": " I need to calculate 29 raised to the 0.23 power.\nAction: calculator\nAction Input: 29^0.23"}[agent/action] [1:chain:agent_executor] Agent selected action: { "tool": "calculator", "toolInput": "29^0.23", "log": " I need to calculate 29 raised to the 0.23 power.\nAction: calculator\nAction
4e9727215e95-3220
need to calculate 29 raised to the 0.23 power.\nAction: calculator\nAction Input: 29^0.23"}[tool/start] [1:chain:agent_executor > 10:tool:calculator] Entering Tool run with input: "29^0.23"[tool/end] [1:chain:agent_executor > 10:tool:calculator] [3ms] Exiting Tool run with output: "2.169459462491557"[chain/start] [1:chain:agent_executor > 11:chain:llm_chain] Entering Chain run with input: { "input": "Who is Olivia Wilde's boyfriend? What is his current age raised to the 0.23 power?
4e9727215e95-3221
", "agent_scratchpad": " I need to find out who Olivia Wilde's boyfriend is and then calculate his age raised to the 0.23 power.\nAction: search\nAction Input: \"Olivia Wilde boyfriend\"\nObservation: In January 2021, Wilde began dating singer Harry Styles after meeting during the filming of Don't Worry Darling. Their relationship ended in November 2022.\nThought: I need to find out Harry Styles' age.\nAction: search\nAction Input: \"Harry Styles age\"\nObservation: 29 years\nThought: I need to calculate 29 raised to the 0.23 power.\nAction: calculator\nAction Input: 29^0.23\nObservation: 2.169459462491557\nThought:", "stop": [ "\nObservation: " ]}[llm/start] [1:chain:agent_executor > 11:chain:llm_chain > 12:llm:openai] Entering LLM run with input: { "prompts": [ "Answer the following questions as best you can. You have access to the following tools:\n\nsearch: a search engine. useful for when you need to answer questions about current events. input should be a search query.\ncalculator: Useful for getting the result of a math expression.
4e9727215e95-3222
The input to this tool should be a valid mathematical expression that could be executed by a simple calculator.\n\nUse the following format in your response:\n\nQuestion: the input question you must answer\nThought: you should always think about what to do\nAction: the action to take, should be one of [search,calculator]\nAction Input: the input to the action\nObservation: the result of the action\n... (this Thought/Action/Action Input/Observation can repeat N times)\nThought: I now know the final answer\nFinal Answer: the final answer to the original input question\n\nBegin!\n\nQuestion: Who is Olivia Wilde's boyfriend? What is his current age raised to the 0.23 power?\nThought: I need to find out who Olivia Wilde's boyfriend is and then calculate his age raised to the 0.23 power.\nAction: search\nAction Input: \"Olivia Wilde boyfriend\"\nObservation: In January 2021, Wilde began dating singer Harry Styles after meeting during the filming of Don't Worry Darling.
4e9727215e95-3223
Their relationship ended in November 2022.\nThought: I need to find out Harry Styles' age.\nAction: search\nAction Input: \"Harry Styles age\"\nObservation: 29 years\nThought: I need to calculate 29 raised to the 0.23 power.\nAction: calculator\nAction Input: 29^0.23\nObservation: 2.169459462491557\nThought:" ]}[llm/end] [1:chain:agent_executor > 11:chain:llm_chain > 12:llm:openai] [3.51s] Exiting LLM run with output: { "generations": [ [ { "text": " I now know the final answer.\nFinal Answer: Harry Styles is Olivia Wilde's boyfriend and his current age raised to the 0.23 power is 2.169459462491557. ", "generationInfo": { "finishReason": "stop", "logprobs": null } } ] ], "llmOutput": { "tokenUsage": { "completionTokens": 39, "promptTokens": 371, "totalTokens": 410 } }}[chain/end] [1:chain:agent_executor > 11:chain:llm_chain] [3.51s] Exiting Chain run with output: { "text": " I now know the final answer.\nFinal Answer: Harry Styles is Olivia Wilde's boyfriend and his current age raised to the 0.23 power is
4e9727215e95-3224
Harry Styles is Olivia Wilde's boyfriend and his current age raised to the 0.23 power is 2.169459462491557. "}[chain/end] [1:chain:agent_executor] [14.90s] Exiting Chain run with output: { "output": "Harry Styles is Olivia Wilde's boyfriend and his current age raised to the 0.23 power is 2.169459462491557. "}PreviousCustom LLM Agent (with a ChatModel)NextAdding a timeout
4e9727215e95-3225
Logging and tracingYou can pass the verbose flag when creating an agent to enable logging of all events to the console. For example:You can also enable tracing by setting the LANGCHAIN_TRACING environment variable to true.import { initializeAgentExecutorWithOptions } from "langchain/agents";import { OpenAI } from "langchain/llms/openai";import { SerpAPI } from "langchain/tools";import { Calculator } from "langchain/tools/calculator";const model = new OpenAI({ temperature: 0 });const tools = [ new SerpAPI(process.env.SERPAPI_API_KEY, { location: "Austin,Texas,United States", hl: "en", gl: "us", }), new Calculator(),];const executor = await initializeAgentExecutorWithOptions(tools, model, { agentType: "zero-shot-react-description", verbose: true,});const input = `Who is Olivia Wilde's boyfriend? What is his current age raised to the 0.23 power?`;const result = await executor.call({ input });API Reference:initializeAgentExecutorWithOptions from langchain/agentsOpenAI from langchain/llms/openaiSerpAPI from langchain/toolsCalculator from langchain/tools/calculator[chain/start] [1:chain:agent_executor] Entering Chain run with input: { "input": "Who is Olivia Wilde's boyfriend? What is his current age raised to the 0.23 power? "}[chain/start] [1:chain:agent_executor > 2:chain:llm_chain] Entering Chain run with input: { "input": "Who is Olivia Wilde's boyfriend? What is his current age raised to the 0.23 power?
4e9727215e95-3226
", "agent_scratchpad": "", "stop": [ "\nObservation: " ]}[llm/start] [1:chain:agent_executor > 2:chain:llm_chain > 3:llm:openai] Entering LLM run with input: { "prompts": [ "Answer the following questions as best you can. You have access to the following tools:\n\nsearch: a search engine. useful for when you need to answer questions about current events. input should be a search query.\ncalculator: Useful for getting the result of a math expression. The input to this tool should be a valid mathematical expression that could be executed by a simple calculator.\n\nUse the following format in your response:\n\nQuestion: the input question you must answer\nThought: you should always think about what to do\nAction: the action to take, should be one of [search,calculator]\nAction Input: the input to the action\nObservation: the result of the action\n... (this Thought/Action/Action Input/Observation can repeat N times)\nThought: I now know the final answer\nFinal Answer: the final answer to the original input question\n\nBegin!\n\nQuestion: Who is Olivia Wilde's boyfriend?
4e9727215e95-3227
What is his current age raised to the 0.23 power?\nThought:" ]}[llm/end] [1:chain:agent_executor > 2:chain:llm_chain > 3:llm:openai] [3.52s] Exiting LLM run with output: { "generations": [ [ { "text": " I need to find out who Olivia Wilde's boyfriend is and then calculate his age raised to the 0.23 power.\nAction: search\nAction Input: \"Olivia Wilde boyfriend\"", "generationInfo": { "finishReason": "stop", "logprobs": null } } ] ], "llmOutput": { "tokenUsage": { "completionTokens": 39, "promptTokens": 220, "totalTokens": 259 } }}[chain/end] [1:chain:agent_executor > 2:chain:llm_chain] [3.53s] Exiting Chain run with output: { "text": " I need to find out who Olivia Wilde's boyfriend is and then calculate his age raised to the 0.23 power.\nAction: search\nAction Input: \"Olivia Wilde boyfriend\""}[agent/action] [1:chain:agent_executor] Agent selected action: { "tool": "search", "toolInput": "Olivia Wilde boyfriend", "log": " I need to find out who Olivia Wilde's boyfriend is and then calculate his age raised to the 0.23 power.\nAction: search\nAction
4e9727215e95-3228
and then calculate his age raised to the 0.23 power.\nAction: search\nAction Input: \"Olivia Wilde boyfriend\""}[tool/start] [1:chain:agent_executor > 4:tool:search] Entering Tool run with input: "Olivia Wilde boyfriend"[tool/end] [1:chain:agent_executor > 4:tool:search] [845ms] Exiting Tool run with output: "In January 2021, Wilde began dating singer Harry Styles after meeting during the filming of Don't Worry Darling.
4e9727215e95-3229
Their relationship ended in November 2022. "[chain/start] [1:chain:agent_executor > 5:chain:llm_chain] Entering Chain run with input: { "input": "Who is Olivia Wilde's boyfriend? What is his current age raised to the 0.23 power? ", "agent_scratchpad": " I need to find out who Olivia Wilde's boyfriend is and then calculate his age raised to the 0.23 power.\nAction: search\nAction Input: \"Olivia Wilde boyfriend\"\nObservation: In January 2021, Wilde began dating singer Harry Styles after meeting during the filming of Don't Worry Darling. Their relationship ended in November 2022.\nThought:", "stop": [ "\nObservation: " ]}[llm/start] [1:chain:agent_executor > 5:chain:llm_chain > 6:llm:openai] Entering LLM run with input: { "prompts": [ "Answer the following questions as best you can. You have access to the following tools:\n\nsearch: a search engine. useful for when you need to answer questions about current events. input should be a search query.\ncalculator: Useful for getting the result of a math expression.
4e9727215e95-3230
The input to this tool should be a valid mathematical expression that could be executed by a simple calculator.\n\nUse the following format in your response:\n\nQuestion: the input question you must answer\nThought: you should always think about what to do\nAction: the action to take, should be one of [search,calculator]\nAction Input: the input to the action\nObservation: the result of the action\n... (this Thought/Action/Action Input/Observation can repeat N times)\nThought: I now know the final answer\nFinal Answer: the final answer to the original input question\n\nBegin!\n\nQuestion: Who is Olivia Wilde's boyfriend? What is his current age raised to the 0.23 power?\nThought: I need to find out who Olivia Wilde's boyfriend is and then calculate his age raised to the 0.23 power.\nAction: search\nAction Input: \"Olivia Wilde boyfriend\"\nObservation: In January 2021, Wilde began dating singer Harry Styles after meeting during the filming of Don't Worry Darling.
4e9727215e95-3231
Their relationship ended in November 2022.\nThought:" ]}[llm/end] [1:chain:agent_executor > 5:chain:llm_chain > 6:llm:openai] [3.65s] Exiting LLM run with output: { "generations": [ [ { "text": " I need to find out Harry Styles' age.\nAction: search\nAction Input: \"Harry Styles age\"", "generationInfo": { "finishReason": "stop", "logprobs": null } } ] ], "llmOutput": { "tokenUsage": { "completionTokens": 23, "promptTokens": 296, "totalTokens": 319 } }}[chain/end] [1:chain:agent_executor > 5:chain:llm_chain] [3.65s] Exiting Chain run with output: { "text": " I need to find out Harry Styles' age.\nAction: search\nAction Input: \"Harry Styles age\""}[agent/action] [1:chain:agent_executor] Agent selected action: { "tool": "search", "toolInput": "Harry Styles age", "log": " I need to find out Harry Styles' age.\nAction: search\nAction Input: \"Harry Styles age\""}[tool/start] [1:chain:agent_executor > 7:tool:search] Entering Tool run with input: "Harry Styles age"[tool/end] [1:chain:agent_executor >
4e9727215e95-3232
run with input: "Harry Styles age"[tool/end] [1:chain:agent_executor > 7:tool:search] [632ms] Exiting Tool run with output: "29 years"[chain/start] [1:chain:agent_executor > 8:chain:llm_chain] Entering Chain run with input: { "input": "Who is Olivia Wilde's boyfriend? What is his current age raised to the 0.23 power?
4e9727215e95-3233
", "agent_scratchpad": " I need to find out who Olivia Wilde's boyfriend is and then calculate his age raised to the 0.23 power.\nAction: search\nAction Input: \"Olivia Wilde boyfriend\"\nObservation: In January 2021, Wilde began dating singer Harry Styles after meeting during the filming of Don't Worry Darling. Their relationship ended in November 2022.\nThought: I need to find out Harry Styles' age.\nAction: search\nAction Input: \"Harry Styles age\"\nObservation: 29 years\nThought:", "stop": [ "\nObservation: " ]}[llm/start] [1:chain:agent_executor > 8:chain:llm_chain > 9:llm:openai] Entering LLM run with input: { "prompts": [ "Answer the following questions as best you can. You have access to the following tools:\n\nsearch: a search engine. useful for when you need to answer questions about current events. input should be a search query.\ncalculator: Useful for getting the result of a math expression.
4e9727215e95-3234
The input to this tool should be a valid mathematical expression that could be executed by a simple calculator.\n\nUse the following format in your response:\n\nQuestion: the input question you must answer\nThought: you should always think about what to do\nAction: the action to take, should be one of [search,calculator]\nAction Input: the input to the action\nObservation: the result of the action\n... (this Thought/Action/Action Input/Observation can repeat N times)\nThought: I now know the final answer\nFinal Answer: the final answer to the original input question\n\nBegin!\n\nQuestion: Who is Olivia Wilde's boyfriend? What is his current age raised to the 0.23 power?\nThought: I need to find out who Olivia Wilde's boyfriend is and then calculate his age raised to the 0.23 power.\nAction: search\nAction Input: \"Olivia Wilde boyfriend\"\nObservation: In January 2021, Wilde began dating singer Harry Styles after meeting during the filming of Don't Worry Darling.
4e9727215e95-3235
Their relationship ended in November 2022.\nThought: I need to find out Harry Styles' age.\nAction: search\nAction Input: \"Harry Styles age\"\nObservation: 29 years\nThought:" ]}[llm/end] [1:chain:agent_executor > 8:chain:llm_chain > 9:llm:openai] [2.72s] Exiting LLM run with output: { "generations": [ [ { "text": " I need to calculate 29 raised to the 0.23 power.\nAction: calculator\nAction Input: 29^0.23", "generationInfo": { "finishReason": "stop", "logprobs": null } } ] ], "llmOutput": { "tokenUsage": { "completionTokens": 26, "promptTokens": 329, "totalTokens": 355 } }}[chain/end] [1:chain:agent_executor > 8:chain:llm_chain] [2.72s] Exiting Chain run with output: { "text": " I need to calculate 29 raised to the 0.23 power.\nAction: calculator\nAction Input: 29^0.23"}[agent/action] [1:chain:agent_executor] Agent selected action: { "tool": "calculator", "toolInput": "29^0.23", "log": " I need to calculate 29 raised to the 0.23 power.\nAction: calculator\nAction
4e9727215e95-3236
need to calculate 29 raised to the 0.23 power.\nAction: calculator\nAction Input: 29^0.23"}[tool/start] [1:chain:agent_executor > 10:tool:calculator] Entering Tool run with input: "29^0.23"[tool/end] [1:chain:agent_executor > 10:tool:calculator] [3ms] Exiting Tool run with output: "2.169459462491557"[chain/start] [1:chain:agent_executor > 11:chain:llm_chain] Entering Chain run with input: { "input": "Who is Olivia Wilde's boyfriend? What is his current age raised to the 0.23 power?
4e9727215e95-3237
", "agent_scratchpad": " I need to find out who Olivia Wilde's boyfriend is and then calculate his age raised to the 0.23 power.\nAction: search\nAction Input: \"Olivia Wilde boyfriend\"\nObservation: In January 2021, Wilde began dating singer Harry Styles after meeting during the filming of Don't Worry Darling. Their relationship ended in November 2022.\nThought: I need to find out Harry Styles' age.\nAction: search\nAction Input: \"Harry Styles age\"\nObservation: 29 years\nThought: I need to calculate 29 raised to the 0.23 power.\nAction: calculator\nAction Input: 29^0.23\nObservation: 2.169459462491557\nThought:", "stop": [ "\nObservation: " ]}[llm/start] [1:chain:agent_executor > 11:chain:llm_chain > 12:llm:openai] Entering LLM run with input: { "prompts": [ "Answer the following questions as best you can. You have access to the following tools:\n\nsearch: a search engine. useful for when you need to answer questions about current events. input should be a search query.\ncalculator: Useful for getting the result of a math expression.
4e9727215e95-3238
The input to this tool should be a valid mathematical expression that could be executed by a simple calculator.\n\nUse the following format in your response:\n\nQuestion: the input question you must answer\nThought: you should always think about what to do\nAction: the action to take, should be one of [search,calculator]\nAction Input: the input to the action\nObservation: the result of the action\n... (this Thought/Action/Action Input/Observation can repeat N times)\nThought: I now know the final answer\nFinal Answer: the final answer to the original input question\n\nBegin!\n\nQuestion: Who is Olivia Wilde's boyfriend? What is his current age raised to the 0.23 power?\nThought: I need to find out who Olivia Wilde's boyfriend is and then calculate his age raised to the 0.23 power.\nAction: search\nAction Input: \"Olivia Wilde boyfriend\"\nObservation: In January 2021, Wilde began dating singer Harry Styles after meeting during the filming of Don't Worry Darling.
4e9727215e95-3239
Their relationship ended in November 2022.\nThought: I need to find out Harry Styles' age.\nAction: search\nAction Input: \"Harry Styles age\"\nObservation: 29 years\nThought: I need to calculate 29 raised to the 0.23 power.\nAction: calculator\nAction Input: 29^0.23\nObservation: 2.169459462491557\nThought:" ]}[llm/end] [1:chain:agent_executor > 11:chain:llm_chain > 12:llm:openai] [3.51s] Exiting LLM run with output: { "generations": [ [ { "text": " I now know the final answer.\nFinal Answer: Harry Styles is Olivia Wilde's boyfriend and his current age raised to the 0.23 power is 2.169459462491557. ", "generationInfo": { "finishReason": "stop", "logprobs": null } } ] ], "llmOutput": { "tokenUsage": { "completionTokens": 39, "promptTokens": 371, "totalTokens": 410 } }}[chain/end] [1:chain:agent_executor > 11:chain:llm_chain] [3.51s] Exiting Chain run with output: { "text": " I now know the final answer.\nFinal Answer: Harry Styles is Olivia Wilde's boyfriend and his current age raised to the 0.23 power is
4e9727215e95-3240
Harry Styles is Olivia Wilde's boyfriend and his current age raised to the 0.23 power is 2.169459462491557. "}[chain/end] [1:chain:agent_executor] [14.90s] Exiting Chain run with output: { "output": "Harry Styles is Olivia Wilde's boyfriend and his current age raised to the 0.23 power is 2.169459462491557."}
4e9727215e95-3241
You can pass the verbose flag when creating an agent to enable logging of all events to the console. For example: You can also enable tracing by setting the LANGCHAIN_TRACING environment variable to true.
4e9727215e95-3242
You can also enable tracing by setting the LANGCHAIN_TRACING environment variable to true. [chain/start] [1:chain:agent_executor] Entering Chain run with input: { "input": "Who is Olivia Wilde's boyfriend? What is his current age raised to the 0.23 power? "}[chain/start] [1:chain:agent_executor > 2:chain:llm_chain] Entering Chain run with input: { "input": "Who is Olivia Wilde's boyfriend? What is his current age raised to the 0.23 power? ", "agent_scratchpad": "", "stop": [ "\nObservation: " ]}[llm/start] [1:chain:agent_executor > 2:chain:llm_chain > 3:llm:openai] Entering LLM run with input: { "prompts": [ "Answer the following questions as best you can. You have access to the following tools:\n\nsearch: a search engine. useful for when you need to answer questions about current events. input should be a search query.\ncalculator: Useful for getting the result of a math expression. The input to this tool should be a valid mathematical expression that could be executed by a simple calculator.\n\nUse the following format in your response:\n\nQuestion: the input question you must answer\nThought: you should always think about what to do\nAction: the action to take, should be one of [search,calculator]\nAction Input: the input to the action\nObservation: the result of the action\n... (this Thought/Action/Action Input/Observation can repeat N times)\nThought: I now know the final answer\nFinal Answer: the final answer to the original input question\n\nBegin!\n\nQuestion: Who is Olivia Wilde's boyfriend?
4e9727215e95-3243
What is his current age raised to the 0.23 power?\nThought:" ]}[llm/end] [1:chain:agent_executor > 2:chain:llm_chain > 3:llm:openai] [3.52s] Exiting LLM run with output: { "generations": [ [ { "text": " I need to find out who Olivia Wilde's boyfriend is and then calculate his age raised to the 0.23 power.\nAction: search\nAction Input: \"Olivia Wilde boyfriend\"", "generationInfo": { "finishReason": "stop", "logprobs": null } } ] ], "llmOutput": { "tokenUsage": { "completionTokens": 39, "promptTokens": 220, "totalTokens": 259 } }}[chain/end] [1:chain:agent_executor > 2:chain:llm_chain] [3.53s] Exiting Chain run with output: { "text": " I need to find out who Olivia Wilde's boyfriend is and then calculate his age raised to the 0.23 power.\nAction: search\nAction Input: \"Olivia Wilde boyfriend\""}[agent/action] [1:chain:agent_executor] Agent selected action: { "tool": "search", "toolInput": "Olivia Wilde boyfriend", "log": " I need to find out who Olivia Wilde's boyfriend is and then calculate his age raised to the 0.23 power.\nAction: search\nAction
4e9727215e95-3244
and then calculate his age raised to the 0.23 power.\nAction: search\nAction Input: \"Olivia Wilde boyfriend\""}[tool/start] [1:chain:agent_executor > 4:tool:search] Entering Tool run with input: "Olivia Wilde boyfriend"[tool/end] [1:chain:agent_executor > 4:tool:search] [845ms] Exiting Tool run with output: "In January 2021, Wilde began dating singer Harry Styles after meeting during the filming of Don't Worry Darling.
4e9727215e95-3245
Their relationship ended in November 2022. "[chain/start] [1:chain:agent_executor > 5:chain:llm_chain] Entering Chain run with input: { "input": "Who is Olivia Wilde's boyfriend? What is his current age raised to the 0.23 power? ", "agent_scratchpad": " I need to find out who Olivia Wilde's boyfriend is and then calculate his age raised to the 0.23 power.\nAction: search\nAction Input: \"Olivia Wilde boyfriend\"\nObservation: In January 2021, Wilde began dating singer Harry Styles after meeting during the filming of Don't Worry Darling. Their relationship ended in November 2022.\nThought:", "stop": [ "\nObservation: " ]}[llm/start] [1:chain:agent_executor > 5:chain:llm_chain > 6:llm:openai] Entering LLM run with input: { "prompts": [ "Answer the following questions as best you can. You have access to the following tools:\n\nsearch: a search engine. useful for when you need to answer questions about current events. input should be a search query.\ncalculator: Useful for getting the result of a math expression.
4e9727215e95-3246
The input to this tool should be a valid mathematical expression that could be executed by a simple calculator.\n\nUse the following format in your response:\n\nQuestion: the input question you must answer\nThought: you should always think about what to do\nAction: the action to take, should be one of [search,calculator]\nAction Input: the input to the action\nObservation: the result of the action\n... (this Thought/Action/Action Input/Observation can repeat N times)\nThought: I now know the final answer\nFinal Answer: the final answer to the original input question\n\nBegin!\n\nQuestion: Who is Olivia Wilde's boyfriend? What is his current age raised to the 0.23 power?\nThought: I need to find out who Olivia Wilde's boyfriend is and then calculate his age raised to the 0.23 power.\nAction: search\nAction Input: \"Olivia Wilde boyfriend\"\nObservation: In January 2021, Wilde began dating singer Harry Styles after meeting during the filming of Don't Worry Darling.
4e9727215e95-3247
Their relationship ended in November 2022.\nThought:" ]}[llm/end] [1:chain:agent_executor > 5:chain:llm_chain > 6:llm:openai] [3.65s] Exiting LLM run with output: { "generations": [ [ { "text": " I need to find out Harry Styles' age.\nAction: search\nAction Input: \"Harry Styles age\"", "generationInfo": { "finishReason": "stop", "logprobs": null } } ] ], "llmOutput": { "tokenUsage": { "completionTokens": 23, "promptTokens": 296, "totalTokens": 319 } }}[chain/end] [1:chain:agent_executor > 5:chain:llm_chain] [3.65s] Exiting Chain run with output: { "text": " I need to find out Harry Styles' age.\nAction: search\nAction Input: \"Harry Styles age\""}[agent/action] [1:chain:agent_executor] Agent selected action: { "tool": "search", "toolInput": "Harry Styles age", "log": " I need to find out Harry Styles' age.\nAction: search\nAction Input: \"Harry Styles age\""}[tool/start] [1:chain:agent_executor > 7:tool:search] Entering Tool run with input: "Harry Styles age"[tool/end] [1:chain:agent_executor >
4e9727215e95-3248
run with input: "Harry Styles age"[tool/end] [1:chain:agent_executor > 7:tool:search] [632ms] Exiting Tool run with output: "29 years"[chain/start] [1:chain:agent_executor > 8:chain:llm_chain] Entering Chain run with input: { "input": "Who is Olivia Wilde's boyfriend? What is his current age raised to the 0.23 power?
4e9727215e95-3249
", "agent_scratchpad": " I need to find out who Olivia Wilde's boyfriend is and then calculate his age raised to the 0.23 power.\nAction: search\nAction Input: \"Olivia Wilde boyfriend\"\nObservation: In January 2021, Wilde began dating singer Harry Styles after meeting during the filming of Don't Worry Darling. Their relationship ended in November 2022.\nThought: I need to find out Harry Styles' age.\nAction: search\nAction Input: \"Harry Styles age\"\nObservation: 29 years\nThought:", "stop": [ "\nObservation: " ]}[llm/start] [1:chain:agent_executor > 8:chain:llm_chain > 9:llm:openai] Entering LLM run with input: { "prompts": [ "Answer the following questions as best you can. You have access to the following tools:\n\nsearch: a search engine. useful for when you need to answer questions about current events. input should be a search query.\ncalculator: Useful for getting the result of a math expression.
4e9727215e95-3250
The input to this tool should be a valid mathematical expression that could be executed by a simple calculator.\n\nUse the following format in your response:\n\nQuestion: the input question you must answer\nThought: you should always think about what to do\nAction: the action to take, should be one of [search,calculator]\nAction Input: the input to the action\nObservation: the result of the action\n... (this Thought/Action/Action Input/Observation can repeat N times)\nThought: I now know the final answer\nFinal Answer: the final answer to the original input question\n\nBegin!\n\nQuestion: Who is Olivia Wilde's boyfriend? What is his current age raised to the 0.23 power?\nThought: I need to find out who Olivia Wilde's boyfriend is and then calculate his age raised to the 0.23 power.\nAction: search\nAction Input: \"Olivia Wilde boyfriend\"\nObservation: In January 2021, Wilde began dating singer Harry Styles after meeting during the filming of Don't Worry Darling.
4e9727215e95-3251
Their relationship ended in November 2022.\nThought: I need to find out Harry Styles' age.\nAction: search\nAction Input: \"Harry Styles age\"\nObservation: 29 years\nThought:" ]}[llm/end] [1:chain:agent_executor > 8:chain:llm_chain > 9:llm:openai] [2.72s] Exiting LLM run with output: { "generations": [ [ { "text": " I need to calculate 29 raised to the 0.23 power.\nAction: calculator\nAction Input: 29^0.23", "generationInfo": { "finishReason": "stop", "logprobs": null } } ] ], "llmOutput": { "tokenUsage": { "completionTokens": 26, "promptTokens": 329, "totalTokens": 355 } }}[chain/end] [1:chain:agent_executor > 8:chain:llm_chain] [2.72s] Exiting Chain run with output: { "text": " I need to calculate 29 raised to the 0.23 power.\nAction: calculator\nAction Input: 29^0.23"}[agent/action] [1:chain:agent_executor] Agent selected action: { "tool": "calculator", "toolInput": "29^0.23", "log": " I need to calculate 29 raised to the 0.23 power.\nAction: calculator\nAction
4e9727215e95-3252
need to calculate 29 raised to the 0.23 power.\nAction: calculator\nAction Input: 29^0.23"}[tool/start] [1:chain:agent_executor > 10:tool:calculator] Entering Tool run with input: "29^0.23"[tool/end] [1:chain:agent_executor > 10:tool:calculator] [3ms] Exiting Tool run with output: "2.169459462491557"[chain/start] [1:chain:agent_executor > 11:chain:llm_chain] Entering Chain run with input: { "input": "Who is Olivia Wilde's boyfriend? What is his current age raised to the 0.23 power?
4e9727215e95-3253
", "agent_scratchpad": " I need to find out who Olivia Wilde's boyfriend is and then calculate his age raised to the 0.23 power.\nAction: search\nAction Input: \"Olivia Wilde boyfriend\"\nObservation: In January 2021, Wilde began dating singer Harry Styles after meeting during the filming of Don't Worry Darling. Their relationship ended in November 2022.\nThought: I need to find out Harry Styles' age.\nAction: search\nAction Input: \"Harry Styles age\"\nObservation: 29 years\nThought: I need to calculate 29 raised to the 0.23 power.\nAction: calculator\nAction Input: 29^0.23\nObservation: 2.169459462491557\nThought:", "stop": [ "\nObservation: " ]}[llm/start] [1:chain:agent_executor > 11:chain:llm_chain > 12:llm:openai] Entering LLM run with input: { "prompts": [ "Answer the following questions as best you can. You have access to the following tools:\n\nsearch: a search engine. useful for when you need to answer questions about current events. input should be a search query.\ncalculator: Useful for getting the result of a math expression.
4e9727215e95-3254
The input to this tool should be a valid mathematical expression that could be executed by a simple calculator.\n\nUse the following format in your response:\n\nQuestion: the input question you must answer\nThought: you should always think about what to do\nAction: the action to take, should be one of [search,calculator]\nAction Input: the input to the action\nObservation: the result of the action\n... (this Thought/Action/Action Input/Observation can repeat N times)\nThought: I now know the final answer\nFinal Answer: the final answer to the original input question\n\nBegin!\n\nQuestion: Who is Olivia Wilde's boyfriend? What is his current age raised to the 0.23 power?\nThought: I need to find out who Olivia Wilde's boyfriend is and then calculate his age raised to the 0.23 power.\nAction: search\nAction Input: \"Olivia Wilde boyfriend\"\nObservation: In January 2021, Wilde began dating singer Harry Styles after meeting during the filming of Don't Worry Darling.
4e9727215e95-3255
Their relationship ended in November 2022.\nThought: I need to find out Harry Styles' age.\nAction: search\nAction Input: \"Harry Styles age\"\nObservation: 29 years\nThought: I need to calculate 29 raised to the 0.23 power.\nAction: calculator\nAction Input: 29^0.23\nObservation: 2.169459462491557\nThought:" ]}[llm/end] [1:chain:agent_executor > 11:chain:llm_chain > 12:llm:openai] [3.51s] Exiting LLM run with output: { "generations": [ [ { "text": " I now know the final answer.\nFinal Answer: Harry Styles is Olivia Wilde's boyfriend and his current age raised to the 0.23 power is 2.169459462491557. ", "generationInfo": { "finishReason": "stop", "logprobs": null } } ] ], "llmOutput": { "tokenUsage": { "completionTokens": 39, "promptTokens": 371, "totalTokens": 410 } }}[chain/end] [1:chain:agent_executor > 11:chain:llm_chain] [3.51s] Exiting Chain run with output: { "text": " I now know the final answer.\nFinal Answer: Harry Styles is Olivia Wilde's boyfriend and his current age raised to the 0.23 power is
4e9727215e95-3256
Harry Styles is Olivia Wilde's boyfriend and his current age raised to the 0.23 power is 2.169459462491557. "}[chain/end] [1:chain:agent_executor] [14.90s] Exiting Chain run with output: { "output": "Harry Styles is Olivia Wilde's boyfriend and his current age raised to the 0.23 power is 2.169459462491557."}
4e9727215e95-3257
Paragraphs: Skip to main content🦜️🔗 LangChainDocsUse casesAPILangSmithPython DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/​OData connectionChainsMemoryAgentsAgent typesHow-toSubscribing to eventsCancelling requestsCustom LLM AgentCustom LLM Agent (with a ChatModel)Logging and tracingAdding a timeoutToolsToolkitsCallbacksModulesGuidesEcosystemAdditional resourcesCommunity navigatorAPI referenceModulesAgentsHow-toAdding a timeoutAdding a timeoutBy default, LangChain will wait indefinitely for a response from the model provider. If you want to add a timeout to an agent, you can pass a timeout option, when you run the agent. For example:import { initializeAgentExecutorWithOptions } from "langchain/agents";import { OpenAI } from "langchain/llms/openai";import { SerpAPI } from "langchain/tools";import { Calculator } from "langchain/tools/calculator";const model = new OpenAI({ temperature: 0 });const tools = [ new SerpAPI(process.env.SERPAPI_API_KEY, { location: "Austin,Texas,United States", hl: "en", gl: "us", }), new Calculator(),];const executor = await initializeAgentExecutorWithOptions(tools, model, { agentType: "zero-shot-react-description",});try { const input = `Who is Olivia Wilde's boyfriend?
4e9727215e95-3258
What is his current age raised to the 0.23 power?`; const result = await executor.call({ input, timeout: 2000 }); // 2 seconds} catch (e) { console.log(e); /* Error: Cancel: canceled at file:///Users/nuno/dev/langchainjs/langchain/dist/util/async_caller.js:60:23 at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at RetryOperation._fn (/Users/nuno/dev/langchainjs/node_modules/p-retry/index.js:50:12) { attemptNumber: 1, retriesLeft: 6 } */}API Reference:initializeAgentExecutorWithOptions from langchain/agentsOpenAI from langchain/llms/openaiSerpAPI from langchain/toolsCalculator from langchain/tools/calculatorPreviousLogging and tracingNextToolsCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright © 2023 LangChain, Inc.
4e9727215e95-3259
Get startedIntroductionInstallationQuickstartModulesModel I/​OData connectionChainsMemoryAgentsAgent typesHow-toSubscribing to eventsCancelling requestsCustom LLM AgentCustom LLM Agent (with a ChatModel)Logging and tracingAdding a timeoutToolsToolkitsCallbacksModulesGuidesEcosystemAdditional resourcesCommunity navigatorAPI referenceModulesAgentsHow-toAdding a timeoutAdding a timeoutBy default, LangChain will wait indefinitely for a response from the model provider. If you want to add a timeout to an agent, you can pass a timeout option, when you run the agent. For example:import { initializeAgentExecutorWithOptions } from "langchain/agents";import { OpenAI } from "langchain/llms/openai";import { SerpAPI } from "langchain/tools";import { Calculator } from "langchain/tools/calculator";const model = new OpenAI({ temperature: 0 });const tools = [ new SerpAPI(process.env.SERPAPI_API_KEY, { location: "Austin,Texas,United States", hl: "en", gl: "us", }), new Calculator(),];const executor = await initializeAgentExecutorWithOptions(tools, model, { agentType: "zero-shot-react-description",});try { const input = `Who is Olivia Wilde's boyfriend?
4e9727215e95-3260
What is his current age raised to the 0.23 power?`; const result = await executor.call({ input, timeout: 2000 }); // 2 seconds} catch (e) { console.log(e); /* Error: Cancel: canceled at file:///Users/nuno/dev/langchainjs/langchain/dist/util/async_caller.js:60:23 at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at RetryOperation._fn (/Users/nuno/dev/langchainjs/node_modules/p-retry/index.js:50:12) { attemptNumber: 1, retriesLeft: 6 } */}API Reference:initializeAgentExecutorWithOptions from langchain/agentsOpenAI from langchain/llms/openaiSerpAPI from langchain/toolsCalculator from langchain/tools/calculatorPreviousLogging and tracingNextTools ModulesAgentsHow-toAdding a timeoutAdding a timeoutBy default, LangChain will wait indefinitely for a response from the model provider. If you want to add a timeout to an agent, you can pass a timeout option, when you run the agent. For example:import { initializeAgentExecutorWithOptions } from "langchain/agents";import { OpenAI } from "langchain/llms/openai";import { SerpAPI } from "langchain/tools";import { Calculator } from "langchain/tools/calculator";const model = new OpenAI({ temperature: 0 });const tools = [ new SerpAPI(process.env.SERPAPI_API_KEY, { location: "Austin,Texas,United States", hl: "en", gl: "us", }), new Calculator(),];const executor = await initializeAgentExecutorWithOptions(tools, model, { agentType: "zero-shot-react-description",});try { const input = `Who is Olivia Wilde's boyfriend?
4e9727215e95-3261
What is his current age raised to the 0.23 power?`; const result = await executor.call({ input, timeout: 2000 }); // 2 seconds} catch (e) { console.log(e); /* Error: Cancel: canceled at file:///Users/nuno/dev/langchainjs/langchain/dist/util/async_caller.js:60:23 at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at RetryOperation._fn (/Users/nuno/dev/langchainjs/node_modules/p-retry/index.js:50:12) { attemptNumber: 1, retriesLeft: 6 } */}API Reference:initializeAgentExecutorWithOptions from langchain/agentsOpenAI from langchain/llms/openaiSerpAPI from langchain/toolsCalculator from langchain/tools/calculatorPreviousLogging and tracingNextTools
4e9727215e95-3262
Adding a timeoutBy default, LangChain will wait indefinitely for a response from the model provider. If you want to add a timeout to an agent, you can pass a timeout option, when you run the agent. For example:import { initializeAgentExecutorWithOptions } from "langchain/agents";import { OpenAI } from "langchain/llms/openai";import { SerpAPI } from "langchain/tools";import { Calculator } from "langchain/tools/calculator";const model = new OpenAI({ temperature: 0 });const tools = [ new SerpAPI(process.env.SERPAPI_API_KEY, { location: "Austin,Texas,United States", hl: "en", gl: "us", }), new Calculator(),];const executor = await initializeAgentExecutorWithOptions(tools, model, { agentType: "zero-shot-react-description",});try { const input = `Who is Olivia Wilde's boyfriend? What is his current age raised to the 0.23 power?`; const result = await executor.call({ input, timeout: 2000 }); // 2 seconds} catch (e) { console.log(e); /* Error: Cancel: canceled at file:///Users/nuno/dev/langchainjs/langchain/dist/util/async_caller.js:60:23 at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at RetryOperation._fn (/Users/nuno/dev/langchainjs/node_modules/p-retry/index.js:50:12) { attemptNumber: 1, retriesLeft: 6 } */}API Reference:initializeAgentExecutorWithOptions from langchain/agentsOpenAI from langchain/llms/openaiSerpAPI from langchain/toolsCalculator from langchain/tools/calculator
4e9727215e95-3263
By default, LangChain will wait indefinitely for a response from the model provider. If you want to add a timeout to an agent, you can pass a timeout option, when you run the agent. For example: import { initializeAgentExecutorWithOptions } from "langchain/agents";import { OpenAI } from "langchain/llms/openai";import { SerpAPI } from "langchain/tools";import { Calculator } from "langchain/tools/calculator";const model = new OpenAI({ temperature: 0 });const tools = [ new SerpAPI(process.env.SERPAPI_API_KEY, { location: "Austin,Texas,United States", hl: "en", gl: "us", }), new Calculator(),];const executor = await initializeAgentExecutorWithOptions(tools, model, { agentType: "zero-shot-react-description",});try { const input = `Who is Olivia Wilde's boyfriend? What is his current age raised to the 0.23 power?`; const result = await executor.call({ input, timeout: 2000 }); // 2 seconds} catch (e) { console.log(e); /* Error: Cancel: canceled at file:///Users/nuno/dev/langchainjs/langchain/dist/util/async_caller.js:60:23 at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at RetryOperation._fn (/Users/nuno/dev/langchainjs/node_modules/p-retry/index.js:50:12) { attemptNumber: 1, retriesLeft: 6 } */} Page Title: Tools | 🦜️🔗 Langchain Paragraphs:
4e9727215e95-3264
Page Title: Tools | 🦜️🔗 Langchain Paragraphs: Skip to main content🦜️🔗 LangChainDocsUse casesAPILangSmithPython DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/​OData connectionChainsMemoryAgentsAgent typesHow-toToolsHow-toIntegrationsToolkitsCallbacksModulesGuidesEcosystemAdditional resourcesCommunity navigatorAPI referenceModulesAgentsToolsOn this pageToolsTools are interfaces that an agent can use to interact with the world.Get started​Tools are functions that agents can use to interact with the world. These tools can be generic utilities (e.g. search), other chains, or even other agents.Specifically, the interface of a tool has a single text input and a single text output. It includes a name and description that communicate to the model what the tool does and when to use it.interface Tool { call(arg: string): Promise<string>; name: string; description: string;}Advanced​To implement your own tool you can subclass the Tool class and implement the _call method. The _call method is called with the input text and should return the output text. The Tool superclass implements the call method, which takes care of calling the right CallbackManager methods before and after calling your _call method. When an error occurs, the _call method should when possible return a string representing an error, rather than throwing an error. This allows the error to be passed to the LLM and the LLM can decide how to handle it. If an error is thrown then execution of the agent will stop.abstract class Tool { abstract _call(arg: string): Promise<string>; abstract name: string; abstract description: string;}PreviousAdding a timeoutNextVector stores as toolsGet startedCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright © 2023 LangChain, Inc.
4e9727215e95-3265
Get startedIntroductionInstallationQuickstartModulesModel I/​OData connectionChainsMemoryAgentsAgent typesHow-toToolsHow-toIntegrationsToolkitsCallbacksModulesGuidesEcosystemAdditional resourcesCommunity navigatorAPI referenceModulesAgentsToolsOn this pageToolsTools are interfaces that an agent can use to interact with the world.Get started​Tools are functions that agents can use to interact with the world. These tools can be generic utilities (e.g. search), other chains, or even other agents.Specifically, the interface of a tool has a single text input and a single text output. It includes a name and description that communicate to the model what the tool does and when to use it.interface Tool { call(arg: string): Promise<string>; name: string; description: string;}Advanced​To implement your own tool you can subclass the Tool class and implement the _call method. The _call method is called with the input text and should return the output text. The Tool superclass implements the call method, which takes care of calling the right CallbackManager methods before and after calling your _call method. When an error occurs, the _call method should when possible return a string representing an error, rather than throwing an error. This allows the error to be passed to the LLM and the LLM can decide how to handle it. If an error is thrown then execution of the agent will stop.abstract class Tool { abstract _call(arg: string): Promise<string>; abstract name: string; abstract description: string;}PreviousAdding a timeoutNextVector stores as toolsGet started Get startedIntroductionInstallationQuickstartModulesModel I/​OData connectionChainsMemoryAgentsAgent typesHow-toToolsHow-toIntegrationsToolkitsCallbacksModulesGuidesEcosystemAdditional resourcesCommunity navigatorAPI reference
4e9727215e95-3266
ModulesAgentsToolsOn this pageToolsTools are interfaces that an agent can use to interact with the world.Get started​Tools are functions that agents can use to interact with the world. These tools can be generic utilities (e.g. search), other chains, or even other agents.Specifically, the interface of a tool has a single text input and a single text output. It includes a name and description that communicate to the model what the tool does and when to use it.interface Tool { call(arg: string): Promise<string>; name: string; description: string;}Advanced​To implement your own tool you can subclass the Tool class and implement the _call method. The _call method is called with the input text and should return the output text. The Tool superclass implements the call method, which takes care of calling the right CallbackManager methods before and after calling your _call method. When an error occurs, the _call method should when possible return a string representing an error, rather than throwing an error. This allows the error to be passed to the LLM and the LLM can decide how to handle it. If an error is thrown then execution of the agent will stop.abstract class Tool { abstract _call(arg: string): Promise<string>; abstract name: string; abstract description: string;}PreviousAdding a timeoutNextVector stores as toolsGet started ModulesAgentsToolsOn this pageToolsTools are interfaces that an agent can use to interact with the world.Get started​Tools are functions that agents can use to interact with the world.
4e9727215e95-3267
These tools can be generic utilities (e.g. search), other chains, or even other agents.Specifically, the interface of a tool has a single text input and a single text output. It includes a name and description that communicate to the model what the tool does and when to use it.interface Tool { call(arg: string): Promise<string>; name: string; description: string;}Advanced​To implement your own tool you can subclass the Tool class and implement the _call method. The _call method is called with the input text and should return the output text. The Tool superclass implements the call method, which takes care of calling the right CallbackManager methods before and after calling your _call method. When an error occurs, the _call method should when possible return a string representing an error, rather than throwing an error. This allows the error to be passed to the LLM and the LLM can decide how to handle it. If an error is thrown then execution of the agent will stop.abstract class Tool { abstract _call(arg: string): Promise<string>; abstract name: string; abstract description: string;}PreviousAdding a timeoutNextVector stores as tools ToolsTools are interfaces that an agent can use to interact with the world.Get started​Tools are functions that agents can use to interact with the world.
4e9727215e95-3268
These tools can be generic utilities (e.g. search), other chains, or even other agents.Specifically, the interface of a tool has a single text input and a single text output. It includes a name and description that communicate to the model what the tool does and when to use it.interface Tool { call(arg: string): Promise<string>; name: string; description: string;}Advanced​To implement your own tool you can subclass the Tool class and implement the _call method. The _call method is called with the input text and should return the output text. The Tool superclass implements the call method, which takes care of calling the right CallbackManager methods before and after calling your _call method. When an error occurs, the _call method should when possible return a string representing an error, rather than throwing an error. This allows the error to be passed to the LLM and the LLM can decide how to handle it. If an error is thrown then execution of the agent will stop.abstract class Tool { abstract _call(arg: string): Promise<string>; abstract name: string; abstract description: string;} Tools are interfaces that an agent can use to interact with the world. Tools are functions that agents can use to interact with the world. These tools can be generic utilities (e.g. search), other chains, or even other agents. Specifically, the interface of a tool has a single text input and a single text output. It includes a name and description that communicate to the model what the tool does and when to use it. interface Tool { call(arg: string): Promise<string>; name: string; description: string;}
4e9727215e95-3269
To implement your own tool you can subclass the Tool class and implement the _call method. The _call method is called with the input text and should return the output text. The Tool superclass implements the call method, which takes care of calling the right CallbackManager methods before and after calling your _call method. When an error occurs, the _call method should when possible return a string representing an error, rather than throwing an error. This allows the error to be passed to the LLM and the LLM can decide how to handle it. If an error is thrown then execution of the agent will stop. abstract class Tool { abstract _call(arg: string): Promise<string>; abstract name: string; abstract description: string;} Vector stores as tools Page Title: Vector stores as tools | 🦜️🔗 Langchain Paragraphs: Skip to main content🦜️🔗 LangChainDocsUse casesAPILangSmithPython DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/​OData connectionChainsMemoryAgentsAgent typesHow-toToolsHow-toVector stores as toolsCustom toolsIntegrationsToolkitsCallbacksModulesGuidesEcosystemAdditional resourcesCommunity navigatorAPI referenceModulesAgentsToolsHow-toVector stores as toolsVector stores as toolsThis notebook covers how to combine agents and vector stores. The use case for this is that you’ve ingested your data into a vector store and want to interact with it in an agentic manner.The recommended method for doing so is to create a VectorDBQAChain and then use that as a tool in the overall agent. Let’s take a look at doing this below. You can do this with multiple different vector databases, and use the agent as a way to choose between them.
4e9727215e95-3270
There are two different ways of doing this - you can either let the agent use the vector stores as normal tools, or you can set returnDirect: true to just use the agent as a router.First, you'll want to import the relevant modules:import { OpenAI } from "langchain/llms/openai";import { initializeAgentExecutorWithOptions } from "langchain/agents";import { SerpAPI, ChainTool } from "langchain/tools";import { Calculator } from "langchain/tools/calculator";import { VectorDBQAChain } from "langchain/chains";import { HNSWLib } from "langchain/vectorstores/hnswlib";import { OpenAIEmbeddings } from "langchain/embeddings/openai";import { RecursiveCharacterTextSplitter } from "langchain/text_splitter";import * as fs from "fs";Next, you'll want to create the vector store with your data, and then the QA chain to interact with that vector store.const model = new OpenAI({ temperature: 0 });/* Load in the file we want to do question answering over */const text = fs.readFileSync("state_of_the_union.txt", "utf8");/* Split the text into chunks */const textSplitter = new RecursiveCharacterTextSplitter({ chunkSize: 1000 });const docs = await textSplitter.createDocuments([text]);/* Create the vectorstore */const vectorStore = await HNSWLib.fromDocuments(docs, new OpenAIEmbeddings());/* Create the chain */const chain = VectorDBQAChain.fromLLM(model, vectorStore);Now that you have that chain, you can create a tool to use that chain.
4e9727215e95-3271
Note that you should update the name and description to be specific to your QA chain.const qaTool = new ChainTool({ name: "state-of-union-qa", description: "State of the Union QA - useful for when you need to ask questions about the most recent state of the union address. ", chain: chain,});Now you can construct and using the tool just as you would any other!const tools = [ new SerpAPI(process.env.SERPAPI_API_KEY, { location: "Austin,Texas,United States", hl: "en", gl: "us", }), new Calculator(), qaTool,];const executor = await initializeAgentExecutorWithOptions(tools, model, { agentType: "zero-shot-react-description",});console.log("Loaded agent. ");const input = `What did biden say about ketanji brown jackson is the state of the union address?`;console.log(`Executing with input "${input}"...`);const result = await executor.call({ input });console.log(`Got output ${result.output}`);You can also set returnDirect: true if you intend to use the agent as a router and just want to directly return the result of the VectorDBQAChain.const qaTool = new ChainTool({ name: "state-of-union-qa", description: "State of the Union QA - useful for when you need to ask questions about the most recent state of the union address. ", chain: chain, returnDirect: true,});PreviousToolsNextCustom toolsCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright © 2023 LangChain, Inc.
4e9727215e95-3272
Get startedIntroductionInstallationQuickstartModulesModel I/​OData connectionChainsMemoryAgentsAgent typesHow-toToolsHow-toVector stores as toolsCustom toolsIntegrationsToolkitsCallbacksModulesGuidesEcosystemAdditional resourcesCommunity navigatorAPI referenceModulesAgentsToolsHow-toVector stores as toolsVector stores as toolsThis notebook covers how to combine agents and vector stores. The use case for this is that you’ve ingested your data into a vector store and want to interact with it in an agentic manner.The recommended method for doing so is to create a VectorDBQAChain and then use that as a tool in the overall agent. Let’s take a look at doing this below. You can do this with multiple different vector databases, and use the agent as a way to choose between them.
4e9727215e95-3273
There are two different ways of doing this - you can either let the agent use the vector stores as normal tools, or you can set returnDirect: true to just use the agent as a router.First, you'll want to import the relevant modules:import { OpenAI } from "langchain/llms/openai";import { initializeAgentExecutorWithOptions } from "langchain/agents";import { SerpAPI, ChainTool } from "langchain/tools";import { Calculator } from "langchain/tools/calculator";import { VectorDBQAChain } from "langchain/chains";import { HNSWLib } from "langchain/vectorstores/hnswlib";import { OpenAIEmbeddings } from "langchain/embeddings/openai";import { RecursiveCharacterTextSplitter } from "langchain/text_splitter";import * as fs from "fs";Next, you'll want to create the vector store with your data, and then the QA chain to interact with that vector store.const model = new OpenAI({ temperature: 0 });/* Load in the file we want to do question answering over */const text = fs.readFileSync("state_of_the_union.txt", "utf8");/* Split the text into chunks */const textSplitter = new RecursiveCharacterTextSplitter({ chunkSize: 1000 });const docs = await textSplitter.createDocuments([text]);/* Create the vectorstore */const vectorStore = await HNSWLib.fromDocuments(docs, new OpenAIEmbeddings());/* Create the chain */const chain = VectorDBQAChain.fromLLM(model, vectorStore);Now that you have that chain, you can create a tool to use that chain.
4e9727215e95-3274
Note that you should update the name and description to be specific to your QA chain.const qaTool = new ChainTool({ name: "state-of-union-qa", description: "State of the Union QA - useful for when you need to ask questions about the most recent state of the union address. ", chain: chain,});Now you can construct and using the tool just as you would any other!const tools = [ new SerpAPI(process.env.SERPAPI_API_KEY, { location: "Austin,Texas,United States", hl: "en", gl: "us", }), new Calculator(), qaTool,];const executor = await initializeAgentExecutorWithOptions(tools, model, { agentType: "zero-shot-react-description",});console.log("Loaded agent. ");const input = `What did biden say about ketanji brown jackson is the state of the union address?`;console.log(`Executing with input "${input}"...`);const result = await executor.call({ input });console.log(`Got output ${result.output}`);You can also set returnDirect: true if you intend to use the agent as a router and just want to directly return the result of the VectorDBQAChain.const qaTool = new ChainTool({ name: "state-of-union-qa", description: "State of the Union QA - useful for when you need to ask questions about the most recent state of the union address. ", chain: chain, returnDirect: true,});PreviousToolsNextCustom tools Get startedIntroductionInstallationQuickstartModulesModel I/​OData connectionChainsMemoryAgentsAgent typesHow-toToolsHow-toVector stores as toolsCustom toolsIntegrationsToolkitsCallbacksModulesGuidesEcosystemAdditional resourcesCommunity navigatorAPI reference
4e9727215e95-3275
ModulesAgentsToolsHow-toVector stores as toolsVector stores as toolsThis notebook covers how to combine agents and vector stores. The use case for this is that you’ve ingested your data into a vector store and want to interact with it in an agentic manner.The recommended method for doing so is to create a VectorDBQAChain and then use that as a tool in the overall agent. Let’s take a look at doing this below. You can do this with multiple different vector databases, and use the agent as a way to choose between them.
4e9727215e95-3276
There are two different ways of doing this - you can either let the agent use the vector stores as normal tools, or you can set returnDirect: true to just use the agent as a router.First, you'll want to import the relevant modules:import { OpenAI } from "langchain/llms/openai";import { initializeAgentExecutorWithOptions } from "langchain/agents";import { SerpAPI, ChainTool } from "langchain/tools";import { Calculator } from "langchain/tools/calculator";import { VectorDBQAChain } from "langchain/chains";import { HNSWLib } from "langchain/vectorstores/hnswlib";import { OpenAIEmbeddings } from "langchain/embeddings/openai";import { RecursiveCharacterTextSplitter } from "langchain/text_splitter";import * as fs from "fs";Next, you'll want to create the vector store with your data, and then the QA chain to interact with that vector store.const model = new OpenAI({ temperature: 0 });/* Load in the file we want to do question answering over */const text = fs.readFileSync("state_of_the_union.txt", "utf8");/* Split the text into chunks */const textSplitter = new RecursiveCharacterTextSplitter({ chunkSize: 1000 });const docs = await textSplitter.createDocuments([text]);/* Create the vectorstore */const vectorStore = await HNSWLib.fromDocuments(docs, new OpenAIEmbeddings());/* Create the chain */const chain = VectorDBQAChain.fromLLM(model, vectorStore);Now that you have that chain, you can create a tool to use that chain.
4e9727215e95-3277
Note that you should update the name and description to be specific to your QA chain.const qaTool = new ChainTool({ name: "state-of-union-qa", description: "State of the Union QA - useful for when you need to ask questions about the most recent state of the union address. ", chain: chain,});Now you can construct and using the tool just as you would any other!const tools = [ new SerpAPI(process.env.SERPAPI_API_KEY, { location: "Austin,Texas,United States", hl: "en", gl: "us", }), new Calculator(), qaTool,];const executor = await initializeAgentExecutorWithOptions(tools, model, { agentType: "zero-shot-react-description",});console.log("Loaded agent. ");const input = `What did biden say about ketanji brown jackson is the state of the union address?`;console.log(`Executing with input "${input}"...`);const result = await executor.call({ input });console.log(`Got output ${result.output}`);You can also set returnDirect: true if you intend to use the agent as a router and just want to directly return the result of the VectorDBQAChain.const qaTool = new ChainTool({ name: "state-of-union-qa", description: "State of the Union QA - useful for when you need to ask questions about the most recent state of the union address. ", chain: chain, returnDirect: true,});PreviousToolsNextCustom tools
4e9727215e95-3278
Vector stores as toolsThis notebook covers how to combine agents and vector stores. The use case for this is that you’ve ingested your data into a vector store and want to interact with it in an agentic manner.The recommended method for doing so is to create a VectorDBQAChain and then use that as a tool in the overall agent. Let’s take a look at doing this below. You can do this with multiple different vector databases, and use the agent as a way to choose between them.
4e9727215e95-3279
There are two different ways of doing this - you can either let the agent use the vector stores as normal tools, or you can set returnDirect: true to just use the agent as a router.First, you'll want to import the relevant modules:import { OpenAI } from "langchain/llms/openai";import { initializeAgentExecutorWithOptions } from "langchain/agents";import { SerpAPI, ChainTool } from "langchain/tools";import { Calculator } from "langchain/tools/calculator";import { VectorDBQAChain } from "langchain/chains";import { HNSWLib } from "langchain/vectorstores/hnswlib";import { OpenAIEmbeddings } from "langchain/embeddings/openai";import { RecursiveCharacterTextSplitter } from "langchain/text_splitter";import * as fs from "fs";Next, you'll want to create the vector store with your data, and then the QA chain to interact with that vector store.const model = new OpenAI({ temperature: 0 });/* Load in the file we want to do question answering over */const text = fs.readFileSync("state_of_the_union.txt", "utf8");/* Split the text into chunks */const textSplitter = new RecursiveCharacterTextSplitter({ chunkSize: 1000 });const docs = await textSplitter.createDocuments([text]);/* Create the vectorstore */const vectorStore = await HNSWLib.fromDocuments(docs, new OpenAIEmbeddings());/* Create the chain */const chain = VectorDBQAChain.fromLLM(model, vectorStore);Now that you have that chain, you can create a tool to use that chain.
4e9727215e95-3280
Note that you should update the name and description to be specific to your QA chain.const qaTool = new ChainTool({ name: "state-of-union-qa", description: "State of the Union QA - useful for when you need to ask questions about the most recent state of the union address. ", chain: chain,});Now you can construct and using the tool just as you would any other!const tools = [ new SerpAPI(process.env.SERPAPI_API_KEY, { location: "Austin,Texas,United States", hl: "en", gl: "us", }), new Calculator(), qaTool,];const executor = await initializeAgentExecutorWithOptions(tools, model, { agentType: "zero-shot-react-description",});console.log("Loaded agent. ");const input = `What did biden say about ketanji brown jackson is the state of the union address?`;console.log(`Executing with input "${input}"...`);const result = await executor.call({ input });console.log(`Got output ${result.output}`);You can also set returnDirect: true if you intend to use the agent as a router and just want to directly return the result of the VectorDBQAChain.const qaTool = new ChainTool({ name: "state-of-union-qa", description: "State of the Union QA - useful for when you need to ask questions about the most recent state of the union address. ", chain: chain, returnDirect: true,}); This notebook covers how to combine agents and vector stores. The use case for this is that you’ve ingested your data into a vector store and want to interact with it in an agentic manner.
4e9727215e95-3281
The recommended method for doing so is to create a VectorDBQAChain and then use that as a tool in the overall agent. Let’s take a look at doing this below. You can do this with multiple different vector databases, and use the agent as a way to choose between them. There are two different ways of doing this - you can either let the agent use the vector stores as normal tools, or you can set returnDirect: true to just use the agent as a router. First, you'll want to import the relevant modules: import { OpenAI } from "langchain/llms/openai";import { initializeAgentExecutorWithOptions } from "langchain/agents";import { SerpAPI, ChainTool } from "langchain/tools";import { Calculator } from "langchain/tools/calculator";import { VectorDBQAChain } from "langchain/chains";import { HNSWLib } from "langchain/vectorstores/hnswlib";import { OpenAIEmbeddings } from "langchain/embeddings/openai";import { RecursiveCharacterTextSplitter } from "langchain/text_splitter";import * as fs from "fs"; Next, you'll want to create the vector store with your data, and then the QA chain to interact with that vector store. const model = new OpenAI({ temperature: 0 });/* Load in the file we want to do question answering over */const text = fs.readFileSync("state_of_the_union.txt", "utf8");/* Split the text into chunks */const textSplitter = new RecursiveCharacterTextSplitter({ chunkSize: 1000 });const docs = await textSplitter.createDocuments([text]);/* Create the vectorstore */const vectorStore = await HNSWLib.fromDocuments(docs, new OpenAIEmbeddings());/* Create the chain */const chain = VectorDBQAChain.fromLLM(model, vectorStore);
4e9727215e95-3282
Now that you have that chain, you can create a tool to use that chain. Note that you should update the name and description to be specific to your QA chain. const qaTool = new ChainTool({ name: "state-of-union-qa", description: "State of the Union QA - useful for when you need to ask questions about the most recent state of the union address. ", chain: chain,}); Now you can construct and using the tool just as you would any other! const tools = [ new SerpAPI(process.env.SERPAPI_API_KEY, { location: "Austin,Texas,United States", hl: "en", gl: "us", }), new Calculator(), qaTool,];const executor = await initializeAgentExecutorWithOptions(tools, model, { agentType: "zero-shot-react-description",});console.log("Loaded agent. ");const input = `What did biden say about ketanji brown jackson is the state of the union address?`;console.log(`Executing with input "${input}"...`);const result = await executor.call({ input });console.log(`Got output ${result.output}`); You can also set returnDirect: true if you intend to use the agent as a router and just want to directly return the result of the VectorDBQAChain. const qaTool = new ChainTool({ name: "state-of-union-qa", description: "State of the Union QA - useful for when you need to ask questions about the most recent state of the union address. ", chain: chain, returnDirect: true,}); Custom tools Page Title: Custom tools | 🦜️🔗 Langchain Paragraphs:
4e9727215e95-3283
Page Title: Custom tools | 🦜️🔗 Langchain Paragraphs: Skip to main content🦜️🔗 LangChainDocsUse casesAPILangSmithPython DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/​OData connectionChainsMemoryAgentsAgent typesHow-toToolsHow-toVector stores as toolsCustom toolsIntegrationsToolkitsCallbacksModulesGuidesEcosystemAdditional resourcesCommunity navigatorAPI referenceModulesAgentsToolsHow-toCustom toolsCustom toolsOne option for creating a tool that runs custom code is to use a DynamicTool.The DynamicTool class takes as input a name, a description, and a function. Importantly, the name and the description will be used by the language model to determine when to call this function and with what parameters, so make sure to set these to some values the language model can reason about!The provided function is what will the agent will actually call. When an error occurs, the function should, when possible, return a string representing an error, rather than throwing an error.
4e9727215e95-3284
This allows the error to be passed to the LLM and the LLM can decide how to handle it. If an error is thrown, then execution of the agent will stop.See below for an example of defining and using DynamicTools.import { OpenAI } from "langchain/llms/openai";import { initializeAgentExecutorWithOptions } from "langchain/agents";import { DynamicTool } from "langchain/tools";export const run = async () => { const model = new OpenAI({ temperature: 0 }); const tools = [ new DynamicTool({ name: "FOO", description: "call this to get the value of foo. input should be an empty string. ", func: async () => "baz", }), new DynamicTool({ name: "BAR", description: "call this to get the value of bar. input should be an empty string. ", func: async () => "baz1", }), ]; const executor = await initializeAgentExecutorWithOptions(tools, model, { agentType: "zero-shot-react-description", }); console.log("Loaded agent. "); const input = `What is the value of foo?`; console.log(`Executing with input "${input}"...`); const result = await executor.call({ input }); console.log(`Got output ${result.output}`);};PreviousVector stores as toolsNextIntegrationsCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright © 2023 LangChain, Inc.
4e9727215e95-3285
Get startedIntroductionInstallationQuickstartModulesModel I/​OData connectionChainsMemoryAgentsAgent typesHow-toToolsHow-toVector stores as toolsCustom toolsIntegrationsToolkitsCallbacksModulesGuidesEcosystemAdditional resourcesCommunity navigatorAPI referenceModulesAgentsToolsHow-toCustom toolsCustom toolsOne option for creating a tool that runs custom code is to use a DynamicTool.The DynamicTool class takes as input a name, a description, and a function. Importantly, the name and the description will be used by the language model to determine when to call this function and with what parameters, so make sure to set these to some values the language model can reason about!The provided function is what will the agent will actually call. When an error occurs, the function should, when possible, return a string representing an error, rather than throwing an error.
4e9727215e95-3286
This allows the error to be passed to the LLM and the LLM can decide how to handle it. If an error is thrown, then execution of the agent will stop.See below for an example of defining and using DynamicTools.import { OpenAI } from "langchain/llms/openai";import { initializeAgentExecutorWithOptions } from "langchain/agents";import { DynamicTool } from "langchain/tools";export const run = async () => { const model = new OpenAI({ temperature: 0 }); const tools = [ new DynamicTool({ name: "FOO", description: "call this to get the value of foo. input should be an empty string. ", func: async () => "baz", }), new DynamicTool({ name: "BAR", description: "call this to get the value of bar. input should be an empty string. ", func: async () => "baz1", }), ]; const executor = await initializeAgentExecutorWithOptions(tools, model, { agentType: "zero-shot-react-description", }); console.log("Loaded agent. "); const input = `What is the value of foo?`; console.log(`Executing with input "${input}"...`); const result = await executor.call({ input }); console.log(`Got output ${result.output}`);};PreviousVector stores as toolsNextIntegrations ModulesAgentsToolsHow-toCustom toolsCustom toolsOne option for creating a tool that runs custom code is to use a DynamicTool.The DynamicTool class takes as input a name, a description, and a function. Importantly, the name and the description will be used by the language model to determine when to call this function and with what parameters,
4e9727215e95-3287
so make sure to set these to some values the language model can reason about!The provided function is what will the agent will actually call. When an error occurs, the function should, when possible, return a string representing an error, rather than throwing an error. This allows the error to be passed to the LLM and the LLM can decide how to handle it. If an error is thrown, then execution of the agent will stop.See below for an example of defining and using DynamicTools.import { OpenAI } from "langchain/llms/openai";import { initializeAgentExecutorWithOptions } from "langchain/agents";import { DynamicTool } from "langchain/tools";export const run = async () => { const model = new OpenAI({ temperature: 0 }); const tools = [ new DynamicTool({ name: "FOO", description: "call this to get the value of foo. input should be an empty string. ", func: async () => "baz", }), new DynamicTool({ name: "BAR", description: "call this to get the value of bar. input should be an empty string. ", func: async () => "baz1", }), ]; const executor = await initializeAgentExecutorWithOptions(tools, model, { agentType: "zero-shot-react-description", }); console.log("Loaded agent. "); const input = `What is the value of foo?`; console.log(`Executing with input "${input}"...`); const result = await executor.call({ input }); console.log(`Got output ${result.output}`);};PreviousVector stores as toolsNextIntegrations Custom toolsOne option for creating a tool that runs custom code is to use a DynamicTool.The DynamicTool class takes as input a name, a description, and a function.
4e9727215e95-3288
Importantly, the name and the description will be used by the language model to determine when to call this function and with what parameters, so make sure to set these to some values the language model can reason about!The provided function is what will the agent will actually call. When an error occurs, the function should, when possible, return a string representing an error, rather than throwing an error. This allows the error to be passed to the LLM and the LLM can decide how to handle it. If an error is thrown, then execution of the agent will stop.See below for an example of defining and using DynamicTools.import { OpenAI } from "langchain/llms/openai";import { initializeAgentExecutorWithOptions } from "langchain/agents";import { DynamicTool } from "langchain/tools";export const run = async () => { const model = new OpenAI({ temperature: 0 }); const tools = [ new DynamicTool({ name: "FOO", description: "call this to get the value of foo. input should be an empty string. ", func: async () => "baz", }), new DynamicTool({ name: "BAR", description: "call this to get the value of bar. input should be an empty string. ", func: async () => "baz1", }), ]; const executor = await initializeAgentExecutorWithOptions(tools, model, { agentType: "zero-shot-react-description", }); console.log("Loaded agent. "); const input = `What is the value of foo?`; console.log(`Executing with input "${input}"...`); const result = await executor.call({ input }); console.log(`Got output ${result.output}`);}; One option for creating a tool that runs custom code is to use a DynamicTool.
4e9727215e95-3289
One option for creating a tool that runs custom code is to use a DynamicTool. The DynamicTool class takes as input a name, a description, and a function. Importantly, the name and the description will be used by the language model to determine when to call this function and with what parameters, so make sure to set these to some values the language model can reason about! The provided function is what will the agent will actually call. When an error occurs, the function should, when possible, return a string representing an error, rather than throwing an error. This allows the error to be passed to the LLM and the LLM can decide how to handle it. If an error is thrown, then execution of the agent will stop. See below for an example of defining and using DynamicTools.
4e9727215e95-3290
See below for an example of defining and using DynamicTools. import { OpenAI } from "langchain/llms/openai";import { initializeAgentExecutorWithOptions } from "langchain/agents";import { DynamicTool } from "langchain/tools";export const run = async () => { const model = new OpenAI({ temperature: 0 }); const tools = [ new DynamicTool({ name: "FOO", description: "call this to get the value of foo. input should be an empty string. ", func: async () => "baz", }), new DynamicTool({ name: "BAR", description: "call this to get the value of bar. input should be an empty string. ", func: async () => "baz1", }), ]; const executor = await initializeAgentExecutorWithOptions(tools, model, { agentType: "zero-shot-react-description", }); console.log("Loaded agent. "); const input = `What is the value of foo?`; console.log(`Executing with input "${input}"...`); const result = await executor.call({ input }); console.log(`Got output ${result.output}`);};
111341e12467-0
Page Title: Pinecone Paragraphs: © Pinecone Systems, Inc. | San Francisco, CA | Terms | Privacy | Cookies | Trust & Security | System Status Pinecone is a registered trademark of Pinecone Systems, Inc. Page Title: Overview Paragraphs: An introduction to the Pinecone vector database. Pinecone makes it easy to provide long-term memory for high-performance AI applications. It’s a managed, cloud-native vector database with a simple API and no infrastructure hassles. Pinecone serves fresh, filtered query results with low latency at the scale of billions of vectors. Applications that involve large language models, generative AI, and semantic search rely on vector embeddings, a type of data that represents semantic information. This information allows AI applications to gain understanding and maintain a long-term memory that they can draw upon when executing complex tasks. Vector databases like Pinecone offer optimized storage and querying capabilities for embeddings. Traditional scalar-based databases can’t keep up with the complexity and scale of such data, making it difficult to extract insights and perform real-time analysis. Vector indexes like FAISS lack useful features that are present in any database. Vector databases combine the familiar features of traditional databases with the optimized performance of vector indexes. Each record in a Pinecone index contains a unique ID and an array of floats representing a dense vector embedding. Each record may also contain a sparse vector embedding for hybrid search and metadata key-value pairs for filtered queries. Pinecone returns low-latency, accurate results for indexes with billions of vectors. High-performance pods return up to 200 queries per second per replica. Queries reflect up-to-the-second updates such as upserts and deletes. Filter by namespaces and metadata or add resources to improve performance. Perform CRUD operations and query your vectors using HTTP, Python, or Node.js. Specify the distance metric your index uses to evaluate vector similarity, along with dimensions and replicas.
111341e12467-1
Specify the distance metric your index uses to evaluate vector similarity, along with dimensions and replicas. Find the top k most similar vectors, or query by ID. Go to the quickstart guide to get a production-ready vector search service up and running in minutes. Updated 28 days ago Paragraphs: Paragraphs: Page Title: Quickstart Paragraphs: How to get started with the Pinecone vector database. This guide explains how to set up a Pinecone vector database in minutes. This step is optional. Do this step only if you want to use the Python client. Use the following shell command to install Pinecone: For other clients, see Libraries. To use Pinecone, you must have an API key. To find your API key, open the Pinecone console and click API Keys. This view also displays the environment for your project. Note both your API key and your environment. To verify that your Pinecone API key works, use the following commands: If you don't receive an error message, then your API key is valid. You can complete the remaining steps in three ways: 1. Initialize Pinecone 2. Create an index. The commands below create an index named "quickstart" that performs approximate nearest-neighbor search using the Euclidean distance metric for 8-dimensional vectors. Index creation takes roughly a minute. ⚠️Warning Warning In general, indexes on the Starter (free) plan are archived as collections and deleted after 7 days of inactivity; for indexes created by certain open source projects such as AutoGPT, indexes are archived and deleted after 1 day of inactivity. To prevent this, you can send any API request to Pinecone and the counter will reset. 3. Retrieve a list of your indexes. Once your index is created, its name appears in the index list.
111341e12467-2
Once your index is created, its name appears in the index list. Use the following commands to return a list of your indexes. 4. Connect to the index (Client only). Before you can query your index using a client, you must connect to the index. Use the following commands to connect to your index. 5. Insert the data. To ingest vectors into your index, use the upsert operation. The upsert operation inserts a new vector in the index or updates the vector if a vector with the same ID is already present. The following commands upsert 5 8-dimensional vectors into your index. The cURL command above uses the endpoint for your Pinecone index. ℹ️Note Note When upserting larger amounts of data, upsert data in batches of 100 vectors or fewer over multiple upsert requests. 6. Get statistics about your index. The following commands return statistics about the contents of your index. 7. Query the index and get similar vectors. The following example queries the index for the three (3) vectors that are most similar to an example 8-dimensional vector using the Euclidean distance metric specified in step 2 ("Create an index.") above. 8. Delete the index. Once you no longer need the index, use the delete_index operation to delete it. The following commands delete the index. After you delete an index, you cannot use it again. Now that you’re successfully making indexes with your API key, you can start inserting data or view more examples. Updated about 22 hours ago Page Title: Choosing index type and size Paragraphs: When planning your Pinecone deployment, it is important to understand the approximate storage requirements of your vectors to choose the appropriate pod type and number. This page will give guidance on sizing to help you plan accordingly.
111341e12467-3
As with all guidelines, these considerations are general and may not apply to your specific use case. We caution you to always test your deployment and ensure that the index configuration you are using is appropriate to your requirements. Collections make it easy to create new versions of your index with different pod types and sizes, and we encourage you to take advantage of that feature to test different configurations. This guide is merely an overview of sizing considerations and should not be taken as a definitive guide. Users on the Standard, Enterprise, and Enterprise Dedicated plans can contact support for further help with sizing and testing. There are five main considerations when deciding how to configure your Pinecone index: Each of these considerations comes with requirements for index size, pod type, and replication strategy. The most important consideration in sizing is the number of vectors you plan on working with. As a rule of thumb, a single p1 pod can store approximately 1M vectors, while a s1 pod can store 5M vectors. However, this can be affected by other factors, such as dimensionality and metadata, which are explained below. The rules of thumb above for how many vectors can be stored in a given pod assumes a typical configuration of 768 dimensions per vector. As your individual use case will dictate the dimensionality of your vectors, the amount of space required to store them may necessarily be larger or smaller. Each dimension on a single vector consumes 4 bytes of memory and storage per dimension, so if you expect to have 1M vectors with 768 dimensions each, that’s about 3GB of storage without factoring in metadata or other overhead. Using that reference, we can estimate the typical pod size and number needed for a given index. Table 1 below gives some examples of this. Table 1: Estimated number of pods per 1M vectors by dimensionality
111341e12467-4
Table 1: Estimated number of pods per 1M vectors by dimensionality Pinecone does not support fractional pod deployments, so always round up to the next nearest whole number when choosing your pods. QPS speeds are governed by a combination of the pod type of the index, the number of replicas, and the top_k value of queries. The pod type is the primary factor driving QPS, as the different pod types are optimized for different approaches. The p1 pods are performance-optimized pods which provide very low query latencies, but hold fewer vectors per pod than s1 pods. They are ideal for applications with low latency requirements (<100ms). The s1 pods are optimized for storage and provide large storage capacity and lower overall costs with slightly higher query latencies than p1 pods. They are ideal for very large indexes with moderate or relaxed latency requirements. The p2 pod type provides greater query throughput with lower latency. They support 200 QPS per replica and return queries in less than 10ms. This means that query throughput and latency are better than s1 and p1, especially for low dimension vectors (<512D). As a rule, a single p1 pod with 1M vectors of 768 dimensions each and no replicas can handle about 20 QPS. It’s possible to get greater or lesser speeds, depending on the size of your metadata, number of vectors, the dimensionality of your vectors, and the top_K value for your search. See Table 2 below for more examples. Table 2: QPS by pod type and top_k value* The QPS values in Table 2 represent baseline QPS with 1M vectors and 768 dimensions.
111341e12467-5
Adding replicas is the simplest way to increase your QPS. Each replica increases the throughput potential by roughly the same QPS, so aiming for 150 QPS using p1 pods means using the primary pod and 5 replicas. Using threading or multiprocessing in your application is also important, as issuing single queries sequentially still subjects you to delays from any underlying latency. The Pinecone gRPC client can also be used to increase throughput of upserts. The last consideration when planning your indexes is the cardinality and size of your metadata. While the increases are small when talking about a few million vectors, they can have a real impact as you grow to hundreds of millions or billions of vectors. Indexes with very high cardinality, like those storing a unique user ID on each vector, can have significant memory requirements, resulting in fewer vectors fitting per pod. Also, if the size of the metadata per vector is larger, the index requires more storage. Limiting which metadata fields are indexed using selective metadata indexing can help lower memory usage. You can also start with one of the larger pod sizes, like p1.x2. Each step up in pod size doubles the space available for your vectors. We recommend starting with x1 pods and scaling as you grow. This way, you don’t start with too large a pod size and have nowhere else to go up, meaning you have to migrate to a new index before you’re ready. Projects on the gcp-starter environment do not use pods. The following examples will showcase how to use the sizing guidelines above to choose the appropriate type, size, and number of pods for your index.
111341e12467-6
In our first example, we’ll use the demo app for semantic search from our documentation. In this case, we’re only working with 204,135 vectors. The vectors use 300 dimensions each, well under the general measure of 768 dimensions. Using the rule of thumb above of up to 1M vectors per p1 pod, we can run this app comfortably with a single p1.x1 pod. For this example, suppose you’re building an application to identify customers using facial recognition for a secure banking app. Facial recognition can work with as few as 128 dimensions, but in this case, because the app will be used for access to finances, we want to make sure we’re certain that the person using it is the right one. We plan for 100M customers and use 2048 dimensions per vector. We know from our rules of thumb above that 1M vectors with 768 dimensions fit nicely in a p1.x1 pod. We can just divide those numbers into the new targets to get the ratios we’ll need for our pod estimate: So we need 267 p1.x1 pods. We can reduce that by switching to s1 pods instead, sacrificing latency by increasing storage availability. They hold five times the storage of p1.x1, so the math is simple: So we estimate that we need 54 s1.x1 pods to store very high dimensional data for the face of each of the bank’s customers. Updated 2 months ago Page Title: Understanding organizations Paragraphs: A Pinecone organization is a set of projects that use the same billing. Organizations allow one or more users to control billing and project permissions for all of the projects belonging to the organization. Each project belongs to an organization. For a guide to adding users to an organization, see Add users to a project or organization.
111341e12467-7
For a guide to adding users to an organization, see Add users to a project or organization. Each organization contains one or more projects that share the same organization owners and billing settings. Each project belongs to exactly one organization. If you need to move a project from one organization to another, contact Pinecone support. All of the projects in an organization share the same billing method and settings. The billing settings for the organization are controlled by the organization owners. There are two organization roles: organization owner and organization user. Organization owners manage organization billing, users, and projects. Organization owners are also project owners for every project belonging to the organization. This means that organization owners have all permissions to manage project members, API keys, and quotas for these projects. Unlike organization owners, organization users cannot edit billing settings or invite new users to the organization. Organization users can create new projects, and project owners can add organization members to a project. New users have whatever role the organization owners and project owners grant them. Project owners can add users to a project if those users belong to the same organization as the project. Table 1: Organization roles and permissions SSO allows organizations to manage their teams' access to Pinecone through their identity management solution. Once your integration is configured, you can require that users from your domain sign in through SSO, and you can specify a default role for teammates when they sign up. Only organizations in the enterprise tier can set up SSO. To set up your SSO integration, contact Pinecone support at [email protected]. Updated about 2 months ago Page Title: Managing cost Paragraphs: This topic provides guidance on managing the cost of Pinecone. For the latest pricing details, see our pricing page. For help estimating total cost, see Understanding total cost. To see a calculation of your current usage and costs, see the usage dashboard in the Pinecone console.
111341e12467-8
The total cost of Pinecone usage derives from pod type, the number of pods in use, pod size, the total time each pod is running, and the billing plan. This topic describes several ways you can manage your overall Pinecone cost by adjusting these variables. The Starter Plan incurs no costs, and supports roughly 100,000 vectors with 1536 dimensions. If this meets the needs of your project, you can use Pinecone for free; if you decide to scale your index or move it to production, you can upgrade your billing plan later. Different Pinecone pod sizes are designed for different applications, and some are more expensive than others. By choosing the appropriate pod type and size, you can pay for the resources you need. For example, the s1 pod type provides large storage capacity and lower overall costs with slightly higher query latencies than p1 pods. By switching to a different pod type, you may be able to reduce costs while still getting the performance your application needs. When a specific index is not in use, back it up using collections and delete the inactive index. When you're ready to use these vectors again, you can create a new index from the collection. This new index can also use a different index type or size. Because it's relatively cheap to store collections, you can reduce costs by only running an index when it's in use. If your application requires you to separate users into groups, consider using namespaces to isolate segments of vectors within a single index. Depending on your application requirements, this may allow you to reduce the total number of active indexes. Users who commit to an annual contract may qualify for discounted rates. To learn more, contact Pinecone sales. Users on the Standard and Enterprise plans can contact support for help in optimizing costs. Page Title: Understanding cost Paragraphs: