mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 18:54:30 +00:00
Litellm merge pr (#7161)
* build: merge branch * test: fix openai naming * fix(main.py): fix openai renaming * style: ignore function length for config factory * fix(sagemaker/): fix routing logic * fix: fix imports * fix: fix override
This commit is contained in:
parent
d5aae81c6d
commit
350cfc36f7
88 changed files with 3617 additions and 4421 deletions
|
@ -1931,66 +1931,11 @@ async def test_completion_watsonx_stream():
|
|||
# raise Exception("Empty response received")
|
||||
# except Exception:
|
||||
# pytest.fail(f"error occurred: {traceback.format_exc()}")
|
||||
# test_maritalk_streaming()
|
||||
# test on openai completion call
|
||||
|
||||
|
||||
# # test on ai21 completion call
|
||||
def ai21_completion_call():
|
||||
try:
|
||||
messages = [
|
||||
{
|
||||
"role": "system",
|
||||
"content": "You are an all-knowing oracle",
|
||||
},
|
||||
{"role": "user", "content": "What is the meaning of the Universe?"},
|
||||
]
|
||||
response = completion(
|
||||
model="j2-ultra", messages=messages, stream=True, max_tokens=500
|
||||
)
|
||||
print(f"response: {response}")
|
||||
has_finished = False
|
||||
complete_response = ""
|
||||
start_time = time.time()
|
||||
for idx, chunk in enumerate(response):
|
||||
chunk, finished = streaming_format_tests(idx, chunk)
|
||||
has_finished = finished
|
||||
complete_response += chunk
|
||||
if finished:
|
||||
break
|
||||
if has_finished is False:
|
||||
raise Exception("finished reason missing from final chunk")
|
||||
if complete_response.strip() == "":
|
||||
raise Exception("Empty response received")
|
||||
print(f"completion_response: {complete_response}")
|
||||
except Exception:
|
||||
pytest.fail(f"error occurred: {traceback.format_exc()}")
|
||||
|
||||
|
||||
# ai21_completion_call()
|
||||
|
||||
|
||||
def ai21_completion_call_bad_key():
|
||||
try:
|
||||
api_key = "bad-key"
|
||||
response = completion(
|
||||
model="j2-ultra", messages=messages, stream=True, api_key=api_key
|
||||
)
|
||||
print(f"response: {response}")
|
||||
complete_response = ""
|
||||
start_time = time.time()
|
||||
for idx, chunk in enumerate(response):
|
||||
chunk, finished = streaming_format_tests(idx, chunk)
|
||||
if finished:
|
||||
break
|
||||
complete_response += chunk
|
||||
if complete_response.strip() == "":
|
||||
raise Exception("Empty response received")
|
||||
print(f"completion_response: {complete_response}")
|
||||
except Exception:
|
||||
pytest.fail(f"error occurred: {traceback.format_exc()}")
|
||||
|
||||
|
||||
# ai21_completion_call_bad_key()
|
||||
|
||||
|
||||
|
@ -2418,34 +2363,6 @@ def test_completion_openai_with_functions():
|
|||
#### Test Async streaming ####
|
||||
|
||||
|
||||
# # test on ai21 completion call
|
||||
async def ai21_async_completion_call():
|
||||
try:
|
||||
response = completion(
|
||||
model="j2-ultra", messages=messages, stream=True, logger_fn=logger_fn
|
||||
)
|
||||
print(f"response: {response}")
|
||||
complete_response = ""
|
||||
start_time = time.time()
|
||||
# Change for loop to async for loop
|
||||
idx = 0
|
||||
async for chunk in response:
|
||||
chunk, finished = streaming_format_tests(idx, chunk)
|
||||
if finished:
|
||||
break
|
||||
complete_response += chunk
|
||||
idx += 1
|
||||
if complete_response.strip() == "":
|
||||
raise Exception("Empty response received")
|
||||
print(f"complete response: {complete_response}")
|
||||
except Exception:
|
||||
print(f"error occurred: {traceback.format_exc()}")
|
||||
pass
|
||||
|
||||
|
||||
# asyncio.run(ai21_async_completion_call())
|
||||
|
||||
|
||||
async def completion_call():
|
||||
try:
|
||||
response = completion(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue