-
Notifications
You must be signed in to change notification settings - Fork 14k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trying to pass custom prompt in load_qa_with_sources_chain results in error #2858
Comments
That should work It seems to be expecting {summaries} variable,
|
I may really be doing something wrong. I get the error: from langchain import PromptTemplate
from langchain.chains.qa_with_sources import load_qa_with_sources_chain
from langchain.chat_models import ChatOpenAI
from dotenv import load_dotenv
load_dotenv()
def get_chain(template: str, variables, verbose: bool = False):
llm = ChatOpenAI()
prompt_template = PromptTemplate(
template=template,
input_variables=variables,
)
return load_qa_with_sources_chain(
llm=llm,
prompt=prompt_template,
verbose=verbose,
)
chain = get_chain(template="""Only answer the question 'What is my name?' by replaying with only the name. My name is {name}
=========
{summaries}
=========
Final Answer:""", variables=["summaries", "name"])
question = "test question?"
answer = chain.run(input_documents="", question=question) |
I am a bit confused about how you're defining "name" in the prompt, actually I don't exactly understand the prompt since you do not take the name as input anywhere, what do you want to do exactly? This works for me:
|
How would the screenshot u shared work if you're not passing the |
Another question about this. Why is |
I have the same question... why is {summaries} even required? |
Is there an example of making it work with The code examples above do not work with |
I have the same issue... |
Have there been any resolutions here? This issue is still persistent. I am getting the same error when I am passing a custom prompt purposefully with no variables associated with the f-string. Following the documentation directly from LangChain: |
Maybe this helps:
|
Did you ever solve it? What did you do |
Running the code below produces the following error:
document_variable_name summaries was not found in llm_chain input_variables: ['name'] (type=value_error)
Any ideas?
Code:
The text was updated successfully, but these errors were encountered: