bug(scores): create_score sends numpy.bool_ as JSON `true` and Decimal as "<Decimal>" since v5.0.2
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 74/100
調査の方向性
まず #2006 の変更を読み、再現手順に記載された create_score のペイロード構築と EventSerializer の動作を調べてください。提供されたオフライン再現を numpy.bool_ と decimal.Decimal で実行し、float() が受け付けるすべての非文字列値が JSON の数値としてシリアライズされ、文字列は文字列のままであることを確認してください。
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
#2006 (perf: build create_score body without Fern's dict(), in v5.0.2) replaced CreateScoreRequest(...) with a hand-built dict and kept only the bool/int → float coercion the model used to do. The model coerced every non-str value to float, so other numeric types now go out differently:
value passed to create_score |
v5.0.1 (before #2006) | main (ab861f1) |
|---|---|---|
True |
1.0 |
1.0 |
numpy.bool_(True) (e.g. np.mean(hits) > 0.5) |
1.0 |
true |
decimal.Decimal("0.75") |
0.75 |
"<Decimal>" |
numpy.int64(3) |
3.0 |
3 |
The server's score body takes z.union([z.string(), z.number()]) for value, so a JSON boolean is rejected. "<Decimal>" is accepted as a string, so the numeric score quietly turns into a categorical value "<Decimal>". This goes through every scoring path: create_score, span.score(), score_current_span/trace, and experiment item and run evaluators (Evaluation(value=...)), where numpy results are common.
To reproduce (no network, the score queue is captured)
import json, decimal, numpy as np
from langfuse import Langfuse
from langfuse._utils.serializer import EventSerializer
lf = Langfuse(public_key="pk-lf-test", secret_key="sk-lf-test", base_url="http://127.0.0.1:9")
sent = []
lf._resources.add_score_task = lambda score, **kw: sent.append(score)
for v in [np.bool_(True), decimal.Decimal("0.75")]:
lf.create_score(name="accuracy", value=v, trace_id="0" * 31 + "1")
print([json.loads(json.dumps(s, cls=EventSerializer))["value"] for s in sent])
# main: [True, '<Decimal>'] v5.0.1: [1.0, 0.75]
Expected
Same payload as before #2006: any non-str value that float() accepts is sent as a float.
SDK: langfuse-python main ab861f1 (v5.0.4), Python 3.12.
- 主要言語
- Python
- スター
- 504
- フォーク
- 391
- 平均マージ
- 1日 1時間
- マージ済み PR(30日)
- 64
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
langfuse/langfuse-python のほかの issue
-
tests/unit/test_prompt.py fails on a fresh clone without LANGFUSE_* env vars対応中かも @Mathoholic が 18 日前に担当しました。 オープン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 が 7 日前に担当しました。 オープンbug integration-openai sdk-python
langfuse/langfuse-python#2039 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
fix(serializer): handle single-string __slots__ and detect cycles in slotted objects対応中かも @hassiebp が 13 日前に担当しました。 オープンbug sdk-python
langfuse/langfuse-python#2014 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
bug: ChatPromptClient.compile appends str(whole list) once per non-dict placeholder item対応中かも @nimarb が 8 日前に担当しました。 オープンbug feat-prompt-management sdk-python
langfuse/langfuse-python#1971 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
bug: GCS upload detection in MediaManager uses substring match on the full URL対応中かも @hassiebp が 29 日前に担当しました。 オープンbug feat-multimodal-media sdk-python
langfuse/langfuse-python#1913 · コメント 1 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
langfuse/langfuse-python の issue をすべて見る
似ている issue
-
factory
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
Arize-ai/phoenix#17420 · コメント 1 件 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
FireDynamics/LEDSmokeAnalysis#176 ·
メンテナーはふだん 1 日以内に返信
-
PC
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
メンテナーはふだん 1 日以内に返信
-
dependencies
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
dlt-contrib/dlt-filesystem#51 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信