Skip to content

Commit

Permalink
Recommend dotenv for managing credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
cpsievert committed Jul 1, 2024
1 parent 030b695 commit 297ecfd
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 8 deletions.
1 change: 1 addition & 0 deletions examples/chat/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.env
5 changes: 4 additions & 1 deletion examples/chat/enterprise/aws-bedrock-anthropic/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@

from shiny.express import ui

# Provide your AWS info here (or set the environment variable)
# Although you can set the AWS credentials here, it's recommended to put them in an .env
# file and load them with `dotenv` so your keys aren't exposed with your code.
# from dotenv import load_dotenv
# load_dotenv()
llm = AnthropicBedrock(
# aws_secret_key="..."
# aws_access_key="..."
Expand Down
5 changes: 4 additions & 1 deletion examples/chat/enterprise/azure-openai/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@

from shiny.express import ui

# # Provide your Azure info here (or set the environment variable)
# Although you can set API keys here, it's recommended to put it in an .env file
# and load it with `dotenv` so your keys aren't exposed with your code.
# from dotenv import load_dotenv
# load_dotenv()
llm = AzureOpenAI(
api_key=os.getenv("AZURE_OPENAI_API_KEY"),
api_version="2024-02-01",
Expand Down
5 changes: 4 additions & 1 deletion examples/chat/hello-providers/anthropic/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@

from shiny.express import ui

# Provide your API key here (or set the environment variable)
# Although you can set the API key here, it's recommended to put it in an .env file
# and load it with `dotenv` so your key isn't exposed with your code.
# from dotenv import load_dotenv
# load_dotenv()
llm = AsyncAnthropic(api_key=os.environ.get("ANTHROPIC_API_KEY"))

# Set some Shiny page options
Expand Down
7 changes: 4 additions & 3 deletions examples/chat/hello-providers/gemini/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@

from shiny.express import ui

# Set the environment variable GOOGLE_API_KEY to your Google API key
# import os
# os.environ["GOOGLE_API_KEY"] = "your_google_api_key"
# You'll need to set the GOOGLE_API_KEY environment variable to your Google API key.
# We recommend putting it in a .env file and loading it with `dotenv`:
# from dotenv import load_dotenv
# load_dotenv()
llm = GenerativeModel()

# Set some Shiny page options
Expand Down
5 changes: 4 additions & 1 deletion examples/chat/hello-providers/langchain/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@

from shiny.express import ui

# Provide your API key here (or set the environment variable)
# Although you can set the API key here, it's recommended to put it in an .env file
# and load it with `dotenv` so your key isn't exposed with your code:
# from dotenv import load_dotenv
# load_dotenv()
llm = ChatOpenAI(api_key=os.environ.get("OPENAI_API_KEY"))

# Set some Shiny page options
Expand Down
5 changes: 4 additions & 1 deletion examples/chat/hello-providers/openai/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@

from shiny.express import ui

# Provide your API key here (or set the environment variable)
# Although you can set the API key here, it's recommended to put it in an .env file
# and load it with `dotenv` so your key isn't exposed with your code:
# from dotenv import load_dotenv
# load_dotenv()
llm = AsyncOpenAI(api_key=os.environ.get("OPENAI_API_KEY"))

# Set some Shiny page options
Expand Down

0 comments on commit 297ecfd

Please sign in to comment.