diff --git a/poetry.lock b/poetry.lock index 8046aac..f516a3e 100644 --- a/poetry.lock +++ b/poetry.lock @@ -475,13 +475,13 @@ files = [ [[package]] name = "langchain-core" -version = "0.3.22" +version = "0.3.23" description = "Building applications with LLMs through composability" optional = true python-versions = "<4.0,>=3.9" files = [ - {file = "langchain_core-0.3.22-py3-none-any.whl", hash = "sha256:b40b036b3bd4abc1dfc820e149f5a3c4abef2fee83eb807c4310a41a064580e0"}, - {file = "langchain_core-0.3.22.tar.gz", hash = "sha256:c61c6d62f137dff2a1ec785473a3225e4fa237e53eac88f5359fda664dc5d91c"}, + {file = "langchain_core-0.3.23-py3-none-any.whl", hash = "sha256:550c0b996990830fa6515a71a1192a8a0343367999afc36d4ede14222941e420"}, + {file = "langchain_core-0.3.23.tar.gz", hash = "sha256:f9e175e3b82063cc3b160c2ca2b155832e1c6f915312e1204828f97d4aabf6e1"}, ] [package.dependencies] @@ -1160,4 +1160,4 @@ langchain = ["langchain-core"] [metadata] lock-version = "2.0" python-versions = ">=3.9,<3.14" -content-hash = "939f562e03e07e01ef7d0de0bda236525830c552a443b2a1b7522264a89240ff" +content-hash = "6d0221e565670b422162df15ccbf1067a4ba1ccae4a0c84ee0672e482ed27621" diff --git a/promptgit/prompt.py b/promptgit/prompt.py index cf09581..1c5ca9f 100644 --- a/promptgit/prompt.py +++ b/promptgit/prompt.py @@ -153,11 +153,18 @@ def parse_children(children): def as_langchain(self): try: - from langchain_core.prompts import PromptTemplate + from langchain_core.prompts import PromptTemplate, ChatPromptTemplate except ModuleNotFoundError: raise ModuleNotFoundError('Install promptgit[langchain] to use with langchain prompts') - return PromptTemplate.from_template(self.prompt) + if isinstance(self.prompt, str): + return PromptTemplate(template=self.prompt, template_format='f-string', input_variables=self.variables) + else: + return ChatPromptTemplate( + template = [(item.role, item.content) for item in self.prompt], + template_format='f-string', + input_variables=self.variables + ) def __str__(self): if isinstance(self.prompt, str): diff --git a/pyproject.toml b/pyproject.toml index d2bad6b..160bd5a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,7 +13,7 @@ GitPython = ">=3.0.0,<4.0.0" urllib3 = ">=2.2.2,<3.0.0" langchain-core = { version = ">=0.3.0,<0.4.0", optional = true } pyyaml = ">=6.0.0" -mistletoe = "^1.4.0" +mistletoe = ">=1.4.0,<2.0.0" [tool.poetry.extras] langchain = [ "langchain-core" ]