core[patch]: fix structured prompt template format (#27003)

template_format is an init argument on ChatPromptTemplate but not an
attribute on the object so was getting shoved into
StructuredPrompt.structured_ouptut_kwargs
This commit is contained in:
Bagatur
2024-09-30 11:47:46 -07:00
committed by GitHub
parent 0078493a80
commit 248be02259
3 changed files with 15 additions and 3 deletions

View File

@@ -2,6 +2,7 @@ from collections.abc import Iterator, Mapping, Sequence
from typing import (
Any,
Callable,
Literal,
Optional,
Union,
)
@@ -37,6 +38,7 @@ class StructuredPrompt(ChatPromptTemplate):
schema_: Optional[Union[dict, type[BaseModel]]] = None,
*,
structured_output_kwargs: Optional[dict[str, Any]] = None,
template_format: Literal["f-string", "mustache", "jinja2"] = "f-string",
**kwargs: Any,
) -> None:
schema_ = schema_ or kwargs.pop("schema")
@@ -47,6 +49,7 @@ class StructuredPrompt(ChatPromptTemplate):
messages=messages,
schema_=schema_,
structured_output_kwargs=structured_output_kwargs,
template_format=template_format,
**kwargs,
)