Spaces:
				
			
			
	
			
			
					
		Running
		
	
	
	
			
			
	
	
	
	
		
		
					
		Running
		
	Commit 
							
							·
						
						28ebe52
	
1
								Parent(s):
							
							34c6d2f
								
mammal collage for Field Museum
Browse files
    	
        app.py
    CHANGED
    
    | @@ -271,8 +271,8 @@ def handle_image_upload_and_gallery_hf(uploaded_files): | |
| 271 | 
             
                            return True
         | 
| 272 |  | 
| 273 | 
             
                        # Print out details of the uploaded file for debugging
         | 
| 274 | 
            -
                        st.write(f"Uploaded file: {uploaded_file.name}")
         | 
| 275 | 
            -
                        st.write(f"File size: {len(uploaded_file.getvalue())} bytes")
         | 
| 276 |  | 
| 277 | 
             
                        # Check if the uploaded file is not empty
         | 
| 278 | 
             
                        if len(uploaded_file.getvalue()) == 0:
         | 
|  | |
| 271 | 
             
                            return True
         | 
| 272 |  | 
| 273 | 
             
                        # Print out details of the uploaded file for debugging
         | 
| 274 | 
            +
                        # st.write(f"Uploaded file: {uploaded_file.name}")
         | 
| 275 | 
            +
                        # st.write(f"File size: {len(uploaded_file.getvalue())} bytes")
         | 
| 276 |  | 
| 277 | 
             
                        # Check if the uploaded file is not empty
         | 
| 278 | 
             
                        if len(uploaded_file.getvalue()) == 0:
         | 
    	
        vouchervision/API_validation.py
    CHANGED
    
    | @@ -318,7 +318,6 @@ class APIvalidation: | |
| 318 | 
             
                        k_OPENAI_API_KEY = self.cfg_private['openai']['OPENAI_API_KEY']
         | 
| 319 | 
             
                        k_openai_azure = self.cfg_private['openai_azure']['OPENAI_API_KEY_AZURE']
         | 
| 320 |  | 
| 321 | 
            -
                        k_huggingface = self.cfg_private['huggingface']['hf_token']
         | 
| 322 |  | 
| 323 | 
             
                        k_project_id = self.cfg_private['google']['GOOGLE_PROJECT_ID']
         | 
| 324 | 
             
                        k_location = self.cfg_private['google']['GOOGLE_LOCATION']
         | 
| @@ -328,7 +327,9 @@ class APIvalidation: | |
| 328 | 
             
                        k_here = self.cfg_private['here']['API_KEY']
         | 
| 329 | 
             
                        k_opencage = self.cfg_private['open_cage_geocode']['API_KEY']
         | 
| 330 |  | 
| 331 | 
            -
                        
         | 
|  | |
|  | |
| 332 |  | 
| 333 |  | 
| 334 | 
             
                    # Check each key and add to the respective list
         | 
|  | |
| 318 | 
             
                        k_OPENAI_API_KEY = self.cfg_private['openai']['OPENAI_API_KEY']
         | 
| 319 | 
             
                        k_openai_azure = self.cfg_private['openai_azure']['OPENAI_API_KEY_AZURE']
         | 
| 320 |  | 
|  | |
| 321 |  | 
| 322 | 
             
                        k_project_id = self.cfg_private['google']['GOOGLE_PROJECT_ID']
         | 
| 323 | 
             
                        k_location = self.cfg_private['google']['GOOGLE_LOCATION']
         | 
|  | |
| 327 | 
             
                        k_here = self.cfg_private['here']['API_KEY']
         | 
| 328 | 
             
                        k_opencage = self.cfg_private['open_cage_geocode']['API_KEY']
         | 
| 329 |  | 
| 330 | 
            +
                        k_huggingface = self.cfg_private['huggingface']['hf_token']
         | 
| 331 | 
            +
                        os.environ["HUGGING_FACE_KEY"] = k_huggingface
         | 
| 332 | 
            +
             | 
| 333 |  | 
| 334 |  | 
| 335 | 
             
                    # Check each key and add to the respective list
         | 
    	
        vouchervision/LLM_local_MistralAI.py
    CHANGED
    
    | @@ -36,7 +36,12 @@ class LocalMistralHandler: | |
| 36 |  | 
| 37 | 
             
                    self.model_name = model_name
         | 
| 38 | 
             
                    self.model_id = f"mistralai/{self.model_name}"
         | 
| 39 | 
            -
                     | 
|  | |
|  | |
|  | |
|  | |
|  | |
| 40 |  | 
| 41 | 
             
                    self.JSON_dict_structure = JSON_dict_structure
         | 
| 42 | 
             
                    self.starting_temp = float(self.STARTING_TEMP)
         | 
|  | |
| 36 |  | 
| 37 | 
             
                    self.model_name = model_name
         | 
| 38 | 
             
                    self.model_id = f"mistralai/{self.model_name}"
         | 
| 39 | 
            +
                    huggingface_token = os.getenv("HUGGING_FACE_KEY")
         | 
| 40 | 
            +
                    if not huggingface_token:
         | 
