Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can ellmer integrate DeepSeek provided by other manufacturers? #296

Open
trafficfan opened this issue Feb 4, 2025 · 0 comments
Open

Comments

@trafficfan
Copy link

trafficfan commented Feb 4, 2025

DeepseekR1 is open-source and available from many manufacturers, but the price of the tokens varies. I found a cheaper option, but there were problems with the integration.
The provider‘s web here
百度云文档
here's the python code

from openai import OpenAI

client = OpenAI(
   api_key="bce-v3/ALTAK-KZke********/f1d6ee*************",  # bearer token
   base_url="https://qianfan.baidubce.com/v2"
)

completion = client.chat.completions.create(
    model="deepseek-r1",   
    messages=[{'role': 'system', 'content': 'You are a helpful assistant.'},
              {'role': 'user', 'content': '你是谁?'}]
)

print(completion.choices[0].message)

I've tried ellmer, maybe it should be like

library(ellmer)
chat <- chat_openai(
  system_prompt = NULL,
  turns = NULL,
  base_url = "https://qianfan.baidubce.com/v2/chat/completions",
  api_key = "bce-v3/ALTAK-KZke********/f1d6ee*************",
  model = "deepseek-r1",
  seed = NULL,
  api_args = list(),
  echo = c("none", "text", "all")
)
chat$chat("
  What is the difference between a tibble and a data frame?
  Answer with a bulleted list
")

chat$chat("Tell me three funny jokes about statistcians")

however it returns

Error in `httr2::req_perform_connection()`:
! HTTP 404 Not Found.
Run `rlang::last_trace()` to see where the error occurred.

I want to know if it's my code that's wrong or if Ellmer doesn't support it temporarily? I think I used the correct API key.

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

No branches or pull requests

1 participant