Replies: 2 comments 1 reply
-
The error you're encountering is due to the prompt missing required variables: missing_vars = {"tools", "tool_names", "agent_scratchpad"}.difference(
prompt.input_variables
)
if missing_vars:
raise ValueError(f"Prompt missing required variables: {missing_vars}") This code snippet checks if the To fix this issue, you need to ensure that the prompt you are using is correctly defined with all the required input variables. Here's an example of how the prompt template should include these variables: from langchain_core.prompts import PromptTemplate
template = '''Answer the following questions as best you can. You have access to the following tools:
{tools}
Use the following format:
Question: the input question you must answer
Thought: you should always think about what to do
Action: the action to take, should be one of [{tool_names}]
Action Input: the input to the action
Observation: the result of the action
... (this Thought/Action/Action Input/Observation can repeat N times)
Thought: I now know the final answer
Final Answer: the final answer to the original input question
Begin!
Question: {input}
Thought:{agent_scratchpad}'''
prompt = PromptTemplate.from_template(template) Ensure that the prompt you are using is similar to the example above, with placeholders for You can find more details about this in the LangChain repository. Regarding the The exact implementation of the Sources
|
Beta Was this translation helpful? Give feedback.
-
mark |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Checked other resources
Commit to Help
Example Code
Description
When I use a third-party model instead of an OpenAI model to create_sql_agent, it reports an error "ValueError: Prompt missing required variables: {'tools', 'tool_names'} when using third-party models."
System Info
Package Information
Packages not installed (Not Necessarily a Problem)
The following packages were not found:
Beta Was this translation helpful? Give feedback.
All reactions