This page consolidates guidance that used to live under xb/doc/ai_application/. It focuses on three workflows: Retrieval-Augmented Generation (RAG), Agent tooling, and analytics dashboards backed by xb.
tenant_id, lang, tags).queryVec := embedder.Encode(prompt)
resultsJSON, _ := xb.Of(&DocVector{}).
Custom(qdrantCustom).
Eq("tenant_id", tenantID).
VectorSearch("embedding", queryVec, 8).
Build().
JsonOfSelect()
Feed resultsJSON to the RAG orchestrator (LangChain, LlamaIndex, Semantic Kernel, etc.). Each toolkit consumes the same payload because xb sticks to raw Qdrant JSON.
recommend_feed, discover_code, scroll_notifications).Meta(func) to inject agent/session IDs and enforce quotas in interceptors.ScrollID and send chunks to the agent runtime.Example tool definition:
func RecommendFeedTool(input RecommendInput) (string, error) {
json, err := xb.Of(&FeedVector{}).
Custom(qdrantCustom).
Eq("tenant_id", input.Tenant).
VectorSearch("embedding", input.Vector, input.Limit).
Build().
JsonOfSelect()
if err != nil {
return "", err
}
return string(json), nil
}
Even if the front-end is SQL-only, xb helps keep AI activity auditable:
Meta(func) to log TraceID, UserID, Model per query.AfterBuild interceptors to push query summaries to observability systems.built.SqlOfSelect() alongside built.JsonOfSelect() to correlate SQL + vector traces.| Toolkit | Tip |
|---|---|
| LangChain | Wrap xb builders as Runnable objects; use JsonOfSelect output directly |
| LlamaIndex | Register a custom retriever that calls xb; keep metadata consistent |
| Semantic Kernel | Implement IQueryFunction to invoke xb and return embeddings |
QUICKSTART.md for the core builder APIQDRANT_GUIDE.md for advanced vector payloadsVECTOR_GUIDE.md for embedding hygiene and diversity settingsFILTERING.md to understand how inputs are sanitized automaticallyIf you have a repeatable AI workflow (RAG, agent, analytics) worth sharing, PRs to this file are welcome.