Hi,
I encountored the error that looks cannot access the st.secrets api key.
After rebooting my app, this error suddenly happens. I didn’t make any changes my secrets settings.
Public App:
Public GitHub repo:
(branch: json)
Specified Libraries Versions (requirements.txt):
streamlit==1.39.0
openai==1.42.0
tornado>=6.4.2
(Python 3.12 on Streamlit Cloud setting)
Error Message on main screen;
=========
TypeError: This app has encountered an error. The original error message is redacted to prevent data leaks. Full error details have been recorded in the logs (if you’re on Streamlit Cloud, click on ‘Manage app’ in the lower right of your app).
Traceback:
File “/home/adminuser/venv/lib/python3.12/site-packages/streamlit/runtime/scriptrunner/exec_code.py”, line 88, in exec_func_with_error_handling
result = func()
^^^^^^
File “/home/adminuser/venv/lib/python3.12/site-packages/streamlit/runtime/scriptrunner/script_runner.py”, line 579, in code_to_exec
exec(code, module.dict)
File “/mount/src/marketing_openai_notion_post/コンテンツ生成_ナノ分類.py”, line 54, in
openai_client = OpenAI(api_key=st.secrets[“OPENAI_API_KEY”])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/home/adminuser/venv/lib/python3.12/site-packages/openai/_client.py”, line 123, in init
super().init(
File “/home/adminuser/venv/lib/python3.12/site-packages/openai/_base_client.py”, line 844, in init
self._client = http_client or SyncHttpxClientWrapper(
^^^^^^^^^^^^^^^^^^^^^^^
File “/home/adminuser/venv/lib/python3.12/site-packages/openai/_base_client.py”, line 742, in init
super().init(**kwargs)
================
Error message on the console:
────────────────────────────────────────────────────────────────────────────────
TypeError: Client.init() got an unexpected keyword argument ‘proxies’
────────────────────── Traceback (most recent call last) ───────────────────────
/home/adminuser/venv/lib/python3.12/site-packages/streamlit/runtime/scriptru
nner/exec_code.py:88 in exec_func_with_error_handling
/home/adminuser/venv/lib/python3.12/site-packages/streamlit/runtime/scriptru
nner/script_runner.py:579 in code_to_exec
/mount/src/marketing_openai_temporary/コンテンツ生成_ナノ分類.py:54 in
51
52 ## Set API Clients
53 # OpenAI client
❱ 54 openai_client = OpenAI(api_key=st.secrets[“OPENAI_API_KEY”])
55
56
57 ## Settings for OpenAI
/home/adminuser/venv/lib/python3.12/site-packages/openai/_client.py:123 in
init
120 │ │ if base_url is None:
121 │ │ │ base_url = f"https://api.openai.com/v1"
122 │ │
❱ 123 │ │ super().init(
124 │ │ │ version=version,
125 │ │ │ base_url=base_url,
126 │ │ │ max_retries=max_retries,
/home/adminuser/venv/lib/python3.12/site-packages/openai/_base_client.py:844
in init
841 │ │ │ custom_headers=custom_headers,
842 │ │ │ _strict_response_validation=_strict_response_validation,
843 │ │ )
❱ 844 │ │ self._client = http_client or SyncHttpxClientWrapper(
845 │ │ │ base_url=base_url,
846 │ │ │ # cast to a valid type because mypy doesn’t understand ou
847 │ │ │ timeout=cast(Timeout, timeout),
/home/adminuser/venv/lib/python3.12/site-packages/openai/_base_client.py:742
in init
739 │ │ kwargs.setdefault("timeout", DEFAULT_TIMEOUT)
740 │ │ kwargs.setdefault("limits", DEFAULT_CONNECTION_LIMITS)
741 │ │ kwargs.setdefault("follow_redirects", True)
❱ 742 │ │ super().init(**kwargs)
743
744
745 if TYPE_CHECKING:
────────────────────────────────────────────────────────────────────────────────
TypeError: Client.init() got an unexpected keyword argument ‘proxies’
────────────────────── Traceback (most recent call last) ───────────────────────
/home/adminuser/venv/lib/python3.12/site-packages/streamlit/runtime/scriptru
nner/exec_code.py:88 in exec_func_with_error_handling
/home/adminuser/venv/lib/python3.12/site-packages/streamlit/runtime/scriptru
nner/script_runner.py:579 in code_to_exec
/mount/src/marketing_openai_temporary/コンテンツ生成_ナノ分類.py:54 in
51
52 ## Set API Clients
53 # OpenAI client
❱ 54 openai_client = OpenAI(api_key=st.secrets[“OPENAI_API_KEY”])
55
56
57 ## Settings for OpenAI
/home/adminuser/venv/lib/python3.12/site-packages/openai/_client.py:123 in
init
120 │ │ if base_url is None:
121 │ │ │ base_url = f"https://api.openai.com/v1"
122 │ │
❱ 123 │ │ super().init(
124 │ │ │ version=version,
125 │ │ │ base_url=base_url,
126 │ │ │ max_retries=max_retries,
/home/adminuser/venv/lib/python3.12/site-packages/openai/_base_client.py:844
in init
841 │ │ │ custom_headers=custom_headers,
842 │ │ │ _strict_response_validation=_strict_response_validation,
843 │ │ )
❱ 844 │ │ self._client = http_client or SyncHttpxClientWrapper(
845 │ │ │ base_url=base_url,
846 │ │ │ # cast to a valid type because mypy doesn’t understand ou
847 │ │ │ timeout=cast(Timeout, timeout),
/home/adminuser/venv/lib/python3.12/site-packages/openai/_base_client.py:742
in init
739 │ │ kwargs.setdefault("timeout", DEFAULT_TIMEOUT)
740 │ │ kwargs.setdefault("limits", DEFAULT_CONNECTION_LIMITS)
741 │ │ kwargs.setdefault("follow_redirects", True)
❱ 742 │ │ super().init(**kwargs)
743
744
745 if TYPE_CHECKING:
────────────────────────────────────────────────────────────────────────────────
TypeError: Client.init() got an unexpected keyword argument ‘proxies’
json
atsuyamaru/marketing_openai_temporary/json/コンテンツ生成_ナノ分類.py
… (looping)…
=======
Hope your help. Thanks.