apis-client-and-sandbox
Operate DB-GPT 0.8.1 through its Python client, HTTP service APIs, application routes, file and app workflows, and explicitly bounded sandbox runtimes.
- License 许可
- MIT
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- apis-client-and-sandbox
- license
- MIT
- metadata
- { "disco-role": "operating" }
- description
- Operate DB-GPT 0.8.1 through its Python client, HTTP service APIs, application routes, file and app workflows, and explicitly bounded sandbox runtimes.
- disable-model-invocation
- true
02 资源文件 5
- 参考文档references/client-api-reference.md10.4 KB
- 参考文档references/sandbox-workflows.md9.6 KB
- 参考文档references/service-endpoints.md13.5 KB
- 参考文档references/troubleshooting.md12.0 KB
- 脚本scripts/sandbox_cli_wrapper.py4.6 KB
03 SKILL.md 正文
APIs, client, and sandbox
Use this route when a task names dbgpt-client, dbgpt_serve, dbgpt-app HTTP/OpenAPI, datasource or knowledge CRUD, AWEL flow service calls, app/skill/file uploads, model service endpoints, or dbgpt-sandbox. It is the integration boundary: it teaches request construction, service composition, response/error interpretation, and safe execution boundaries. It does not replace the data/RAG, agent/AWEL, or model-provider routes.
Route quickly
- Python client or CRUD: load client-api-reference.md. Use the async helpers for the operations they actually cover; use the endpoint reference for operations absent from the client or where its legacy helper does not match the server schema.
- HTTP route, service prefix, auth, or multipart request: load service-endpoints.md.
- Sandbox session, runtime selection, code execution, or artifact retrieval: load sandbox-workflows.md, then apply the safety boundary in troubleshooting.md.
- Failure or uncertain live integration: start with troubleshooting.md. Do not infer a live service, model, database, container image, credential, or network from a successful import.
Operating contract
Inputs
Establish these before making a request or executing code:
- Target surface: client helper, raw HTTP, app OpenAPI,
dbgpt-serve, or standalone sandbox API. - Base URL and version: the client expects a full URL such as
http://localhost:5670/api/v2; do not give it only a host or a URL ending at/apiunless the operation is intentionally raw HTTP. - Authentication: use
DBGPT_API_KEYor an explicitly supplied key only when the server is configured with API keys. Never place a real key in a script, fixture, log, or prompt. The client sendsAuthorization: Bearer <key>when a key is present. - Dependency order and ownership: create or verify a datasource before using it in data chat; create or verify a knowledge space before creating/syncing documents; resolve a flow/app/model identifier before running it. Use the server's returned identifier, not a guessed name.
- Execution boundary: default to mock/local schema checks. A live call requires an explicitly reachable server and approved credentials; a sandbox container requires an available image/runtime. No helper in this route starts a service by default.
Workflow
- Discover without side effects. Import only the public package needed for the operation. For a live deployment, use its
/docsor OpenAPI description to confirm the exact mounted prefix and request shape. A safe health or test-auth request is optional and still counts as a live request. - Build the smallest valid request. Validate required fields, identifiers, content type, pagination, and whether data belongs in JSON, query parameters, form fields, or multipart files. Keep database passwords, bearer tokens, and provider keys out of diagnostics.
- Execute asynchronously and close resources.
Clientuseshttpx.AsyncClient; useawait client.aclose()in afinallyblock. Treat stream iterators as one-shot and consumedata: [DONE]for OpenAI-style SSE. - Check both transport and envelope. Service endpoints generally return a DB-GPT
Resultenvelope with asuccessflag anddata, while some failures are HTTP 400/401/404/5xx. Do not call a response successful merely because JSON parsed. - Record identifiers and cleanup. Preserve response IDs, flow UIDs, file IDs, and sandbox session IDs. Delete temporary uploads, flow/session resources, and test fixtures when the operation finishes or fails.
- Escalate boundary failures. Distinguish malformed request (usually 400/422), missing/invalid key (401), missing entity (404), conflict/dependency (409 or an unsuccessful
Result), service failure (5xx), connection/timeout, and missing optional backend. See the troubleshooting reference.
High-value facts
- DB-GPT application defaults to web host
0.0.0.0and port5670; the standard API base ishttp://localhost:5670/api/v2. Client(api_base=None, api_key=None, version="v2", timeout=120)readsDBGPT_API_BASEandDBGPT_API_KEY. The URL must have a scheme and network location. A timeout ofNonecreates an unlimitedhttpxtimeout and should be used only deliberately.- The client appends
/servefor its generic service methods. Thusclient.get("/datasources")targets<api_base>/serve/datasources, andpost_paramsends query parameters rather than a JSON body. - Client CRUD helpers are async functions in
dbgpt_client.datasource,dbgpt_client.knowledge,dbgpt_client.flow, anddbgpt_client.app; onlyClientandClientExceptionare exported from the package root. - The v2 chat request requires
modelandmessages.chat_modeis normallychat_normal; specialized modes requirechat_param:chat_app,chat_flow,chat_knowledge,chat_data,chat_with_db_qa, andchat_dashboard. Non-streaming app chat is rejected by the v2 route. Flow and app chat normally stream. - Application OpenAPI v1 routes are mounted under
/api; v2 chat is/api/v2/chat/completions. Stable service routes are mounted under/api/v2/serve/...; a few compatibility v1 routes remain and are not automatically compatible with v2. dbgpt-servecomponents are registered into one FastAPI application. A health response indicates a route is alive, not that its datasource, model, vector store, file backend, or sandbox dependency is healthy.- Sandbox auto-selection prefers Docker, then Podman, then Nerdctl, and fails closed when no container backend is available. Host-local execution is an explicit opt-in and must never be described as container isolation.
Boundaries and non-goals
- Route RAG loaders, chunking, embeddings, vector stores, connector-specific SQL, and retrieval implementation to
data-and-rag. - Route agent construction, tool packs, ReAct behavior, and AWEL graph topology to
agents-and-awel; this route only covers calling a persisted flow or app over an API. - Route provider credentials, model adapter installation, controller/worker deployment, GPU, CUDA, and VRAM to
models-and-serving. - Do not run an installer, start Uvicorn, launch a model, contact a provider, clone/import a remote skill, install sandbox dependencies, or provision an external database as an implicit validation step.
- Do not claim that a local sandbox is secure isolation. Its code check is a simple pattern check and its
network_disabledsetting is not host-network isolation inLocalRuntime. - Do not put untrusted package names into shell-built dependency-install commands, pass secrets through sandbox environment variables, or return host file paths as if they were portable artifact URIs.
Validation checklist
For a client/API change, validate without a live service where possible:
inspect.signatureand imports resolve forClient,ClientException, the target schema, and the target helper.- A mocked response covers success, unsuccessful
Result, malformed response, 401/404/409, and a transport/timeout failure. - The asserted HTTP method and path match the mounted endpoint, and JSON/query/form/multipart placement is explicit.
- Streams parse only
data:JSON events and stop at[DONE]; non-200 streams are failures, not assistant content. - The async client is closed and no credential or external-service side effect occurs.
For a sandbox change, validate safely:
RuntimeFactory.create()fails closed with container detection disabled and local opt-in absent.- Explicit
localfails unless both local opt-in controls were enabled before module initialization; an opted-in local factory reportsLocalRuntime. - A tiny local session can execute deterministic, non-I/O code, reject a known dangerous pattern, and remove its automatically created temporary directory on destroy.
- Missing image/runtime, timeout, process termination, dependency-install failure, and artifact cleanup are reported as bounded errors.
The bundled sandbox_cli_wrapper.py validates request payloads and policy-shaped code locally. It never starts a server or executes the supplied code.
Troubleshooting
Use the symptom-driven matrix in troubleshooting.md. Preserve the original HTTP status, response body (with secrets redacted), request path, operation ID, and whether the failure occurred before or after the service boundary. Do not retry destructive create/delete or upload operations blindly; check idempotency and current resource state first.
04 同仓库更多 Skills
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.
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.
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.
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.
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.
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).