Fix Gemini LLM AssertionError: force httpx transport over aiohttp
google-genai SDK uses aiohttp when it's available in the environment (installed via llama-index-core), causing AssertionError (connector is None) on async requests. Pass httpx_async_client in HttpOptions to bypass aiohttp. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
2c6505f472
commit
c00728f375
1 changed files with 10 additions and 1 deletions
|
|
@ -36,8 +36,17 @@ def get_gemini_client():
|
|||
Creating a new client per call avoids event loop mismatch issues that occur
|
||||
when caching clients in ASGI environments where requests may come on different
|
||||
event loops. The overhead is minimal compared to the LLM API call.
|
||||
|
||||
Force httpx transport to avoid aiohttp AssertionError (connector is None)
|
||||
that occurs when aiohttp is installed in the environment via other packages.
|
||||
"""
|
||||
return genai.Client(api_key=GEMINI_API_KEY)
|
||||
from google.genai import types as genai_types
|
||||
return genai.Client(
|
||||
api_key=GEMINI_API_KEY,
|
||||
http_options=genai_types.HttpOptions(
|
||||
httpx_async_client=httpx.AsyncClient(timeout=600.0)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def get_openai_client():
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue