mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-27 11:43:54 +00:00
test: update testing
This commit is contained in:
parent
2b81a76440
commit
7b82144fd0
1 changed files with 1 additions and 52 deletions
|
@ -147,7 +147,7 @@ async def test_get_response():
|
||||||
prompt = '\ndef count_nums(arr):\n """\n Write a function count_nums which takes an array of integers and returns\n the number of elements which has a sum of digits > 0.\n If a number is negative, then its first signed digit will be negative:\n e.g. -123 has signed digits -1, 2, and 3.\n >>> count_nums([]) == 0\n >>> count_nums([-1, 11, -11]) == 1\n >>> count_nums([1, 1, 2]) == 3\n """\n'
|
prompt = '\ndef count_nums(arr):\n """\n Write a function count_nums which takes an array of integers and returns\n the number of elements which has a sum of digits > 0.\n If a number is negative, then its first signed digit will be negative:\n e.g. -123 has signed digits -1, 2, and 3.\n >>> count_nums([]) == 0\n >>> count_nums([-1, 11, -11]) == 1\n >>> count_nums([1, 1, 2]) == 3\n """\n'
|
||||||
try:
|
try:
|
||||||
response = await acompletion(
|
response = await acompletion(
|
||||||
model="gemini-pro",
|
model="gemini-1.5-flash",
|
||||||
messages=[
|
messages=[
|
||||||
{
|
{
|
||||||
"role": "system",
|
"role": "system",
|
||||||
|
@ -1844,57 +1844,6 @@ async def test_gemini_pro_function_calling_streaming(sync_mode):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
|
||||||
@pytest.mark.flaky(retries=3, delay=1)
|
|
||||||
async def test_gemini_pro_async_function_calling():
|
|
||||||
load_vertex_ai_credentials()
|
|
||||||
litellm.set_verbose = True
|
|
||||||
try:
|
|
||||||
tools = [
|
|
||||||
{
|
|
||||||
"type": "function",
|
|
||||||
"function": {
|
|
||||||
"name": "get_current_weather",
|
|
||||||
"description": "Get the current weather in a given location.",
|
|
||||||
"parameters": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"location": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "The city and state, e.g. San Francisco, CA",
|
|
||||||
},
|
|
||||||
"unit": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": ["celsius", "fahrenheit"],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"required": ["location"],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
]
|
|
||||||
messages = [
|
|
||||||
{
|
|
||||||
"role": "user",
|
|
||||||
"content": "What's the weather like in Boston today in fahrenheit?",
|
|
||||||
}
|
|
||||||
]
|
|
||||||
completion = await litellm.acompletion(
|
|
||||||
model="gemini-pro", messages=messages, tools=tools, tool_choice="auto"
|
|
||||||
)
|
|
||||||
print(f"completion: {completion}")
|
|
||||||
print(f"message content: {completion.choices[0].message.content}")
|
|
||||||
assert completion.choices[0].message.content is None
|
|
||||||
assert len(completion.choices[0].message.tool_calls) == 1
|
|
||||||
|
|
||||||
# except litellm.APIError as e:
|
|
||||||
# pass
|
|
||||||
except litellm.RateLimitError as e:
|
|
||||||
pass
|
|
||||||
except Exception as e:
|
|
||||||
pytest.fail(f"An exception occurred - {str(e)}")
|
|
||||||
# raise Exception("it worked!")
|
|
||||||
|
|
||||||
|
|
||||||
# asyncio.run(gemini_pro_async_function_calling())
|
# asyncio.run(gemini_pro_async_function_calling())
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue