Spaces:
Running
Running
Commit
•
904c317
1
Parent(s):
55035d6
update set api keys
Browse files
app.py
CHANGED
@@ -309,85 +309,92 @@ def create_private_file():
|
|
309 |
st.write("Deleting this file will allow you to reset API keys. Alternatively, you can edit the keys in the user interface.")
|
310 |
st.write("Leave keys blank if you do not intend to use that service.")
|
311 |
|
312 |
-
st.write("---")
|
313 |
-
st.subheader("Google Vision (*Required*)")
|
314 |
-
st.markdown("VoucherVision currently uses [Google Vision API](https://cloud.google.com/vision/docs/ocr) for OCR. Generating an API key for this is more involved than the others. [Please carefully follow the instructions outlined here to create and setup your account.](https://cloud.google.com/vision/docs/setup) ")
|
315 |
-
st.markdown("""
|
316 |
-
Once your account is created, [visit this page](https://console.cloud.google.com) and create a project. Then follow these instructions:
|
317 |
-
|
318 |
-
- **Select your Project**: If you have multiple projects, ensure you select the one where you've enabled the Vision API.
|
319 |
-
- **Open the Navigation Menu**: Click on the hamburger menu (three horizontal lines) in the top left corner.
|
320 |
-
- **Go to IAM & Admin**: In the navigation pane, hover over "IAM & Admin" and then click on "Service accounts."
|
321 |
-
- **Locate Your Service Account**: Find the service account for which you wish to download the JSON key. If you haven't created a service account yet, you'll need to do so by clicking the "CREATE SERVICE ACCOUNT" button at the top.
|
322 |
-
- **Download the JSON Key**:
|
323 |
-
- Click on the three dots (actions menu) on the right side of your service account name.
|
324 |
-
- Select "Manage keys."
|
325 |
-
- In the pop-up window, click on the "ADD KEY" button and select "JSON."
|
326 |
-
- The JSON key file will automatically be downloaded to your computer.
|
327 |
-
- **Store Safely**: This file contains sensitive data that can be used to authenticate and bill your Google Cloud account. Never commit it to public repositories or expose it in any way. Always keep it safe and secure.
|
328 |
-
""")
|
329 |
-
with st.container():
|
330 |
-
c_in_ocr, c_button_ocr = st.columns([10,2])
|
331 |
-
with c_in_ocr:
|
332 |
-
google_vision = st.text_input(label = 'Full path to Google Cloud JSON API key file', value = os.environ.get('GOOGLE_APPLICATION_CREDENTIALS', ''),
|
333 |
-
placeholder = 'e.g. copy contents of file application_default_credentials.json',
|
334 |
-
help ="This API Key is in the form of a JSON file. Please save the JSON file in a safe directory. DO NOT store the JSON key inside of the VoucherVision directory.",
|
335 |
-
type='password',key='924857298734590283750932809238')
|
336 |
-
with c_button_ocr:
|
337 |
-
st.empty()
|
338 |
-
|
339 |
-
|
340 |
-
st.write("---")
|
341 |
-
st.subheader("OpenAI")
|
342 |
-
st.markdown("API key for first-party OpenAI API. Create an account with OpenAI [here](https://platform.openai.com/signup), then create an API key [here](https://platform.openai.com/account/api-keys).")
|
343 |
-
with st.container():
|
344 |
-
c_in_openai, c_button_openai = st.columns([10,2])
|
345 |
-
with c_in_openai:
|
346 |
-
openai_api_key = st.text_input("openai_api_key", os.environ.get('OPENAI_API_KEY', ''),
|
347 |
-
help='The actual API key. Likely to be a string of 2 character, a dash, and then a 48-character string: sk-XXXXXXXX...',
|
348 |
-
placeholder = 'e.g. sk-XXXXXXXX...',
|
349 |
-
type='password')
|
350 |
-
with c_button_openai:
|
351 |
-
st.empty()
|
352 |
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
with
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
391 |
|
392 |
with st.container():
|
393 |
with c_button_ocr:
|
|
|
309 |
st.write("Deleting this file will allow you to reset API keys. Alternatively, you can edit the keys in the user interface.")
|
310 |
st.write("Leave keys blank if you do not intend to use that service.")
|
311 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
312 |
|
313 |
+
if os.getenv('GOOGLE_APPLICATION_CREDENTIALS') is None:
|
314 |
+
st.write("---")
|
315 |
+
st.subheader("Google Vision (*Required*)")
|
316 |
+
st.markdown("VoucherVision currently uses [Google Vision API](https://cloud.google.com/vision/docs/ocr) for OCR. Generating an API key for this is more involved than the others. [Please carefully follow the instructions outlined here to create and setup your account.](https://cloud.google.com/vision/docs/setup) ")
|
317 |
+
st.markdown("""
|
318 |
+
Once your account is created, [visit this page](https://console.cloud.google.com) and create a project. Then follow these instructions:
|
319 |
+
|
320 |
+
- **Select your Project**: If you have multiple projects, ensure you select the one where you've enabled the Vision API.
|
321 |
+
- **Open the Navigation Menu**: Click on the hamburger menu (three horizontal lines) in the top left corner.
|
322 |
+
- **Go to IAM & Admin**: In the navigation pane, hover over "IAM & Admin" and then click on "Service accounts."
|
323 |
+
- **Locate Your Service Account**: Find the service account for which you wish to download the JSON key. If you haven't created a service account yet, you'll need to do so by clicking the "CREATE SERVICE ACCOUNT" button at the top.
|
324 |
+
- **Download the JSON Key**:
|
325 |
+
- Click on the three dots (actions menu) on the right side of your service account name.
|
326 |
+
- Select "Manage keys."
|
327 |
+
- In the pop-up window, click on the "ADD KEY" button and select "JSON."
|
328 |
+
- The JSON key file will automatically be downloaded to your computer.
|
329 |
+
- **Store Safely**: This file contains sensitive data that can be used to authenticate and bill your Google Cloud account. Never commit it to public repositories or expose it in any way. Always keep it safe and secure.
|
330 |
+
""")
|
331 |
+
with st.container():
|
332 |
+
c_in_ocr, c_button_ocr = st.columns([10,2])
|
333 |
+
with c_in_ocr:
|
334 |
+
google_vision = st.text_input(label = 'Full path to Google Cloud JSON API key file', value = '',
|
335 |
+
placeholder = 'e.g. copy contents of file application_default_credentials.json',
|
336 |
+
help ="This API Key is in the form of a JSON file. Please save the JSON file in a safe directory. DO NOT store the JSON key inside of the VoucherVision directory.",
|
337 |
+
type='password',key='924857298734590283750932809238')
|
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("---")
|
344 |
+
st.subheader("OpenAI")
|
345 |
+
st.markdown("API key for first-party OpenAI API. Create an account with OpenAI [here](https://platform.openai.com/signup), then create an API key [here](https://platform.openai.com/account/api-keys).")
|
346 |
+
with st.container():
|
347 |
+
c_in_openai, c_button_openai = st.columns([10,2])
|
348 |
+
with c_in_openai:
|
349 |
+
openai_api_key = st.text_input("openai_api_key", os.environ.get('OPENAI_API_KEY', ''),
|
350 |
+
help='The actual API key. Likely to be a string of 2 character, a dash, and then a 48-character string: sk-XXXXXXXX...',
|
351 |
+
placeholder = 'e.g. sk-XXXXXXXX...',
|
352 |
+
type='password')
|
353 |
+
with c_button_openai:
|
354 |
+
st.empty()
|
355 |
+
|
356 |
+
|
357 |
+
if os.getenv('AZURE_API_KEY') is None:
|
358 |
+
st.write("---")
|
359 |
+
st.subheader("OpenAI - Azure")
|
360 |
+
st.markdown("This version OpenAI relies on Azure servers directly as is intended for private enterprise instances of OpenAI's services, such as [UM-GPT](https://its.umich.edu/computing/ai). Administrators will provide you with the following information.")
|
361 |
+
azure_openai_api_version = st.text_input("azure_openai_api_version", os.environ.get('AZURE_API_VERSION', ''),
|
362 |
+
help='API Version e.g. "2023-05-15"',
|
363 |
+
placeholder = 'e.g. 2023-05-15',
|
364 |
+
type='password')
|
365 |
+
azure_openai_api_key = st.text_input("azure_openai_api_key", os.environ.get('AZURE_API_KEY', ''),
|
366 |
+
help='The actual API key. Likely to be a 32-character string',
|
367 |
+
placeholder = 'e.g. 12333333333333333333333333333332',
|
368 |
+
type='password')
|
369 |
+
azure_openai_api_base = st.text_input("azure_openai_api_base", os.environ.get('AZURE_API_BASE', ''),
|
370 |
+
help='The base url for the API e.g. "https://api.umgpt.umich.edu/azure-openai-api"',
|
371 |
+
placeholder = 'e.g. https://api.umgpt.umich.edu/azure-openai-api',
|
372 |
+
type='password')
|
373 |
+
azure_openai_organization = st.text_input("azure_openai_organization", os.environ.get('AZURE_ORGANIZATION', ''),
|
374 |
+
help='Your organization code. Likely a short string',
|
375 |
+
placeholder = 'e.g. 123456',
|
376 |
+
type='password')
|
377 |
+
azure_openai_api_type = st.text_input("azure_openai_api_type", os.environ.get('AZURE_API_TYPE', ''),
|
378 |
+
help='The API type. Typically "azure"',
|
379 |
+
placeholder = 'e.g. azure',
|
380 |
+
type='password')
|
381 |
+
with st.container():
|
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('GOOGLE_PALM_API') is None:
|
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('GOOGLE_PALM_API', ''),
|
395 |
+
help='The MakerSuite API key e.g. a 32-character string',
|
396 |
+
placeholder='e.g. SATgthsykuE64FgrrrrEervr3S4455t_geyDeGq',
|
397 |
+
type='password')
|
398 |
|
399 |
with st.container():
|
400 |
with c_button_ocr:
|