-
Notifications
You must be signed in to change notification settings - Fork 19.7k
fix(core): implement ChatPromptTemplate.save() method
#32654
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
Conversation
if annotation is not present or None, it shall default to empty list []. Similar to line number langchain-ai#3875 "annotations": block. Get("annotations") or []
Fixes ruff formatting issues
Fixes langchain-ai#26348 where streaming LLM outputs could fail with TypeError when UsageMetadata contains None values for token counts. The issue occurred when providers returned None for token counts during streaming, causing _dict_int_op to raise a ValueError about unsupported types. Changes: - Modified _dict_int_op to treat None values as the default value (0) - Added comprehensive tests for None value handling - Updated error message to include None as a supported type This ensures robust handling of partial or missing token metadata during streaming operations. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
- Replace NotImplementedError with working implementation - Use dumpd() for proper serialization to ensure compatibility with load() - Support both JSON and YAML formats - Add comprehensive unit tests for save functionality - Handle error cases (invalid extensions, partial variables) - Ensure directory creation when saving to nested paths Fixes langchain-ai#32637 Co-Authored-By: Keyu <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
CodSpeed WallTime Performance ReportMerging #32654 will not alter performanceComparing
|
- Remove trailing whitespace - Remove whitespace in blank lines - Use Path.open() instead of open() for file operations
- Parse JSON data before passing to load() function - Fix trailing whitespace issues - Tests now correctly verify save/load functionality
CodSpeed Instrumentation Performance ReportMerging #32654 will not alter performanceComparing Summary
|
- Add blank line after import statement - Add trailing comma in function arguments - Consolidate single-line ChatPromptTemplate instantiations
ChatPromptTemplate.save() method
|
@mdrxy any update? |
ccurme
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Closing as duplicated with #33631.
Summary
Fixes #32637 - ChatPromptTemplate.save() method now properly saves templates to files instead of raising NotImplementedError.
Problem
The
save()method inChatPromptTemplatewas not implemented and simply raisedNotImplementedError, preventing users from saving their chat prompt templates to files.Solution
save()method that usesdumpd()for proper serializationload()functionChanges
Implemented ChatPromptTemplate.save() method:
dumpd()fromlangchain_core.loadfor proper serializationAdded comprehensive unit tests:
Test plan
Added unit tests that verify:
All tests pass successfully.
Example Usage