diff --git a/README.md b/README.md index 504400d6..9bd89872 100644 --- a/README.md +++ b/README.md @@ -83,7 +83,7 @@ he config embedder -p vllm -u http://localhost:8001/v1 -k dummy -m BAAI/bge-m3 ```
-More providers — Anthropic (Claude), Alibaba Bailian, OrcaRouter… +More providers — Anthropic (Claude), Google Gemini, Alibaba Bailian, OrcaRouter…
```bash @@ -91,11 +91,15 @@ he config embedder -p vllm -u http://localhost:8001/v1 -k dummy -m BAAI/bge-m3 he config llm -p anthropic -k YOUR_ANTHROPIC_API_KEY he config embedder -p openai -k YOUR_OPENAI_API_KEY +# Google Gemini — LLM only (default: gemini-3.8-flash) +he config llm -p google -k YOUR_GOOGLE_API_KEY +he config embedder -p openai -k YOUR_OPENAI_API_KEY + # Alibaba Bailian (Qwen, LLM + embeddings in one key) he config init -p bailian -k YOUR_BAILIAN_API_KEY ``` -> OpenAI and Bailian provide both LLM and embedding models in one API. Anthropic and DeepSeek are LLM-only (pair them with an OpenAI-compatible embedder). DeepSeek is the most cost-effective option (~$0.001-0.005/page). +> OpenAI and Bailian provide both LLM and embedding models in one API. Anthropic, Google Gemini, and DeepSeek are LLM-only (pair them with an OpenAI-compatible embedder). DeepSeek is the most cost-effective option (~$0.001-0.005/page).
@@ -243,6 +247,7 @@ Hyper-Extract uses LangChain structured output with **function calling**. The mo |----------|-----------------| | **OpenAI** | gpt-4o, gpt-4o-mini, gpt-5 | | **Anthropic** | claude-opus-4-8, claude-sonnet-4-6, claude-haiku-4-5 | +| **Google Gemini** | gemini-3.8-flash | | **DeepSeek** | deepseek-v4-flash, deepseek-v4-pro | | **阿里云百炼** | qwen-plus, qwen-turbo, deepseek-r1 | | **Local vLLM** | Qwen3.5-9B (GPTQ-Marlin) | @@ -250,7 +255,7 @@ Hyper-Extract uses LangChain structured output with **function calling**. The mo **Embedding models** (semantic search) work with any OpenAI-compatible endpoint: `text-embedding-3-small`, `text-embedding-v4` (Bailian), `bge-m3` (local vLLM).
-Provider notes — DeepSeek & Anthropic pairing +Provider notes — DeepSeek, Anthropic & Gemini pairing
> **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: @@ -267,6 +272,13 @@ Hyper-Extract uses LangChain structured output with **function calling**. The mo > llm, emb = create_client(llm="anthropic", embedder="openai:text-embedding-3-small") > ``` +> **Google Gemini:** Gemini is used for the **LLM** (set `GOOGLE_API_KEY` or `GEMINI_API_KEY`, extra: `pip install 'hyperextract[google]'`). Default model is `gemini-3.8-flash`. No mature embedder path in this repo: +> +> ```python +> from hyperextract import create_client +> llm, emb = create_client(llm="google", embedder="openai:text-embedding-3-small") +> ``` +
> 📖 Full guide: [Provider System & Local Model Support](https://yifanfeng97.github.io/Hyper-Extract/latest/concepts/provider-system/) diff --git a/README_ZH.md b/README_ZH.md index 2eb25de7..8ff6e505 100644 --- a/README_ZH.md +++ b/README_ZH.md @@ -83,7 +83,7 @@ he config embedder -p vllm -u http://localhost:8001/v1 -k dummy -m BAAI/bge-m3 ```
-更多 provider — Anthropic (Claude)、阿里云百炼、OrcaRouter… +更多 provider — Anthropic (Claude)、Google Gemini、阿里云百炼、OrcaRouter…
```bash @@ -91,11 +91,15 @@ he config embedder -p vllm -u http://localhost:8001/v1 -k dummy -m BAAI/bge-m3 he config llm -p anthropic -k YOUR_ANTHROPIC_API_KEY he config embedder -p openai -k YOUR_OPENAI_API_KEY +# Google Gemini —— 仅 LLM(默认:gemini-3.8-flash) +he config llm -p google -k YOUR_GOOGLE_API_KEY +he config embedder -p openai -k YOUR_OPENAI_API_KEY + # 百炼(阿里云,Qwen,一个 key 同时提供 LLM 和 embedding) he config init -p bailian -k YOUR_BAILIAN_API_KEY ``` -> OpenAI 和百炼同时提供 LLM 和 embedding 模型;Anthropic 和 DeepSeek 仅提供 LLM(需搭配 OpenAI 兼容 embedder)。DeepSeek 最经济(约 $0.001-0.005/页)。 +> OpenAI 和百炼同时提供 LLM 和 embedding 模型;Anthropic、Google Gemini 和 DeepSeek 仅提供 LLM(需搭配 OpenAI 兼容 embedder)。DeepSeek 最经济(约 $0.001-0.005/页)。
@@ -243,6 +247,7 @@ Hyper-Extract 通过 LangChain 结构化输出的 **function calling** 方法工 |----------|-----------------| | **OpenAI** | gpt-4o, gpt-4o-mini, gpt-5 | | **Anthropic** | claude-opus-4-8, claude-sonnet-4-6, claude-haiku-4-5 | +| **Google Gemini** | gemini-3.8-flash | | **DeepSeek** | deepseek-v4-flash, deepseek-v4-pro | | **阿里云百炼** | qwen-plus, qwen-turbo, deepseek-r1 | | **本地 vLLM** | Qwen3.5-9B (GPTQ-Marlin) | @@ -250,7 +255,7 @@ Hyper-Extract 通过 LangChain 结构化输出的 **function calling** 方法工 **嵌入模型**(语义搜索)支持任意 OpenAI 兼容端点:`text-embedding-3-small`、`text-embedding-v4`(百炼)、`bge-m3`(本地 vLLM)。
-Provider 说明 — DeepSeek 与 Anthropic 的搭配方式 +Provider 说明 — DeepSeek、Anthropic 与 Gemini 的搭配方式
> **DeepSeek:** V4 模型默认开启 "thinking" 模式,Hyper-Extract 会自动关闭以保证结构化抽取可用。设置 `DEEPSEEK_API_KEY`。DeepSeek 没有嵌入接口: @@ -267,6 +272,13 @@ Hyper-Extract 通过 LangChain 结构化输出的 **function calling** 方法工 > llm, emb = create_client(llm="anthropic", embedder="openai:text-embedding-3-small") > ``` +> **Google Gemini:** Gemini 仅用于 **LLM**(设置 `GOOGLE_API_KEY` 或 `GEMINI_API_KEY`,额外依赖:`pip install 'hyperextract[google]'`)。默认模型为 `gemini-3.8-flash`。本仓库没有成熟的 embedder 路径: +> +> ```python +> from hyperextract import create_client +> llm, emb = create_client(llm="google", embedder="openai:text-embedding-3-small") +> ``` +
> 📖 完整指南:[Provider 系统与本地模型支持](https://yifanfeng97.github.io/Hyper-Extract/latest/zh/concepts/provider-system/) diff --git a/examples/README.md b/examples/README.md index 1b7aa4f8..539c3b5f 100644 --- a/examples/README.md +++ b/examples/README.md @@ -21,6 +21,9 @@ python providers/deepseek_demo.py # Anthropic python providers/anthropic_demo.py +# Google Gemini +python providers/google_demo.py + # OrcaRouter python providers/orcarouter_demo.py @@ -50,6 +53,7 @@ examples/ │ ├── bailian_demo.py # Bailian (Alibaba Cloud) setup │ ├── deepseek_demo.py # DeepSeek setup │ ├── anthropic_demo.py # Anthropic setup +│ ├── google_demo.py # Google Gemini setup │ ├── orcarouter_demo.py # OrcaRouter setup │ └── vllm_demo.py # Local vLLM setup ├── en/ # English demos diff --git a/examples/README_ZH.md b/examples/README_ZH.md index cca4946b..14ab7cab 100644 --- a/examples/README_ZH.md +++ b/examples/README_ZH.md @@ -21,6 +21,9 @@ python providers/deepseek_demo.py # Anthropic python providers/anthropic_demo.py +# Google Gemini +python providers/google_demo.py + # OrcaRouter python providers/orcarouter_demo.py @@ -51,6 +54,7 @@ examples/ │ ├── bailian_demo.py # 百炼(阿里云)配置 │ ├── deepseek_demo.py # DeepSeek 配置 │ ├── anthropic_demo.py # Anthropic 配置 +│ ├── google_demo.py # Google Gemini 配置 │ ├── orcarouter_demo.py # OrcaRouter 配置 │ └── vllm_demo.py # 本地 vLLM 配置 ├── en/ # 英文演示 diff --git a/examples/providers/google_demo.py b/examples/providers/google_demo.py new file mode 100644 index 00000000..35cb2880 --- /dev/null +++ b/examples/providers/google_demo.py @@ -0,0 +1,36 @@ +""" +Google Gemini Provider Demo + +Extract entities and relationships using the Gemini Developer API. +Gemini has no mature embedder path in this repo, so pair it with an +OpenAI-compatible embedder. Requires `pip install 'hyperextract[google]'`. +Set GOOGLE_API_KEY or GEMINI_API_KEY. No real key is required to read +this file. + +Usage: + GOOGLE_API_KEY=xxx OPENAI_API_KEY=sk-xxx python examples/providers/google_demo.py +""" + +from hyperextract import create_client, AutoGraph + +# Gemini for LLM, OpenAI for embeddings (no Gemini embedder path here) +llm, emb = create_client( + llm="google", # default: gemini-3.8-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})")