Spaces:
Runtime error
Runtime error
Use os.environ instead of st.secrets
Browse files- knowledge_gpt/main.py +12 -13
knowledge_gpt/main.py
CHANGED
@@ -7,12 +7,11 @@ st.set_page_config(page_title="ReferenceBot", page_icon="📖", layout="wide")
|
|
7 |
# add all secrets into environmental variables
|
8 |
try:
|
9 |
for key, value in st.secrets.items():
|
10 |
-
|
11 |
-
st.session_state[key] = value
|
12 |
except FileNotFoundError as e:
|
13 |
print(e)
|
14 |
-
print("./streamlit/secrets.toml not found. Assuming secrets are
|
15 |
-
"as environmental variables...")
|
16 |
|
17 |
|
18 |
from knowledge_gpt.components.sidebar import sidebar
|
@@ -49,7 +48,7 @@ def main():
|
|
49 |
|
50 |
sidebar()
|
51 |
|
52 |
-
openai_api_key =
|
53 |
|
54 |
if not openai_api_key:
|
55 |
st.warning(
|
@@ -87,10 +86,10 @@ def main():
|
|
87 |
files=[chunked_file],
|
88 |
embedding=EMBEDDING if model != "debug" else "debug",
|
89 |
vector_store=VECTOR_STORE if model != "debug" else "debug",
|
90 |
-
deployment=
|
91 |
-
model=
|
92 |
-
openai_api_key=
|
93 |
-
openai_api_base=
|
94 |
openai_api_type="azure",
|
95 |
chunk_size = 1,
|
96 |
)
|
@@ -113,10 +112,10 @@ def main():
|
|
113 |
|
114 |
with st.spinner("Setting up AzureChatOpenAI bot..."):
|
115 |
llm = AzureChatOpenAI(
|
116 |
-
openai_api_base=
|
117 |
-
openai_api_version=
|
118 |
-
deployment_name=
|
119 |
-
openai_api_key=
|
120 |
openai_api_type="azure",
|
121 |
temperature=0,
|
122 |
)
|
|
|
7 |
# add all secrets into environmental variables
|
8 |
try:
|
9 |
for key, value in st.secrets.items():
|
10 |
+
os.environ[key] = value
|
|
|
11 |
except FileNotFoundError as e:
|
12 |
print(e)
|
13 |
+
print("./streamlit/secrets.toml not found. Assuming secrets are"
|
14 |
+
" already available as environmental variables...")
|
15 |
|
16 |
|
17 |
from knowledge_gpt.components.sidebar import sidebar
|
|
|
48 |
|
49 |
sidebar()
|
50 |
|
51 |
+
openai_api_key = os.environ["OPENAI_API_KEY"]
|
52 |
|
53 |
if not openai_api_key:
|
54 |
st.warning(
|
|
|
86 |
files=[chunked_file],
|
87 |
embedding=EMBEDDING if model != "debug" else "debug",
|
88 |
vector_store=VECTOR_STORE if model != "debug" else "debug",
|
89 |
+
deployment=os.environ["ENGINE_EMBEDDING"],
|
90 |
+
model=os.environ["ENGINE"],
|
91 |
+
openai_api_key=os.environ["OPENAI_API_KEY"],
|
92 |
+
openai_api_base=os.environ["OPENAI_API_BASE"],
|
93 |
openai_api_type="azure",
|
94 |
chunk_size = 1,
|
95 |
)
|
|
|
112 |
|
113 |
with st.spinner("Setting up AzureChatOpenAI bot..."):
|
114 |
llm = AzureChatOpenAI(
|
115 |
+
openai_api_base=os.environ["OPENAI_API_BASE"],
|
116 |
+
openai_api_version=os.environ["OPENAI_API_VERSION"],
|
117 |
+
deployment_name=os.environ["ENGINE"],
|
118 |
+
openai_api_key=os.environ["OPENAI_API_KEY"],
|
119 |
openai_api_type="azure",
|
120 |
temperature=0,
|
121 |
)
|