| 41 | 
            +
                        self.logger.error("Hugging Face token is not set. Please set it using the HUGGING_FACE_KEY environment variable.")
         | 
| 42 | 
            +
                        raise ValueError("Hugging Face token is not set.")
         | 
| 43 | 
            +
                    
         | 
| 44 | 
            +
                    self.model_path = hf_hub_download(repo_id=self.model_id, repo_type="model", filename="config.json", token=huggingface_token)
         | 
| 45 |  | 
| 46 | 
             
                    self.JSON_dict_structure = JSON_dict_structure
         | 
| 47 | 
             
                    self.starting_temp = float(self.STARTING_TEMP)
         | 
    	
        vouchervision/LLM_local_cpu_MistralAI.py
    CHANGED
    
    | @@ -48,12 +48,18 @@ class LocalCPUMistralHandler: | |
| 48 | 
             
                    self.model_name = "Mistral-7B-Instruct-v0.2-GGUF"  #huggingface-cli download TheBloke/Mistral-7B-Instruct-v0.2-GGUF mistral-7b-instruct-v0.2.Q4_K_M.gguf --local-dir /home/brlab/.cache --local-dir-use-symlinks False
         | 
| 49 | 
             
                    self.model_id = f"TheBloke/{self.model_name}"
         | 
| 50 | 
             
                    name_parts = self.model_name.split('-')
         | 
|  | |
|  | |
|  | |
|  | |
|  | |
| 51 |  | 
| 52 | 
             
                    if self.model_name == "Mistral-7B-Instruct-v0.2-GGUF":
         | 
| 53 | 
             
                        self.model_file = 'mistral-7b-instruct-v0.2.Q4_K_M.gguf'
         | 
| 54 | 
             
                        self.model_path = hf_hub_download(repo_id=self.model_id,
         | 
| 55 | 
             
                                             filename=self.model_file,
         | 
| 56 | 
            -
                                             repo_type="model" | 
|  | |
| 57 | 
             
                    else:
         | 
| 58 | 
             
                        raise f"Unsupported GGUF model name"
         | 
| 59 |  | 
|  | |
| 48 | 
             
                    self.model_name = "Mistral-7B-Instruct-v0.2-GGUF"  #huggingface-cli download TheBloke/Mistral-7B-Instruct-v0.2-GGUF mistral-7b-instruct-v0.2.Q4_K_M.gguf --local-dir /home/brlab/.cache --local-dir-use-symlinks False
         | 
| 49 | 
             
                    self.model_id = f"TheBloke/{self.model_name}"
         | 
| 50 | 
             
                    name_parts = self.model_name.split('-')
         | 
| 51 | 
            +
             | 
| 52 | 
            +
                    huggingface_token = os.getenv("HUGGING_FACE_KEY")
         | 
| 53 | 
            +
                    if not huggingface_token:
         | 
| 54 | 
            +
                        self.logger.error("Hugging Face token is not set. Please set it using the HUGGING_FACE_KEY environment variable.")
         | 
| 55 | 
            +
                        raise ValueError("Hugging Face token is not set.")
         | 
| 56 |  | 
| 57 | 
             
                    if self.model_name == "Mistral-7B-Instruct-v0.2-GGUF":
         | 
| 58 | 
             
                        self.model_file = 'mistral-7b-instruct-v0.2.Q4_K_M.gguf'
         | 
| 59 | 
             
                        self.model_path = hf_hub_download(repo_id=self.model_id,
         | 
| 60 | 
             
                                             filename=self.model_file,
         | 
| 61 | 
            +
                                             repo_type="model",
         | 
| 62 | 
            +
                                             token=huggingface_token)
         | 
| 63 | 
             
                    else:
         | 
| 64 | 
             
                        raise f"Unsupported GGUF model name"
         | 
| 65 |  | 
    	
        vouchervision/utils_VoucherVision.py
    CHANGED
    
    | @@ -472,6 +472,7 @@ class VoucherVision(): | |
| 472 | 
             
                        k_openai_azure = self.cfg_private['openai_azure']['OPENAI_API_KEY_AZURE']
         | 
| 473 |  | 
| 474 | 
             
                        k_huggingface = self.cfg_private['huggingface']['hf_token']
         | 
|  | |
| 475 |  | 
| 476 | 
             
                        k_google_project_id = self.cfg_private['google']['GOOGLE_PROJECT_ID']
         | 
| 477 | 
             
                        k_google_location = self.cfg_private['google']['GOOGLE_LOCATION']
         | 
|  | |
| 472 | 
             
                        k_openai_azure = self.cfg_private['openai_azure']['OPENAI_API_KEY_AZURE']
         | 
| 473 |  | 
| 474 | 
             
                        k_huggingface = self.cfg_private['huggingface']['hf_token']
         | 
| 475 | 
            +
                        os.environ["HUGGING_FACE_KEY"] = k_huggingface
         | 
| 476 |  | 
| 477 | 
             
                        k_google_project_id = self.cfg_private['google']['GOOGLE_PROJECT_ID']
         | 
| 478 | 
             
                        k_google_location = self.cfg_private['google']['GOOGLE_LOCATION']
         | 
