phyloforfun commited on
Commit
7d58ebe
1 Parent(s): 6d5de38

Major update. Support for 15 LLMs, World Flora Online taxonomy validation, geolocation, 2 OCR methods, significant UI changes, stability improvements, consistent JSON parsing

Browse files
.streamlit/config.toml CHANGED
@@ -1,3 +1,4 @@
1
  [theme]
2
- base = "dark"
3
- primaryColor = "#00ff00"
 
 
1
  [theme]
2
+ primaryColor = "#00ff00"
3
+ backgroundColor="#FFFFFF"
4
+ secondaryBackgroundColor="#5c5c5c"
.streamlit/secrets.toml DELETED
@@ -1,25 +0,0 @@
1
- # Streamlit secrets
2
-
3
- GOOGLE_APPLICATION_CREDENTIALS_JSON = '''
4
- {
5
- "type": "service_account",
6
- "project_id": "directed-curve-401601",
7
- "private_key_id": "53457e69bc362dd27bacb83228839a93c7361640",
8
- "private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCnnRop1c/YAwQZ\nWuXJn9brvNUVJDuf+zmSuhZt9J3J4xnbeGDVrqJ78YOfB/W9HfdywtSXP/m0q2LC\nIeatg+Kc4aFrfjQueexNr6pYV+TklU+vhFMEJP8AJcUCLC5YymYntqUWHTMy4swg\n/JsfDQPB5KgxIC7yo907QbF7KAD/VHiPqRje8J5OV+5yAnvEmdcc3E/lXvMEKVo3\nfpDf3IO6knpnvlxtcMlKCLFb23m070jJhuUqjbBS8rI8qKZI9mUutMPXGOeVucIV\nkFfRoTCCIlRlSnrq0DewPx+RQkXEJUVSQbTi9MLsXIqmu2RkwpusmBX3GFuUXBwk\n33/aJwqfAgMBAAECggEASE+JFYpWECGA97VU1C6+iFYfcW7/wC2gcXIRsh8poYr1\nwU7GK/maxLD1cTr8Y7nVYq+2CoiBoFWeFhWNEMeIkNjwjFDWj0RvUzaZXWKR76GQ\nzq5eKDgTwQsKWr0Xw5uSBckQoKE5UNcybHq+K1+wgso0W3lAd9KE44ccW/7uqzgg\n/ls/rSlFff0QU5yLawBHWHlNwDhAhElPeZ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
9
- "client_email": "vouchervision@directed-curve-401601.iam.gserviceaccount.com",
10
- "client_id": "100706991621579323653",
11
- "auth_uri": "https://accounts.google.com/o/oauth2/auth",
12
- "token_uri": "https://oauth2.googleapis.com/token",
13
- "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
14
- "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/vouchervision%40directed-curve-401601.iam.gserviceaccount.com",
15
- "universe_domain": "googleapis.com"
16
- }
17
- '''
18
-
19
- OPENAI_API_KEY = "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"
20
- AZURE_API_VERSION = "2023-05-15"
21
- AZURE_API_KEY = "2a841cc7fde64109975d84ea0f9685d4"
22
- AZURE_API_BASE = "https://api.umgpt.umich.edu/azure-openai-api"
23
- AZURE_ORGANIZATION = "123456"
24
- AZURE_API_TYPE = "azure"
25
- GOOGLE_PALM_API = "AIzaSyCiTxmzxi6vHih0jbAf8wtSX9_dBBXttKA"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app.py CHANGED
@@ -105,7 +105,7 @@ def create_download_button(zip_filepath, col):
105
  data=bytes_io,
106
  file_name=os.path.basename(zip_filepath),
107
  mime='application/zip',
108
- use_container_width=True
109
  )
110
 
111
 
@@ -142,7 +142,7 @@ def create_download_button_yaml(file_path, selected_yaml_file):
142
  label=file_label,
143
  data=f,
144
  file_name=os.path.basename(file_path),
145
- mime='application/x-yaml',use_container_width=True
146
  )
147
 
148
 
@@ -2384,7 +2384,7 @@ if 'dir_uploaded_images' not in st.session_state:
2384
  if 'dir_uploaded_images_small' not in st.session_state:
2385
  st.session_state['dir_uploaded_images_small'] = os.path.join(st.session_state.dir_home,'uploads_small')
2386
  validate_dir(os.path.join(st.session_state.dir_home,'uploads_small'))
