fix: OpenAIRerankerClient now properly supports AzureOpenAILLMClient
Description
This PR fixes issue #1006 where OpenAIRerankerClient failed to properly support AzureOpenAILLMClient.
Problem
The OpenAIRerankerClient only checked for OpenAIClient instances when unwrapping the client, causing AzureOpenAILLMClient to be passed through without unwrapping. This resulted in:
AttributeError: 'AzureOpenAILLMClient' object has no attribute 'chat'
Solution
Updated the type detection to use BaseOpenAIClient which is the parent class of both OpenAIClient and AzureOpenAILLMClient. This allows both client types to be properly unwrapped to their underlying AsyncOpenAI or AsyncAzureOpenAI instances.
Changes
- Modified
graphiti_core/cross_encoder/openai_reranker_client.py:- Added import for
BaseOpenAIClient - Updated type hint from
OpenAIClienttoBaseOpenAIClient - Changed
isinstancecheck to useBaseOpenAIClient
- Added import for
- Added comprehensive test coverage in
tests/cross_encoder/test_openai_reranker_client.py:- Test for
OpenAIClientcompatibility (regression test) - Test for
AzureOpenAILLMClientcompatibility (fixes #1006) - Test for direct
AsyncOpenAIusage - Test for default client creation
- Integration test for
rank()method with Azure client
- Test for
Testing
All tests pass:
✓ 5 tests in test_openai_reranker_client.py
✓ 25 tests in tests/cross_encoder/ (full suite)
Fixes #1006
All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.
I have read the CLA Document and I hereby sign the CLA