mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-24 18:24:20 +00:00
(ci/cd) test exceptions
This commit is contained in:
parent
afd20098be
commit
4c4dde60c7
1 changed files with 32 additions and 33 deletions
|
@ -262,43 +262,42 @@ def test_completion_openai_exception():
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# test_invalid_request_error(model="command-nightly")
|
# test_invalid_request_error(model="command-nightly")
|
||||||
# Test 3: Rate Limit Errors
|
# Test 3: Rate Limit Errors
|
||||||
def test_model_call(model):
|
# def test_model_call(model):
|
||||||
try:
|
# try:
|
||||||
sample_text = "how does a court case get to the Supreme Court?"
|
# sample_text = "how does a court case get to the Supreme Court?"
|
||||||
messages = [{ "content": sample_text,"role": "user"}]
|
# messages = [{ "content": sample_text,"role": "user"}]
|
||||||
print(f"model: {model}")
|
# print(f"model: {model}")
|
||||||
response = completion(model=model, messages=messages)
|
# response = completion(model=model, messages=messages)
|
||||||
except RateLimitError as e:
|
# except RateLimitError as e:
|
||||||
print(f"headers: {e.response.headers}")
|
# print(f"headers: {e.response.headers}")
|
||||||
return True
|
# return True
|
||||||
# except OpenAIError: # is at least an openai error -> in case of random model errors - e.g. overloaded server
|
# # except OpenAIError: # is at least an openai error -> in case of random model errors - e.g. overloaded server
|
||||||
# return True
|
# # return True
|
||||||
except Exception as e:
|
# except Exception as e:
|
||||||
print(f"Uncaught Exception {model}: {type(e).__name__} - {e}")
|
# print(f"Uncaught Exception {model}: {type(e).__name__} - {e}")
|
||||||
traceback.print_exc()
|
# traceback.print_exc()
|
||||||
pass
|
# pass
|
||||||
return False
|
# return False
|
||||||
# Repeat each model 500 times
|
# # Repeat each model 500 times
|
||||||
# extended_models = [model for model in models for _ in range(250)]
|
# # extended_models = [model for model in models for _ in range(250)]
|
||||||
extended_models = ["azure/chatgpt-v-2" for _ in range(250)]
|
# extended_models = ["azure/chatgpt-v-2" for _ in range(250)]
|
||||||
|
|
||||||
def worker(model):
|
# def worker(model):
|
||||||
return test_model_call(model)
|
# return test_model_call(model)
|
||||||
|
|
||||||
# Create a dictionary to store the results
|
# # Create a dictionary to store the results
|
||||||
counts = {True: 0, False: 0}
|
# counts = {True: 0, False: 0}
|
||||||
|
|
||||||
# Use Thread Pool Executor
|
# # Use Thread Pool Executor
|
||||||
with ThreadPoolExecutor(max_workers=500) as executor:
|
# with ThreadPoolExecutor(max_workers=500) as executor:
|
||||||
# Use map to start the operation in thread pool
|
# # Use map to start the operation in thread pool
|
||||||
results = executor.map(worker, extended_models)
|
# results = executor.map(worker, extended_models)
|
||||||
|
|
||||||
# Iterate over results and count True/False
|
# # Iterate over results and count True/False
|
||||||
for result in results:
|
# for result in results:
|
||||||
counts[result] += 1
|
# counts[result] += 1
|
||||||
|
|
||||||
accuracy_score = counts[True]/(counts[True] + counts[False])
|
# accuracy_score = counts[True]/(counts[True] + counts[False])
|
||||||
print(f"accuracy_score: {accuracy_score}")
|
# print(f"accuracy_score: {accuracy_score}")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue