mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 18:54:30 +00:00
* LiteLLM Minor Fixes & Improvements (09/23/2024) (#5842) * feat(auth_utils.py): enable admin to allow client-side credentials to be passed Makes it easier for devs to experiment with finetuned fireworks ai models * feat(router.py): allow setting configurable_clientside_auth_params for a model Closes https://github.com/BerriAI/litellm/issues/5843 * build(model_prices_and_context_window.json): fix anthropic claude-3-5-sonnet max output token limit Fixes https://github.com/BerriAI/litellm/issues/5850 * fix(azure_ai/): support content list for azure ai Fixes https://github.com/BerriAI/litellm/issues/4237 * fix(litellm_logging.py): always set saved_cache_cost Set to 0 by default * fix(fireworks_ai/cost_calculator.py): add fireworks ai default pricing handles calling 405b+ size models * fix(slack_alerting.py): fix error alerting for failed spend tracking Fixes regression with slack alerting error monitoring * fix(vertex_and_google_ai_studio_gemini.py): handle gemini no candidates in streaming chunk error * docs(bedrock.md): add llama3-1 models * test: fix tests * fix(azure_ai/chat): fix transformation for azure ai calls
32 lines
1,008 B
Python
32 lines
1,008 B
Python
"""
|
|
Common utility functions used for translating messages across providers
|
|
"""
|
|
|
|
from typing import List
|
|
|
|
from litellm.types.llms.openai import AllMessageValues
|
|
|
|
|
|
def convert_content_list_to_str(message: AllMessageValues) -> AllMessageValues:
|
|
"""
|
|
- handles scenario where content is list and not string
|
|
- content list is just text, and no images
|
|
- if image passed in, then just return as is (user-intended)
|
|
|
|
Motivation: mistral api + azure ai don't support content as a list
|
|
"""
|
|
texts = ""
|
|
message_content = message.get("content")
|
|
if message_content:
|
|
if message_content is not None and isinstance(message_content, list):
|
|
for c in message_content:
|
|
text_content = c.get("text")
|
|
if text_content:
|
|
texts += text_content
|
|
elif message_content is not None and isinstance(message_content, str):
|
|
texts = message_content
|
|
|
|
if texts:
|
|
message["content"] = texts
|
|
|
|
return message
|