Skip to content

Add support for chatting with models hosted on Databricks#152

Merged
hadley merged 1 commit into
tidyverse:mainfrom
atheriel:databricks-provider
Nov 18, 2024
Merged

Add support for chatting with models hosted on Databricks#152
hadley merged 1 commit into
tidyverse:mainfrom
atheriel:databricks-provider

Conversation

@atheriel

@atheriel atheriel commented Nov 8, 2024

Copy link
Copy Markdown
Collaborator

This commit adds support for chatbots that work with models hosted on Databricks.

According to their documentation, Databricks models can be queried by the OpenAI Python SDK, so in theory they would be compatible with our OpenAI provider. But in practice there are enough differences that a new provider is necessary.

There are other limitations, too: structured outputs are in public preview, and there is no image support.

Finally, I've found that tool calling support (also in public preview) is very limited, too limited for elmer to work properly at all:

> chat <- chat_databricks()
> chat$register_tool(tool(function() "2024-01-01", "Gets the current date"))
Using model = "databricks-dbrx-instruct".
> chat$chat("What's the current date in YMD format?")
Error in `req_perform_connection()` at elmer/R/httr2.R:36:3:
! HTTP 400 Bad Request.Bad request: Model does not support continuing the chat past the first tool call
Show Traceback
> chat
<Chat turns=2 tokens=726/11>
── user ────────────────────────────────────────────────────────────────────────────────────────
What's the current date in YMD format?
── assistant ───────────────────────────────────────────────────────────────────────────────────
[tool request (call_93d2e2fe-1a2e-4ef4-80df-4feaed245569)]: tool_001()

Databricks has announced that this limition will be lifted once tool calling is out of public preview, so I suppose we'll have to cross our fingers that this will start working at that point.

Unit tests and docs are included.

Closes #55.

@atheriel
atheriel force-pushed the databricks-provider branch 2 times, most recently from 7032406 to 4c5e61c Compare November 12, 2024 18:54
@atheriel atheriel changed the title WIP: Add support for chatting with models hosted on Databricks Add support for chatting with models hosted on Databricks Nov 12, 2024
@atheriel
atheriel marked this pull request as ready for review November 12, 2024 18:55
Comment thread R/provider-databricks.R Outdated
Comment thread R/provider-databricks.R
Comment thread R/provider-databricks.R Outdated
Comment thread tests/testthat/test-provider-databricks.R
@atheriel
atheriel force-pushed the databricks-provider branch from 4c5e61c to 6e1967f Compare November 16, 2024 00:50
@hadley

hadley commented Nov 16, 2024

Copy link
Copy Markdown
Member

Shall we add this to the automated tests too?

This commit adds support for chatbots that work with models hosted on
Databricks [0].

According to their documentation, Databricks models can be queried by
the OpenAI Python SDK, so in theory they would be compatible with our
OpenAI provider. But in practice there are enough differences that a new
provider is necessary.

There are other limitations, too: structured outputs are in public
preview, and there is no image support.

Finally, I've found that tool calling support (also in public preview)
is very limited, too limited for `elmer` to work properly at all:

    > chat <- chat_databricks()
    > chat$register_tool(tool(function() "2024-01-01", "Gets the current date"))
    Using model = "databricks-dbrx-instruct".
    > chat$chat("What's the current date in YMD format?")
    Error in `req_perform_connection()` at elmer/R/httr2.R:36:3:
    ! HTTP 400 Bad Request.
    • Bad request: Model does not support continuing the chat past the first tool call
    Show Traceback
    > chat
    <Chat turns=2 tokens=726/11>
    ── user ────────────────────────────────────────────────────────────────────────────────────────
    What's the current date in YMD format?
    ── assistant ───────────────────────────────────────────────────────────────────────────────────
    [tool request (call_93d2e2fe-1a2e-4ef4-80df-4feaed245569)]: tool_001()

Databricks has announced that this limition will be lifted once tool
calling is out of public preview [1], so I suppose we'll have to cross
our fingers that this will start working at that point.

Unit tests and docs are included.

[0]: https://docs.databricks.com/en/machine-learning/model-serving/score-foundation-models.html
[1]: https://docs.databricks.com/en/machine-learning/model-serving/function-calling.html#limitations

Signed-off-by: Aaron Jacobs <aaron.jacobs@posit.co>
@atheriel
atheriel force-pushed the databricks-provider branch from 6e1967f to 04340af Compare November 18, 2024 20:17
@atheriel

Copy link
Copy Markdown
Collaborator Author

This PR only supports PAT authentication, which we could use for CI, but I'd rather land support for Databricks service principals first. I have a SP set up for CI use already. Can we hold off until then?

@hadley

hadley commented Nov 18, 2024

Copy link
Copy Markdown
Member

Yeah, sure thing.

@hadley
hadley merged commit 3184d7d into tidyverse:main Nov 18, 2024
@atheriel
atheriel deleted the databricks-provider branch November 18, 2024 22:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Explore databricks backend

2 participants