Skip to content

Support local configuration, not only global #161

@sandstrom

Description

@sandstrom

The plan mentions supporting both global and local state.

```ruby
# Simple case - sets global state (default)
Braintrust.init(
api_key: ENV['BRAINTRUST_API_KEY'],
project: "my-project"
)
# Explicit state (for testing, multi-tenant)
state = Braintrust.init(
api_key: "key",
project: "project",
set_global: false
)

This is a very good pattern.

But currently, only global seems to be supported. At least that's all that's in the readme.

Also, if you support local state, I would suggest the traditional class pattern with new (idiomatic ruby):

# Simple case - sets global state (default)
Braintrust.init(
  api_key: ENV['BRAINTRUST_API_KEY'],
  project: "my-project"
)

# Explicit state (for testing, multi-tenant)
braintrust_instance = Braintrust.new(
  api_key: "key",
  project: "project",
  set_global: false
)

(the one in the plan is even broken, it wouldn't work at all as mentioned in the plan)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions