Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,22 @@
},
"security": {
"noDangerouslySetInnerHtml": "off"
},
"style": {
"noRestrictedImports": {
"level": "error",
"options": {
"patterns": [
{
"group": [
"@databricks/sdk-experimental",
"@databricks/sdk-experimental/**"
],
"message": "Import the Databricks SDK only through the wrapper in packages/appkit/src/workspace-client. Add a re-export there if you need a new symbol."
}
]
}
}
}
}
},
Expand All @@ -56,5 +72,17 @@
"organizeImports": "on"
}
}
}
},
"overrides": [
{
"includes": ["packages/appkit/src/workspace-client/**"],
"linter": {
"rules": {
"style": {
"noRestrictedImports": "off"
}
}
}
}
]
}
5 changes: 2 additions & 3 deletions docs/docs/api/appkit/Class.DatabricksAdapter.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions docs/docs/api/appkit/Function.createApp.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions docs/docs/api/appkit/Function.createWorkspaceClient.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

118 changes: 118 additions & 0 deletions docs/docs/api/appkit/Interface.WorkspaceClient.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 47 additions & 0 deletions docs/docs/api/appkit/Interface.WorkspaceClientOptions.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions docs/docs/api/appkit/index.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions docs/docs/api/appkit/typedoc-sidebar.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 6 additions & 8 deletions packages/appkit/src/agents/databricks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import type {
} from "shared";
import { stream as servingStream } from "../connectors/serving/client";
import { APPKIT_USER_AGENT, getClientOptions } from "../context/client-options";
import { createWorkspaceClient } from "../workspace-client";

/** Default cap for a single incomplete SSE line tail (DoS guard). */
const DEFAULT_MAX_SSE_LINE_CHARS = 1024 * 1024;
Expand Down Expand Up @@ -203,12 +204,11 @@ interface DeltaToolCall {
*
* @example Using the factory (recommended)
* ```ts
* import { createApp, createAgent, agents } from "@databricks/appkit";
* import { createApp, createAgent, agents, createWorkspaceClient } from "@databricks/appkit";
* import { DatabricksAdapter } from "@databricks/appkit/beta";
* import { WorkspaceClient } from "@databricks/sdk-experimental";
*
* const adapter = DatabricksAdapter.fromServingEndpoint({
* workspaceClient: new WorkspaceClient({}),
* workspaceClient: createWorkspaceClient(),
* endpointName: "my-endpoint",
* });
*
Expand Down Expand Up @@ -358,11 +358,9 @@ export class DatabricksAdapter implements AgentAdapter {
let workspaceClient: WorkspaceClientLike | undefined =
options?.workspaceClient;
if (!workspaceClient) {
const sdk = await import("@databricks/sdk-experimental");
workspaceClient = new sdk.WorkspaceClient(
{},
getClientOptions(),
) as unknown as WorkspaceClientLike;
workspaceClient = createWorkspaceClient({
clientOptions: getClientOptions(),
}) as unknown as WorkspaceClientLike;
}

return DatabricksAdapter.fromServingEndpoint({
Expand Down
15 changes: 10 additions & 5 deletions packages/appkit/src/agents/tests/databricks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -944,11 +944,16 @@ describe("DatabricksAdapter.fromModelServing", () => {
test("reads endpoint from DATABRICKS_SERVING_ENDPOINT_NAME env var", async () => {
process.env.DATABRICKS_SERVING_ENDPOINT_NAME = "my-model";

vi.mock("@databricks/sdk-experimental", () => ({
WorkspaceClient: vi.fn().mockImplementation(() => ({
apiClient: { request: vi.fn() },
})),
}));
vi.mock("../../workspace-client", async (importOriginal) => {
const actual =
await importOriginal<typeof import("../../workspace-client")>();
return {
...actual,
createWorkspaceClient: vi.fn().mockImplementation(() => ({
apiClient: { request: vi.fn() },
})),
};
});

const adapter = await DatabricksAdapter.fromModelServing();
expect(adapter).toBeInstanceOf(DatabricksAdapter);
Expand Down
6 changes: 4 additions & 2 deletions packages/appkit/src/cache/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { createHash } from "node:crypto";
import { ApiError, WorkspaceClient } from "@databricks/sdk-experimental";
import type { CacheConfig, CacheEntry, CacheStorage } from "shared";
import { createLakebasePool } from "../connectors/lakebase";
import { getClientOptions } from "../context/client-options";
Expand All @@ -8,6 +7,7 @@ import { createLogger } from "../logging/logger";
import type { Counter, TelemetryProvider } from "../telemetry";
import { SpanStatusCode, TelemetryManager } from "../telemetry";
import { deepMerge } from "../utils";
import { ApiError, createWorkspaceClient } from "../workspace-client";
import { cacheDefaults } from "./defaults";
import { InMemoryStorage, PersistentStorage } from "./storage";

Expand Down Expand Up @@ -171,7 +171,9 @@ export class CacheManager {

// try to use lakebase storage
try {
const workspaceClient = new WorkspaceClient({}, getClientOptions());
const workspaceClient = createWorkspaceClient({
clientOptions: getClientOptions(),
}).toLegacyWorkspaceClient();
const pool = createLakebasePool({ workspaceClient });
const persistentStorage = new PersistentStorage(config, pool);

Expand Down
Loading