Spaces:
Running
Running
Commit
·
d2bc00d
1
Parent(s):
904c317
update set api keys
Browse files
app.py
CHANGED
|
@@ -293,7 +293,7 @@ def create_private_file():
|
|
| 293 |
'AZURE_API_TYPE': os.getenv('AZURE_API_TYPE'),
|
| 294 |
'AZURE_DEPLOYMENT_NAME': os.getenv('AZURE_DEPLOYMENT_NAME'),
|
| 295 |
'GOOGLE_APPLICATION_CREDENTIALS': os.getenv('GOOGLE_APPLICATION_CREDENTIALS'),
|
| 296 |
-
'
|
| 297 |
}
|
| 298 |
|
| 299 |
# Check if all environment variables are set
|
|
@@ -338,6 +338,13 @@ def create_private_file():
|
|
| 338 |
st.secrets["db_username"]
|
| 339 |
with c_button_ocr:
|
| 340 |
st.empty()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 341 |
|
| 342 |
if os.getenv('OPENAI_API_KEY') is None:
|
| 343 |
st.write("---")
|
|
@@ -352,6 +359,12 @@ def create_private_file():
|
|
| 352 |
type='password')
|
| 353 |
with c_button_openai:
|
| 354 |
st.empty()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 355 |
|
| 356 |
|
| 357 |
if os.getenv('AZURE_API_KEY') is None:
|
|
@@ -382,43 +395,30 @@ def create_private_file():
|
|
| 382 |
c_in_azure, c_button_azure = st.columns([10,2])
|
| 383 |
with c_button_azure:
|
| 384 |
st.empty()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 385 |
|
| 386 |
|
| 387 |
-
if os.getenv('
|
| 388 |
st.write("---")
|
| 389 |
st.subheader("Google PaLM 2")
|
| 390 |
st.markdown('Follow these [instructions](https://developers.generativeai.google/tutorials/setup) to generate an API key for PaLM 2. You may need to also activate an account with [MakerSuite](https://makersuite.google.com/app/apikey) and enable "early access."')
|
| 391 |
with st.container():
|
| 392 |
c_in_palm, c_button_palm = st.columns([10,2])
|
| 393 |
with c_in_palm:
|
| 394 |
-
google_palm = st.text_input("Google PaLM 2 API Key", os.environ.get('
|
| 395 |
help='The MakerSuite API key e.g. a 32-character string',
|
| 396 |
placeholder='e.g. SATgthsykuE64FgrrrrEervr3S4455t_geyDeGq',
|
| 397 |
type='password')
|
| 398 |
-
|
| 399 |
-
|
| 400 |
-
|
| 401 |
-
|
| 402 |
-
|
| 403 |
-
azure_openai_api_base,azure_openai_organization,azure_openai_api_type,google_vision,google_palm])
|
| 404 |
-
|
| 405 |
-
with st.container():
|
| 406 |
-
with c_button_openai:
|
| 407 |
-
st.write("##")
|
| 408 |
-
st.button("Test OpenAI", on_click=test_API, args=['openai',c_in_openai,openai_api_key,azure_openai_api_version,azure_openai_api_key,
|
| 409 |
-
azure_openai_api_base,azure_openai_organization,azure_openai_api_type,google_vision,google_palm])
|
| 410 |
-
|
| 411 |
-
with st.container():
|
| 412 |
-
with c_button_azure:
|
| 413 |
-
st.write("##")
|
| 414 |
-
st.button("Test Azure OpenAI", on_click=test_API, args=['azure_openai',c_in_azure,openai_api_key,azure_openai_api_version,azure_openai_api_key,
|
| 415 |
-
azure_openai_api_base,azure_openai_organization,azure_openai_api_type,google_vision,google_palm])
|
| 416 |
-
|
| 417 |
-
with st.container():
|
| 418 |
-
with c_button_palm:
|
| 419 |
-
st.write("##")
|
| 420 |
-
st.button("Test PaLM 2", on_click=test_API, args=['palm',c_in_palm,openai_api_key,azure_openai_api_version,azure_openai_api_key,
|
| 421 |
-
azure_openai_api_base,azure_openai_organization,azure_openai_api_type,google_vision,google_palm])
|
| 422 |
|
| 423 |
st.button("Set API Keys",type='primary', on_click=set_API_keys, args=[openai_api_key,azure_openai_api_version,azure_openai_api_key,
|
| 424 |
azure_openai_api_base,azure_openai_organization,azure_openai_api_type,google_vision,google_palm])
|
|
|
|
| 293 |
'AZURE_API_TYPE': os.getenv('AZURE_API_TYPE'),
|
| 294 |
'AZURE_DEPLOYMENT_NAME': os.getenv('AZURE_DEPLOYMENT_NAME'),
|
| 295 |
'GOOGLE_APPLICATION_CREDENTIALS': os.getenv('GOOGLE_APPLICATION_CREDENTIALS'),
|
| 296 |
+
'PALM_API_KEY': os.getenv('PALM_API_KEY')
|
| 297 |
}
|
| 298 |
|
| 299 |
# Check if all environment variables are set
|
|
|
|
| 338 |
st.secrets["db_username"]
|
| 339 |
with c_button_ocr:
|
| 340 |
st.empty()
|
| 341 |
+
|
| 342 |
+
with st.container():
|
| 343 |
+
with c_button_ocr:
|
| 344 |
+
st.write("##")
|
| 345 |
+
st.button("Test OCR", on_click=test_API, args=['google_vision',c_in_ocr,openai_api_key,azure_openai_api_version,azure_openai_api_key,
|
| 346 |
+
azure_openai_api_base,azure_openai_organization,azure_openai_api_type,google_vision,google_palm])
|
| 347 |
+
|
| 348 |
|
| 349 |
if os.getenv('OPENAI_API_KEY') is None:
|
| 350 |
st.write("---")
|
|
|
|
| 359 |
type='password')
|
| 360 |
with c_button_openai:
|
| 361 |
st.empty()
|
| 362 |
+
with st.container():
|
| 363 |
+
with c_button_openai:
|
| 364 |
+
st.write("##")
|
| 365 |
+
st.button("Test OpenAI", on_click=test_API, args=['openai',c_in_openai,openai_api_key,azure_openai_api_version,azure_openai_api_key,
|
| 366 |
+
azure_openai_api_base,azure_openai_organization,azure_openai_api_type,google_vision,google_palm])
|
| 367 |
+
|
| 368 |
|
| 369 |
|
| 370 |
if os.getenv('AZURE_API_KEY') is None:
|
|
|
|
| 395 |
c_in_azure, c_button_azure = st.columns([10,2])
|
| 396 |
with c_button_azure:
|
| 397 |
st.empty()
|
| 398 |
+
with st.container():
|
| 399 |
+
with c_button_azure:
|
| 400 |
+
st.write("##")
|
| 401 |
+
st.button("Test Azure OpenAI", on_click=test_API, args=['azure_openai',c_in_azure,openai_api_key,azure_openai_api_version,azure_openai_api_key,
|
| 402 |
+
azure_openai_api_base,azure_openai_organization,azure_openai_api_type,google_vision,google_palm])
|
| 403 |
+
|
| 404 |
|
| 405 |
|
| 406 |
+
if os.getenv('PALM_API_KEY') is None:
|
| 407 |
st.write("---")
|
| 408 |
st.subheader("Google PaLM 2")
|
| 409 |
st.markdown('Follow these [instructions](https://developers.generativeai.google/tutorials/setup) to generate an API key for PaLM 2. You may need to also activate an account with [MakerSuite](https://makersuite.google.com/app/apikey) and enable "early access."')
|
| 410 |
with st.container():
|
| 411 |
c_in_palm, c_button_palm = st.columns([10,2])
|
| 412 |
with c_in_palm:
|
| 413 |
+
google_palm = st.text_input("Google PaLM 2 API Key", os.environ.get('PALM_API_KEY', ''),
|
| 414 |
help='The MakerSuite API key e.g. a 32-character string',
|
| 415 |
placeholder='e.g. SATgthsykuE64FgrrrrEervr3S4455t_geyDeGq',
|
| 416 |
type='password')
|
| 417 |
+
with st.container():
|
| 418 |
+
with c_button_palm:
|
| 419 |
+
st.write("##")
|
| 420 |
+
st.button("Test PaLM 2", on_click=test_API, args=['palm',c_in_palm,openai_api_key,azure_openai_api_version,azure_openai_api_key,
|
| 421 |
+
azure_openai_api_base,azure_openai_organization,azure_openai_api_type,google_vision,google_palm])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 422 |
|
| 423 |
st.button("Set API Keys",type='primary', on_click=set_API_keys, args=[openai_api_key,azure_openai_api_version,azure_openai_api_key,
|
| 424 |
azure_openai_api_base,azure_openai_organization,azure_openai_api_type,google_vision,google_palm])
|