File tree Expand file tree Collapse file tree 1 file changed +3
-5
lines changed
Expand file tree Collapse file tree 1 file changed +3
-5
lines changed Original file line number Diff line number Diff line change 55import time
66
77import yaml
8- from openai import InternalServerError , OpenAI
8+ from openai import InternalServerError , OpenAI , RateLimitError
99
1010context_files = json .loads (sys .argv [1 ])
1111question = sys .argv [2 ]
@@ -128,11 +128,9 @@ def encode_image_to_base64(image_path):
128128 with open ("output.md" , "w" ) as f :
129129 f .write (response .choices [0 ].message .content or "" )
130130 break
131- except InternalServerError as e :
131+ except ( InternalServerError , RateLimitError ) as e :
132132 if attempt == max_retries - 1 :
133133 sys .exit ("Max retries reached. Exiting." )
134134 sleep_time = min (2 ** attempt + random .uniform (0 , 1 ), max_delay )
135- print (
136- f"InternalServerError encountered ({ e } ). Retrying in { sleep_time :.2f} seconds..."
137- )
135+ print (f"Error encountered ({ e } ). Retrying in { sleep_time :.2f} seconds..." )
138136 time .sleep (sleep_time )
You can’t perform that action at this time.
0 commit comments