Files
litellm/tests/test_litellm/passthrough/test_passthrough_main.py
T
Krish Dholakia dd92b1a0ac Refactor: bedrock passthrough fixes - migrate to Passthrough SDK (#12089)
* feat: initial commit adding bedrock support via the new sdk passthrough logic

ensures correct sequencing of tasks (pre call checks etc. can run before signing request)

* fix(route_llm_requests.py): passthrough to allm_passthrough_route if no model found

* feat(bedrock/passthrough): working bedrock passthrough via sdk support

* fix(passthrough/main.py): re-add data and json

* feat(passthrough/main): support async passthrough calls to bedrock

* feat(passthrough/main.py): async streaming + completion support

* feat(llm_passthrough_endpoints.py): migrate bedrock passthrough calls to to new bedrock passthrough sdk

Enables calls to work correctly

* fix: fix linting errors

* test: update test
2025-06-26 22:51:35 -07:00

48 lines
1.3 KiB
Python

import json
import os
import sys
import pytest
from fastapi.testclient import TestClient
sys.path.insert(
0, os.path.abspath("../../..")
) # Adds the parent directory to the system path
from unittest.mock import MagicMock, patch
import litellm
from litellm.passthrough.main import llm_passthrough_route
def test_llm_passthrough_route():
from litellm.llms.custom_httpx.http_handler import HTTPHandler
client = HTTPHandler()
with patch.object(
client.client,
"send",
return_value=MagicMock(status_code=200, json={"message": "Hello, world!"}),
) as mock_post:
response = llm_passthrough_route(
model="vllm/anthropic.claude-3-5-sonnet-20240620-v1:0",
endpoint="v1/chat/completions",
method="POST",
request_url="http://localhost:8000/v1/chat/completions",
api_base="http://localhost:8090",
json={
"model": "my-custom-model",
"messages": [{"role": "user", "content": "Hello, world!"}],
},
client=client,
)
mock_post.call_args.kwargs[
"request"
].url == "http://localhost:8090/v1/chat/completions"
assert response.status_code == 200
assert response.json == {"message": "Hello, world!"}