[appkit plugin] [5/x] Add chat server plugin to @databricks/appkit-agent#387
[appkit plugin] [5/x] Add chat server plugin to @databricks/appkit-agent#387hubertzub-db wants to merge 12 commits intodatabricks:mainfrom
Conversation
2d61336 to
fa5fffc
Compare
bceae2d to
2be31ff
Compare
2be31ff to
59b4915
Compare
| @@ -0,0 +1,299 @@ | |||
| /** | |||
There was a problem hiding this comment.
| @@ -0,0 +1,28 @@ | |||
| import type { ChatRow } from "./schema"; | |||
There was a problem hiding this comment.
| @@ -0,0 +1,52 @@ | |||
| const MAX_ENTRIES = 10_000; | |||
|
|
|||
| function setBounded<K, V>(map: Map<K, V>, key: K, value: V): void { | |||
There was a problem hiding this comment.
|
|
||
| export type { ChatRow, MessageRow }; | ||
|
|
||
| export function createDb(pool: Pool) { |
There was a problem hiding this comment.
note: reimplemented from https://github.com/databricks/app-templates/tree/main/e2e-chatbot-app-next/packages/db
1d83c9e to
61bf6ac
Compare
c469eda to
c4d0cb8
Compare
| * Consolidated Databricks authentication module. | ||
| * | ||
| * Supported auth methods (checked in priority order): | ||
| * 1. PAT — DATABRICKS_TOKEN env var |
There was a problem hiding this comment.
nit: can we make pat the lowest priority?
oauth u2m, oauth sp, then pat
could we also add a test to codify this priority order in the future
| this.registerEndpoint("chat", `/api/${this.name}`); | ||
| } | ||
|
|
||
| private resolveBackend(req: express.Request): { |
There was a problem hiding this comment.
nit: can we add tests for this?
| } | ||
|
|
||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| type LanguageModel = any; |
There was a problem hiding this comment.
should this be the type from the ai-sdk?
| * Resolve session for the request. | ||
| * | ||
| * Resolution order: | ||
| * 1. Custom getSession callback (if provided in plugin config) |
There was a problem hiding this comment.
can we add some tests to codify this ordering? priority makes sense / is the same as the existing templat
| ); | ||
| this.registerEndpoint("deleteChat", `/api/${this.name}/:id`); | ||
|
|
||
| // ── POST / (main chat handler) ─────────────────────────────────────── |
There was a problem hiding this comment.
generally for this file, can we add tests for expected behavior of each route?
i think the post is probably the most important to test (ex. fallback behvior, what to do with MCP approvals / denials etc)
There was a problem hiding this comment.
let me add some tests with simulated requests/responses
| /** Enable feedback feature (thumbs up/down). Defaults to !!process.env.MLFLOW_EXPERIMENT_ID. */ | ||
| feedbackEnabled?: boolean; | ||
| /** Auto-create the ai_chatbot schema and tables on startup. Defaults to false. */ | ||
| autoMigrate?: boolean; |
There was a problem hiding this comment.
should this default to true? in what case would we not want this to run
There was a problem hiding this comment.
good point, changed to true as default and retested - seems to be idempotent and works well
Move agent plugin source code into src/agent-plugin/ subfolder for better organization when hosting multiple plugins.
Signed-off-by: Hubert Zub <hubert.zub@databricks.com>
Signed-off-by: Hubert Zub <hubert.zub@databricks.com>
Signed-off-by: Hubert Zub <hubert.zub@databricks.com>
Add per-package pnpm-lock.yaml and CI/release workflows with explicit pnpm version and cache-dependency-path.
Signed-off-by: Hubert Zub <hubert.zub@databricks.com>
Signed-off-by: Hubert Zub <hubert.zub@databricks.com>
Signed-off-by: Hubert Zub <hubert.zub@databricks.com>
c4d0cb8 to
b8cc404
Compare
Signed-off-by: Hubert Zub <hubert.zub@databricks.com>
b8cc404 to
638d1ee
Compare
🥞 Stacked PR
Summary
Adds a
ChatPluginto@databricks/appkit-agent, exported from the@databricks/appkit-agent/chatsubpath. The plugin provides a complete chat backend: streaming responses from agent or Databricks model serving endpoints, session management, optional PostgreSQL persistence, feedback via MLflow Traces, and stream resumption.Adapted from
app-templates/e2e-chatbot-app-next](https://github.com/databricks/app-templates/tree/main/e2e-chatbot-app-next), with@databricks/appkitas a peer dependency and a standalone auth module replacing internal imports.Usage
Demo of the chat with persistence and tools (the UI runs from existing
e2e-chatbot-app-next)Screen.Recording.2026-03-25.at.11.04.21.mov
What's included
ChatPluginclass extending AppKit'sPlugin<ChatConfig>, registered as"chat". Exposes achat()factory viatoPlugin()and wires 13 Express routes under/api/chat/.autoMigrateflag