Spaces:
Running
Running
Commit
•
ae3d41c
1
Parent(s):
35f5e08
file upload gallery
Browse files
app.py
CHANGED
@@ -1354,17 +1354,11 @@ def content_tab_settings():
|
|
1354 |
# index=LLM_VERSIONS.index(st.session_state.config['leafmachine'].get('LLM_version', 'Azure GPT 4')),
|
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 |
-
#
|
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 =
|
1368 |
if st.session_state.get(key_state, False):
|
1369 |
available_versions.extend(versions)
|
1370 |
|
@@ -1739,29 +1733,24 @@ if 'show_prompt_name_w' not in st.session_state:
|
|
1739 |
if 'user_clicked_load_prompt_yaml' not in st.session_state:
|
1740 |
st.session_state['user_clicked_load_prompt_yaml'] = None
|
1741 |
|
1742 |
-
if 'has_key_openai' not in st.session_state:
|
1743 |
-
st.session_state['has_key_openai'] = False
|
1744 |
-
if 'has_key_google_OCR' not in st.session_state:
|
1745 |
-
st.session_state['has_key_google_OCR'] = False
|
1746 |
-
if 'has_key_palm2' not in st.session_state:
|
1747 |
-
st.session_state['has_key_palm2'] = False
|
1748 |
-
if 'has_key_azure' not in st.session_state:
|
1749 |
-
st.session_state['has_key_azure'] = False
|
1750 |
if 'LLM_VERSIONS' not in st.session_state:
|
1751 |
st.session_state['LLM_VERSIONS'] = {
|
1752 |
'OpenAI API': ["GPT 4", "GPT 3.5"],
|
1753 |
'Azure API': ["Azure GPT 4", "Azure GPT 3.5"],
|
1754 |
'Palm API': ["PaLM 2"]
|
1755 |
}
|
1756 |
-
if '
|
1757 |
-
st.session_state['
|
1758 |
-
|
1759 |
-
|
1760 |
-
|
1761 |
-
|
1762 |
-
|
1763 |
-
|
1764 |
-
|
|
|
|
|
|
|
1765 |
|
1766 |
# if not st.session_state.private_file:
|
1767 |
# create_private_file()
|
|
|
1354 |
# index=LLM_VERSIONS.index(st.session_state.config['leafmachine'].get('LLM_version', 'Azure GPT 4')),
|
1355 |
# label_visibility='collapsed')
|
1356 |
# st.markdown("""***Note:*** GPT-4 is significantly more expensive than GPT-3.5 """)
|
|
|
1357 |
|
1358 |
+
# Determine the available versions based on the API keys present
|
|
|
|
|
|
|
|
|
|
|
1359 |
available_versions = []
|
1360 |
for api_name, versions in st.session_state['LLM_VERSIONS'].items():
|
1361 |
+
key_state = st.session_state['api_name_to_key_state'][api_name]
|
1362 |
if st.session_state.get(key_state, False):
|
1363 |
available_versions.extend(versions)
|
1364 |
|
|
|
1733 |
if 'user_clicked_load_prompt_yaml' not in st.session_state:
|
1734 |
st.session_state['user_clicked_load_prompt_yaml'] = None
|
1735 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1736 |
if 'LLM_VERSIONS' not in st.session_state:
|
1737 |
st.session_state['LLM_VERSIONS'] = {
|
1738 |
'OpenAI API': ["GPT 4", "GPT 3.5"],
|
1739 |
'Azure API': ["Azure GPT 4", "Azure GPT 3.5"],
|
1740 |
'Palm API': ["PaLM 2"]
|
1741 |
}
|
1742 |
+
if 'api_name_to_key_state ' not in st.session_state:
|
1743 |
+
st.session_state['api_name_to_key_state'] = {
|
1744 |
+
'OpenAI API': 'has_key_openai',
|
1745 |
+
'Google OCR API': 'has_key_google_OCR',
|
1746 |
+
'Palm API': 'has_key_palm2',
|
1747 |
+
'Azure API': 'has_key_azure'
|
1748 |
+
}
|
1749 |
+
|
1750 |
+
# Initialize API key states if not already in session_state
|
1751 |
+
for api_name, key_state in st.session_state['api_name_to_key_state'].items():
|
1752 |
+
if key_state not in st.session_state:
|
1753 |
+
st.session_state[key_state] = False
|
1754 |
|
1755 |
# if not st.session_state.private_file:
|
1756 |
# create_private_file()
|