ChatDeepSeek 통합

ChatDeepSeek 통합

LangChain JavaScript로 ChatDeepSeek 채팅 모델과 통합하는 방법을 안내할게요.

출처: 문서

본문

이 문서는 ChatDeepSeek 채팅 모델을 시작하는 데 도움을 줘요. 모든 ChatDeepSeek 기능과 구성에 대한 자세한 문서는 API 레퍼런스를 참고하세요.

개요

통합 세부 정보

클래스 패키지 Serializable PY 지원 Downloads Version
ChatDeepSeek @langchain/deepseek beta NPM - Downloads NPM - Version

모델 기능

아래 표 헤더의 링크에서 특정 기능을 사용하는 방법에 대한 가이드를 확인할 수 있어요.

Tool calling Structured output Image input Audio input Video input Token-level streaming Token usage Logprobs

참고: 1/27/25 기준, deepseek-reasoner에 대해서는 tool calling과 structured output이 아직 지원되지 않아요.

설정

DeepSeek 모델에 접근하려면 DeepSeek 계정을 만들고 API 키를 받은 뒤 @langchain/deepseek 통합 패키지를 설치해야 해요.

Ollama 같은 제공자를 통해 DeepSeek API에 접근할 수도 있어요.

자격 증명

deepseek.com에서 DeepSeek에 가입하고 API 키를 생성하세요. 완료되면 DEEPSEEK_API_KEY 환경 변수를 설정하세요:

export DEEPSEEK_API_KEY="your-api-key"

모델 호출의 자동 추적(tracing)을 원한다면 아래 주석을 해제해 LangSmith API 키를 설정할 수도 있어요:

# export LANGSMITH_TRACING="true"
# export LANGSMITH_API_KEY="your-api-key"

설치

LangChain ChatDeepSeek 통합은 @langchain/deepseek 패키지에 있어요:

```bash npm theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}} npm install @langchain/deepseek @langchain/core ```
yarn add @langchain/deepseek @langchain/core
pnpm add @langchain/deepseek @langchain/core

인스턴스 생성

이제 모델 객체를 생성하고 채팅 완성을 생성할 수 있어요:

import { ChatDeepSeek } from "@langchain/deepseek";

const llm = new ChatDeepSeek({
  model: "deepseek-reasoner",
  temperature: 0,
  // other params...
})
const aiMsg = await llm.invoke([
  [
    "system",
    "You are a helpful assistant that translates English to French. Translate the user sentence.",
  ],
  ["human", "I love programming."],
])
aiMsg
AIMessage {
  "id": "e2874482-68a7-4552-8154-b6a245bab429",
  "content": "J'adore la programmation.",
  "additional_kwargs": {
    "reasoning_content": "..."
  },
  "response_metadata": {
    "tokenUsage": {
      "promptTokens": 23,
      "completionTokens": 7,
      "totalTokens": 30
    },
    "finish_reason": "stop",
    "model_name": "deepseek-reasoner",
    "usage": {
      "prompt_tokens": 23,
      "completion_tokens": 7,
      "total_tokens": 30,
      "prompt_tokens_details": {
        "cached_tokens": 0
      },
      "prompt_cache_hit_tokens": 0,
      "prompt_cache_miss_tokens": 23
    },
    "system_fingerprint": "fp_3a5770e1b4"
  },
  "tool_calls": [],
  "invalid_tool_calls": [],
  "usage_metadata": {
    "output_tokens": 7,
    "input_tokens": 23,
    "total_tokens": 30,
    "input_token_details": {
      "cache_read": 0
    },
    "output_token_details": {}
  }
}
console.log(aiMsg.content)
J'adore la programmation.

API 레퍼런스

모든 ChatDeepSeek 기능과 구성에 대한 자세한 문서는 API 레퍼런스를 참고하세요.


[Connect these docs](/use-these-docs) to Claude, VSCode, and more via MCP for real-time answers. [Edit this page on GitHub](https://github.com/langchain-ai/docs/edit/main/src/oss/javascript/integrations/chat/deepseek.mdx) or [file an issue](https://github.com/langchain-ai/docs/issues/new/choose).

더 알아보기