forked from phoenix/litellm-mirror
fix(test_amazing_vertex_completion.py): handle vertex ai rate limit error
This commit is contained in:
parent
3dbb547af0
commit
f7537f2cdf
1 changed files with 44 additions and 12 deletions
|
@ -487,6 +487,35 @@ def test_gemini_pro_vision_base64():
|
||||||
|
|
||||||
|
|
||||||
def test_gemini_pro_function_calling():
|
def test_gemini_pro_function_calling():
|
||||||
|
load_vertex_ai_credentials()
|
||||||
|
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?"}]
|
||||||
|
completion = litellm.completion(
|
||||||
|
model="gemini-pro", messages=messages, tools=tools, tool_choice="auto"
|
||||||
|
)
|
||||||
|
print(f"completion: {completion}")
|
||||||
|
assert completion.choices[0].message.content is None
|
||||||
|
assert len(completion.choices[0].message.tool_calls) == 1
|
||||||
try:
|
try:
|
||||||
load_vertex_ai_credentials()
|
load_vertex_ai_credentials()
|
||||||
tools = [
|
tools = [
|
||||||
|
@ -557,6 +586,7 @@ def test_gemini_pro_function_calling_streaming():
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
messages = [{"role": "user", "content": "What's the weather like in Boston today?"}]
|
messages = [{"role": "user", "content": "What's the weather like in Boston today?"}]
|
||||||
|
try:
|
||||||
completion = litellm.completion(
|
completion = litellm.completion(
|
||||||
model="gemini-pro",
|
model="gemini-pro",
|
||||||
messages=messages,
|
messages=messages,
|
||||||
|
@ -569,6 +599,8 @@ def test_gemini_pro_function_calling_streaming():
|
||||||
# assert len(completion.choices[0].message.tool_calls) == 1
|
# assert len(completion.choices[0].message.tool_calls) == 1
|
||||||
for chunk in completion:
|
for chunk in completion:
|
||||||
print(f"chunk: {chunk}")
|
print(f"chunk: {chunk}")
|
||||||
|
except litellm.RateLimitError as e:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue