Skip to content

Add DatabricksModel #2947

@DouweM

Description

@DouweM

Description

The Databricks "Chat Completions-compatible API" is mostly, but not quite, OpenAIChatModel-compatible.

Specifically, the message.content field is not str | None like in the OpenAI SDK, but str | list[ContentItem]. The docs helpfully explain:

The content can be either a string or an array that contains a series of multimodal elements in a single chat interaction. These elements follow the sequence in which they are processed as inputs or outputs by the models. This array input is specifically designed for use with proprietary models accessible only through external model providers. Currently, only Claude models are supported. Use string-typed content for other external model providers, open source models (Llama), or models hosted by customers on Databricks. list[ContentItem] is not compatible with OpenAI's specifications.

This means we'll need a new DatabricksModel to support Databricks, similar to how we'll be adding an OpenRouterModel (#2936) and already have GroqModel and HuggingFaceModel -- all used to be fully Chat Completions-compatible and, for understandable reasons, diverged over time.

Since this is (so far) the only thing we'll need to handle differently than OpenAIChatModel, I'd prefer not to copy-paste the entire class, but rather to subclass it and change the behavior through hooks. Or if we need a new class, to extract the common bits into helper functions.

References

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions