bug: ChatPromptClient.compile appends str(whole list) once per non-dict placeholder item
維護者通常 1 天內回覆
評估
這個 Issue 還沒有評估資料。
描述
Describe the bug
In ChatPromptClient.compile, when a placeholder value is a list and an element is not a dict, the code appends ChatMessageDict(role="NOT_GIVEN", content=str(placeholder_value)). This is the inner else of the per-item loop, at langfuse/model.py line 365 (lines 362-368).
placeholder_value is the whole list, not the current item. N non-dict items therefore produce N identical messages, each containing the full list, and no message contains its own element. The input is already invalid (the warning says "Appended as string"), but the output is duplicated, garbled content.
I would expect one message per item, for example with content=str(msg), though maintainers may prefer a different handling of invalid items (skipping them, raising, etc.). The point is that the current output repeats the whole list per item.
Steps to reproduce
from langfuse.model import ChatPromptClient
from langfuse.api import Prompt_Chat
c = ChatPromptClient(Prompt_Chat(name="p", version=1, type="chat", config={}, labels=[], tags=[], commit_message=None,
prompt=[{"type": "chatmessage", "role": "system", "content": "hi {{x}}"}, {"type": "placeholder", "name": "history"}]))
print(c.compile(x="1", history=["a", "b"]))
Observed:
[{'role': 'system', 'content': 'hi 1'}, {'role': 'NOT_GIVEN', 'content': "['a', 'b']"}, {'role': 'NOT_GIVEN', 'content': "['a', 'b']"}]
The last two messages each contain the whole list ['a', 'b'] instead of 'a' and 'b' respectively.
Langfuse Cloud or self-hosted?
Langfuse Cloud (not server dependent; the behavior is purely client-side in the SDK)
If self-hosted, what version are you running?
N/A
SDK and integration versions
langfuse 4.17.0 (main at bf11ec121479145923ff27b32ec2ad1d06fd2d51), Python 3.14.0
Additional information
Related open PR #1840 (LangChain message objects in placeholders) touches the same loop; as far as its diff shows it keeps the str(placeholder_value) fallback for other non-dict items.
Are you interested in contributing a fix for this bug?
No
- 主要語言
- Python
- 星號
- 502
- 分支
- 381
- 平均合併
- 1 天 1 小時
- 30 天內合併 PR
- 64
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
langfuse/langfuse-python 的其他 Issue
-
bug(scores): create_score sends numpy.bool_ as JSON `true` and Decimal as "<Decimal>" since v5.0.2可能已有人在做 @lalith0407 於 2 天前認領。 未關閉bug feat-scores sdk-python
難度 2/5 1-3 小時 新手友好度 74/100
langfuse/langfuse-python#2057 ·
維護者通常 1 天內回覆
-
tests/unit/test_prompt.py fails on a fresh clone without LANGFUSE_* env vars可能已有人在做 @Mathoholic 於 15 天前認領。 未關閉bug feat-prompt-management sdk-python
難度 2/5 1-3 小時 新手友好度 80/100
langfuse/langfuse-python#1976 · 3 則留言 ·
維護者通常 1 天內回覆
-
bug(openai): a stream that fails mid-iteration ends the generation without level ERROR可能已有人在做 @hassiebp 於 5 天前認領。 未關閉bug integration-openai sdk-python
langfuse/langfuse-python#2039 · 已指派 1 人 ·
維護者通常 1 天內回覆
-
fix(serializer): handle single-string __slots__ and detect cycles in slotted objects可能已有人在做 @hassiebp 於 10 天前認領。 未關閉bug sdk-python
langfuse/langfuse-python#2014 · 已指派 1 人 ·
維護者通常 1 天內回覆
-
bug: GCS upload detection in MediaManager uses substring match on the full URL可能已有人在做 @hassiebp 於 26 天前認領。 未關閉bug feat-multimodal-media sdk-python
langfuse/langfuse-python#1913 · 1 則留言 · 已指派 1 人 ·
維護者通常 1 天內回覆
查看 langfuse/langfuse-python 的全部 Issue
相似的 Issue
-
[oblt-aw][autodoc] Update docs for security org scaffolding and Docs AI menu permission changes可能已有人在做 @github-actions 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 75/100
維護者通常 1 天內回覆
-
external integration integration-submission
難度 2/5 1-3 小時 新手友好度 68/100
langchain-ai/docs#7077 ·
維護者通常 1 天內回覆
-
author-page correction
難度 2/5 1-3 小時 新手友好度 68/100
acl-org/acl-anthology#10623 · 1 則留言 ·
維護者通常 1 天內回覆
-
Use context to recognize personal initials and lowercase names可能已有人在做 @lipikaramaswamy 今天認領。 未關閉bug
難度 2/5 1-3 小時 新手友好度 67/100
NVIDIA-NeMo/Anonymizer#340 ·
維護者通常 1 天內回覆
-
難度 1/5 1 小時以內 新手友好度 82/100
btclib-org/btclib-node#2083 ·
維護者通常 1 天內回覆