mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-26 19:24:27 +00:00
test(test_function_call_parsing.py): fix test
This commit is contained in:
parent
2b7a64ee28
commit
edbe9e0741
1 changed files with 57 additions and 51 deletions
|
@ -1,23 +1,27 @@
|
|||
# What is this?
|
||||
## Test to make sure function call response always works with json.loads() -> no extra parsing required. Relevant issue - https://github.com/BerriAI/litellm/issues/2654
|
||||
import sys, os
|
||||
import os
|
||||
import sys
|
||||
import traceback
|
||||
|
||||
from dotenv import load_dotenv
|
||||
|
||||
load_dotenv()
|
||||
import os, io
|
||||
import io
|
||||
import os
|
||||
|
||||
sys.path.insert(
|
||||
0, os.path.abspath("../..")
|
||||
) # Adds the parent directory to the system path
|
||||
import pytest
|
||||
import litellm
|
||||
import json
|
||||
import warnings
|
||||
|
||||
from litellm import completion
|
||||
from typing import List
|
||||
|
||||
import pytest
|
||||
|
||||
import litellm
|
||||
from litellm import completion
|
||||
|
||||
|
||||
# Just a stub to keep the sample code simple
|
||||
class Trade:
|
||||
|
@ -78,6 +82,7 @@ def trade(model_name: str) -> List[Trade]:
|
|||
},
|
||||
}
|
||||
|
||||
try:
|
||||
response = completion(
|
||||
model_name,
|
||||
[
|
||||
|
@ -129,7 +134,8 @@ def trade(model_name: str) -> List[Trade]:
|
|||
"function": {"name": tool_spec["function"]["name"]}, # type: ignore
|
||||
},
|
||||
)
|
||||
|
||||
except litellm.InternalServerError:
|
||||
pass
|
||||
calls = response.choices[0].message.tool_calls
|
||||
trades = [trade for call in calls for trade in parse_call(call)]
|
||||
return trades
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue