Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade litellm 1.52.8 for Snyk #360

Merged
merged 13 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ jobs:
GOOGLE_API_KEY : ${{ secrets.GOOGLE_API_KEY }}
PERPLEXITYAI_API_KEY: ${{ secrets.PERPLEXITYAI_API_KEY }}
CEREBRAS_API_KEY: ${{ secrets.CEREBRAS_API_KEY }}
PYTEST_ADDOPTS: "--color=yes"
steps:
- uses: actions/checkout@v4
- name: Install poetry
Expand Down Expand Up @@ -131,15 +132,16 @@ jobs:

if $empty_inputs; then
echo "All variables are empty"
poetry run pytest -vv tests/ --ignore=tests/test_cli.py
poetry run pytest -vv tests/ --ignore=tests/test_cli.py --ignore=tests/test_litellm.py --ignore=tests/test_magentic_perplexity.py
poetry run pytest -vv tests/test_litellm.py
poetry run pytest --llm_provider=anthropic -vv tests/test_magentic.py
poetry run pytest --llm_provider=litellm --openai_compatibility_model=perplexity/llama-3.1-sonar-small-128k-chat -vv tests/test_magentic.py -m chat
poetry run pytest tests/test_magentic_perplexity.py -vv
fi

- name: Run scheduled llm tests
if: ${{ github.event_name == 'schedule' }}
run: |
echo "This is a schedule event"
poetry run pytest -vv tests/ --ignore=tests/test_cli.py
poetry run pytest -vv tests/ --ignore=tests/test_cli.py --ignore=tests/test_litellm.py --ignore=tests/test_magentic_perplexity.py
poetry run pytest --openai_model=gpt-4o -m chat -vv tests/test_openai.py
poetry run pytest --llm_provider=litellm --openai_compatibility_model=perplexity/llama-3.1-sonar-small-128k-chat -vv tests/test_magentic.py -m chat
poetry run pytest tests/test_magentic_perplexity.py -vv
14 changes: 7 additions & 7 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pytest-metadata = ">=1.0.0"
langchain = {version = "^0.2.10", optional = true}
langchain-community = {version = "^0.2.19", optional = true}
magentic = {version = ">=0.17.0", optional = true, markers = "python_version >= '3.10'"}
litellm = {version = "^1.41.12", optional = true}
litellm = {version = ">=1.49.6", optional = true}
lamini = {version = "^2.1.8", optional = true}
google-cloud-aiplatform = {version = ">=1.44.0", optional = true}
mistralai = {version = "^0.1.5", optional = true}
Expand Down
5 changes: 5 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ def magentic_models(request):
}


@pytest.fixture
def openai_compatibility_model(request):
return request.config.getoption("--openai_compatibility_model")


@pytest.fixture
def session():
with log10_session() as session:
Expand Down
39 changes: 39 additions & 0 deletions tests/test_magentic_perplexity.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import time

import litellm
import pytest
from magentic import StreamedStr, prompt
from magentic.chat_model.litellm_chat_model import LitellmChatModel

from log10.litellm import Log10LitellmLogger
from tests.utils import _LogAssertion


log10_handler = Log10LitellmLogger(tags=["litellm_perplexity"])
litellm.callbacks = [log10_handler]


@pytest.mark.chat
def test_prompt(session, openai_compatibility_model):
@prompt("What happened on this day?", model=LitellmChatModel(model=openai_compatibility_model))
def llm() -> str: ...

output = llm()
assert isinstance(output, str)

time.sleep(3)

_LogAssertion(completion_id=session.last_completion_id(), message_content=output).assert_chat_response()


@pytest.mark.chat
@pytest.mark.stream
def test_prompt_stream(session, openai_compatibility_model):
@prompt("What happened on this day?", model=LitellmChatModel(model=openai_compatibility_model))
def llm() -> StreamedStr: ...

response = llm()
output = ""
for chunk in response:
output += chunk
_LogAssertion(completion_id=session.last_completion_id(), message_content=output).assert_chat_response()
Loading