8000 feat: support New client with explicit params by emranbm · Pull Request #3 · henomis/langfuse-go · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat: support New client with explicit params #3

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@

# Go workspace file
go.work

# IDE specific files
.idea/
17 changes: 12 additions & 5 deletions internal/pkg/api/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,23 @@ type Client struct {
restClient *restclientgo.RestClient
}

// New creates a new Langfuse client with the environment variables:
// LANGFUSE_HOST, LANGFUSE_PUBLIC_KEY, and LANGFUSE_SECRET_KEY.
func New() *Client {
langfuseHost := os.Getenv("LANGFUSE_HOST")
if langfuseHost == "" {
langfuseHost = langfuseDefaultEndpoint
}

publicKey := os.Getenv("LANGFUSE_PUBLIC_KEY")
secretKey := os.Getenv("LANGFUSE_SECRET_KEY")
return NewWithParams(langfuseHost, publicKey, secretKey)

restClient := restclientgo.New(langfuseHost)
}

// NewWithParams creates a new Langfuse client with the specified endpoint, public key, and secret key.
// If the endpoint is empty, it defaults to the Langfuse cloud endpoint.
func NewWithParams(endpoint, publicKey, secretKey string) *Client {
if endpoint == "" {
endpoint = langfuseDefaultEndpoint
}
restClient := restclientgo.New(endpoint)
restClient.SetRequestModifier(func(req *http.Request) *http.Request {
req.Header.Set("Authorization", basicAuth(publicKey, secretKey))
return req
Expand Down
2 changes: 0 additions & 2 deletions internal/pkg/api/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ const (
ContentTypeJSON = "application/json"
)

type Request struct{}

type Ingestion struct {
Batch []model.IngestionEvent `json:"batch"`
}
Expand Down
0