@databricks/appkit-ui 0.22.0 → 0.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +11 -0
- package/NOTICE.md +1 -0
- package/dist/cli/commands/docs.js +7 -1
- package/dist/cli/commands/docs.js.map +1 -1
- package/dist/cli/commands/generate-types.js +27 -15
- package/dist/cli/commands/generate-types.js.map +1 -1
- package/dist/cli/commands/lint.js +3 -1
- package/dist/cli/commands/lint.js.map +1 -1
- package/dist/cli/commands/plugin/add-resource/add-resource.js +73 -8
- package/dist/cli/commands/plugin/add-resource/add-resource.js.map +1 -1
- package/dist/cli/commands/plugin/create/create.js +164 -20
- package/dist/cli/commands/plugin/create/create.js.map +1 -1
- package/dist/cli/commands/plugin/create/resource-defaults.js +5 -1
- package/dist/cli/commands/plugin/create/resource-defaults.js.map +1 -1
- package/dist/cli/commands/plugin/index.js +7 -1
- package/dist/cli/commands/plugin/index.js.map +1 -1
- package/dist/cli/commands/plugin/list/list.js +7 -1
- package/dist/cli/commands/plugin/list/list.js.map +1 -1
- package/dist/cli/commands/plugin/sync/sync.js +27 -14
- package/dist/cli/commands/plugin/sync/sync.js.map +1 -1
- package/dist/cli/commands/plugin/validate/validate.js +39 -9
- package/dist/cli/commands/plugin/validate/validate.js.map +1 -1
- package/dist/cli/commands/setup.js +6 -5
- package/dist/cli/commands/setup.js.map +1 -1
- package/dist/react/hooks/index.d.ts +4 -2
- package/dist/react/hooks/index.js +2 -0
- package/dist/react/hooks/types.d.ts +31 -2
- package/dist/react/hooks/types.d.ts.map +1 -1
- package/dist/react/hooks/use-serving-invoke.d.ts +30 -0
- package/dist/react/hooks/use-serving-invoke.d.ts.map +1 -0
- package/dist/react/hooks/use-serving-invoke.js +82 -0
- package/dist/react/hooks/use-serving-invoke.js.map +1 -0
- package/dist/react/hooks/use-serving-stream.d.ts +35 -0
- package/dist/react/hooks/use-serving-stream.d.ts.map +1 -0
- package/dist/react/hooks/use-serving-stream.js +101 -0
- package/dist/react/hooks/use-serving-stream.js.map +1 -0
- package/dist/react/index.d.ts +4 -2
- package/dist/react/index.js +3 -1
- package/docs/api/appkit/Class.Plugin.md +8 -3
- package/docs/api/appkit/Function.appKitServingTypesPlugin.md +24 -0
- package/docs/api/appkit/Function.extractServingEndpoints.md +22 -0
- package/docs/api/appkit/Function.findServerFile.md +20 -0
- package/docs/api/appkit/Interface.EndpointConfig.md +23 -0
- package/docs/api/appkit/Interface.ServingEndpointEntry.md +30 -0
- package/docs/api/appkit/Interface.ServingEndpointRegistry.md +3 -0
- package/docs/api/appkit/TypeAlias.ExecutionResult.md +36 -0
- package/docs/api/appkit/TypeAlias.ServingFactory.md +19 -0
- package/docs/api/appkit.md +39 -31
- package/docs/development/type-generation.md +6 -5
- package/docs/faq.md +66 -0
- package/docs/plugins/analytics.md +1 -1
- package/docs/plugins/custom-plugins.md +4 -0
- package/docs/plugins/plugin-management.md +22 -6
- package/docs/plugins/serving.md +223 -0
- package/docs/plugins/vector-search.md +247 -0
- package/llms.txt +11 -0
- package/package.json +1 -1
- package/sbom.cdx.json +1 -1
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
# Serving plugin
|
|
2
|
+
|
|
3
|
+
Provides an authenticated proxy to [Databricks Model Serving](https://docs.databricks.com/aws/en/machine-learning/model-serving) endpoints, with invoke and streaming support.
|
|
4
|
+
|
|
5
|
+
**Key features:**
|
|
6
|
+
|
|
7
|
+
* Named endpoint aliases for multiple serving endpoints
|
|
8
|
+
* Non-streaming (`invoke`) and SSE streaming (`stream`) invocation
|
|
9
|
+
* Automatic OpenAPI type generation for request/response schemas
|
|
10
|
+
* Request body filtering based on endpoint schema
|
|
11
|
+
* On-behalf-of (OBO) user execution
|
|
12
|
+
|
|
13
|
+
## Basic usage[](#basic-usage "Direct link to Basic usage")
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { createApp, server, serving } from "@databricks/appkit";
|
|
17
|
+
|
|
18
|
+
await createApp({
|
|
19
|
+
plugins: [
|
|
20
|
+
server(),
|
|
21
|
+
serving(),
|
|
22
|
+
],
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
With no configuration, the plugin reads `DATABRICKS_SERVING_ENDPOINT_NAME` from the environment and registers it under the `default` alias.
|
|
28
|
+
|
|
29
|
+
## Configuration options[](#configuration-options "Direct link to Configuration options")
|
|
30
|
+
|
|
31
|
+
| Option | Type | Default | Description |
|
|
32
|
+
| ----------- | -------------------------------- | ---------------------------------------------------------- | -------------------------------------- |
|
|
33
|
+
| `endpoints` | `Record<string, EndpointConfig>` | `{ default: { env: "DATABRICKS_SERVING_ENDPOINT_NAME" } }` | Map of alias names to endpoint configs |
|
|
34
|
+
| `timeout` | `number` | `120000` | Request timeout in ms |
|
|
35
|
+
|
|
36
|
+
### Endpoint aliases[](#endpoint-aliases "Direct link to Endpoint aliases")
|
|
37
|
+
|
|
38
|
+
Endpoint aliases let you reference multiple serving endpoints by name:
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
serving({
|
|
42
|
+
endpoints: {
|
|
43
|
+
llm: { env: "DATABRICKS_SERVING_ENDPOINT_NAME" },
|
|
44
|
+
classifier: { env: "DATABRICKS_SERVING_ENDPOINT_CLASSIFIER" },
|
|
45
|
+
},
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Each alias maps to an environment variable holding the actual endpoint name. If an endpoint serves multiple models, you can use `servedModel` to bypass traffic routing and target a specific model directly:
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
serving({
|
|
54
|
+
endpoints: {
|
|
55
|
+
llm: { env: "DATABRICKS_SERVING_ENDPOINT_NAME", servedModel: "llama-v2" },
|
|
56
|
+
},
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Type generation[](#type-generation "Direct link to Type generation")
|
|
62
|
+
|
|
63
|
+
The `appKitServingTypesPlugin()` Vite plugin generates TypeScript types from your serving endpoints' OpenAPI schemas. **No manual setup needed** — the AppKit dev server includes this plugin automatically.
|
|
64
|
+
|
|
65
|
+
The plugin auto-discovers endpoint configuration from your server file (`server/index.ts` or `server/server.ts`).
|
|
66
|
+
|
|
67
|
+
Generated types provide:
|
|
68
|
+
|
|
69
|
+
* **Alias autocomplete** in both backend (`AppKit.serving("alias")`) and frontend hooks (`useServingStream`, `useServingInvoke`)
|
|
70
|
+
* **Typed request/response/chunk** per endpoint based on OpenAPI schemas
|
|
71
|
+
|
|
72
|
+
If an endpoint's OpenAPI schema is unavailable (not deployed, env var not set), the plugin generates generic fallback types. The endpoint is still usable — just without typed request/response.
|
|
73
|
+
|
|
74
|
+
note
|
|
75
|
+
|
|
76
|
+
Endpoints that don't define a streaming response schema in their OpenAPI spec will have `chunk: unknown`. For these endpoints, use `useServingInvoke` instead of `useServingStream` — the `response` type will still be properly typed.
|
|
77
|
+
|
|
78
|
+
## Environment variables[](#environment-variables "Direct link to Environment variables")
|
|
79
|
+
|
|
80
|
+
| Variable | Description |
|
|
81
|
+
| ---------------------------------- | --------------------------------------------------------------- |
|
|
82
|
+
| `DATABRICKS_SERVING_ENDPOINT_NAME` | Default endpoint name (used when `endpoints` config is omitted) |
|
|
83
|
+
|
|
84
|
+
When using named endpoints, define a custom environment variable per alias (e.g. `DATABRICKS_SERVING_ENDPOINT_CLASSIFIER`).
|
|
85
|
+
|
|
86
|
+
## Execution context[](#execution-context "Direct link to Execution context")
|
|
87
|
+
|
|
88
|
+
All serving routes execute on behalf of the authenticated user (OBO) by default, consistent with the Genie and Files plugins. This ensures per-user `CAN_QUERY` permissions are enforced on the serving endpoint.
|
|
89
|
+
|
|
90
|
+
For programmatic access via `exports()`, use `.asUser(req)` to run in user context:
|
|
91
|
+
|
|
92
|
+
```ts
|
|
93
|
+
// Service principal context (default)
|
|
94
|
+
const result = await AppKit.serving("llm").invoke({ messages });
|
|
95
|
+
|
|
96
|
+
// User context (recommended in route handlers)
|
|
97
|
+
const result = await AppKit.serving("llm").asUser(req).invoke({ messages });
|
|
98
|
+
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## HTTP endpoints[](#http-endpoints "Direct link to HTTP endpoints")
|
|
102
|
+
|
|
103
|
+
### Named mode (with `endpoints` config)[](#named-mode-with-endpoints-config "Direct link to named-mode-with-endpoints-config")
|
|
104
|
+
|
|
105
|
+
* `POST /api/serving/:alias/invoke` — Non-streaming invocation
|
|
106
|
+
* `POST /api/serving/:alias/stream` — SSE streaming invocation
|
|
107
|
+
|
|
108
|
+
### Default mode (no `endpoints` config)[](#default-mode-no-endpoints-config "Direct link to default-mode-no-endpoints-config")
|
|
109
|
+
|
|
110
|
+
* `POST /api/serving/invoke` — Non-streaming invocation
|
|
111
|
+
* `POST /api/serving/stream` — SSE streaming invocation
|
|
112
|
+
|
|
113
|
+
### Request format[](#request-format "Direct link to Request format")
|
|
114
|
+
|
|
115
|
+
```text
|
|
116
|
+
POST /api/serving/:alias/invoke
|
|
117
|
+
Content-Type: application/json
|
|
118
|
+
|
|
119
|
+
{
|
|
120
|
+
"messages": [
|
|
121
|
+
{ "role": "user", "content": "Hello" }
|
|
122
|
+
]
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Programmatic access[](#programmatic-access "Direct link to Programmatic access")
|
|
128
|
+
|
|
129
|
+
The plugin exports `invoke` and `stream` methods for server-side use:
|
|
130
|
+
|
|
131
|
+
```ts
|
|
132
|
+
const AppKit = await createApp({
|
|
133
|
+
plugins: [
|
|
134
|
+
server(),
|
|
135
|
+
serving({
|
|
136
|
+
endpoints: {
|
|
137
|
+
llm: { env: "DATABRICKS_SERVING_ENDPOINT_NAME" },
|
|
138
|
+
},
|
|
139
|
+
}),
|
|
140
|
+
],
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
// Non-streaming
|
|
144
|
+
const result = await AppKit.serving("llm").invoke({
|
|
145
|
+
messages: [{ role: "user", content: "Hello" }],
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
// Streaming
|
|
149
|
+
for await (const chunk of AppKit.serving("llm").stream({
|
|
150
|
+
messages: [{ role: "user", content: "Hello" }],
|
|
151
|
+
})) {
|
|
152
|
+
console.log(chunk);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## Frontend hooks[](#frontend-hooks "Direct link to Frontend hooks")
|
|
158
|
+
|
|
159
|
+
The `@databricks/appkit-ui` package provides React hooks for serving endpoints:
|
|
160
|
+
|
|
161
|
+
### useServingStream[](#useservingstream "Direct link to useServingStream")
|
|
162
|
+
|
|
163
|
+
Streaming invocation via SSE:
|
|
164
|
+
|
|
165
|
+
```tsx
|
|
166
|
+
import { useServingStream } from "@databricks/appkit-ui/react";
|
|
167
|
+
|
|
168
|
+
function ChatStream() {
|
|
169
|
+
const { stream, chunks, streaming, error, reset } = useServingStream(
|
|
170
|
+
{ messages: [{ role: "user", content: "Hello" }] },
|
|
171
|
+
{
|
|
172
|
+
alias: "llm",
|
|
173
|
+
onComplete: (finalChunks) => {
|
|
174
|
+
// Called with all accumulated chunks when the stream finishes
|
|
175
|
+
console.log("Stream done, got", finalChunks.length, "chunks");
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
);
|
|
179
|
+
|
|
180
|
+
return (
|
|
181
|
+
<>
|
|
182
|
+
<button onClick={stream} disabled={streaming}>Send</button>
|
|
183
|
+
<button onClick={reset}>Reset</button>
|
|
184
|
+
{chunks.map((chunk, i) => <pre key={i}>{JSON.stringify(chunk)}</pre>)}
|
|
185
|
+
{error && <p>{error}</p>}
|
|
186
|
+
</>
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### useServingInvoke[](#useservinginvoke "Direct link to useServingInvoke")
|
|
193
|
+
|
|
194
|
+
Non-streaming invocation. `invoke()` returns a promise with the response data (or `null` on error):
|
|
195
|
+
|
|
196
|
+
```tsx
|
|
197
|
+
import { useServingInvoke } from "@databricks/appkit-ui/react";
|
|
198
|
+
|
|
199
|
+
function Classify() {
|
|
200
|
+
const { invoke, data, loading, error } = useServingInvoke(
|
|
201
|
+
{ inputs: ["sample text"] },
|
|
202
|
+
{ alias: "classifier" },
|
|
203
|
+
);
|
|
204
|
+
|
|
205
|
+
async function handleClick() {
|
|
206
|
+
const result = await invoke();
|
|
207
|
+
if (result) {
|
|
208
|
+
console.log("Classification result:", result);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
return (
|
|
213
|
+
<>
|
|
214
|
+
<button onClick={handleClick} disabled={loading}>Classify</button>
|
|
215
|
+
{data && <pre>{JSON.stringify(data)}</pre>}
|
|
216
|
+
{error && <p>{error}</p>}
|
|
217
|
+
</>
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
Both hooks accept `autoStart: true` to invoke automatically on mount.
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
# Vector Search plugin
|
|
2
|
+
|
|
3
|
+
Query Databricks Vector Search indexes with hybrid search, reranking, and cursor pagination from your AppKit application.
|
|
4
|
+
|
|
5
|
+
**Key features:**
|
|
6
|
+
|
|
7
|
+
* Named index aliases for multiple Vector Search indexes
|
|
8
|
+
* Hybrid, ANN, and full-text query modes
|
|
9
|
+
* Optional reranking with column-level control
|
|
10
|
+
* Cursor-based pagination for large result sets
|
|
11
|
+
* Service principal (default) and on-behalf-of-user auth
|
|
12
|
+
* Self-managed embedding indexes via custom `embeddingFn`
|
|
13
|
+
|
|
14
|
+
## Basic usage[](#basic-usage "Direct link to Basic usage")
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
import { createApp, vectorSearch, server } from "@databricks/appkit";
|
|
18
|
+
|
|
19
|
+
await createApp({
|
|
20
|
+
plugins: [
|
|
21
|
+
server(),
|
|
22
|
+
vectorSearch({
|
|
23
|
+
indexes: {
|
|
24
|
+
products: {
|
|
25
|
+
indexName: "catalog.schema.products_idx",
|
|
26
|
+
columns: ["id", "name", "description"],
|
|
27
|
+
queryType: "hybrid",
|
|
28
|
+
numResults: 20,
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
}),
|
|
32
|
+
],
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Configuration options[](#configuration-options "Direct link to Configuration options")
|
|
38
|
+
|
|
39
|
+
| Option | Type | Default | Description |
|
|
40
|
+
| --------- | ----------------------------- | ------- | -------------------------------------------------------- |
|
|
41
|
+
| `indexes` | `Record<string, IndexConfig>` | — | **Required.** Map of alias names to index configurations |
|
|
42
|
+
| `timeout` | `number` | `30000` | Query timeout in ms |
|
|
43
|
+
|
|
44
|
+
### Index aliases[](#index-aliases "Direct link to Index aliases")
|
|
45
|
+
|
|
46
|
+
Index aliases let you reference multiple Vector Search indexes by name. The alias is used in API routes and programmatic calls:
|
|
47
|
+
|
|
48
|
+
```ts
|
|
49
|
+
vectorSearch({
|
|
50
|
+
indexes: {
|
|
51
|
+
products: {
|
|
52
|
+
indexName: "catalog.schema.products_idx",
|
|
53
|
+
columns: ["id", "name", "description"],
|
|
54
|
+
},
|
|
55
|
+
docs: {
|
|
56
|
+
indexName: "catalog.schema.docs_idx",
|
|
57
|
+
columns: ["id", "title", "content", "url"],
|
|
58
|
+
queryType: "full_text",
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## IndexConfig[](#indexconfig "Direct link to IndexConfig")
|
|
66
|
+
|
|
67
|
+
| Field | Type | Default | Description |
|
|
68
|
+
| -------------- | -------------------------------------------- | --------------------- | ------------------------------------------------------------------------------- |
|
|
69
|
+
| `indexName` | `string` | — | **Required.** Three-level Unity Catalog name (`catalog.schema.index`) |
|
|
70
|
+
| `columns` | `string[]` | — | **Required.** Columns to return in query results |
|
|
71
|
+
| `queryType` | `"ann" \| "hybrid" \| "full_text"` | `"hybrid"` | Search mode |
|
|
72
|
+
| `numResults` | `number` | `20` | Maximum results per query |
|
|
73
|
+
| `reranker` | `boolean \| { columnsToRerank: string[] }` | — | Enable reranking. Pass `true` to rerank all result columns, or specify a subset |
|
|
74
|
+
| `auth` | `"service-principal" \| "on-behalf-of-user"` | `"service-principal"` | Authentication mode for query execution |
|
|
75
|
+
| `pagination` | `boolean` | — | Enable cursor-based pagination |
|
|
76
|
+
| `endpointName` | `string` | — | Vector Search endpoint name. Required when `pagination` is `true` |
|
|
77
|
+
| `embeddingFn` | `(text: string) => Promise<number[]>` | — | Custom embedding function for self-managed embedding indexes |
|
|
78
|
+
|
|
79
|
+
### Query types[](#query-types "Direct link to Query types")
|
|
80
|
+
|
|
81
|
+
* **`hybrid`** — Combines vector similarity and keyword search. Best for general-purpose retrieval.
|
|
82
|
+
* **`ann`** — Approximate nearest neighbor search using embeddings only. Best for semantic similarity.
|
|
83
|
+
* **`full_text`** — Keyword-based search with no embedding required.
|
|
84
|
+
|
|
85
|
+
### Reranking[](#reranking "Direct link to Reranking")
|
|
86
|
+
|
|
87
|
+
Reranking improves result relevance by running a second-stage model over the initial candidates:
|
|
88
|
+
|
|
89
|
+
```ts
|
|
90
|
+
vectorSearch({
|
|
91
|
+
indexes: {
|
|
92
|
+
products: {
|
|
93
|
+
indexName: "catalog.schema.products_idx",
|
|
94
|
+
columns: ["id", "name", "description", "category"],
|
|
95
|
+
reranker: { columnsToRerank: ["name", "description"] },
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Pass `reranker: true` to rerank across all returned columns.
|
|
103
|
+
|
|
104
|
+
### On-behalf-of-user auth[](#on-behalf-of-user-auth "Direct link to On-behalf-of-user auth")
|
|
105
|
+
|
|
106
|
+
By default, queries run as the app's service principal. Set `auth: "on-behalf-of-user"` to execute queries as the signed-in user instead:
|
|
107
|
+
|
|
108
|
+
```ts
|
|
109
|
+
vectorSearch({
|
|
110
|
+
indexes: {
|
|
111
|
+
documents: {
|
|
112
|
+
indexName: "catalog.schema.documents_idx",
|
|
113
|
+
columns: ["id", "title", "body"],
|
|
114
|
+
auth: "on-behalf-of-user",
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Pagination[](#pagination "Direct link to Pagination")
|
|
122
|
+
|
|
123
|
+
Enable cursor pagination to page through large result sets:
|
|
124
|
+
|
|
125
|
+
```ts
|
|
126
|
+
vectorSearch({
|
|
127
|
+
indexes: {
|
|
128
|
+
products: {
|
|
129
|
+
indexName: "catalog.schema.products_idx",
|
|
130
|
+
columns: ["id", "name", "description"],
|
|
131
|
+
pagination: true,
|
|
132
|
+
endpointName: "my-vector-search-endpoint",
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
`endpointName` is required when `pagination` is `true`. Use the `/:alias/next-page` route to fetch subsequent pages.
|
|
140
|
+
|
|
141
|
+
### Self-managed embedding indexes[](#self-managed-embedding-indexes "Direct link to Self-managed embedding indexes")
|
|
142
|
+
|
|
143
|
+
For indexes that manage their own embeddings, provide an `embeddingFn` that takes a query string and returns a vector:
|
|
144
|
+
|
|
145
|
+
```ts
|
|
146
|
+
import { embed } from "./my-embedding-client";
|
|
147
|
+
|
|
148
|
+
vectorSearch({
|
|
149
|
+
indexes: {
|
|
150
|
+
products: {
|
|
151
|
+
indexName: "catalog.schema.products_idx",
|
|
152
|
+
columns: ["id", "name", "description"],
|
|
153
|
+
queryType: "ann",
|
|
154
|
+
embeddingFn: (text) => embed(text),
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## HTTP routes[](#http-routes "Direct link to HTTP routes")
|
|
162
|
+
|
|
163
|
+
Routes are mounted at `/api/vector-search`.
|
|
164
|
+
|
|
165
|
+
| Method | Path | Description |
|
|
166
|
+
| ------ | ------------------- | ------------------------------------------------------------ |
|
|
167
|
+
| `POST` | `/:alias/query` | Query an index by alias |
|
|
168
|
+
| `POST` | `/:alias/next-page` | Fetch the next page of results (requires `pagination: true`) |
|
|
169
|
+
| `GET` | `/:alias/config` | Return the resolved config for an index alias |
|
|
170
|
+
|
|
171
|
+
### Query an index[](#query-an-index "Direct link to Query an index")
|
|
172
|
+
|
|
173
|
+
```text
|
|
174
|
+
POST /api/vector-search/:alias/query
|
|
175
|
+
Content-Type: application/json
|
|
176
|
+
|
|
177
|
+
{
|
|
178
|
+
"queryText": "machine learning guide",
|
|
179
|
+
"numResults": 10
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
Response:
|
|
185
|
+
|
|
186
|
+
```json
|
|
187
|
+
{
|
|
188
|
+
"results": [
|
|
189
|
+
{ "id": "42", "name": "Intro to ML", "description": "..." }
|
|
190
|
+
],
|
|
191
|
+
"nextPageToken": "eyJvZmZzZXQiOjEwfQ=="
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
`nextPageToken` is only present when `pagination` is enabled and more results are available.
|
|
197
|
+
|
|
198
|
+
### Fetch the next page[](#fetch-the-next-page "Direct link to Fetch the next page")
|
|
199
|
+
|
|
200
|
+
```text
|
|
201
|
+
POST /api/vector-search/:alias/next-page
|
|
202
|
+
Content-Type: application/json
|
|
203
|
+
|
|
204
|
+
{
|
|
205
|
+
"queryText": "machine learning guide",
|
|
206
|
+
"pageToken": "eyJvZmZzZXQiOjEwfQ=="
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### Get index config[](#get-index-config "Direct link to Get index config")
|
|
212
|
+
|
|
213
|
+
```text
|
|
214
|
+
GET /api/vector-search/:alias/config
|
|
215
|
+
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
Returns the resolved `IndexConfig` for the alias (excluding `embeddingFn`).
|
|
219
|
+
|
|
220
|
+
## Programmatic access[](#programmatic-access "Direct link to Programmatic access")
|
|
221
|
+
|
|
222
|
+
The plugin exposes a `query` method for server-side use:
|
|
223
|
+
|
|
224
|
+
```ts
|
|
225
|
+
const AppKit = await createApp({
|
|
226
|
+
plugins: [
|
|
227
|
+
server(),
|
|
228
|
+
vectorSearch({
|
|
229
|
+
indexes: {
|
|
230
|
+
products: {
|
|
231
|
+
indexName: "catalog.schema.products_idx",
|
|
232
|
+
columns: ["id", "name", "description"],
|
|
233
|
+
},
|
|
234
|
+
},
|
|
235
|
+
}),
|
|
236
|
+
],
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
const result = await AppKit.vectorSearch.query("products", {
|
|
240
|
+
queryText: "machine learning guide",
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
console.log(result.results);
|
|
244
|
+
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
Pass optional overrides as a second argument to `query` to adjust `numResults` or other per-call settings.
|
package/llms.txt
CHANGED
|
@@ -27,6 +27,7 @@ npx @databricks/appkit docs <query>
|
|
|
27
27
|
- [Configuration](./docs/configuration.md): This guide covers environment variables and configuration options for AppKit applications.
|
|
28
28
|
- [Core principles](./docs/core-principles.md): Learn about the fundamental concepts and principles behind AppKit.
|
|
29
29
|
- [Development](./docs/development.md): AppKit provides multiple development workflows to suit different needs: local development with hot reload, AI-assisted development with Agent Skills, and remote tunneling to deployed backends.
|
|
30
|
+
- [FAQ](./docs/faq.md): Integrations
|
|
30
31
|
- [Plugins](./docs/plugins.md): Plugins are modular extensions that add capabilities to your AppKit application. They follow a defined lifecycle and have access to shared services like caching, telemetry, and streaming.
|
|
31
32
|
|
|
32
33
|
## Development
|
|
@@ -50,6 +51,8 @@ npx @databricks/appkit docs <query>
|
|
|
50
51
|
- [Lakebase plugin](./docs/plugins/lakebase.md): Provides a PostgreSQL connection pool for Databricks Lakebase Autoscaling with automatic OAuth token refresh.
|
|
51
52
|
- [Plugin management](./docs/plugins/plugin-management.md): AppKit includes a CLI for managing plugins. All commands are available under npx @databricks/appkit plugin.
|
|
52
53
|
- [Server plugin](./docs/plugins/server.md): Provides HTTP server capabilities with development and production modes.
|
|
54
|
+
- [Serving plugin](./docs/plugins/serving.md): Provides an authenticated proxy to Databricks Model Serving endpoints, with invoke and streaming support.
|
|
55
|
+
- [Vector Search plugin](./docs/plugins/vector-search.md): Query Databricks Vector Search indexes with hybrid search, reranking, and cursor pagination from your AppKit application.
|
|
53
56
|
|
|
54
57
|
## appkit API reference [collapsed]
|
|
55
58
|
|
|
@@ -67,9 +70,12 @@ npx @databricks/appkit docs <query>
|
|
|
67
70
|
- [Class: ValidationError](./docs/api/appkit/Class.ValidationError.md): Error thrown when input validation fails.
|
|
68
71
|
- [Enumeration: RequestedClaimsPermissionSet](./docs/api/appkit/Enumeration.RequestedClaimsPermissionSet.md): Permission set for Unity Catalog table access
|
|
69
72
|
- [Enumeration: ResourceType](./docs/api/appkit/Enumeration.ResourceType.md): Resource types from schema $defs.resourceType.enum
|
|
73
|
+
- [Function: appKitServingTypesPlugin()](./docs/api/appkit/Function.appKitServingTypesPlugin.md): Vite plugin to generate TypeScript types for AppKit serving endpoints.
|
|
70
74
|
- [Function: appKitTypesPlugin()](./docs/api/appkit/Function.appKitTypesPlugin.md): Vite plugin to generate types for AppKit queries.
|
|
71
75
|
- [Function: createApp()](./docs/api/appkit/Function.createApp.md): Bootstraps AppKit with the provided configuration.
|
|
72
76
|
- [Function: createLakebasePool()](./docs/api/appkit/Function.createLakebasePool.md): Create a Lakebase pool with appkit's logger integration.
|
|
77
|
+
- [Function: extractServingEndpoints()](./docs/api/appkit/Function.extractServingEndpoints.md): Extract serving endpoint config from a server file by AST-parsing it.
|
|
78
|
+
- [Function: findServerFile()](./docs/api/appkit/Function.findServerFile.md): Find the server entry file by checking candidate paths in order.
|
|
73
79
|
- [Function: generateDatabaseCredential()](./docs/api/appkit/Function.generateDatabaseCredential.md): Generate OAuth credentials for Postgres database connection using the proper Postgres API.
|
|
74
80
|
- [Function: getExecutionContext()](./docs/api/appkit/Function.getExecutionContext.md): Get the current execution context.
|
|
75
81
|
- [Function: getLakebaseOrmConfig()](./docs/api/appkit/Function.getLakebaseOrmConfig.md): Get Lakebase connection configuration for ORMs that don't accept pg.Pool directly.
|
|
@@ -82,6 +88,7 @@ npx @databricks/appkit docs <query>
|
|
|
82
88
|
- [Interface: BasePluginConfig](./docs/api/appkit/Interface.BasePluginConfig.md): Base configuration interface for AppKit plugins
|
|
83
89
|
- [Interface: CacheConfig](./docs/api/appkit/Interface.CacheConfig.md): Configuration for the CacheInterceptor. Controls TTL, size limits, storage backend, and probabilistic cleanup.
|
|
84
90
|
- [Interface: DatabaseCredential](./docs/api/appkit/Interface.DatabaseCredential.md): Database credentials with OAuth token for Postgres connection
|
|
91
|
+
- [Interface: EndpointConfig](./docs/api/appkit/Interface.EndpointConfig.md): Properties
|
|
85
92
|
- [Interface: GenerateDatabaseCredentialRequest](./docs/api/appkit/Interface.GenerateDatabaseCredentialRequest.md): Request parameters for generating database OAuth credentials
|
|
86
93
|
- [Interface: ITelemetry](./docs/api/appkit/Interface.ITelemetry.md): Plugin-facing interface for OpenTelemetry instrumentation.
|
|
87
94
|
- [Interface: LakebasePoolConfig](./docs/api/appkit/Interface.LakebasePoolConfig.md): Configuration for creating a Lakebase connection pool
|
|
@@ -91,13 +98,17 @@ npx @databricks/appkit docs <query>
|
|
|
91
98
|
- [Interface: ResourceEntry](./docs/api/appkit/Interface.ResourceEntry.md): Internal representation of a resource in the registry.
|
|
92
99
|
- [Interface: ResourceFieldEntry](./docs/api/appkit/Interface.ResourceFieldEntry.md): Defines a single field for a resource. Each field has its own environment variable and optional description. Single-value types use one key (e.g. id); multi-value types (database, secret) use multiple (e.g. instancename, databasename or scope, key).
|
|
93
100
|
- [Interface: ResourceRequirement](./docs/api/appkit/Interface.ResourceRequirement.md): Declares a resource requirement for a plugin.
|
|
101
|
+
- [Interface: ServingEndpointEntry](./docs/api/appkit/Interface.ServingEndpointEntry.md): Shape of a single registry entry.
|
|
102
|
+
- [Interface: ServingEndpointRegistry](./docs/api/appkit/Interface.ServingEndpointRegistry.md): Registry interface for serving endpoint type generation.
|
|
94
103
|
- [Interface: StreamExecutionSettings](./docs/api/appkit/Interface.StreamExecutionSettings.md): Execution settings for streaming endpoints. Extends PluginExecutionSettings with SSE stream configuration.
|
|
95
104
|
- [Interface: TelemetryConfig](./docs/api/appkit/Interface.TelemetryConfig.md): OpenTelemetry configuration for AppKit applications
|
|
96
105
|
- [Interface: ValidationResult](./docs/api/appkit/Interface.ValidationResult.md): Result of validating all registered resources against the environment.
|
|
97
106
|
- [Type Alias: ConfigSchema](./docs/api/appkit/TypeAlias.ConfigSchema.md): Configuration schema definition for plugin config.
|
|
107
|
+
- [Type Alias: ExecutionResult<T>](./docs/api/appkit/TypeAlias.ExecutionResult.md): Discriminated union for plugin execution results.
|
|
98
108
|
- [Type Alias: IAppRouter](./docs/api/appkit/TypeAlias.IAppRouter.md): Express router type for plugin route registration
|
|
99
109
|
- [Type Alias: PluginData<T, U, N>](./docs/api/appkit/TypeAlias.PluginData.md): Tuple of plugin class, config, and name. Created by toPlugin() and passed to createApp().
|
|
100
110
|
- [Type Alias: ResourcePermission](./docs/api/appkit/TypeAlias.ResourcePermission.md): Union of all possible permission levels across all resource types.
|
|
111
|
+
- [Type Alias: ServingFactory](./docs/api/appkit/TypeAlias.ServingFactory.md): Factory function returned by AppKit.serving.
|
|
101
112
|
- [Type Alias: ToPlugin()<T, U, N>](./docs/api/appkit/TypeAlias.ToPlugin.md): Factory function type returned by toPlugin(). Accepts optional config and returns a PluginData tuple.
|
|
102
113
|
- [Variable: sql](./docs/api/appkit/Variable.sql.md): SQL helper namespace
|
|
103
114
|
|