mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 10:44:24 +00:00
LiteLLM Minor Fixes & Improvements (11/01/2024) (#6551)
* fix: add lm_studio support * fix(cohere_transformation.py): fix transformation logic for azure cohere embedding model name Fixes https://github.com/BerriAI/litellm/issues/6540 * fix(utils.py): require base64 str to begin with `data:` Fixes https://github.com/BerriAI/litellm/issues/6541 * fix: cleanup tests * docs(guardrails.md): fix typo * fix(opentelemetry.py): move to `.exception` and update 'response_obj' value to handle 'None' case Fixes https://github.com/BerriAI/litellm/issues/6510 * fix: fix linting noqa placement
This commit is contained in:
parent
bac2ac2a49
commit
22b8f93f53
12 changed files with 123 additions and 17 deletions
|
@ -8631,11 +8631,16 @@ def is_cached_message(message: AllMessageValues) -> bool:
|
|||
def is_base64_encoded(s: str) -> bool:
|
||||
try:
|
||||
# Strip out the prefix if it exists
|
||||
if s.startswith("data:"):
|
||||
s = s.split(",")[1]
|
||||
if not s.startswith(
|
||||
"data:"
|
||||
): # require `data:` for base64 str, like openai. Prevents false positives like s='Dog'
|
||||
return False
|
||||
|
||||
s = s.split(",")[1]
|
||||
|
||||
# Try to decode the string
|
||||
decoded_bytes = base64.b64decode(s, validate=True)
|
||||
|
||||
# Check if the original string can be re-encoded to the same string
|
||||
return base64.b64encode(decoded_bytes).decode("utf-8") == s
|
||||
except Exception:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue