mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-07-02 11:50:37 +08:00
line 253-258, pass extra_headers fields from settings to litellm, exception handling to check if extra_headers is in dict format
This commit is contained in:
@ -251,8 +251,10 @@ class LiteLLMAIHandler(BaseAiHandler):
|
||||
get_logger().info(f"\nUser prompt:\n{user}")
|
||||
|
||||
#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):
|
||||
kwargs["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):
|
||||
raise ValueError("LITELLM.EXTRA_HEADERS must be a JSON object")
|
||||
kwargs["extra_headers"] = litellm_extra_headers
|
||||
|
||||
response = await acompletion(**kwargs)
|
||||
except (openai.APIError, openai.APITimeoutError) as e:
|
||||
|
Reference in New Issue
Block a user