bug(scores): create_score sends numpy.bool_ as JSON `true` and Decimal as "<Decimal>" since v5.0.2
Mantenedores costumam responder em até 1 dia
Avaliação
- Dificuldade
- 2/5
- Tempo estimado
- 1-3 horas
- Facilidade para iniciantes
- 74/100
Direção de pesquisa
Comece lendo a alteração em #2006 e inspecione a construção do payload de create_score e o comportamento de EventSerializer mencionados na reprodução. Execute a reprodução offline fornecida com numpy.bool_ e decimal.Decimal e, em seguida, verifique se todo valor que não seja string e que float() aceite é serializado como um número JSON, enquanto strings continuam sendo strings.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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.
- Linguagem predominante
- Python
- Estrelas
- 504
- Forks
- 391
- Merge médio
- 1d 1h
- PRs com merge (30d)
- 64
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de langfuse/langfuse-python
-
tests/unit/test_prompt.py fails on a fresh clone without LANGFUSE_* env varsTalvez já em andamento @Mathoholic assumiu há 18 dias. Abertabug feat-prompt-management sdk-python
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 80/100
langfuse/langfuse-python#1976 · 3 comentários ·
Mantenedores costumam responder em até 1 dia
-
bug(openai): a stream that fails mid-iteration ends the generation without level ERRORTalvez já em andamento @hassiebp assumiu há 7 dias. Abertabug integration-openai sdk-python
langfuse/langfuse-python#2039 · 1 responsável ·
Mantenedores costumam responder em até 1 dia
-
fix(serializer): handle single-string __slots__ and detect cycles in slotted objectsTalvez já em andamento @hassiebp assumiu há 13 dias. Abertabug sdk-python
langfuse/langfuse-python#2014 · 1 responsável ·
Mantenedores costumam responder em até 1 dia
-
bug: ChatPromptClient.compile appends str(whole list) once per non-dict placeholder itemTalvez já em andamento @nimarb assumiu há 8 dias. Abertabug feat-prompt-management sdk-python
langfuse/langfuse-python#1971 · 1 responsável ·
Mantenedores costumam responder em até 1 dia
-
bug: GCS upload detection in MediaManager uses substring match on the full URLTalvez já em andamento @hassiebp assumiu há 28 dias. Abertabug feat-multimodal-media sdk-python
langfuse/langfuse-python#1913 · 1 comentário · 1 responsável ·
Mantenedores costumam responder em até 1 dia
Todas as issues de langfuse/langfuse-python
Issues semelhantes
-
app: scripts status: backlog type: documentation
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 86/100
netbox-community/netbox-scripts#68 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 91/100
marin-community/marin#10765 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 70/100
flathub/com.unity.UnityHub#230 ·
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
Mantenedores costumam responder em até 1 dia
-
namespace operations
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 63/100
EclipseFdn/open-vsx.org#14910 ·
Mantenedores costumam responder em até 1 dia