Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The update event functions do not update output. #5

Open
paris0120 opened this issue Mar 15, 2025 · 7 comments
Open

The update event functions do not update output. #5

paris0120 opened this issue Mar 15, 2025 · 7 comments
Assignees

Comments

@paris0120
Copy link

The only field it updates it end time I think. It would be nice if it could update the output after the execution.

@Steffen911
Copy link
Contributor

@paris0120 This should be possible. Can you share an example of what you have tried?

@Steffen911 Steffen911 self-assigned this Mar 16, 2025
@paris0120
Copy link
Author

public IngestionEvent updateGenerationEvent(LangfuseId id, Object output, ChatCompletionResponseUsage usage, ObservationLevel level) {
    OffsetDateTime currentTime = OffsetDateTime.now();
    String currentTimestamp = currentTime.toString();
    OpenAiUsage openAiUsage = OpenAiUsage.builder()
            .completionTokens(usage.getCompletion_tokens())
            .promptTokens(usage.getPrompt_tokens())
            .totalTokens(usage.getTotal_tokens())
            .build();

    IngestionUsage ingestionUsage = IngestionUsage.of(openAiUsage);
    UpdateGenerationBody._FinalStage body = UpdateGenerationBody.builder()
            .id(id.getEventId())
            .traceId(id.getTraceId())
            .parentObservationId(id.getParentEventId())
            .output(output)
            .endTime(currentTime)
            .usage(ingestionUsage);

    if (level != null) {
        body.level(level);
    }

    UpdateGenerationEvent event = UpdateGenerationEvent
            .builder()
            .id(id.getEventId())
            .timestamp(currentTimestamp)
            .body(body.build())
            .build();

    return IngestionEvent.generationUpdate(event);
}

endtime is updated but not output

@Steffen911
Copy link
Contributor

@paris0120 Are you using this with the langfuse cloud version? If yes, could you share the traceId you use? That would help me check the raw events that are received.

Alternatively, you could check in your S3/Minio bucket what is uploaded in /events//observation//.json. There should be two files there one for the initial create and one for the update. Could you share both with redacted data in case it's sensitive?

@paris0120
Copy link
Author

No I have only one file there. It doesn't update the end time too.

@paris0120
Copy link
Author

Image

@paris0120
Copy link
Author

Also why there is no way to update trace. It will be nice if we can update the output at least

@Steffen911
Copy link
Contributor

@paris0120 Do you set different eventIds on the update? The id on the surrounding event must be different to avoid overwrites on the cloud storage.

Regarding the trace: You can just use the trace-create event multiple times and it will always perform upsert operations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants