Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions libs/core/langchain_core/prompts/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -1281,14 +1281,6 @@ def _prompt_type(self) -> str:
"""Name of prompt type. Used for serialization."""
return "chat"

def save(self, file_path: Path | str) -> None:
"""Save prompt to file.

Args:
file_path: path to file.
"""
raise NotImplementedError

@override
def pretty_repr(self, html: bool = False) -> str:
"""Human-readable representation.
Expand Down
11 changes: 11 additions & 0 deletions libs/core/tests/unit_tests/prompts/test_loading.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import pytest

from langchain_core.prompts import ChatPromptTemplate
from langchain_core.prompts.few_shot import FewShotPromptTemplate
from langchain_core.prompts.loading import load_prompt
from langchain_core.prompts.prompt import PromptTemplate
Expand Down Expand Up @@ -87,6 +88,16 @@ def test_saving_loading_round_trip(tmp_path: Path) -> None:
loaded_prompt = load_prompt(tmp_path / "few_shot.yaml")
assert loaded_prompt == few_shot_prompt

chat_prompt = ChatPromptTemplate(
[
{"role": "system", "content": "{foo} foo"},
{"role": "user", "content": "{bar} bar"},
]
)
chat_prompt.save(file_path=tmp_path / "chat_prompt.yaml")
loaded_prompt = load_prompt(tmp_path / "chat_prompt.yaml")
assert loaded_prompt == chat_prompt


def test_loading_with_template_as_file() -> None:
"""Test loading when the template is a file."""
Expand Down
Loading