Skip to content

Commit 8405ee5

Browse files
update docs for env vars (#1987)
This updates docs for #1949 I feel like we shouldn't explicitly talk about lazy loading env vars, it's just extra information for a programming language user. It should just work out of the box. <!-- ELLIPSIS_HIDDEN --> ---- > [!IMPORTANT] > Update documentation for environment variables, including deprecation warnings and new examples for Python, TypeScript, and Ruby. > > - **Documentation Updates**: > - Removed redundant section "Setting Environment Variables" from `env-vars.mdx`. > - Added deprecation warning for `reset_baml_env_vars` in `config.mdx`. > - Updated `with_options.mdx` to include `env` parameter in examples for Python, TypeScript, and Ruby. > - Updated `setting-env-vars.mdx` to remove outdated examples and clarify usage of `dotenv` in Python, TypeScript, and Ruby. > - **Behavior**: > - Environment variables are now lazily loaded on each function call, as noted in `config.mdx`. > > <sup>This description was created by </sup>[<img alt="Ellipsis" src="https://img.shields.io/badge/Ellipsis-blue?color=175173">](https://www.ellipsis.dev?ref=BoundaryML%2Fbaml&utm_source=github&utm_medium=referral)<sup> for 1ddf894. You can [customize](https://app.ellipsis.dev/BoundaryML/settings/summaries) this summary. It will automatically update as commits are pushed.</sup> <!-- ELLIPSIS_HIDDEN --> --------- Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
1 parent 0b645e3 commit 8405ee5

4 files changed

Lines changed: 12 additions & 59 deletions

File tree

fern/03-reference/baml/env-vars.mdx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ client<llm> MyCustomClient {
2121
}
2222
```
2323

24-
## Setting Environment Variables
2524
<Markdown src="/snippets/setting-env-vars.mdx" />
2625

2726
## Error Handling

fern/03-reference/baml_client/config.mdx

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

fern/03-reference/baml_client/with_options.mdx

Lines changed: 8 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

fern/snippets/setting-env-vars.mdx

Lines changed: 1 addition & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -29,26 +29,11 @@ python my_program_using_baml.py
2929

3030
<Tabs>
3131
<Tab title="python">
32-
> **Warning**: If you are using the `python-dotenv` package, please check the import order for some edge cases.
33-
34-
```python
35-
import dotenv
36-
from baml_client import b
37-
# This will work regardless of import order, since dotenv is imported as a module
38-
dotenv.load_dotenv()
39-
```
40-
41-
```python
42-
from baml_client import b
43-
from dotenv import load_dotenv
44-
# This will work since load_dotenv is imported after baml_client
45-
load_dotenv()
46-
```
4732

4833
```python
4934
from dotenv import load_dotenv
5035
from baml_client import b
51-
# This will not work as expected since baml_client is imported AFTER load_dotenv
36+
5237
load_dotenv()
5338
```
5439
</Tab>
@@ -58,52 +43,13 @@ python my_program_using_baml.py
5843
import dotenv from 'dotenv'
5944
import { b } from './baml_client'
6045

61-
// This should "just work"!
6246
dotenv.config()
6347
```
6448
</Tab>
6549
<Tab title="ruby">
6650
```ruby
6751
require 'dotenv/load'
68-
69-
# Wait to import the BAML client until after loading environment variables
70-
# reset_baml_env_vars is not yet implemented in the Ruby client
7152
require 'baml_client'
7253
```
7354
</Tab>
7455
</Tabs>
75-
76-
77-
### For Your App (Manually)
78-
79-
<Info>
80-
Requires BAML Version 0.57+
81-
</Info>
82-
83-
Reset the environment variables to those manually set in your code.
84-
85-
<Tabs>
86-
<Tab title="python">
87-
```python
88-
from baml_client import b
89-
from baml_client.config import reset_baml_env_vars
90-
91-
# This will load the environment variables from the .env file
92-
reset_baml_env_vars({ "OPENAI_API_KEY": "sk-super-secret-key" })
93-
```
94-
</Tab>
95-
<Tab title="typescript">
96-
```typescript
97-
// Wait to import the BAML client until after loading environment variables
98-
import { b } from './baml_client'
99-
import { resetBamlEnvVars } from './baml_client/config'
100-
101-
resetBamlEnvVars({ "OPENAI_API_KEY": "sk-super-secret-key" })
102-
```
103-
</Tab>
104-
<Tab title="ruby">
105-
```ruby
106-
# not implemented yet
107-
```
108-
</Tab>
109-
</Tabs>

0 commit comments

Comments
 (0)