mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-07-04 21:00:40 +08:00
line 253-261, pass extra_headers fields from settings to litellm, exception handling to check if extra_headers is in dict format
This commit is contained in:
@ -252,9 +252,12 @@ class LiteLLMAIHandler(BaseAiHandler):
|
|||||||
|
|
||||||
#Added support for extra_headers while using litellm to call underlying model, via a api management gateway, would allow for passing custom headers for security and authorization
|
#Added support for extra_headers while using litellm to call underlying model, via a api management gateway, would allow for passing custom headers for security and authorization
|
||||||
if get_settings().get("LITELLM.EXTRA_HEADERS", None):
|
if get_settings().get("LITELLM.EXTRA_HEADERS", None):
|
||||||
|
try:
|
||||||
litellm_extra_headers = json.loads(get_settings().litellm.extra_headers)
|
litellm_extra_headers = json.loads(get_settings().litellm.extra_headers)
|
||||||
if not isinstance(litellm_extra_headers, dict):
|
if not isinstance(litellm_extra_headers, dict):
|
||||||
raise ValueError("LITELLM.EXTRA_HEADERS must be a JSON object")
|
raise ValueError("LITELLM.EXTRA_HEADERS must be a JSON object")
|
||||||
|
except json.JSONDecodeError as e:
|
||||||
|
raise ValueError(f"LITELLM.EXTRA_HEADERS contains invalid JSON: {str(e)}")
|
||||||
kwargs["extra_headers"] = litellm_extra_headers
|
kwargs["extra_headers"] = litellm_extra_headers
|
||||||
|
|
||||||
response = await acompletion(**kwargs)
|
response = await acompletion(**kwargs)
|
||||||
|
Reference in New Issue
Block a user