feat(databricks/chat): support structured outputs on databricks

Closes https://github.com/BerriAI/litellm/pull/6978

- handles content as list for dbrx, - handles streaming+response_format for dbrx
This commit is contained in:
Krrish Dholakia 2024-12-02 18:23:05 -08:00
parent 12aea45447
commit 0caf804f4c
18 changed files with 538 additions and 193 deletions

View file

@ -37,6 +37,22 @@ def handle_messages_with_content_list_to_str_conversion(
return messages
def strip_name_from_messages(
messages: List[AllMessageValues],
) -> List[AllMessageValues]:
"""
Removes 'name' from messages
"""
new_messages = []
for message in messages:
msg_role = message.get("role")
msg_copy = message.copy()
if msg_role == "user":
msg_copy.pop("name", None) # type: ignore
new_messages.append(msg_copy)
return new_messages
def convert_content_list_to_str(message: AllMessageValues) -> str:
"""
- handles scenario where content is list and not string