Skip to content

Conversation

@cwarre33
Copy link

Remove NotImplementedError override in ChatPromptTemplate.save() to allow the parent BasePromptTemplate implementation to handle serialization. ChatPromptTemplate already has the required _prompt_type property ('chat') for proper serialization.

This enables users to save and load ChatPromptTemplate instances to/from YAML and JSON files, matching the functionality of PromptTemplate and FewShotPromptTemplate.

Changes:

  • Remove NotImplementedError override from ChatPromptTemplate.save()
  • Add comprehensive test for save/load roundtrip with both YAML and JSON formats

Fixes #32637

(Replace this entire block of text)

Thank you for contributing to LangChain! Follow these steps to mark your pull request as ready for review. If any of these steps are not completed, your PR will not be considered for review.

  • PR title: Follows the format: {TYPE}({SCOPE}): {DESCRIPTION}

    • Examples:
      • feat(core): add multi-tenant support
      • fix(cli): resolve flag parsing error
      • docs(openai): update API usage examples
    • Allowed {TYPE} values:
      • feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert, release
    • Allowed {SCOPE} values (optional):
      • core, cli, langchain, standard-tests, text-splitters, docs, anthropic, chroma, deepseek, exa, fireworks, groq, huggingface, mistralai, nomic, ollama, openai, perplexity, prompty, qdrant, xai, infra
    • Once you've written the title, please delete this checklist item; do not include it in the PR.
  • PR message: Delete this entire checklist and replace with

  • Lint and test: Run make format, make lint and make test from the root of the package(s) you've modified. We will not consider a PR unless these three are passing in CI. See contribution guidelines for more.

Additional guidelines:

  • Most PRs should not touch more than one package.
  • Please do not add dependencies to pyproject.toml files (even optional ones) unless they are required for unit tests. Likewise, please do not update the uv.lock files unless you are adding a required dependency.
  • Changes should be backwards compatible.
  • Make sure optional dependencies are imported within a function.

@cwarre33 cwarre33 requested a review from eyurtsev as a code owner October 21, 2025 21:38
@github-actions github-actions bot added core Related to the package `langchain-core` fix labels Oct 21, 2025
@codspeed-hq
Copy link

codspeed-hq bot commented Oct 21, 2025

CodSpeed Performance Report

Merging #33631 will improve performances by 11.07%

Comparing cwarre33:fix-chat-prompt-template-save-32637 (e00f3ff) with master (5acd34a)1

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

Summary

⚡ 1 improvement
✅ 12 untouched
⏩ 21 skipped2

Benchmarks breakdown

Mode Benchmark BASE HEAD Change
WallTime test_import_time[BaseChatModel] 562.3 ms 506.3 ms +11.07%

Footnotes

  1. No successful run was found on master (f8adbbc) during the generation of this report, so 5acd34a was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

  2. 21 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@cwarre33 cwarre33 force-pushed the fix-chat-prompt-template-save-32637 branch 4 times, most recently from 428c567 to aa038a8 Compare October 21, 2025 21:58
@cwarre33 cwarre33 changed the title fix(prompts): implement ChatPromptTemplate.save() method (#32637) fix(core): implement ChatPromptTemplate.save() method (#32637) Oct 21, 2025
@github-actions github-actions bot added fix and removed fix labels Oct 21, 2025
@cwarre33 cwarre33 force-pushed the fix-chat-prompt-template-save-32637 branch from aa038a8 to e00f3ff Compare October 21, 2025 22:08
…2637)

Remove NotImplementedError override in ChatPromptTemplate.save() to allow the
parent BasePromptTemplate implementation to handle serialization. ChatPromptTemplate
already has the required _prompt_type property ('chat') for proper serialization.

This enables users to save and load ChatPromptTemplate instances to/from YAML
and JSON files, matching the functionality of PromptTemplate and
FewShotPromptTemplate.

Changes:
- Remove NotImplementedError override from ChatPromptTemplate.save()
- Add comprehensive test for save/load roundtrip with both YAML and JSON formats

Fixes langchain-ai#32637
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Related to the package `langchain-core` fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ChatPromptTemplate save() not implemented

1 participant