mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-26 03:04:13 +00:00
Pass router tags in request headers - x-litellm-tags
(#8609)
* feat(litellm_pre_call_utils.py): support `x-litellm-tags` request header allow tag based routing + spend tracking via request headers * docs(request_headers.md): document new `x-litellm-tags` for tag based routing and spend tracking * docs(tag_routing.md): add to docs * fix(utils.py): only pass str values for openai metadata param * fix(utils.py): drop non-str values for metadata param to openai preview-feature, otel span was being sent in
This commit is contained in:
parent
5b84d11597
commit
e6c69c9a6f
9 changed files with 122 additions and 22 deletions
|
@ -6368,7 +6368,9 @@ def get_non_default_completion_params(kwargs: dict) -> dict:
|
|||
|
||||
def add_openai_metadata(metadata: dict) -> dict:
|
||||
"""
|
||||
Add metadata to openai optional parameters, excluding hidden params
|
||||
Add metadata to openai optional parameters, excluding hidden params.
|
||||
|
||||
OpenAI 'metadata' only supports string values.
|
||||
|
||||
Args:
|
||||
params (dict): Dictionary of API parameters
|
||||
|
@ -6380,5 +6382,10 @@ def add_openai_metadata(metadata: dict) -> dict:
|
|||
if metadata is None:
|
||||
return None
|
||||
# Only include non-hidden parameters
|
||||
visible_metadata = {k: v for k, v in metadata.items() if k != "hidden_params"}
|
||||
visible_metadata = {
|
||||
k: v
|
||||
for k, v in metadata.items()
|
||||
if k != "hidden_params" and isinstance(v, (str))
|
||||
}
|
||||
|
||||
return visible_metadata.copy()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue