knowledge-base-and-api
Use Langchain-Chatchat FastAPI, OpenAI-compatible chat, knowledge-base RAG, file RAG, tools, and vector-store workflows.
- License 许可
- Apache-2.0
- 最近更新
- 2026-10-08
- Stars
- ★ 11
- Forks
- 3
01 前言 Front Matter
- name
- knowledge-base-and-api
- license
- Apache 2.0
- metadata
- { "disco-role": "operating" }
- description
- Use Langchain-Chatchat FastAPI, OpenAI-compatible chat, knowledge-base RAG, file RAG, tools, and vector-store workflows.
- disable-model-invocation
- true
02 资源文件 4
- 参考文档references/api-reference.md4.3 KB
- 参考文档references/rag-workflows.md3.0 KB
- 参考文档references/troubleshooting.md3.7 KB
- 参考文档references/vector-store-and-data-formats.md3.1 KB
03 SKILL.md 正文
Knowledge Base and API
Use this sub-skill when a task asks for Langchain-Chatchat HTTP APIs, RAG modes, knowledge-base document operations, file/temp KB chat, search-engine chat, tools, OpenAI-compatible endpoints, route discovery, or vector-store behavior.
Read first
references/api-reference.mdmaps verified route families and request patterns.references/rag-workflows.mdcovers local KB, temp-file, search-engine, direct retrieval, and tool-choice workflows.references/vector-store-and-data-formats.mdcovers document/vector-store settings and supported backends.references/troubleshooting.mdcovers route, provider, streaming, KB, and vector-store failures.- Run
scripts/api_surface_probe.pyto list the installed API routes without binding a service port.
Preconditions
langchain-chatchatis installed and imports.CHATCHAT_ROOThas been initialized withchatchat init.- API server is running for live HTTP calls:
chatchat start --apiorchatchat start -a. - Model provider settings are valid for any route that invokes LLMs or embeddings.
- For vector rebuilds or retrieval over indexed docs, the embedding model is reachable.
If any precondition is false, route setup/config work to ../server-setup-and-cli/SKILL.md.
Route families
| Task | Route family |
|---|---|
| Unified chat, pure LLM chat, agent/tool chat | /chat/chat/completions |
| Legacy/specific KB and file chat helpers | /chat/kb_chat, /chat/file_chat |
| OpenAI-compatible RAG by mode | `/knowledge_base/{local_kb |
| KB CRUD and document operations | /knowledge_base/list_knowledge_bases, /create_knowledge_base, /delete_knowledge_base, /list_files, /upload_docs, /delete_docs, /update_docs, /search_docs, /download_doc, /recreate_vector_store |
| Temp docs | /knowledge_base/upload_temp_docs, /search_temp_docs |
| Summary routes | /knowledge_base/kb_summary_api/* |
| Tool registry/calls | /tools, /tools/call |
| OpenAI-compatible provider proxy | /v1/models, /v1/chat/completions, /v1/completions, /v1/embeddings, /v1/images/*, /v1/audio/*, /v1/files* |
| Server state/prompts | /server/configs, /server/get_prompt_template |
| MCP connections | /api/v1/mcp_connections/* |
Common API patterns
Direct retrieval from local KB without LLM generation
Use OpenAI-compatible RAG route plus return_direct=True in extra_body when the task only needs retrieved documents.
from openai import Client
client = Client(base_url="http://127.0.0.1:7861/knowledge_base/local_kb/samples", api_key="EMPTY")
resp = client.chat.completions.create(
model="configured-llm-name",
messages=[{"role": "user", "content": "How do I ask high-quality questions?"}],
stream=True,
extra_body={"top_k": 3, "score_threshold": 2.0, "return_direct": True},
)
for chunk in resp:
print(chunk)
Tool-assisted chat
Fetch /tools first. If the model can choose tools, pass tools. If it cannot reliably infer arguments, pass tool_choice and extra_body.tool_input to make the tool call explicit.
File/temp KB chat
Upload temporary docs first, capture knowledge_id, then use /knowledge_base/temp_kb/{knowledge_id}/chat/completions or the SDK's temp-doc methods.
Verification boundaries
api_surface_probe.pyverifies installed route registration only; it does not prove the API server, provider, or models are running.- A
return_direct=TrueRAG route still needs retrieval inputs and often an initialized vector store, but it avoids LLM answer generation. - Live
/v1/modelsdepends on provider configuration; failures there are often provider setup failures, not route-definition failures.
04 同仓库更多 Skills
obsidian-clipper-template-creator
Guide for creating templates for the Obsidian Web Clipper. Use when you want to create a new clipping template, understand available variables, or format clipped content.
obsidian-clipper-template-creator
Guide for creating templates for the Obsidian Web Clipper. Use when you want to create a new clipping template, understand available variables, or format clipped content.
python-api
Programmatic Object-Detection-Metrics API guidance for BoundingBox, BoundingBoxes, Evaluator, enums, coordinate conversion, AP/mAP semantics, and source-style import diagnostics.
file-evaluation
Folder-based PASCAL VOC AP/mAP evaluation from ground-truth and detection text files.
object-detection-metrics
Guides legacy Object-Detection-Metrics PASCAL VOC AP/mAP evaluation from detection text folders and direct Python API classes.
nx-workspace-patterns
Configure and optimize Nx monorepo workspaces. Use when setting up Nx, configuring project boundaries, optimizing build caching, or implementing affected commands.