/fe-app-toolkit:chat-app-utilitiesfrom fe-app-toolkit
Adding admin monitoring, config CRUD, chat pipeline with Genie/KA sources, FastAPI router factories for Databricks Apps
Ships in fe-app-toolkit. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Full-stack library providing chat orchestration, admin/config FastAPI routers, and React monitoring components for Databricks Apps.
https://github.com/databricks-field-eng/agent-chat-app-utilities.gitpip install chat-app-utilities[all]npm install @chat-app-utilities/reactUse this package when you need:
This package provides the backend routers that power the configurable-react-template frontend (see that skill).
Optional[X] not X | None for Databricks App compatibility)NOT published to PyPI or npm. Install via vendoring or local file reference.
Python — vendor into your app:
# Clone into your project directory
git clone https://github.com/databricks-field-eng/agent-chat-app-utilities.git
# Then in requirements.txt or setup.py, reference the local path:
# -e ./chat-app-utilities[all]
TypeScript — the React components are bundled in the same repo:
// package.json — use file: reference
{
"dependencies": {
"@chat-app-utilities/react": "file:../../chat-app-utilities/react"
}
}
The ChatOrchestrator processes each message through 8 phases:
SemanticCache (from lakebase-semantic-cache) for semantically similar prior answersRegexClassifier routes the query to relevant sources (Genie, KA, etc.)DataSource instances in parallel with configurable timeoutfrom fastapi import FastAPI
from chat_app_utilities import ChatOrchestrator, RegexClassifier
from chat_app_utilities.pipeline.sources.genie import GenieSource
from chat_app_utilities.pipeline.sources.ka import KASource
from chat_app_utilities.history.router import create_history_router
from chat_app_utilities.admin import create_admin_router
from chat_app_utilities.config import create_config_router
from chat_app_utilities.auth.lakebase import get_workspace_client, get_db_cursor
app = FastAPI()
# Chat orchestrator
orchestrator = ChatOrchestrator(
fm_endpoint="databricks-claude-sonnet-4-5",
system_prompt_builder=lambda sources: "You are a helpful assistant.",
sources=[
GenieSource(name="genie", space_id_fn=lambda: "my-space-id"),
KASource(name="ka", endpoint_fn=lambda: "my-ka-endpoint"),
],
classifier=RegexClassifier(
source_patterns={"genie": [r"price", r"sales", r"revenue"], "ka": [r"policy", r"document"]},
),
workspace_client_fn=get_workspace_client,
)
@app.post("/api/chat")
async def chat(body: dict):
from chat_app_utilities import ChatRequest
request = ChatRequest(**body)
return await orchestrator.chat(request)
# Mount routers
app.include_router(create_history_router(get_db_cursor=get_db_cursor), prefix="/api", tags=["history"])
app.include_router(create_admin_router(get_db_cursor=get_db_cursor), prefix="/api", tags=["admin"])
app.include_router(create_config_router(get_db_cursor=get_db_cursor, default_config={"company_name": "My Company", "color_primary": "#1B3139"}), prefix="/api", tags=["config"])
import { FloatingChat, useChatState, createChatApi, createAdminApi } from "@chat-app-utilities/react";
const chatApi = createChatApi("/api");
const adminApi = createAdminApi("/api");
function App() {
const chatState = useChatState({ api: chatApi, storageKey: "my-app" });
return <FloatingChat chatState={chatState} visible={true} />;
}
| Class | Purpose |
|---|---|
ChatOrchestrator | 8-phase pipeline: deictic resolution, cache, classify, fan-out, collect, memory, FM, post-process |
RegexClassifier | Pattern-based query routing to sources. Detects meta-questions and chitchat. |
DeicticResolver | Resolves pronouns/references using FM |
GenieSource | Databricks Genie Space data source |
KASource | Databricks Knowledge Assistant data source |
DataSource | Abstract base class for custom sources |
All routers auto-create their tables on first access (CREATE TABLE IF NOT EXISTS). No manual table creation needed.
| Factory | Endpoints | Auto-created Tables |
|---|---|---|
create_history_router() | GET /chat/history/{id}, PUT /chat/history, DELETE /chat/history/{id}, GET /chat/sessions | chat_history |
create_admin_router() | /admin/cache/*, /admin/memory/*, /admin/system, /admin/chat/*, /admin/install-pgvector, /admin/cache/invalidate, /admin/cache/clear, /admin/cache/cleanup | — |
create_config_router() | GET /config, PATCH /config, POST /config/logo, POST /config/font, POST /config/reset, GET /config/presets, POST /config/presets | demo_config, demo_presets |
Note: create_admin_router system diagnostics and pgvector install work even without semantic_cache installed — they fall back to get_db_cursor for PG operations.
from chat_app_utilities.auth.lakebase import get_workspace_client, get_db_cursor, get_pg_connection
# Singleton WorkspaceClient with Databricks unified auth
ws = get_workspace_client()
# Context manager for database cursor (requires LAKEBASE_ENDPOINT env var)
with get_db_cursor() as cursor:
cursor.execute("SELECT 1")
# Raw psycopg2 connection with health check + reconnect
conn = get_pg_connection()
The auth module supports autoscaling Lakebase (/api/2.0/postgres/ API) via the LAKEBASE_ENDPOINT env var. Regular (non-autoscaling) Lakebase instances use /api/2.0/database/ API and are configured via the LAKEBASE_INSTANCE env var instead. When LAKEBASE_INSTANCE is set, the auth module resolves the connection dynamically using GET /api/2.0/database/instances/{name} for the read_write_dns host and POST /api/2.0/database/credentials for OAuth-based credentials. Use one or the other, not both.
Fresh Lakebase instances don't give the app's service principal permission to create tables. Before the app can work:
Workspace owner must run (once, via SQL console or psql):
GRANT CREATE ON SCHEMA public TO PUBLIC;
GRANT ALL ON ALL TABLES IN SCHEMA public TO PUBLIC;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON TABLES TO PUBLIC;
Tables are auto-created by create_config_router() and create_history_router() on first access. No manual table creation needed.
When attaching Lakebase as a resource via PATCH /api/2.0/apps/{name}, the resource name field cannot match the Lakebase instance name. Use a different name (e.g., "my-app-lakebase" instead of "my-app-db").
| Component | Purpose |
|---|---|
FloatingChat | Collapsible chat widget with session management |
ChatMessage | Single message bubble with markdown rendering |
MentionDropdown | @-mention autocomplete dropdown |
MentionChips | Attached mention chips display |
| Hook | Returns |
|---|---|
useChatState({ api, storageKey }) | ChatState -- messages, sessions, send function, input state |
useMentionState({ items, onSelect }) | MentionState -- dropdown state, keyboard handlers |
| Factory | Returns |
|---|---|
createChatApi(baseUrl) | sendMessage, loadHistory, saveHistory, clearHistory, listSessions |
createAdminApi(baseUrl) | Methods matching template *TabApi interfaces: getStats, getEntries, getEntryDetail, getEvents, deleteEntry, getCacheConfig, updateCacheConfig, invalidateCache, clearCache, cleanupExpired, getDiagnostics, installPgvector, getSessions, getSessionDetail, plus search/deleteEntry for memory |
Recommended pattern: Instead of using createAdminApi(), build per-plugin API objects in apiFactories.ts that directly satisfy each *TabApi interface. This avoids key collision between CacheTabApi.getEntries and MemoryTabApi.getEntries when flat-merging.
React components use CSS custom properties for theming, with Databricks defaults:
--color-primary: #1B3139;
--color-accent: #FF3621;
--color-success: #00984A;
--color-warning: #EB7B30;
--color-danger: #DF002C;
--color-light-bg: #F9F7F4;
These are set automatically when used with the configurable-react-template BrandingProvider.
X | None syntax -- use Optional[X] for Python 3.9 compatibility.GRANT CREATE ON SCHEMA public TO PUBLIC on fresh Lakebase instances before the app can create tables.resources: block in app.yaml is NOT read by databricks apps deploy — must use PATCH /api/2.0/apps/{name} with resources array to attach resources.What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub sarah-hord-db/vibe --plugin fe-app-toolkit4 skills in this plugin
/agent-memory-servicePersistent memory for AI agents, MCP memory service, cross-conversation agent memory on Databricks/configurable-react-templateBuilding a Databricks App frontend, adding UI features (admin, chat, reports, branding), scaffolding a React app for Databricks/lakebase-semantic-cacheAdding semantic caching to a Databricks App, reducing duplicate LLM calls, pgvector cachingOther plugins' skills for the same job