在 AnythingLLM 中使用 oairoute
- 开源的知识库问答工具
- 支持把文档切成向量,配合大模型做检索增强
- 用 OAIRoute 做生成,用内置向量库做检索
第一步:获取 API Key
在 OAIRoute 控制台 创建。
Create one in the OAIRoute console.
第二步:配置大模型
打开 AnythingLLM,进入 设置 → LLM 首选项:
选 Generic OpenAI。
https://api.oairoute.com/v1
你的 OAIRoute Key。
手动填模型 ID,例如 gpt-4o-mini。
填该模型的上下文长度,例如 128000。填小了会过早截断,填大了超出模型上限会报错。
Open AnythingLLM and go to Settings → LLM Preference:
Choose Generic OpenAI.
https://api.oairoute.com/v1
Your OAIRoute key.
Enter the model ID manually, e.g. gpt-4o-mini.
Enter the model's context length, e.g. 128000. Too small and content gets truncated early; too large and requests exceed the model's limit and error out.
第三步:配置向量模型
知识库检索需要 embedding 模型。切到 Embedding 首选项:
选 Generic OpenAI。
https://api.oairoute.com/v1
填 embedding 模型 ID,例如 text-embedding-3-small。
生成用的大模型和检索用的 embedding 模型必须分两次配置。只配前者,上传文档时会报「no embedding model」。
Knowledge-base retrieval needs an embedding model. Switch to Embedding Preference:
Choose Generic OpenAI.
https://api.oairoute.com/v1
Enter the embedding model ID, e.g. text-embedding-3-small.
The LLM for generation and the embedding model for retrieval must be configured separately. Configure only the former and uploading documents fails with "no embedding model".
第四步:建工作区并上传文档
回到主界面建一个工作区,把 PDF、Markdown、网页链接拖进去,点 Save and Embed。完成后就能针对这些文档提问。
Back in the main window, create a workspace, drag in PDFs, Markdown, or web links, and click Save and Embed. Once that finishes you can ask questions about those documents.
常见问题
上传文档卡在 Embedding
embedding 模型没配,或该模型不可用。用模型列表接口核对。
回答答非所问
检索没命中。检查文档是否真的切分入库,以及提问措辞是否与文档用词差异过大。
上下文超限报错
Token context window 填得比模型实际上限大。改成模型真实值。
Upload hangs at Embedding
The embedding model isn't configured, or it isn't available. Check against the models list endpoint.
Answers miss the point
Retrieval isn't matching. Check that the documents were actually chunked and indexed, and that your question's wording isn't too different from the document's.
Context limit exceeded
Token context window is set larger than the model's actual limit. Change it to the model's real value.