ChatDeepSeek Class — langchain Architecture
Architecture documentation for the ChatDeepSeek class in chat_models.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD ac89b6ea_4124_b18b_e754_c72764b6ba7a["ChatDeepSeek"] 6acbd332_f387_0c7a_34ab_a3d88a1064cb["BaseChatOpenAI"] ac89b6ea_4124_b18b_e754_c72764b6ba7a -->|extends| 6acbd332_f387_0c7a_34ab_a3d88a1064cb 17a9b92d_bb83_78d8_7df7_7200745cc17b["AIMessageChunk"] ac89b6ea_4124_b18b_e754_c72764b6ba7a -->|extends| 17a9b92d_bb83_78d8_7df7_7200745cc17b 1e978d6d_90bf_b865_7003_b6c1c5479660["chat_models.py"] ac89b6ea_4124_b18b_e754_c72764b6ba7a -->|defined in| 1e978d6d_90bf_b865_7003_b6c1c5479660 2dec0b4f_26a4_c3ce_b244_c58138a7b334["_llm_type()"] ac89b6ea_4124_b18b_e754_c72764b6ba7a -->|method| 2dec0b4f_26a4_c3ce_b244_c58138a7b334 4021e20f_769b_9b52_ad8b_e027ec894ae1["lc_secrets()"] ac89b6ea_4124_b18b_e754_c72764b6ba7a -->|method| 4021e20f_769b_9b52_ad8b_e027ec894ae1 6bef4ae8_47bb_3029_161e_76b1dae50616["_get_ls_params()"] ac89b6ea_4124_b18b_e754_c72764b6ba7a -->|method| 6bef4ae8_47bb_3029_161e_76b1dae50616 741c8c7d_a1ae_6b7c_5edb_6b10eeebe087["validate_environment()"] ac89b6ea_4124_b18b_e754_c72764b6ba7a -->|method| 741c8c7d_a1ae_6b7c_5edb_6b10eeebe087 a493b05d_d6e0_6791_4023_3ae465162299["_set_model_profile()"] ac89b6ea_4124_b18b_e754_c72764b6ba7a -->|method| a493b05d_d6e0_6791_4023_3ae465162299 0b2bb607_5fe7_68ca_8b5b_8cbfada0e2d3["_get_request_payload()"] ac89b6ea_4124_b18b_e754_c72764b6ba7a -->|method| 0b2bb607_5fe7_68ca_8b5b_8cbfada0e2d3 6616a3f6_ca0e_6ee0_130c_9def7d867424["_create_chat_result()"] ac89b6ea_4124_b18b_e754_c72764b6ba7a -->|method| 6616a3f6_ca0e_6ee0_130c_9def7d867424 844ec1b3_5e5c_ac54_d8cd_83549ea5f6d2["_convert_chunk_to_generation_chunk()"] ac89b6ea_4124_b18b_e754_c72764b6ba7a -->|method| 844ec1b3_5e5c_ac54_d8cd_83549ea5f6d2 138cc5a6_7bf3_b19a_8e71_ee99909d88be["_stream()"] ac89b6ea_4124_b18b_e754_c72764b6ba7a -->|method| 138cc5a6_7bf3_b19a_8e71_ee99909d88be 620f2b43_8095_cab1_8f2e_d84f5af721d9["_generate()"] ac89b6ea_4124_b18b_e754_c72764b6ba7a -->|method| 620f2b43_8095_cab1_8f2e_d84f5af721d9 4f292789_f095_32b8_7a7a_44868bcf9afe["bind_tools()"] ac89b6ea_4124_b18b_e754_c72764b6ba7a -->|method| 4f292789_f095_32b8_7a7a_44868bcf9afe
Relationship Graph
Source Code
libs/partners/deepseek/langchain_deepseek/chat_models.py lines 46–542
class ChatDeepSeek(BaseChatOpenAI):
"""DeepSeek chat model integration to access models hosted in DeepSeek's API.
Setup:
Install `langchain-deepseek` and set environment variable `DEEPSEEK_API_KEY`.
```bash
pip install -U langchain-deepseek
export DEEPSEEK_API_KEY="your-api-key"
```
Key init args — completion params:
model:
Name of DeepSeek model to use, e.g. `'deepseek-chat'`.
temperature:
Sampling temperature.
max_tokens:
Max number of tokens to generate.
Key init args — client params:
timeout:
Timeout for requests.
max_retries:
Max number of retries.
api_key:
DeepSeek API key. If not passed in will be read from env var `DEEPSEEK_API_KEY`.
See full list of supported init args and their descriptions in the params section.
Instantiate:
```python
from langchain_deepseek import ChatDeepSeek
model = ChatDeepSeek(
model="...",
temperature=0,
max_tokens=None,
timeout=None,
max_retries=2,
# api_key="...",
# other params...
)
```
Invoke:
```python
messages = [
("system", "You are a helpful translator. Translate the user sentence to French."),
("human", "I love programming."),
]
model.invoke(messages)
```
Stream:
```python
for chunk in model.stream(messages):
print(chunk.text, end="")
```
```python
stream = model.stream(messages)
full = next(stream)
for chunk in stream:
full += chunk
full
```
Async:
```python
await model.ainvoke(messages)
# stream:
# async for chunk in (await model.astream(messages))
# batch:
# await model.abatch([messages])
```
Tool calling:
```python
from pydantic import BaseModel, Field
Extends
Source
Frequently Asked Questions
What is the ChatDeepSeek class?
ChatDeepSeek is a class in the langchain codebase, defined in libs/partners/deepseek/langchain_deepseek/chat_models.py.
Where is ChatDeepSeek defined?
ChatDeepSeek is defined in libs/partners/deepseek/langchain_deepseek/chat_models.py at line 46.
What does ChatDeepSeek extend?
ChatDeepSeek extends BaseChatOpenAI, AIMessageChunk.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free