|  |  | @ -55,10 +55,12 @@ def translate_phrase(text: str, language: str) -> str: | 
			
		
	
		
		
			
				
					
					|  |  |  |     }, |  |  |  |     }, | 
			
		
	
		
		
			
				
					
					|  |  |  |     headers={ |  |  |  |     headers={ | 
			
		
	
		
		
			
				
					
					|  |  |  |       "Authorization": f"Bearer {OPENAI_API_KEY}", |  |  |  |       "Authorization": f"Bearer {OPENAI_API_KEY}", | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |       "Content-Type": "application/json", | 
			
		
	
		
		
			
				
					
					|  |  |  |     }, |  |  |  |     }, | 
			
		
	
		
		
			
				
					
					|  |  |  |   ) |  |  |  |   ) | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   response.raise_for_status() |  |  |  |   if 400 <= response.status_code < 600: | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     raise requests.HTTPError(f'Error {response.status_code}: {response.json()}', response=response) | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   data = response.json() |  |  |  |   data = response.json() | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | @ -89,8 +91,8 @@ def translate_file(path: pathlib.Path, language: str, all_: bool) -> None: | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |       llm_translation = translate_phrase(cast(str, source.text), language) |  |  |  |       llm_translation = translate_phrase(cast(str, source.text), language) | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |       print(f"Source: {source.text}\n" + \ |  |  |  |       print(f"Source: {source.text}\n" + | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                 f"Current translation: {translation.text}\n" + \ |  |  |  |             f"Current translation: {translation.text}\n" + | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |             f"LLM translation: {llm_translation}") |  |  |  |             f"LLM translation: {llm_translation}") | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |       translation.text = llm_translation |  |  |  |       translation.text = llm_translation | 
			
		
	
	
		
		
			
				
					|  |  | @ -113,7 +115,7 @@ def main(): | 
			
		
	
		
		
			
				
					
					|  |  |  |   args = arg_parser.parse_args() |  |  |  |   args = arg_parser.parse_args() | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   if OPENAI_API_KEY is None: |  |  |  |   if OPENAI_API_KEY is None: | 
			
		
	
		
		
			
				
					
					|  |  |  |     print("OpenAI API key is missing. (Hint: use `export OPENAI_API_KEY=YOUR-KEY` before you run the script).\n" + \ |  |  |  |     print("OpenAI API key is missing. (Hint: use `export OPENAI_API_KEY=YOUR-KEY` before you run the script).\n" + | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |           "If you don't have one go to: https://beta.openai.com/account/api-keys.") |  |  |  |           "If you don't have one go to: https://beta.openai.com/account/api-keys.") | 
			
		
	
		
		
			
				
					
					|  |  |  |     exit(1) |  |  |  |     exit(1) | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | 
 |