2387
-
2388
  if 'cost_openai' not in st.session_state:
2389
  st.session_state['cost_openai'] = None
2390
  if 'cost_azure' not in st.session_state:
 
105
  data=bytes_io,
106
  file_name=os.path.basename(zip_filepath),
107
  mime='application/zip',
108
+ use_container_width=True,key=129385,
109
  )
110
 
111
 
 
142
  label=file_label,
143
  data=f,
144
  file_name=os.path.basename(file_path),
145
+ mime='application/x-yaml',use_container_width=True,key=237895,
146
  )
147
 
148
 
 
2384
  if 'dir_uploaded_images_small' not in st.session_state:
2385
  st.session_state['dir_uploaded_images_small'] = os.path.join(st.session_state.dir_home,'uploads_small')
2386
  validate_dir(os.path.join(st.session_state.dir_home,'uploads_small'))
2387
+
2388
  if 'cost_openai' not in st.session_state:
2389
  st.session_state['cost_openai'] = None
2390
  if 'cost_azure' not in st.session_state:
vouchervision/API_validation.py CHANGED
@@ -232,7 +232,12 @@ class APIvalidation:
232
  # test_response_palm = llm_palm.invoke("Hello")
233
  if test_response_palm:
234
  results["palm2"] = True
 
 
 
 
235
  except Exception as e:
 
236
  pass
237
 
238
  try:
@@ -243,11 +248,17 @@ class APIvalidation:
243
  # test_response_gemini = llm_gemini.invoke("Hello")
244
  if test_response_gemini:
245
  results["gemini"] = True
 
 
 
 
246
  except Exception as e:
 
247
  pass
248
 
249
  return results
250
  except Exception as e: # Replace with a more specific exception if possible
 
251
  return results
252
 
253
  def report_api_key_status(self):
 
232
  # test_response_palm = llm_palm.invoke("Hello")
233
  if test_response_palm:
234
  results["palm2"] = True
235
+ print(f"palm2 pass [{test_response_palm}]")
236
+ else:
237
+ print(f"palm2 yes [{test_response_palm}]")
238
+
239
  except Exception as e:
240
+ print(f"palm2 [{e}]")
241
  pass
242
 
243
  try:
 
248
  # test_response_gemini = llm_gemini.invoke("Hello")
249
  if test_response_gemini:
250
  results["gemini"] = True
251
+ print(f"gemini pass [{test_response_palm}]")
252
+ else:
253
+ print(f"gemini yes [{test_response_palm}]")
254
+
255
  except Exception as e:
256
+ print(f"gemini [{e}]")
257
  pass
258
 
259
  return results
260
  except Exception as e: # Replace with a more specific exception if possible
261
+ print(f"Immediate [{e}]")
262
  return results
263
 
264
  def report_api_key_status(self):
vouchervision/utils_hf.py CHANGED
@@ -81,19 +81,25 @@ def upload_to_drive(filepath, filename):
81
 
82
  # Get the folder ID from the environment variable
83
  folder_id = os.environ.get('GDRIVE')
84
- # st.info(f"{folder_id}")
85
 
86
  if folder_id:
87
  file_metadata = {
88
  'name': filename,
89
  'parents': [folder_id]
90
  }
91
- # st.info(f"{file_metadata}")
92
 
93
- media = MediaFileUpload(filepath, mimetype='application/x-yaml')
 
 
 
 
 
 
94
 
95
- service.files().create(
96
- body=file_metadata,
97
- media_body=media,
98
- fields='id'
99
- ).execute()
 
 
 
81
 
82
  # Get the folder ID from the environment variable
83
  folder_id = os.environ.get('GDRIVE')
 
84
 
85
  if folder_id:
86
  file_metadata = {
87
  'name': filename,
88
  'parents': [folder_id]
89
  }
 
90
 
91
+ # Determine the mimetype based on the file extension
92
+ if filename.endswith('.yaml') or filename.endswith('.yml'):
93
+ mimetype = 'application/x-yaml'
94
+ elif filename.endswith('.zip'):
95
+ mimetype = 'application/zip'
96
+ else:
97
+ mimetype = None # or set a default mimetype
98
 
99
+ if mimetype:
100
+ media = MediaFileUpload(filepath, mimetype=mimetype)
101
+ service.files().create(
102
+ body=file_metadata,
103
+ media_body=media,
104
+ fields='id'
105
+ ).execute()