bug: ChatPromptClient.compile appends str(whole list) once per non-dict placeholder item
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
Issue này chưa được đánh giá.
Mô tả
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
- Ngôn ngữ chính
- Python
- Star
- 500
- Fork
- 367
- Merge trung bình
- 15 giờ 9 phút
- Pull request đã merge (30 ngày)
- 53
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của langfuse/langfuse-python
-
tests/unit/test_prompt.py fails on a fresh clone without LANGFUSE_* env varsCó thể đã có người làm @Mathoholic đã nhận 4 ngày trước. Đang mởbug feat-prompt-management sdk-python
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 80/100
langfuse/langfuse-python#1976 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug(langchain): failed streaming LLM runs retain IDs in callback memoCó thể đã có người làm @hassiebp đã nhận 5 ngày trước. Đang mởbug integration-langchain sdk-python
langfuse/langfuse-python#1977 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug: GCS upload detection in MediaManager uses substring match on the full URLCó thể đã có người làm @hassiebp đã nhận 15 ngày trước. Đang mởbug feat-multimodal-media sdk-python
langfuse/langfuse-python#1913 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
mask is not applied to create_dataset_item or create_score(comment=)Có thể đã có người làm @hassiebp đã nhận 22 ngày trước. Đang mởbug compliance feat-data-masking sdk-python security
langfuse/langfuse-python#1896 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[HTTPXodus] Consider migrating from httpx to httpx2 (the actively maintained fork)Có thể đã có người làm @hassiebp đã nhận 41 ngày trước. Đang mởimprovement sdk-python
langfuse/langfuse-python#1856 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của langfuse/langfuse-python
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
jbacalso24/mimry#291 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
good first issue
Độ khó 2/5 Dưới một giờ Mức phù hợp với người mới 82/100
eli-alvarado/us-watchlist-alerts#14 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
from-review-extraction python severity:nit
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 80/100
LearningCircuit/local-deep-research#7462 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
mermaid_extract.py silently discards single-line state-diagram notes; sequence notes are keptĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
cathrynlavery/diagram-design#441 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
[Cleanup] Include the public header in work_split.cppCó thể đã có người làm @blozano-tt đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
tenstorrent/tt-metal#60850 ·
Maintainer thường phản hồi trong vòng 1 ngày