mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-27 11:43:54 +00:00
pydantic v1 uses `root_validator` and pydantic v2 uses `model_validator`. pydantic v2 emits a warning when `root_validator` is used. E.g.: ``` litellm/proxy/_types.py:225 /Users/abramowi/Code/OpenSource/litellm/litellm/proxy/_types.py:225: PydanticDeprecatedSince20: Pydantic V1 style `@root_validator` validators are deprecated. You should migrate to Pydantic V2 style `@model_validator` validators, see the migration guide for more details. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.7/migration/ @root_validator(pre=True) ``` This change eliminates those warnings with pydantic v2, while retaining compatibility with pydantic v1. pydantic 2.7.1 before ``` $ env -i PATH=$PATH poetry run pytest litellm/tests/test_proxy_server.py ... litellm/proxy/_types.py:225 /Users/abramowi/Code/OpenSource/litellm/litellm/proxy/_types.py:225: PydanticDeprecatedSince20: Pydantic V1 style `@root_validator` validators are deprecated. You should migrate to Pydantic V2 style `@model_validator` validators, see the migration guide for more details. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.7/migration/ @root_validator(pre=True) ... ========================== 10 passed, 2 skipped, 39 warnings in 8.67s =========================== ``` pydantic 2.7.1 after ``` $ env -i PATH=$PATH poetry run pytest litellm/tests/test_proxy_server.py ... ========================== 10 passed, 2 skipped, 27 warnings in 9.85s =========================== ``` pydantic 1.10.5 after ``` $ poetry run pip install 'pydantic<2' ... Successfully installed pydantic-1.10.15 $ env -i PATH=$PATH poetry run pytest litellm/tests/test_proxy_server.py ... =========================== 10 passed, 2 skipped, 1 warning in 8.13s ============================ ``` |
||
---|---|---|
.. | ||
_experimental | ||
auth | ||
db | ||
example_config_yaml | ||
hooks | ||
proxy_load_test | ||
queue | ||
secret_managers | ||
tests | ||
.gitignore | ||
__init__.py | ||
_new_secret_config.yaml | ||
_super_secret_config.yaml | ||
_types.py | ||
admin_ui.py | ||
cached_logo.jpg | ||
custom_callbacks.py | ||
enterprise | ||
health_check.py | ||
lambda.py | ||
llamaguard_prompt.txt | ||
logo.jpg | ||
openapi.json | ||
otel_config.yaml | ||
post_call_rules.py | ||
proxy_cli.py | ||
proxy_config.yaml | ||
proxy_server.py | ||
README.md | ||
schema.prisma | ||
start.sh | ||
utils.py |
litellm-proxy
A local, fast, and lightweight OpenAI-compatible server to call 100+ LLM APIs.
usage
$ pip install litellm
$ litellm --model ollama/codellama
#INFO: Ollama running on http://0.0.0.0:8000
replace openai base
import openai # openai v1.0.0+
client = openai.OpenAI(api_key="anything",base_url="http://0.0.0.0:8000") # set proxy to base_url
# request sent to model set on litellm proxy, `litellm --model`
response = client.chat.completions.create(model="gpt-3.5-turbo", messages = [
{
"role": "user",
"content": "this is a test request, write a short poem"
}
])
print(response)
See how to call Huggingface,Bedrock,TogetherAI,Anthropic, etc.