Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export(live_console)
export(models_anthropic)
export(models_aws_bedrock)
export(models_claude)
export(models_deepseek)
export(models_github)
export(models_google_gemini)
export(models_google_vertex)
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* ellmer will now distinguish text content from thinking content while streaming, allowing downstream packages like shinychat to provide specific UI for thinking content (@simonpcouch, #909).
* `chat_github()` now uses `chat_openai_compatible()` for improved compatibility, and `models_github()` now supports custom `base_url` configuration (@D-M4rk, #877).
* `chat_ollama()` now contains a slot for `top_k` within the `params` argument (@frankiethull).
* `models_deepseek()` lists available models for `chat_deepseek()` (@jcrodriguez1989, #919).

# ellmer 0.4.0

Expand Down
34 changes: 34 additions & 0 deletions R/provider-deepseek.R
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,37 @@ method(as_json, list(ProviderDeepSeek, Turn)) <- function(provider, x, ...) {
}

deepseek_key <- function() key_get("DEEPSEEK_API_KEY")

#' @export
#' @rdname chat_deepseek
models_deepseek <- function(
base_url = "https://api.deepseek.com",
api_key = NULL,
credentials = NULL
) {
credentials <- as_credentials(
"models_deepseek",
\() deepseek_key(),
credentials = credentials,
api_key = api_key
)

provider <- ProviderDeepSeek(
name = "DeepSeek",
model = "",
base_url = base_url,
credentials = credentials
)

req <- base_request(provider)
req <- req_url_path_append(req, "/models")
resp <- req_perform(req)

json <- resp_body_json(resp)

id <- map_chr(json$data, "[[", "id")
owned_by <- map_chr(json$data, "[[", "owned_by")

df <- data.frame(id = id, owned_by = owned_by)
cbind(df, match_prices(provider@name, df$id))
}
7 changes: 7 additions & 0 deletions man/chat_deepseek.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions tests/testthat/test-provider-deepseek.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ test_that("can make simple streaming request", {
expect_match(paste0(unlist(resp), collapse = ""), "2")
})

test_that("can list models", {
test_models(models_deepseek)
})

# Common provider interface -----------------------------------------------

test_that("defaults are reported", {
Expand Down