mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-26 19:24:27 +00:00
* feat(together_ai/completion): handle together ai completion calls * fix: handle list of int / list of list of int for text completion calls * fix(utils.py): check if base model in bedrock converse model list Fixes https://github.com/BerriAI/litellm/issues/6003 * test(test_optional_params.py): add unit tests for bedrock optional param mapping Fixes https://github.com/BerriAI/litellm/issues/6003 * feat(utils.py): enable passing dummy tool call for anthropic/bedrock calls if tool_use blocks exist Fixes https://github.com/BerriAI/litellm/issues/5388 * fixed an issue with tool use of claude models with anthropic and bedrock (#6013) * fix(utils.py): handle empty schema for anthropic/bedrock Fixes https://github.com/BerriAI/litellm/issues/6012 * fix: fix linting errors * fix: fix linting errors * fix: fix linting errors * fix(proxy_cli.py): fix import route for app + health checks path (#6026) * (testing): Enable testing us.anthropic.claude-3-haiku-20240307-v1:0. (#6018) * fix(proxy_cli.py): fix import route for app + health checks gettsburg.wav Fixes https://github.com/BerriAI/litellm/issues/5999 --------- Co-authored-by: David Manouchehri <david.manouchehri@ai.moda> --------- Co-authored-by: Ved Patwardhan <54766411+vedpatwardhan@users.noreply.github.com> Co-authored-by: David Manouchehri <david.manouchehri@ai.moda>
29 lines
943 B
Python
29 lines
943 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) -> str:
|
|
"""
|
|
- 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
|
|
|
|
return texts
|