-
Notifications
You must be signed in to change notification settings - Fork 9
feat: add serving type generator, Vite plugin, and UI hooks #240
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
f5172f1
feat: add serving type generator, Vite plugin, and UI hooks
pkosiec 032219b
fix: use structured requestKeys in cache, add stream body override
pkosiec 9ffa88f
fix: clear chunks after stream completion in useServingStream
pkosiec ef6449f
fix: revert chunk-clearing in useServingStream completion
pkosiec 8837eff
fix: add catch handler to connectSSE promise in useServingStream
pkosiec 053ee40
fix: add overrideBody parameter to useServingInvoke
pkosiec c428977
fix: rename DATABRICKS_SERVING_ENDPOINT to DATABRICKS_SERVING_ENDPOIN…
pkosiec 15b5d3f
fix: address PR review feedback for serving types and hooks
pkosiec b14bfd4
fix: use usePluginClientConfig hook, fix generateServingTypes export
pkosiec 09ec8f3
fix: preserve generateServingTypes export through rolldown tree-shaking
pkosiec File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,3 +9,5 @@ coverage | |
| *.tsbuildinfo | ||
|
|
||
| .turbo | ||
|
|
||
| .databricks | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,114 @@ | ||
| // Auto-generated by AppKit - DO NOT EDIT | ||
| // Generated from serving endpoint OpenAPI schemas | ||
| import "@databricks/appkit"; | ||
| import "@databricks/appkit-ui/react"; | ||
|
|
||
| declare module "@databricks/appkit" { | ||
| interface ServingEndpointRegistry { | ||
| default: { | ||
| request: { | ||
| messages?: { | ||
| role?: "user" | "assistant"; | ||
| content?: string; | ||
| }[]; | ||
| /** @openapi integer, nullable */ | ||
| n?: number | null; | ||
| max_tokens?: number; | ||
| /** @openapi double, nullable */ | ||
| top_p?: number | null; | ||
| reasoning_effort?: "low" | "medium" | "high" | null; | ||
| /** @openapi double, nullable */ | ||
| temperature?: number | null; | ||
| stop?: string | string[] | null; | ||
| }; | ||
| response: { | ||
| model?: string; | ||
| choices?: { | ||
| index?: number; | ||
| message?: { | ||
| role?: "user" | "assistant"; | ||
| content?: string; | ||
| }; | ||
| finish_reason?: string; | ||
| }[]; | ||
| usage?: { | ||
| prompt_tokens?: number; | ||
| completion_tokens?: number; | ||
| total_tokens?: number; | ||
| } | null; | ||
| object?: string; | ||
| id?: string; | ||
| created?: number; | ||
| }; | ||
| chunk: { | ||
| model?: string; | ||
| choices?: { | ||
| index?: number; | ||
| delta?: { | ||
| role?: "user" | "assistant"; | ||
| content?: string; | ||
| }; | ||
| finish_reason?: string | null; | ||
| }[]; | ||
| object?: string; | ||
| id?: string; | ||
| created?: number; | ||
| }; | ||
| }; | ||
| } | ||
| } | ||
|
|
||
| declare module "@databricks/appkit-ui/react" { | ||
| interface ServingEndpointRegistry { | ||
| default: { | ||
| request: { | ||
| messages?: { | ||
| role?: "user" | "assistant"; | ||
| content?: string; | ||
| }[]; | ||
| /** @openapi integer, nullable */ | ||
| n?: number | null; | ||
| max_tokens?: number; | ||
| /** @openapi double, nullable */ | ||
| top_p?: number | null; | ||
| reasoning_effort?: "low" | "medium" | "high" | null; | ||
| /** @openapi double, nullable */ | ||
| temperature?: number | null; | ||
| stop?: string | string[] | null; | ||
| }; | ||
| response: { | ||
| model?: string; | ||
| choices?: { | ||
| index?: number; | ||
| message?: { | ||
| role?: "user" | "assistant"; | ||
| content?: string; | ||
| }; | ||
| finish_reason?: string; | ||
| }[]; | ||
| usage?: { | ||
| prompt_tokens?: number; | ||
| completion_tokens?: number; | ||
| total_tokens?: number; | ||
| } | null; | ||
| object?: string; | ||
| id?: string; | ||
| created?: number; | ||
| }; | ||
| chunk: { | ||
| model?: string; | ||
| choices?: { | ||
| index?: number; | ||
| delta?: { | ||
| role?: "user" | "assistant"; | ||
| content?: string; | ||
| }; | ||
| finish_reason?: string | null; | ||
| }[]; | ||
| object?: string; | ||
| id?: string; | ||
| created?: number; | ||
| }; | ||
| }; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| # Function: appKitServingTypesPlugin() | ||
|
|
||
| ```ts | ||
| function appKitServingTypesPlugin(options?: AppKitServingTypesPluginOptions): Plugin$1; | ||
| ``` | ||
|
|
||
| Vite plugin to generate TypeScript types for AppKit serving endpoints. | ||
| Fetches OpenAPI schemas from Databricks and generates a .d.ts with | ||
| ServingEndpointRegistry module augmentation. | ||
|
|
||
| Endpoint discovery order: | ||
| 1. Explicit `endpoints` option (override) | ||
| 2. AST extraction from server file (server/index.ts or server/server.ts) | ||
| 3. DATABRICKS_SERVING_ENDPOINT_NAME env var (single default endpoint) | ||
|
|
||
| ## Parameters | ||
|
|
||
| | Parameter | Type | | ||
| | ------ | ------ | | ||
| | `options?` | `AppKitServingTypesPluginOptions` | | ||
|
|
||
| ## Returns | ||
|
|
||
| `Plugin$1` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| # Function: extractServingEndpoints() | ||
|
|
||
| ```ts | ||
| function extractServingEndpoints(serverFilePath: string): | ||
| | Record<string, EndpointConfig> | ||
| | null; | ||
| ``` | ||
|
|
||
| Extract serving endpoint config from a server file by AST-parsing it. | ||
| Looks for `serving({ endpoints: { alias: { env: "..." }, ... } })` calls | ||
| and extracts the endpoint alias names and their environment variable mappings. | ||
|
|
||
| ## Parameters | ||
|
|
||
| | Parameter | Type | Description | | ||
| | ------ | ------ | ------ | | ||
| | `serverFilePath` | `string` | Absolute path to the server entry file | | ||
|
|
||
| ## Returns | ||
|
|
||
| \| `Record`\<`string`, [`EndpointConfig`](Interface.EndpointConfig.md)\> | ||
| \| `null` | ||
|
|
||
| Extracted endpoint config, or null if not found or not extractable |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| # Function: findServerFile() | ||
|
|
||
| ```ts | ||
| function findServerFile(basePath: string): string | null; | ||
| ``` | ||
|
|
||
| Find the server entry file by checking candidate paths in order. | ||
|
|
||
| ## Parameters | ||
|
|
||
| | Parameter | Type | Description | | ||
| | ------ | ------ | ------ | | ||
| | `basePath` | `string` | Project root directory to search from | | ||
|
|
||
| ## Returns | ||
|
|
||
| `string` \| `null` | ||
|
|
||
| Absolute path to the server file, or null if none found |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.