Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions libs/acl/langfuse/langfuse.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const (
//go:generate mockgen -source=langfuse.go -destination=./mock/langfuse_mock.go -package=mock Langfuse
type Langfuse interface {
CreateTrace(body *TraceEventBody) (string, error)
UpdateTrace(body *TraceEventBody) error
CreateSpan(body *SpanEventBody) (string, error)
EndSpan(body *SpanEventBody) error
CreateGeneration(body *GenerationEventBody) (string, error)
Expand Down Expand Up @@ -115,6 +116,26 @@ func (l *langfuseIns) CreateTrace(body *TraceEventBody) (string, error) {
})
}

// UpdateTrace updates an existing trace in Langfuse
//
// Parameters:
// - body: The trace event details. ID must be present.
//
// Returns:
// - error: Any error that occurred during creation
func (l *langfuseIns) UpdateTrace(body *TraceEventBody) error {
// There is no event type named "trace-update", and the only way to update a trace
// is to fire an event of type "trace-create" again with the same body id,
// while using a separate event id, which will be filled by CreateTrace.
//
// See https://api.reference.langfuse.com/#tag/ingestion/POST/api/public/ingestion
return l.tm.push(&event{
ID: uuid.NewString(),
Type: EventTypeTraceCreate,
Body: eventBodyUnion{Trace: body},
})
}

// CreateSpan creates a new span within a trace
//
// Parameters:
Expand Down
31 changes: 25 additions & 6 deletions libs/acl/langfuse/mock/langfuse_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading