AGENT SKILL

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-09-03
Stars
★ 351
Forks
27

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 资源文件 5

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

Preconditions

  1. langchain-chatchat is installed and imports.
  2. CHATCHAT_ROOT has been initialized with chatchat init.
  3. API server is running for live HTTP calls: chatchat start --api or chatchat start -a.
  4. Model provider settings are valid for any route that invokes LLMs or embeddings.
  5. 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.py verifies installed route registration only; it does not prove the API server, provider, or models are running.
  • A return_direct=True RAG route still needs retrieval inputs and often an initialized vector store, but it avoids LLM answer generation.
  • Live /v1/models depends on provider configuration; failures there are often provider setup failures, not route-definition failures.

04 同仓库更多 Skills

VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-triton-opt

Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-solve

END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-skill

PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-pattern-fusion

Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-orchestrate

Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-feedback

Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).

★ 351