Skip to content

Commit 31f3dc9

Browse files
committed
fix tests
1 parent 2759684 commit 31f3dc9

2 files changed

Lines changed: 90 additions & 3 deletions

File tree

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# This file was auto-generated by Fern from our API Definition.
2+
3+
from __future__ import annotations
4+
5+
import datetime as dt
6+
import typing
7+
8+
from ....core.datetime_utils import serialize_datetime
9+
from ....core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1
10+
11+
12+
class ChatMessageWithPlaceholders_Chatmessage(pydantic_v1.BaseModel):
13+
role: str
14+
content: str
15+
type: typing.Literal["chatmessage"] = "chatmessage"
16+
17+
def json(self, **kwargs: typing.Any) -> str:
18+
kwargs_with_defaults: typing.Any = {
19+
"by_alias": True,
20+
"exclude_unset": True,
21+
**kwargs,
22+
}
23+
return super().json(**kwargs_with_defaults)
24+
25+
def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]:
26+
kwargs_with_defaults_exclude_unset: typing.Any = {
27+
"by_alias": True,
28+
"exclude_unset": True,
29+
**kwargs,
30+
}
31+
kwargs_with_defaults_exclude_none: typing.Any = {
32+
"by_alias": True,
33+
"exclude_none": True,
34+
**kwargs,
35+
}
36+
37+
return deep_union_pydantic_dicts(
38+
super().dict(**kwargs_with_defaults_exclude_unset),
39+
super().dict(**kwargs_with_defaults_exclude_none),
40+
)
41+
42+
class Config:
43+
frozen = True
44+
smart_union = True
45+
extra = pydantic_v1.Extra.allow
46+
json_encoders = {dt.datetime: serialize_datetime}
47+
48+
49+
class ChatMessageWithPlaceholders_Placeholder(pydantic_v1.BaseModel):
50+
name: str
51+
type: typing.Literal["placeholder"] = "placeholder"
52+
53+
def json(self, **kwargs: typing.Any) -> str:
54+
kwargs_with_defaults: typing.Any = {
55+
"by_alias": True,
56+
"exclude_unset": True,
57+
**kwargs,
58+
}
59+
return super().json(**kwargs_with_defaults)
60+
61+
def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]:
62+
kwargs_with_defaults_exclude_unset: typing.Any = {
63+
"by_alias": True,
64+
"exclude_unset": True,
65+
**kwargs,
66+
}
67+
kwargs_with_defaults_exclude_none: typing.Any = {
68+
"by_alias": True,
69+
"exclude_none": True,
70+
**kwargs,
71+
}
72+
73+
return deep_union_pydantic_dicts(
74+
super().dict(**kwargs_with_defaults_exclude_unset),
75+
super().dict(**kwargs_with_defaults_exclude_none),
76+
)
77+
78+
class Config:
79+
frozen = True
80+
smart_union = True
81+
extra = pydantic_v1.Extra.allow
82+
json_encoders = {dt.datetime: serialize_datetime}
83+
84+
85+
ChatMessageWithPlaceholders = typing.Union[
86+
ChatMessageWithPlaceholders_Chatmessage, ChatMessageWithPlaceholders_Placeholder
87+
]

langfuse/model.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -313,15 +313,15 @@ def compileWithPlaceholders(
313313
return [
314314
ChatMessageDict(
315315
content=TemplateParser.compile_template(
316-
chat_message["content"], variables,
316+
chat_message["content"],
317+
variables,
317318
),
318319
role=chat_message["role"],
319320
)
320321
for chat_message in messages_with_placeholders_replaced
321-
if hasattr(chat_message, "role") and hasattr(chat_message, "content")
322+
if "role" in chat_message and "content" in chat_message
322323
]
323324

324-
325325
def get_langchain_prompt(self, **kwargs):
326326
"""Convert Langfuse prompt into string compatible with Langchain ChatPromptTemplate.
327327

0 commit comments

Comments
 (0)