Skip to content

Commit 1bc57c9

Browse files
committed
fix lint
1 parent 2b52fdc commit 1bc57c9

1 file changed

Lines changed: 17 additions & 3 deletions

File tree

langfuse/model.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@
3838
CreateDatasetRequest,
3939
)
4040
from langfuse.api.resources.prompts import ChatMessage, Prompt, Prompt_Chat, Prompt_Text
41-
from langfuse.api.resources.prompts.types.chat_message_with_placeholders import (
42-
ChatMessageWithPlaceholders,
43-
)
4441

4542

4643
class ModelUsage(TypedDict):
@@ -321,6 +318,23 @@ def __init__(self, prompt: Prompt_Chat, is_fallback: bool = False):
321318
content=p.content,
322319
),
323320
)
321+
# Handle plain dictionaries (fallback case)
322+
elif isinstance(p, dict):
323+
if p.get("type") == "placeholder" and "name" in p:
324+
self.prompt.append(
325+
ChatMessageWithPlaceholdersDict_Placeholder(
326+
type="placeholder",
327+
name=p["name"],
328+
),
329+
)
330+
elif "role" in p and "content" in p:
331+
self.prompt.append(
332+
ChatMessageWithPlaceholdersDict_Message(
333+
type="message",
334+
role=p["role"],
335+
content=p["content"],
336+
),
337+
)
324338

325339
def compile(
326340
self, **kwargs

0 commit comments

Comments
 (0)