mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-07 02:59:05 +00:00
Fix: Add shared_session to all_litellm_params to prevent JSON serialization error
The shared_session parameter (aiohttp.ClientSession) was being passed through to provider API calls, causing "Object of type ClientSession is not JSON serializable" errors during embedding requests. Added shared_session to the all_litellm_params list so it's properly filtered out as a LiteLLM-internal parameter and not passed to the provider's API.
This commit is contained in:
parent
858cfa750f
commit
0e8e2a656e
2 changed files with 43 additions and 0 deletions
|
|
@ -2325,6 +2325,7 @@ all_litellm_params = [
|
|||
"litellm_session_id",
|
||||
"use_litellm_proxy",
|
||||
"prompt_label",
|
||||
"shared_session",
|
||||
] + list(StandardCallbackDynamicParams.__annotations__.keys())
|
||||
|
||||
|
||||
|
|
|
|||
42
test_embedding_session_error_debug.py
Normal file
42
test_embedding_session_error_debug.py
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
"""
|
||||
Test script to reproduce and debug the ClientSession JSON serialization error
|
||||
"""
|
||||
import asyncio
|
||||
import aiohttp
|
||||
import litellm
|
||||
import traceback
|
||||
|
||||
# Enable debug mode
|
||||
litellm._turn_on_debug()
|
||||
|
||||
async def test_embedding_with_shared_session():
|
||||
"""Test that reproduces the ClientSession serialization error"""
|
||||
|
||||
async with aiohttp.ClientSession() as session:
|
||||
print(f"Created ClientSession: {session}")
|
||||
|
||||
try:
|
||||
response = await litellm.aembedding(
|
||||
model="openai/text-embedding-ada-002",
|
||||
input=["test input"],
|
||||
api_key="invalid_key",
|
||||
api_base="https://httpstat.us/500", # This will return 500 error
|
||||
shared_session=session # This is the problematic parameter
|
||||
)
|
||||
print(f"Response: {response}")
|
||||
except Exception as e:
|
||||
print(f"\n❌ Error occurred: {type(e).__name__}")
|
||||
print(f"Error message: {str(e)}")
|
||||
print("\nFull traceback:")
|
||||
traceback.print_exc()
|
||||
|
||||
# Check if this is the ClientSession serialization error
|
||||
if "ClientSession" in str(e) and "JSON serializable" in str(e):
|
||||
print("\n✅ Successfully reproduced the ClientSession serialization error!")
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(test_embedding_with_shared_session())
|
||||
|
||||
Loading…
Add table
Reference in a new issue