mirror of
https://github.com/deepseek-ai/DeepSeek-V2.git
synced 2026-11-05 00:47:23 +00:00
[GH-ISSUE #18] 如何在 langchain 中调用 DeepSeek-V2? #16
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
deepseek-ai/DeepSeek-V2#16
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @soloice on GitHub (May 10, 2024).
Original GitHub issue: https://github.com/deepseek-ai/DeepSeek-V2/issues/18
@soloice commented on GitHub (May 10, 2024):
有些用户问到怎么在 langchain 里调用 DeepSeek-V2,由于我们的接口和 OpenAI 完全兼容,所以可以直接使用 OpenAI 接口,换一下模型名称、url 和 key 即可,如下所示:
@CarlQAQ commented on GitHub (Jul 24, 2024):
不行的,ChatOpenAI方法没有像你这种参数model='deepseek-chat',
openai_api_key=,
openai_api_base='https://api.deepseek.com/v1',
@ZhangJiaQ commented on GitHub (Sep 11, 2024):
从这个地方Import 就有了 @CarlQAQ
from langchain_openai import ChatOpenAI
@SyJarvis commented on GitHub (Jan 27, 2025):
pip install langchain-deepseek
from langchain_deepseek import ChatDeepSeekAI
from langchain_core.output_parsers import StrOutputParser
llm = ChatDeepSeekAI(
model="deepseek-chat",
api_key="sk-...",
)
output_parser = StrOutputParser()
chain = llm | output_parser
response = chain.invoke("太阳系有几大行星?")
print(response)