Skip to content

Hypergraph is more powerful. Transform unstructured text into structured knowledge with LLMs. Graphs, hypergraphs, and spatio-temporal extractions — with one command.

feat: add DeepSeek native provider support (#67)

yifanfeng97555afe14b77d
diff --git a/.env.example b/.env.example
index dce16dd..002959f 100644
--- a/.env.example
+++ b/.env.example
@@ -7,3 +7,6 @@ OPENAI_BASE_URL=https://api.openai.com/v1
# Anthropic / Claude API Key (Optional, required when using the anthropic provider)
# CLAUDE_API_KEY is also accepted as an alias.
ANTHROPIC_API_KEY=sk-ant-your-api-key-here
+
+# DeepSeek API Key (Optional, required when using the deepseek provider)
+DEEPSEEK_API_KEY=sk-your-deepseek-api-key-here
diff --git a/README.md b/README.md
index 5a0b868..a1c3b50 100644
--- a/README.md
+++ b/README.md
@@ -58,6 +58,7 @@
<!-- News snippets are derived from the latest merged PRs. Update as new releases land. -->
+- **🤖 DeepSeek Provider** — Use `deepseek-v4-flash` / `deepseek-v4-pro` directly via `create_client(llm="deepseek")`. V4 thinking mode is auto-disabled for structured extraction compatibility. *(#67)*
- **🔌 MCP Server** — Query your knowledge abstracts from Claude Desktop and IDE agents with `he-mcp`. *(PR #40)*
- **🧠 Anthropic Claude Support** — Use `claude-opus-4-8`, `claude-sonnet-4-6`, and `claude-haiku-4-5` directly as your LLM provider. *(PR #38)*
- **📝 Obsidian Export** — Turn any graph into an Obsidian vault with Markdown notes linked by `[[wikilinks]]`. *(PR #37)*
@@ -131,11 +132,18 @@ Hyper-Extract relies on the LLM's structured output capability (`json_schema` or
|----------|-----------------|
| **OpenAI** | gpt-4o, gpt-4o-mini, gpt-5 |
| **Anthropic** | claude-opus-4-8, claude-sonnet-4-6, claude-haiku-4-5 |
+| **DeepSeek** | deepseek-v4-flash, deepseek-v4-pro |
| **阿里云百炼** | qwen-plus, qwen-turbo, deepseek-r1 |
| **Local vLLM** | Qwen3.5-9B (GPTQ-Marlin) |
**Embedding models** (semantic search) work with any OpenAI-compatible endpoint: `text-embedding-3-small`, `text-embedding-v4` (Bailian), `bge-m3` (local vLLM).
+> **DeepSeek note:** DeepSeek V4 models default to "thinking" mode, which Hyper-Extract auto-disables so structured extraction works. Set `DEEPSEEK_API_KEY`. DeepSeek has no embeddings API — pair it with an OpenAI-compatible embedder:
+> ```python
+> from hyperextract import create_client
+> llm, emb = create_client(llm="deepseek", embedder="openai:text-embedding-3-small")
+> ```
+
> **Anthropic note:** Claude is used for the **LLM** (set `ANTHROPIC_API_KEY`). Anthropic has no embeddings API, so pair it with an OpenAI-compatible embedder:
> ```python
> from hyperextract import create_client
diff --git a/README_ZH.md b/README_ZH.md
index f783cb3..b0796d8 100644
--- a/README_ZH.md
+++ b/README_ZH.md
@@ -58,6 +58,7 @@
<!-- 以下摘要来自最近合并的 PR,随版本更新而更新。 -->
+- **🤖 DeepSeek 提供商** — 直接通过 `create_client(llm="deepseek")` 使用 `deepseek-v4-flash` / `deepseek-v4-pro`。V4 thinking 模式自动关闭,保证结构化抽取兼容。*(#67)*
- **🔌 MCP 服务器** — 通过 `he-mcp` 在 Claude Desktop 和 IDE 智能体中查询你的知识摘要。*(PR #40)*
- **🧠 Anthropic Claude 支持** — 直接调用 `claude-opus-4-8`、`claude-sonnet-4-6`、`claude-haiku-4-5` 作为 LLM 提供商。*(PR #38)*
- **📝 Obsidian 导出** — 将任意图谱导出为 Obsidian 知识库,Markdown 笔记通过 `[[双向链接]]` 关联。*(PR #37)*
@@ -131,11 +132,18 @@ Hyper-Extract 依赖大语言模型的结构化输出能力(`json_schema` 或
|----------|-----------------|
| **OpenAI** | gpt-4o, gpt-4o-mini, gpt-5 |
| **Anthropic** | claude-opus-4-8, claude-sonnet-4-6, claude-haiku-4-5 |
+| **DeepSeek** | deepseek-v4-flash, deepseek-v4-pro |
| **阿里云百炼** | qwen-plus, qwen-turbo, deepseek-r1 |
| **本地 vLLM** | Qwen3.5-9B (GPTQ-Marlin) |
**嵌入模型**(语义搜索)支持任意 OpenAI 兼容端点:`text-embedding-3-small`、`text-embedding-v4`(百炼)、`bge-m3`(本地 vLLM)。
+> **DeepSeek 说明:** V4 模型默认开启 "thinking" 模式,Hyper-Extract 会自动关闭以保证结构化抽取可用。设置 `DEEPSEEK_API_KEY`。DeepSeek 没有嵌入接口,请搭配 OpenAI 兼容的嵌入模型使用:
+> ```python
+> from hyperextract import create_client
+> llm, emb = create_client(llm="deepseek", embedder="openai:text-embedding-3-small")
+> ```
+
> **Anthropic 说明:** Claude 仅用于 **LLM**(设置 `ANTHROPIC_API_KEY`)。Anthropic 没有嵌入接口,请搭配 OpenAI 兼容的嵌入模型使用:
> ```python
> from hyperextract import create_client
diff --git a/docs/en/cli/commands/config.md b/docs/en/cli/commands/config.md
index 93942de..4266d18 100644
--- a/docs/en/cli/commands/config.md
+++ b/docs/en/cli/commands/config.md
@@ -27,6 +27,7 @@ Initialize configuration. This is the **lazy one-step setup** — if you pass `-
- **OpenAI preset**: `gpt-4o-mini` + `text-embedding-3-small`
- **Bailian preset**: `qwen3.6-plus` + `text-embedding-v4`
+- **DeepSeek preset**: `deepseek-v4-flash` (LLM only — no embedder preset)
```bash
he config init [OPTIONS]
@@ -36,7 +37,7 @@ he config init [OPTIONS]
| Option | Short | Description |
|--------|-------|-------------|
-| `--provider` | `-p` | Provider preset (`openai` / `bailian` / `vllm`) |
+| `--provider` | `-p` | Provider preset (`openai` / `bailian` / `deepseek` / `vllm`) |
| `--api-key` | `-k` | API key for both LLM and embedder |
| `--base-url` | `-u` | Custom API base URL (optional) |
@@ -50,6 +51,10 @@ he config init -p openai -k sk-your-api-key-here
# Bailian (Alibaba Cloud)
he config init -p bailian -k sk-your-api-key-here
+
+# DeepSeek (LLM only — pair with an OpenAI-compatible embedder)
+he config llm -p deepseek -k sk-your-deepseek-key
+he config embedder -p openai -k sk-your-openai-key
```
This saves the preset's default model and API URL automatically.
diff --git a/docs/en/cli/configuration.md b/docs/en/cli/configuration.md
index 912fdee..ce98fd0 100644
--- a/docs/en/cli/configuration.md
+++ b/docs/en/cli/configuration.md
@@ -1,6 +1,6 @@
# CLI Configuration Reference
-Configuration guide for Hyper-Extract CLI, supporting **OpenAI**, **Alibaba Cloud Bailian**, and **Local vLLM** deployments.
+Configuration guide for Hyper-Extract CLI, supporting **OpenAI**, **DeepSeek**, **Alibaba Cloud Bailian**, and **Local vLLM** deployments.
---
diff --git a/docs/en/cli/index.md b/docs/en/cli/index.md
index da6bcaf..1b4432f 100644
--- a/docs/en/cli/index.md
+++ b/docs/en/cli/index.md
@@ -95,6 +95,13 @@ flowchart TB
he config init -p bailian -k YOUR_BAILIAN_API_KEY
```
+=== "DeepSeek"
+
+ ```bash
+ he config llm -p deepseek -k YOUR_DEEPSEEK_API_KEY
+ he config embedder -p openai -k YOUR_OPENAI_API_KEY
+ ```
+
=== "Local vLLM"
First install [vLLM](https://docs.vllm.ai/) and start both services:
diff --git a/docs/en/concepts/provider-system.md b/docs/en/concepts/provider-system.md
index 0f1b86d..8d8ff9f 100644
--- a/docs/en/concepts/provider-system.md
+++ b/docs/en/concepts/provider-system.md
@@ -1,6 +1,6 @@
# Provider System
-Hyper-Extract supports three ways to connect to LLMs: **OpenAI**, **Alibaba Bailian**, and **local vLLM**. All use the same `create_client()` interface — only the first line changes.
+Hyper-Extract supports these ways to connect to LLMs: **OpenAI**, **Anthropic**, **Alibaba Bailian**, **DeepSeek**, and **local vLLM**. All use the same `create_client()` interface — only the first line changes.
---
@@ -12,6 +12,7 @@ Hyper-Extract supports three ways to connect to LLMs: **OpenAI**, **Alibaba Bail
|----------|-------|:---------------------:|:----------:|-------|
| **OpenAI** | gpt-4o / gpt-4o-mini / gpt-5 | ✅ | ✅ | Native support, recommended |
| **Anthropic** | claude-opus-4-8 / claude-sonnet-4-6 / claude-haiku-4-5 | ✅ (tool calling) | ✅ | LLM only — no embeddings API (pair with an OpenAI-compatible embedder). Needs `hyperextract[anthropic]` |
+| **DeepSeek** | deepseek-v4-flash / deepseek-v4-pro | ✅ | ✅ | OpenAI-compatible. V4 models default to "thinking" mode, which Hyper-Extract auto-disables (`extra_body`) so structured extraction works. LLM only — no embeddings API. Keys: `DEEPSEEK_API_KEY` |
| **Alibaba Bailian** | qwen-plus / qwen-turbo / qwen3.6-plus / deepseek-r1 | ✅ | ✅ | Works out of the box |
| **Alibaba Bailian** | qwen-max / deepseek-v3 | ❌ | ❌ | Only `json_object`; `json_schema` not supported |
@@ -52,6 +53,15 @@ llm, emb = create_client(
embedder="openai:text-embedding-3-small",
)
+# DeepSeek — OpenAI-compatible, but no embeddings API. The V4 models
+# default to "thinking" mode, which Hyper-Extract auto-disables so that
+# tool-calling (function_calling) structured extraction works out of the box.
+# Key: DEEPSEEK_API_KEY. Override model with "deepseek:deepseek-v4-pro".
+llm, emb = create_client(
+ llm="deepseek",
+ embedder="openai:text-embedding-3-small", # or vllm:bge-m3@localhost:8001/v1
+)
+
# Local vLLM
llm, emb = create_client(
llm="vllm:Qwen3.5-9B@http://localhost:8000/v1",
diff --git a/docs/en/getting-started/cli-quickstart.md b/docs/en/getting-started/cli-quickstart.md
index 077cc53..566b836 100644
--- a/docs/en/getting-started/cli-quickstart.md
+++ b/docs/en/getting-started/cli-quickstart.md
@@ -27,6 +27,13 @@ Choose your deployment method and run the corresponding configuration command:
he config init -p bailian -k YOUR_BAILIAN_API_KEY
```
+=== "DeepSeek"
+
+ ```bash
+ he config llm -p deepseek -k YOUR_DEEPSEEK_API_KEY
+ he config embedder -p openai -k YOUR_OPENAI_API_KEY
+ ```
+
=== "Local vLLM"
```bash
diff --git a/docs/en/getting-started/python-quickstart.md b/docs/en/getting-started/python-quickstart.md
index 1153639..70089e6 100644
--- a/docs/en/getting-started/python-quickstart.md
+++ b/docs/en/getting-started/python-quickstart.md
@@ -38,7 +38,7 @@ Create a `.env` file:
echo "OPENAI_API_KEY=your-api-key" > .env
```
-**Option B — Bailian or vLLM**
+**Option B — Bailian, DeepSeek, or vLLM**
See the [Provider Configuration Guide](../python/guides/provider-configuration.md) for platform-specific setup.
diff --git a/docs/en/python/guides/provider-configuration.md b/docs/en/python/guides/provider-configuration.md
index 0baada3..faa7717 100644
--- a/docs/en/python/guides/provider-configuration.md
+++ b/docs/en/python/guides/provider-configuration.md
@@ -25,6 +25,20 @@ llm, emb = create_client("bailian", api_key="sk-xxx")
# Or override model: create_client("bailian:qwen3.6-plus", api_key="sk-xxx")
```
+### DeepSeek
+
+```python
+from hyperextract import create_client, AutoGraph
+
+# DeepSeek is OpenAI-compatible but has no embeddings API — pair it with an
+# OpenAI-compatible embedder. The V4 models default to "thinking" mode, which
+# Hyper-Extract auto-disables so structured extraction works out of the box.
+llm, emb = create_client(
+ llm="deepseek", # default: deepseek-v4-flash; override with "deepseek:deepseek-v4-pro"
+ embedder="openai:text-embedding-3-small",
+)
+```
+
### Local vLLM
```python
@@ -62,6 +76,7 @@ print(f"Nodes: {len(graph.nodes)}, Edges: {len(graph.edges)}")
|----------|---------|
| **OpenAI** | `he config init -p openai -k sk-xxx` |
| **Bailian** | `he config init -p bailian -k sk-xxx` |
+| **DeepSeek** | `he config llm -p deepseek -k sk-xxx` + `he config embedder -p openai -k sk-xxx` |
| **vLLM** | `he config init` → select "local vLLM" |
| **Mixed** (LLM=Bailian, Embedder=vLLM) | `he config llm -p bailian -k sk-xxx` + `he config embedder -p vllm -u http://localhost:8001/v1 -k dummy` |
diff --git a/docs/zh/cli/commands/config.md b/docs/zh/cli/commands/config.md
index 5c3a58c..7c6b23e 100644
--- a/docs/zh/cli/commands/config.md
+++ b/docs/zh/cli/commands/config.md
@@ -27,6 +27,7 @@ he config [COMMAND] [OPTIONS]
- **OpenAI preset**: `gpt-4o-mini` + `text-embedding-3-small`
- **百炼 preset**: `qwen3.6-plus` + `text-embedding-v4`
+- **DeepSeek preset**: `deepseek-v4-flash`(仅 LLM —— 无嵌入预设)
```bash
he config init [OPTIONS]
@@ -36,7 +37,7 @@ he config init [OPTIONS]
| 选项 | 简写 | 描述 |
|--------|-------|-------------|
-| `--provider` | `-p` | 提供商 preset (`openai` / `bailian` / `vllm`) |
+| `--provider` | `-p` | 提供商 preset (`openai` / `bailian` / `deepseek` / `vllm`) |
| `--api-key` | `-k` | LLM 和嵌入模型的 API 密钥 |
| `--base-url` | `-u` | 自定义 API 基础 URL(可选) |
@@ -50,6 +51,10 @@ he config init -p openai -k sk-your-api-key-here
# 百炼(阿里云)
he config init -p bailian -k sk-your-api-key-here
+
+# DeepSeek(仅 LLM —— 请搭配 OpenAI 兼容嵌入器)
+he config llm -p deepseek -k sk-your-deepseek-key
+he config embedder -p openai -k sk-your-openai-key
```
执行后会自动保存对应 preset 的默认模型和 API 地址。
diff --git a/docs/zh/cli/configuration.md b/docs/zh/cli/configuration.md
index 71a2b77..6013f9c 100644
--- a/docs/zh/cli/configuration.md
+++ b/docs/zh/cli/configuration.md
@@ -1,6 +1,6 @@
# CLI 配置参考
-Hyper-Extract CLI 的配置指南,支持 **OpenAI**、**阿里云百炼** 和 **本地 vLLM** 三种部署方式。
+Hyper-Extract CLI 的配置指南,支持 **OpenAI**、**DeepSeek**、**阿里云百炼** 和 **本地 vLLM** 部署方式。
---
diff --git a/docs/zh/cli/index.md b/docs/zh/cli/index.md
index 9e932be..c249bd6 100644
--- a/docs/zh/cli/index.md
+++ b/docs/zh/cli/index.md
@@ -95,6 +95,13 @@ flowchart TB
he config init -p bailian -k YOUR_BAILIAN_API_KEY
```
+=== "DeepSeek"
+
+ ```bash
+ he config llm -p deepseek -k YOUR_DEEPSEEK_API_KEY
+ he config embedder -p openai -k YOUR_OPENAI_API_KEY
+ ```
+
=== "本地 vLLM"
需先安装 [vLLM](https://docs.vllm.ai/) 并分别启动 LLM 和 Embedding 服务:
diff --git a/docs/zh/concepts/provider-system.md b/docs/zh/concepts/provider-system.md
index 46e94e8..bc2a2a0 100644
--- a/docs/zh/concepts/provider-system.md
+++ b/docs/zh/concepts/provider-system.md
@@ -1,6 +1,6 @@
# Provider 系统
-Hyper-Extract 支持三种接入方式:**OpenAI**、**阿里云百炼**、**本地 vLLM**。统一使用 `create_client()` 接口,仅需修改第一行。
+Hyper-Extract 支持以下接入方式:**OpenAI**、**Anthropic**、**阿里云百炼**、**DeepSeek**、**本地 vLLM**。统一使用 `create_client()` 接口,仅需修改第一行。
---
@@ -12,6 +12,7 @@ Hyper-Extract 支持三种接入方式:**OpenAI**、**阿里云百炼**、**
|------|------|:------------------:|:------:|------|
| **OpenAI** | gpt-4o / gpt-4o-mini / gpt-5 | ✅ | ✅ | 官方原生支持,推荐 |
| **Anthropic** | claude-opus-4-8 / claude-sonnet-4-6 / claude-haiku-4-5 | ✅(工具调用) | ✅ | 仅 LLM——无嵌入接口(请搭配 OpenAI 兼容嵌入器)。需 `hyperextract[anthropic]` |
+| **DeepSeek** | deepseek-v4-flash / deepseek-v4-pro | ✅ | ✅ | OpenAI 兼容。V4 模型默认开启"thinking"模式,Hyper-Extract 会自动关闭以保证结构化抽取可用。仅 LLM——无嵌入接口。密钥:`DEEPSEEK_API_KEY` |
| **阿里云百炼** | qwen-plus / qwen-turbo / qwen3.6-plus / deepseek-r1 | ✅ | ✅ | 直接使用,无需修改 |
| **阿里云百炼** | qwen-max / deepseek-v3 | ❌ | ❌ | 仅支持 `json_object`,不支持 `json_schema` |
@@ -51,6 +52,14 @@ llm, emb = create_client(
embedder="openai:text-embedding-3-small",
)
+# DeepSeek —— OpenAI 兼容,但无嵌入接口。V4 模型默认开启 "thinking" 模式,
+# Hyper-Extract 会自动关闭以保证工具调用(function_calling)结构化抽取可用。
+# 密钥:DEEPSEEK_API_KEY。用 "deepseek:deepseek-v4-pro" 覆盖模型。
+llm, emb = create_client(
+ llm="deepseek",
+ embedder="openai:text-embedding-3-small", # 或 vllm:bge-m3@localhost:8001/v1
+)
+
# 本地 vLLM
llm, emb = create_client(
llm="vllm:Qwen3.5-9B@http://localhost:8000/v1",
diff --git a/docs/zh/getting-started/cli-quickstart.md b/docs/zh/getting-started/cli-quickstart.md
index 6c53952..be985b9 100644
--- a/docs/zh/getting-started/cli-quickstart.md
+++ b/docs/zh/getting-started/cli-quickstart.md
@@ -27,6 +27,13 @@
he config init -p bailian -k YOUR_BAILIAN_API_KEY
```
+=== "DeepSeek"
+
+ ```bash
+ he config llm -p deepseek -k YOUR_DEEPSEEK_API_KEY
+ he config embedder -p openai -k YOUR_OPENAI_API_KEY
+ ```
+
=== "本地 vLLM"
```bash
diff --git a/docs/zh/getting-started/python-quickstart.md b/docs/zh/getting-started/python-quickstart.md
index b8e064f..3e8ebfd 100644
--- a/docs/zh/getting-started/python-quickstart.md
+++ b/docs/zh/getting-started/python-quickstart.md
@@ -38,7 +38,7 @@ pip install hyperextract
echo "OPENAI_API_KEY=your-api-key" > .env
```
-**方式 B — 百炼或 vLLM**
+**方式 B — 百炼、DeepSeek 或 vLLM**
平台特定配置见 [Provider 配置指南](../python/guides/provider-configuration.md)。
diff --git a/docs/zh/python/guides/provider-configuration.md b/docs/zh/python/guides/provider-configuration.md
index 7cc753c..03c7fbe 100644
--- a/docs/zh/python/guides/provider-configuration.md
+++ b/docs/zh/python/guides/provider-configuration.md
@@ -25,6 +25,19 @@ llm, emb = create_client("bailian", api_key="sk-xxx")
# 或换模型: create_client("bailian:qwen3.6-plus", api_key="sk-xxx")
```
+### DeepSeek
+
+```python
+from hyperextract import create_client, AutoGraph
+
+# DeepSeek 兼容 OpenAI 协议,但无嵌入接口——请搭配 OpenAI 兼容嵌入器。
+# V4 模型默认开启 "thinking" 模式,Hyper-Extract 会自动关闭以保证结构化抽取可用。
+llm, emb = create_client(
+ llm="deepseek", # 默认:deepseek-v4-flash;用 "deepseek:deepseek-v4-pro" 覆盖
+ embedder="openai:text-embedding-3-small",
+)
+```
+
### 本地 vLLM
```python
@@ -62,6 +75,7 @@ print(f"节点: {len(graph.nodes)}, 关系: {len(graph.edges)}")
|------|------|
| **OpenAI** | `he config init -p openai -k sk-xxx` |
| **百炼** | `he config init -p bailian -k sk-xxx` |
+| **DeepSeek** | `he config llm -p deepseek -k sk-xxx` + `he config embedder -p openai -k sk-xxx` |
| **vLLM** | `he config init` → 选择「本地 vLLM」 |
| **混合部署**(LLM=百炼 + Embedding=本地) | `he config llm -p bailian -k sk-xxx` + `he config embedder -p vllm -u http://localhost:8001/v1 -k dummy` |
diff --git a/examples/README.md b/examples/README.md
index 2581add..2374ee0 100644
--- a/examples/README.md
+++ b/examples/README.md
@@ -15,6 +15,9 @@ python providers/openai_demo.py
# Bailian (Alibaba Cloud)
python providers/bailian_demo.py
+# DeepSeek
+python providers/deepseek_demo.py
+
# Local vLLM
python providers/vllm_demo.py
```
@@ -39,6 +42,7 @@ examples/
├── providers/ # Provider configuration demos
│ ├── openai_demo.py # OpenAI setup
│ ├── bailian_demo.py # Bailian (Alibaba Cloud) setup
+│ ├── deepseek_demo.py # DeepSeek setup
│ └── vllm_demo.py # Local vLLM setup
├── en/ # English demos
│ ├── tesla.md # Tesla biography data
diff --git a/examples/README_ZH.md b/examples/README_ZH.md
index 718cd5c..77abe9d 100644
--- a/examples/README_ZH.md
+++ b/examples/README_ZH.md
@@ -15,6 +15,9 @@ python providers/openai_demo.py
# 百炼(阿里云)
python providers/bailian_demo.py
+# DeepSeek
+python providers/deepseek_demo.py
+
# 本地 vLLM
python providers/vllm_demo.py
```
@@ -40,6 +43,7 @@ examples/
├── providers/ # Provider 配置示例
│ ├── openai_demo.py # OpenAI 配置
│ ├── bailian_demo.py # 百炼(阿里云)配置
+│ ├── deepseek_demo.py # DeepSeek 配置
│ └── vllm_demo.py # 本地 vLLM 配置
├── en/ # 英文演示
│ ├── tesla.md # 特斯拉传记数据
diff --git a/examples/providers/deepseek_demo.py b/examples/providers/deepseek_demo.py
new file mode 100644
index 0000000..3e7b0f1
--- /dev/null
+++ b/examples/providers/deepseek_demo.py
@@ -0,0 +1,34 @@
+"""
+DeepSeek Provider Demo
+
+Extract entities and relationships using the DeepSeek API.
+DeepSeek is OpenAI-compatible but has no embeddings API, so pair it
+with an OpenAI-compatible embedder.
+
+Usage:
+ DEEPSEEK_API_KEY=sk-xxx OPENAI_API_KEY=sk-xxx python examples/providers/deepseek_demo.py
+"""
+
+from hyperextract import create_client, AutoGraph
+
+# DeepSeek for LLM, OpenAI for embeddings (DeepSeek has no embeddings API)
+llm, emb = create_client(
+ llm="deepseek", # default: deepseek-v4-flash
+ embedder="openai:text-embedding-3-small",
+)
+
+graph = AutoGraph(
+ instruction="Extract people and their relationships",
+ llm_client=llm,
+ embedder=emb,
+ node_key_extractor=lambda n: n.name,
+ edge_key_extractor=lambda e: (e.source, e.target, e.type),
+ nodes_in_edge_extractor=lambda e: (e.source, e.target),
+)
+
+text = "Zhang San founded ByteDance. Li Si serves as CEO."
+graph.parse(text)
+
+print(f"Nodes: {len(graph.nodes)}, Edges: {len(graph.edges)}")
+for n in graph.nodes:
+ print(f" - {n.name} ({n.type})")
diff --git a/hyperextract/cli/commands/config.py b/hyperextract/cli/commands/config.py
index 04c21cc..205e1b9 100644
--- a/hyperextract/cli/commands/config.py
+++ b/hyperextract/cli/commands/config.py
@@ -151,7 +151,7 @@ def llm(
None,
"--provider",
"-p",
- help="Provider preset: openai, anthropic, bailian, vllm",
+ help="Provider preset: openai, anthropic, deepseek, bailian, vllm",
),
api_key: Optional[str] = typer.Option(
None,
@@ -212,7 +212,7 @@ def embedder(
None,
"--provider",
"-p",
- help="Provider preset: openai, anthropic, bailian, vllm",
+ help="Provider preset: openai, anthropic, deepseek, bailian, vllm",
),
api_key: Optional[str] = typer.Option(
None,
@@ -275,7 +275,7 @@ def init(
None,
"--provider",
"-p",
- help="Provider preset: openai, anthropic, bailian, vllm",
+ help="Provider preset: openai, anthropic, deepseek, bailian, vllm",
),
api_key: Optional[str] = typer.Option(
None,
@@ -373,13 +373,14 @@ def init(
providers = [
("openai", "OpenAI", "https://api.openai.com/v1"),
("bailian", "阿里云百炼", "https://dashscope.aliyuncs.com/compatible-mode/v1"),
+ ("deepseek", "DeepSeek", "https://api.deepseek.com"),
("vllm", "本地 vLLM", "自定义地址"),
("custom", "其他 OpenAI 兼容接口", "自定义地址"),
]
for i, (key, name, url) in enumerate(providers, 1):
console.print(f" [{i}] {name:<20} ({url})")
- choice = console.input("\n请选择 [1-4]: ").strip()
+ choice = console.input(f"\n请选择 [1-{len(providers)}]: ").strip()
try:
selected = providers[int(choice) - 1][0] if choice.isdigit() else "openai"
except (IndexError, ValueError):
diff --git a/hyperextract/cli/config.py b/hyperextract/cli/config.py
index d7bc66a..c723871 100644
--- a/hyperextract/cli/config.py
+++ b/hyperextract/cli/config.py
@@ -29,6 +29,12 @@ PROVIDER_PRESETS: Dict[str, Dict[str, str | None]] = {
"default_llm": None,
"default_embedder": None,
},
+ # DeepSeek: OpenAI-compatible, no embeddings API.
+ "deepseek": {
+ "base_url": "https://api.deepseek.com",
+ "default_llm": "deepseek-v4-flash",
+ "default_embedder": None,
+ },
# Anthropic (Claude): native client, no base_url, no embeddings API.
"anthropic": {
"base_url": "",
@@ -46,6 +52,7 @@ PROVIDER_PRESETS: Dict[str, Dict[str, str | None]] = {
PROVIDER_API_KEY_ENV: Dict[str, tuple] = {
"anthropic": ("ANTHROPIC_API_KEY", "CLAUDE_API_KEY"),
"claude": ("ANTHROPIC_API_KEY", "CLAUDE_API_KEY"),
+ "deepseek": ("DEEPSEEK_API_KEY",),
}
diff --git a/hyperextract/utils/client.py b/hyperextract/utils/client.py
index df5cf30..8114524 100644
--- a/hyperextract/utils/client.py
+++ b/hyperextract/utils/client.py
@@ -44,6 +44,16 @@ PROVIDER_PRESETS: Dict[str, Dict[str, str | None]] = {
"default_llm": None,
"default_embedder": None,
},
+ # DeepSeek. OpenAI-compatible endpoint. Current models are deepseek-v4-flash
+ # and deepseek-v4-pro; both default to "thinking" mode, which rejects the
+ # tool_choice that method="function_calling" relies on, so create_llm()
+ # disables thinking for this provider by default (override via extra_body).
+ # DeepSeek has no embeddings API — pair it with an OpenAI-compatible embedder.
+ "deepseek": {
+ "base_url": "https://api.deepseek.com",
+ "default_llm": "deepseek-v4-flash",
+ "default_embedder": None,
+ },
# Anthropic (Claude). Uses the native ChatAnthropic client, so base_url is
# left empty (the SDK targets api.anthropic.com by default). Anthropic has
# no embeddings API, hence default_embedder is None — pair it with an
@@ -68,6 +78,7 @@ ANTHROPIC_PROVIDERS = ("anthropic", "claude")
PROVIDER_API_KEY_ENV: Dict[str, Tuple[str, ...]] = {
"anthropic": ("ANTHROPIC_API_KEY", "CLAUDE_API_KEY"),
"claude": ("ANTHROPIC_API_KEY", "CLAUDE_API_KEY"),
+ "deepseek": ("DEEPSEEK_API_KEY",),
}
@@ -357,12 +368,24 @@ def create_llm(
from langchain_openai import ChatOpenAI
- return ChatOpenAI(
+ # DeepSeek V4 models default to "thinking" mode, which rejects the
+ # tool_choice that method="function_calling" sends for structured output
+ # (HTTP 400: "Thinking mode does not support this tool_choice"). Disable it
+ # by default so Hyper-Extract's structured extraction works out of the box.
+ # Users who want thinking can override: extra_body={"thinking": {"type": "enabled"}}.
+ extra_body = dict(config.get("extra_body") or {})
+ if provider == "deepseek" and "thinking" not in extra_body:
+ extra_body["thinking"] = {"type": "disabled"}
+
+ chat_kwargs: dict[str, Any] = dict(
model=config["model"],
api_key=config["api_key"] or os.environ.get("OPENAI_API_KEY", ""),
base_url=config.get("base_url") or None,
temperature=config.get("temperature", 0),
)
+ if extra_body:
+ chat_kwargs["extra_body"] = extra_body
+ return ChatOpenAI(**chat_kwargs)
def create_embedder(
diff --git a/tests/utils/test_client.py b/tests/utils/test_client.py
index b5d750c..12db895 100644
--- a/tests/utils/test_client.py
+++ b/tests/utils/test_client.py
@@ -99,6 +99,23 @@ class TestCreateLLM:
llm = create_llm("openai", api_key="sk-test")
assert llm.model_name == "gpt-4o-mini"
+ def test_create_llm_deepseek(self):
+ """Create LLM with deepseek preset (OpenAI-compatible)."""
+ llm = create_llm("deepseek", api_key="sk-test")
+ assert llm.model_name == "deepseek-v4-flash"
+ assert llm.openai_api_base == "https://api.deepseek.com"
+ # Thinking is auto-disabled so function_calling structured output works.
+ assert llm.extra_body == {"thinking": {"type": "disabled"}}
+
+ def test_create_llm_deepseek_thinking_override(self):
+ """User-supplied extra_body overrides the default thinking-disable."""
+ llm = create_llm(
+ "deepseek",
+ api_key="sk-test",
+ extra_body={"thinking": {"type": "enabled"}},
+ )
+ assert llm.extra_body == {"thinking": {"type": "enabled"}}
+
def test_create_llm_custom_model(self):
"""Override model via string shorthand."""
llm = create_llm("bailian:qwen-plus", api_key="sk-test")
@@ -466,9 +483,13 @@ class TestProviderPresets:
assert preset["default_llm"] is None
assert preset["default_embedder"] is None
- def test_no_deepseek_provider(self):
- """DeepSeek should not have its own preset (accessed via Bailian)."""
- assert "deepseek" not in PROVIDER_PRESETS
+ def test_deepseek_provider(self):
+ """DeepSeek has its own preset (OpenAI-compatible, no embeddings)."""
+ assert "deepseek" in PROVIDER_PRESETS
+ preset = PROVIDER_PRESETS["deepseek"]
+ assert preset["base_url"] == "https://api.deepseek.com"
+ assert preset["default_llm"] == "deepseek-v4-flash"
+ assert preset["default_embedder"] is None
def test_all_presets_have_base_url_or_none(self):
"""Every preset has either a base_url or None (for vLLM)."""