Spaces:
Running
Running
phyloforfun
commited on
Commit
•
35f5e08
1
Parent(s):
492b0f2
file upload gallery
Browse files
app.py
CHANGED
@@ -1355,14 +1355,20 @@ def content_tab_settings():
|
|
1355 |
# label_visibility='collapsed')
|
1356 |
# st.markdown("""***Note:*** GPT-4 is significantly more expensive than GPT-3.5 """)
|
1357 |
# Now filter the LLM_VERSIONS based on the available API keys
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1358 |
available_versions = []
|
1359 |
for api_name, versions in st.session_state['LLM_VERSIONS'].items():
|
1360 |
-
|
1361 |
-
if st.session_state.get(
|
1362 |
available_versions.extend(versions)
|
1363 |
-
print(available_versions)
|
1364 |
|
1365 |
-
# Show available LLM versions in a select box
|
1366 |
st.subheader('LLM Version')
|
1367 |
if available_versions:
|
1368 |
# Get current selection from session_state, defaulting to the first available version
|
@@ -1747,6 +1753,13 @@ if 'LLM_VERSIONS' not in st.session_state:
|
|
1747 |
'Azure API': ["Azure GPT 4", "Azure GPT 3.5"],
|
1748 |
'Palm API': ["PaLM 2"]
|
1749 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1750 |
|
1751 |
|
1752 |
|
|
|
1355 |
# label_visibility='collapsed')
|
1356 |
# st.markdown("""***Note:*** GPT-4 is significantly more expensive than GPT-3.5 """)
|
1357 |
# Now filter the LLM_VERSIONS based on the available API keys
|
1358 |
+
|
1359 |
+
# Initialize API key states if not already in session_state
|
1360 |
+
for key_state, env_var in st.session_state['api_keys'].items():
|
1361 |
+
if key_state not in st.session_state:
|
1362 |
+
st.session_state[key_state] = os.getenv(env_var) is not None
|
1363 |
+
|
1364 |
+
# Now check which LLM versions are available based on the available API keys
|
1365 |
available_versions = []
|
1366 |
for api_name, versions in st.session_state['LLM_VERSIONS'].items():
|
1367 |
+
key_state = f'has_key_{api_name.lower().replace(" ", "_")}'
|
1368 |
+
if st.session_state.get(key_state, False):
|
1369 |
available_versions.extend(versions)
|
|
|
1370 |
|
1371 |
+
# Show available LLM versions in a select box if there are any
|
1372 |
st.subheader('LLM Version')
|
1373 |
if available_versions:
|
1374 |
# Get current selection from session_state, defaulting to the first available version
|
|
|
1753 |
'Azure API': ["Azure GPT 4", "Azure GPT 3.5"],
|
1754 |
'Palm API': ["PaLM 2"]
|
1755 |
}
|
1756 |
+
if 'api_keys' not in st.session_state:
|
1757 |
+
st.session_state['api_keys'] = {
|
1758 |
+
'has_key_openai': 'OPENAI_API_KEY',
|
1759 |
+
'has_key_google_OCR': 'GOOGLE_APPLICATION_CREDENTIALS',
|
1760 |
+
'has_key_palm2': 'PALM_API_KEY',
|
1761 |
+
'has_key_azure': 'AZURE_API_KEY'
|
1762 |
+
}
|
1763 |
|
1764 |
|
1765 |
|