Litellm dev 12 13 2024 p1 (#7219)

* fix(litellm_logging.py): pass user metadata to langsmith on sdk calls

* fix(litellm_logging.py): pass nested user metadata to logging integration - e.g. langsmith

* fix(exception_mapping_utils.py): catch and clarify watsonx `/text/chat` endpoint not supported error message.

Closes https://github.com/BerriAI/litellm/issues/7213

* fix(watsonx/common_utils.py): accept new 'WATSONX_IAM_URL' env var

allows user to use local watsonx

Fixes https://github.com/BerriAI/litellm/issues/4991

* fix(litellm_logging.py): cleanup unused function

* test: skip bad ibm test
This commit is contained in:
Krish Dholakia 2024-12-13 19:01:28 -08:00 committed by GitHub
parent 30e147a315
commit b150faff90
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 63 additions and 16 deletions

View file

@ -23,6 +23,12 @@ class WatsonXAIError(BaseLLMException):
iam_token_cache = InMemoryCache()
def get_watsonx_iam_url():
return (
get_secret_str("WATSONX_IAM_URL") or "https://iam.cloud.ibm.com/identity/token"
)
def generate_iam_token(api_key=None, **params) -> str:
result: Optional[str] = iam_token_cache.get_cache(api_key) # type: ignore
@ -38,15 +44,14 @@ def generate_iam_token(api_key=None, **params) -> str:
"grant_type": "urn:ibm:params:oauth:grant-type:apikey",
"apikey": api_key,
}
iam_token_url = get_watsonx_iam_url()
verbose_logger.debug(
"calling ibm `/identity/token` to retrieve IAM token.\nURL=%s\nheaders=%s\ndata=%s",
"https://iam.cloud.ibm.com/identity/token",
iam_token_url,
headers,
data,
)
response = httpx.post(
"https://iam.cloud.ibm.com/identity/token", data=data, headers=headers
)
response = httpx.post(iam_token_url, data=data, headers=headers)
response.raise_for_status()
json_data = response.json()