Skip to content
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

ChatPromptTemplate with partial variables is giving validation error #6431

Closed
2 of 14 tasks
xi2asing opened this issue Jun 19, 2023 · 2 comments · Fixed by #6456
Closed
2 of 14 tasks

ChatPromptTemplate with partial variables is giving validation error #6431

xi2asing opened this issue Jun 19, 2023 · 2 comments · Fixed by #6456

Comments

@xi2asing
Copy link

System Info

langchain-0.0.205, python3.10

Who can help?

@hwchase17 @agola11

Information

  • The official example notebooks/scripts
  • My own modified scripts

Related Components

  • LLMs/Chat Models
  • Embedding Models
  • Prompts / Prompt Templates / Prompt Selectors
  • Output Parsers
  • Document Loaders
  • Vector Stores / Retrievers
  • Memory
  • Agents / Agent Executors
  • Tools / Toolkits
  • Chains
  • Callbacks/Tracing
  • Async

Reproduction

  1. Write this into Notebook cell

  2. from langchain.prompts import PromptTemplate, ChatPromptTemplate, HumanMessagePromptTemplate chat_prompt = ChatPromptTemplate( messages=[ HumanMessagePromptTemplate.from_template("Do something with {question} using {context} giving it like {formatins}") ], input_variables=["question", "context"], partial_variables={"formatins": "some structure"} )

  3. It it throwing following error:
    Error: ValidationError: 1 validation error for ChatPromptTemplate __root__ Got mismatched input_variables. Expected: {'formatins', 'question', 'context'}. Got: ['question', 'context'] (type=value_error)

  4. This was working until 24 hours ago. Potentially related to recent commit to langchain/prompts/chat.py.

Expected behavior

The chat_prompt should get created with the partial variables injected.
If this is expected change, can you please help with suggesting what should be the new way to use partial_variables?

Thanks

@Avinash-Raj
Copy link
Contributor

@xi2asing check whether the relevant PR resolves the issue or not.

hwchase17 added a commit that referenced this issue Jun 20, 2023
…dation error (#6456)

W.r.t recent changes, ChatPromptTemplate does not accepting partial
variables. This PR should fix that issue.


Fixes #6431




#### Who can review?



  @hwchase17

---------

Co-authored-by: Harrison Chase <hw.chase.17@gmail.com>
@xi2asing
Copy link
Author

@xi2asing check whether the relevant PR resolves the issue or not.

@Avinash-Raj - Checked that your changes fixed the issue. Thanks for the quick resolution on this.

tconkling added a commit to tconkling/langchain that referenced this issue Jun 20, 2023
* master: (101 commits)
  add FunctionMessage support to `_convert_dict_to_message()` in OpenAI chat model (langchain-ai#6382)
  bump version to 206 (langchain-ai#6465)
  fix neo4j schema query (langchain-ai#6381)
  Update serpapi.py Support baidu list type answer_box (langchain-ai#6386)
  fix: llm caching for replicate (langchain-ai#6396)
  feat: use latest duckduckgo_search API to call (langchain-ai#6409)
  Harrison/unstructured page number (langchain-ai#6464)
  Improve error message (langchain-ai#6275)
  Fix the issue where ANTHROPIC_API_URL set in environment is not takin… (langchain-ai#6400)
  Fix broken links in autonomous agents docs (langchain-ai#6398)
  Update SinglStoreDB vectorstore (langchain-ai#6423)
  Fix for langchain-ai#6431 - chatprompt template with partial variables giing validation error (langchain-ai#6456)
  Harrison/functions in retrieval (langchain-ai#6463)
  Incorrect argument count handling (langchain-ai#5543)
  Fixed a link typo /-/route -> /-/routes. and change endpoint format (langchain-ai#6186)
  docs `retrievers` fixes (langchain-ai#6299)
  Update introduction.mdx (langchain-ai#6425)
  Fix Custom LLM Agent example (langchain-ai#6429)
  Remove backticks without clear purpose from docs (langchain-ai#6442)
  Update web_base.ipynb (langchain-ai#6430)
  ...
This was referenced Jun 25, 2023
kacperlukawski pushed a commit to kacperlukawski/langchain that referenced this issue Jun 29, 2023
…s giing validation error (langchain-ai#6456)

W.r.t recent changes, ChatPromptTemplate does not accepting partial
variables. This PR should fix that issue.


Fixes langchain-ai#6431




#### Who can review?



  @hwchase17

---------

Co-authored-by: Harrison Chase <hw.chase.17@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants