Skip to content
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

Update getting_started.md #4482

Merged
merged 3 commits into from
May 18, 2023
Merged

Conversation

bongsang
Copy link
Contributor

Added another helpful way for developers who want to set OpenAI API Key dynamically

Previous methods like exporting environment variables are good for project-wide settings.
But many use cases need to assign API keys dynamically, recently.

from langchain.llms import OpenAI
llm = OpenAI(openai_api_key="OPENAI_API_KEY")

Before submitting

export OPENAI_API_KEY="..."

Or,

import os
os.environ["OPENAI_API_KEY"] = "..."

Thank you.
Cheers,
Bongsang

- Update: Quickstart Guide > Environment Setup
- Reason:
  Recently, many applications have required each user's API key.
  But, "export OPENAI_API_KEY" or "os.environ" is for
  a project-wide setting. So I added another way the user
  could dynamically assign the API key.
When I first saw the LLMChain, I needed clarification about how to input multiple variables because there is no explanation for the "chain.run" function in detail. So, I added a simple example for multi variables. This is a short example but it will be helpful to one who wants to make various prompts.
@@ -40,6 +40,8 @@
"source": [
"from langchain.prompts import PromptTemplate\n",
"from langchain.llms import OpenAI\n",
"import os\n",
"os.environ[\"OPENAI_API_KEY\"] = \"Your-API-KEY\"\n",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that the API key is not set to a correctly value here, would you mind commenting this code out. It will make it easy for us to keep on re-running the notebook if we need to update it while also informing users that they can set the value dynamically (but first have to uncomment the code)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your advice. That's right. I agree with you.
So, I deleted two lines and committed again with the message: "Deleted key setting lines because how to set the OpenAI key has already been guided." I still need to familiarize myself with open-source contributions. So, if I still need to correct something, please let me know.

@eyurtsev
Copy link
Collaborator

eyurtsev commented May 12, 2023

@bongsang Thank you for helping improve the documents! I have one comment about the notebook, let me know if you have any thoughts / objections.

set the OpenAI key has already been guided.
@hwchase17 hwchase17 merged commit 613bf9b into langchain-ai:master May 18, 2023
@danielchalef danielchalef mentioned this pull request Jun 5, 2023
This was referenced Jun 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants