Skip to content

Commit 768a724

Browse files
Luboslav Yordanovclaude
authored andcommitted
feat: Add Streamlit secrets support for OPENAI_API_KEY
Added fallback to load OPENAI_API_KEY from Streamlit secrets for hosted deployments. Also added langchain-classic to requirements.txt. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent fac848c commit 768a724

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

examples/frontend/batch_speaker_app.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@
3333
# Load environment variables once the module is imported
3434
load_dotenv(ENV_PATH)
3535

36+
# Allow Streamlit secrets to provide API keys in hosted environments
37+
try:
38+
secret_api_key = st.secrets.get("OPENAI_API_KEY") # type: ignore[attr-defined]
39+
if secret_api_key:
40+
os.environ.setdefault("OPENAI_API_KEY", secret_api_key)
41+
except Exception:
42+
pass
43+
3644

3745
class Speaker(BaseModel):
3846
"""Schema for a single speaker entry."""

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ myst-parser>=2.0.0
33
sphinx-copybutton>=0.5.2
44
sphinx-design>=0.5.0
55
sphinx-autodoc-typehints>=1.25.2
6-
sphinx-autoapi>=3.0.0
6+
sphinx-autoapi>=3.0.0
7+
langchain-classic>=0.1.0

0 commit comments

Comments
 (0)