Skip to content

Commit

Permalink
Merge pull request #39 from brainlid/me-env-example-name-change
Browse files Browse the repository at this point in the history
change to use OPENAI_API_KEY spelling
  • Loading branch information
brainlid authored Nov 26, 2023
2 parents d0de7a3 + 80eb17b commit 3b1d07d
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .envrc_template
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export OPENAI_KEY="YOUR_OPENAI_KEY"
export OPENAI_API_KEY="YOUR_OPENAI_KEY"
export OPENAI_ORG_ID="YOUR_OPENAI_ORG_ID"
4 changes: 2 additions & 2 deletions .github/workflows/elixir.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ on:
branches: [ "main" ]

env:
OPENAI_KEY: invalid
OPENAI_API_KEY: invalid

permissions:
contents: read

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ To make API calls, it is necessary to configure the API keys for the services yo
`config/config.exs`:

```elixir
config :langchain, openai_key: System.get_env("OPENAI_KEY")
config :langchain, openai_key: System.get_env("OPENAI_API_KEY")
config :langchain, openai_org_id: System.get_env("OPENAI_ORG_ID")
# OR
config :langchain, openai_key: "YOUR SECRET KEY"
Expand All @@ -73,10 +73,10 @@ config :langchain, openai_org_id: "YOUR_OPENAI_ORG_ID"
It's possible to use a function or a tuple to resolve the secret:

```elixir
config :langchain, openai_key: {MyApp.Secrets, :openai_key, []}
config :langchain, openai_key: {MyApp.Secrets, :openai_api_key, []}
config :langchain, openai_org_id: {MyApp.Secrets, :openai_org_id, []}
# OR
config :langchain, openai_key: fn -> System.get_env("OPENAI_KEY") end
config :langchain, openai_key: fn -> System.get_env("OPENAI_API_KEY") end
config :langchain, openai_org_id: fn -> System.get_env("OPENAI_ORG_ID") end
```

Expand Down
6 changes: 3 additions & 3 deletions notebooks/custom_functions.livemd
Original file line number Diff line number Diff line change
Expand Up @@ -209,15 +209,15 @@ We need to setup the LangChain library to connect with ChatGPT using our API key
<!-- livebook:{"force_markdown":true} -->

```elixir
config :langchain, :openai_key, fn -> System.fetch_env!("OPENAI_KEY") end
config :langchain, :openai_key, fn -> System.fetch_env!("OPENAI_API_KEY") end
```

<!-- livebook:{"break_markdown":true} -->

For the Livebook notebook, use the "Secrets" on the sidebar to create an `OPENAI_KEY` secret with you API key. That is accessible here using `"LB_OPENAI_KEY"`.
For the Livebook notebook, use the "Secrets" on the sidebar to create an `OPENAI_API_KEY` secret with you API key. That is accessible here using `"LB_OPENAI_API_KEY"`.

```elixir
Application.put_env(:langchain, :openai_key, System.fetch_env!("LB_OPENAI_KEY"))
Application.put_env(:langchain, :openai_key, System.fetch_env!("LB_OPENAI_API_KEY"))
```

<!-- livebook:{"output":true} -->
Expand Down
8 changes: 4 additions & 4 deletions notebooks/getting_started.livemd
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ We need to setup the LangChain library to connect with ChatGPT using our API key
<!-- livebook:{"force_markdown":true} -->

```elixir
config :langchain, :openai_key, fn -> System.fetch_env!("OPENAI_KEY") end
config :langchain, :openai_key, fn -> System.fetch_env!("OPENAI_API_KEY") end
```

For the Livebook notebook, use the "Secrets" on the sidebar to create an `OPENAI_KEY` secret with you API key. That is accessible here using `"LB_OPENAI_KEY"`.
For the Livebook notebook, use the "Secrets" on the sidebar to create an `OPENAI_API_KEY` secret with you API key. That is accessible here using `"LB_OPENAI_API_KEY"`.

```elixir
Application.put_env(:langchain, :openai_key, System.fetch_env!("LB_OPENAI_KEY"))
Application.put_env(:langchain, :openai_key, System.fetch_env!("LB_OPENAI_API_KEY"))
```

<!-- livebook:{"output":true} -->
Expand All @@ -40,7 +40,7 @@ Application.put_env(:langchain, :openai_key, System.fetch_env!("LB_OPENAI_KEY"))

Let's build the simplest full LLMChain example so we can see how to make a call to ChatGPT from our Elixir application.

**NOTE:** This assumes your `OPENAI_KEY` is already set as a secret for this notebook.
**NOTE:** This assumes your `OPENAI_API_KEY` is already set as a secret for this notebook.

```elixir
alias LangChain.Chains.LLMChain
Expand Down
2 changes: 1 addition & 1 deletion test/test_helper.exs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Load the ENV key for running live OpenAI tests.
Application.put_env(:langchain, :openai_key, System.fetch_env!("OPENAI_KEY"))
Application.put_env(:langchain, :openai_key, System.fetch_env!("OPENAI_API_KEY"))

ExUnit.configure(capture_log: true, exclude: [live_call: true])
ExUnit.start()

0 comments on commit 3b1d07d

Please sign in to comment.