Skip to content
17 changes: 14 additions & 3 deletions libs/acl/langfuse/langfuse.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type Langfuse interface {
EndGeneration(body *GenerationEventBody) error
CreateEvent(body *EventEventBody) (string, error)
Flush()
Prompt() *PromptClient
}

// NewLangfuse creates a Langfuse client instance
Expand Down Expand Up @@ -68,9 +69,10 @@ func NewLangfuse(
opt(o)
}

httpCli := &http.Client{Timeout: o.timeout}
tm := newTaskManager(
o.threads,
&http.Client{Timeout: o.timeout},
httpCli,
host,
o.maxTaskQueueSize,
o.flushAt,
Expand All @@ -85,11 +87,14 @@ func NewLangfuse(
secretKey,
o.maxRetry,
)
return &langfuseIns{tm: tm}
langfuseCli := newClient(httpCli, host, publicKey, secretKey, sdkVersion)
promptCli := &PromptClient{cli: langfuseCli}
return &langfuseIns{tm: tm, promptCli: promptCli}
}

type langfuseIns struct {
tm *taskManager
tm *taskManager
promptCli *PromptClient
}

// CreateTrace creates a new trace in Langfuse
Expand Down Expand Up @@ -215,3 +220,9 @@ func (l *langfuseIns) CreateEvent(body *EventEventBody) (string, error) {
func (l *langfuseIns) Flush() {
l.tm.flush()
}

// Prompt provides access to the prompt client for managing prompts.
// Use the returned PromptClient to create, retrieve and list prompts.
func (l *langfuseIns) Prompt() *PromptClient {
return l.promptCli
}
14 changes: 14 additions & 0 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
Loading