langfuse

package
v0.2.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 30, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PromptTypeText = "text"
	PromptTypeChat = "chat"
)

Variables

This section is empty.

Functions

func SetTrace added in v0.2.6

func SetTrace(ctx context.Context, opts ...TraceOption) context.Context

Types

type Client added in v0.2.6

type Client struct {
	// contains filtered or unexported fields
}

func NewClient added in v0.2.6

func NewClient(cfg ClientConfig) (*Client, error)

func (*Client) Close added in v0.2.6

func (c *Client) Close()

func (*Client) Enqueue added in v0.2.6

func (c *Client) Enqueue(eventType string, body any)

func (*Client) Flush added in v0.2.6

func (c *Client) Flush()

func (*Client) GetPrompt added in v0.2.6

func (c *Client) GetPrompt(ctx context.Context, name string, opts ...PromptOption) (*Prompt, error)

func (*Client) GetTextPrompt added in v0.2.6

func (c *Client) GetTextPrompt(ctx context.Context, name string, opts ...PromptOption) (string, error)

type ClientConfig added in v0.2.6

type ClientConfig struct {
	Host              string
	PublicKey         string
	SecretKey         string
	HTTPClient        *http.Client
	FlushAt           int
	FlushInterval     time.Duration
	MaxQueueSize      int
	RequestTimeout    time.Duration
	Environment       string
	Release           string
	Version           string
	LogIngestErrors   bool
	DropOnQueueFull   bool
	IngestionMetadata any
}

type Config added in v0.2.6

type Config struct {
	ClientConfig

	Name   string
	Clock  func() time.Time
	Logger *log.Logger
}

type Handler added in v0.2.6

type Handler struct {
	// contains filtered or unexported fields
}

func NewHandler added in v0.2.6

func NewHandler(cfg Config) (*Handler, func(), error)

func (*Handler) Needed added in v0.2.6

func (h *Handler) Needed(ctx context.Context, info *callbacks.RunInfo, timing callbacks.CallbackTiming) bool

func (*Handler) OnEnd added in v0.2.6

func (*Handler) OnEndWithStreamOutput added in v0.2.6

func (h *Handler) OnEndWithStreamOutput(ctx context.Context, info *callbacks.RunInfo, output *schema.StreamReader[callbacks.CallbackOutput]) context.Context

func (*Handler) OnError added in v0.2.6

func (h *Handler) OnError(ctx context.Context, info *callbacks.RunInfo, err error) context.Context

func (*Handler) OnStart added in v0.2.6

func (*Handler) OnStartWithStreamInput added in v0.2.6

func (h *Handler) OnStartWithStreamInput(ctx context.Context, _ *callbacks.RunInfo, input *schema.StreamReader[callbacks.CallbackInput]) context.Context

type Prompt added in v0.2.6

type Prompt struct {
	ID              string          `json:"id,omitempty"`
	CreatedAt       time.Time       `json:"createdAt,omitempty"`
	UpdatedAt       time.Time       `json:"updatedAt,omitempty"`
	ProjectID       string          `json:"projectId,omitempty"`
	CreatedBy       string          `json:"createdBy,omitempty"`
	Name            string          `json:"name"`
	Version         int             `json:"version"`
	Type            string          `json:"type"`
	Text            string          `json:"-"`
	Messages        []PromptMessage `json:"-"`
	Config          any             `json:"config"`
	Labels          []string        `json:"labels"`
	Tags            []string        `json:"tags"`
	CommitMessage   *string         `json:"commitMessage,omitempty"`
	ResolutionGraph any             `json:"resolutionGraph,omitempty"`
	RawPrompt       json.RawMessage `json:"prompt,omitempty"`
}

type PromptMessage added in v0.2.6

type PromptMessage struct {
	Role    string `json:"role,omitempty"`
	Content string `json:"content,omitempty"`
	Name    string `json:"name,omitempty"`
	Type    string `json:"type,omitempty"`
}

type PromptOption added in v0.2.6

type PromptOption func(*promptOptions)

func WithPromptLabel added in v0.2.6

func WithPromptLabel(label string) PromptOption

func WithPromptResolve added in v0.2.6

func WithPromptResolve(resolve bool) PromptOption

func WithPromptVersion added in v0.2.6

func WithPromptVersion(version int) PromptOption

type TraceOption added in v0.2.6

type TraceOption func(*traceOptions)

func WithEnvironment added in v0.2.6

func WithEnvironment(environment string) TraceOption

func WithID added in v0.2.6

func WithID(id string) TraceOption

func WithInput added in v0.2.6

func WithInput(input any) TraceOption

func WithMetadata added in v0.2.6

func WithMetadata(metadata map[string]string) TraceOption

func WithName added in v0.2.6

func WithName(name string) TraceOption

func WithOutput added in v0.2.6

func WithOutput(output any) TraceOption

func WithPublic added in v0.2.6

func WithPublic(public bool) TraceOption

func WithRelease added in v0.2.6

func WithRelease(release string) TraceOption

func WithSessionID added in v0.2.6

func WithSessionID(sessionID string) TraceOption

func WithTags added in v0.2.6

func WithTags(tags ...string) TraceOption

func WithUserID added in v0.2.6

func WithUserID(userID string) TraceOption

func WithVersion added in v0.2.6

func WithVersion(version string) TraceOption

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL