Spaces:
Runtime error
Runtime error
Update streamlit_langchain_chat/streamlit_app.py
Browse files
streamlit_langchain_chat/streamlit_app.py
CHANGED
@@ -157,7 +157,7 @@ def collect_dataset_and_built_index():
|
|
157 |
some_files = True if uploaded_files_rows and uploaded_files_rows[-1].get('filepath') != "" else False
|
158 |
some_urls = bool([True for url, citation in urls_df.to_numpy() if url])
|
159 |
|
160 |
-
openai.api_type = "
|
161 |
openai.api_base = api_base
|
162 |
openai.api_version = "2023-03-15-preview" if type_id == 1 else None
|
163 |
|
@@ -331,19 +331,11 @@ def load_sidebar_page():
|
|
331 |
# ##### #
|
332 |
st.sidebar.markdown("2. Select a model (LLM):")
|
333 |
combination_selected = st.sidebar.selectbox(
|
334 |
-
"Choose type: OpenAI
|
335 |
[key for key, value in TYPE_IDS.items()])
|
336 |
app.params['type_id'] = TYPE_IDS.get(combination_selected, None)
|
337 |
|
338 |
-
if app.params['type_id'] == 1: # with
|
339 |
-
os.environ['OPENAI_API_KEY'] = st.sidebar.text_input(
|
340 |
-
label="Enter OpenAI API Key",
|
341 |
-
placeholder="sk-...",
|
342 |
-
type="password"
|
343 |
-
).strip()
|
344 |
-
app.params['api_base'] = "https://api.openai.com/v1"
|
345 |
-
app.params['deployment_id'] = None
|
346 |
-
elif app.params['type_id'] == 2: # with AzureOpenAI endpoint
|
347 |
# https://docs.streamlit.io/library/api-reference/widgets/st.text_input
|
348 |
os.environ['OPENAI_API_KEY'] = st.sidebar.text_input(
|
349 |
label="Enter Azure OpenAI API Key",
|
@@ -356,6 +348,14 @@ def load_sidebar_page():
|
|
356 |
app.params['deployment_id'] = st.sidebar.text_input(
|
357 |
label="Enter Azure deployment_id",
|
358 |
).strip()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
359 |
|
360 |
# ####### #
|
361 |
# INDEXES #
|
|
|
157 |
some_files = True if uploaded_files_rows and uploaded_files_rows[-1].get('filepath') != "" else False
|
158 |
some_urls = bool([True for url, citation in urls_df.to_numpy() if url])
|
159 |
|
160 |
+
openai.api_type = "azure" if type_id == 1 else "open_ai"
|
161 |
openai.api_base = api_base
|
162 |
openai.api_version = "2023-03-15-preview" if type_id == 1 else None
|
163 |
|
|
|
331 |
# ##### #
|
332 |
st.sidebar.markdown("2. Select a model (LLM):")
|
333 |
combination_selected = st.sidebar.selectbox(
|
334 |
+
"Choose type: MSF Azure OpenAI and model / OpenAI",
|
335 |
[key for key, value in TYPE_IDS.items()])
|
336 |
app.params['type_id'] = TYPE_IDS.get(combination_selected, None)
|
337 |
|
338 |
+
if app.params['type_id'] == 1: # with AzureOpenAI endpoint
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
339 |
# https://docs.streamlit.io/library/api-reference/widgets/st.text_input
|
340 |
os.environ['OPENAI_API_KEY'] = st.sidebar.text_input(
|
341 |
label="Enter Azure OpenAI API Key",
|
|
|
348 |
app.params['deployment_id'] = st.sidebar.text_input(
|
349 |
label="Enter Azure deployment_id",
|
350 |
).strip()
|
351 |
+
elif app.params['type_id'] == 2: # with OpenAI endpoint
|
352 |
+
os.environ['OPENAI_API_KEY'] = st.sidebar.text_input(
|
353 |
+
label="Enter OpenAI API Key",
|
354 |
+
placeholder="sk-...",
|
355 |
+
type="password"
|
356 |
+
).strip()
|
357 |
+
app.params['api_base'] = "https://api.openai.com/v1"
|
358 |
+
app.params['deployment_id'] = None
|
359 |
|
360 |
# ####### #
|
361 |
# INDEXES #
|