graphiti icon indicating copy to clipboard operation
graphiti copied to clipboard

fix: OpenAIRerankerClient now properly supports AzureOpenAILLMClient

Open supmo668 opened this issue 1 month ago • 2 comments

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 OpenAIClient to BaseOpenAIClient
    • Changed isinstance check to use BaseOpenAIClient
  • Added comprehensive test coverage in tests/cross_encoder/test_openai_reranker_client.py:
    • Test for OpenAIClient compatibility (regression test)
    • Test for AzureOpenAILLMClient compatibility (fixes #1006)
    • Test for direct AsyncOpenAI usage
    • Test for default client creation
    • Integration test for rank() method with Azure client

Testing

All tests pass:

✓ 5 tests in test_openai_reranker_client.py
✓ 25 tests in tests/cross_encoder/ (full suite)

Fixes #1006

supmo668 avatar Nov 18 '25 09:11 supmo668

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

danielchalef avatar Nov 18 '25 09:11 danielchalef

I have read the CLA Document and I hereby sign the CLA

supmo668 avatar Nov 19 '25 01:11 supmo668