@kanzo-tech/llm 0.17.0 → 0.18.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/README.md +3 -3
- package/dist/{kanzo.d.ts → gateway.d.ts} +5 -5
- package/dist/gateway.d.ts.map +1 -0
- package/dist/{kanzo.js → gateway.js} +4 -4
- package/dist/gateway.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/dist/kanzo.d.ts.map +0 -1
- package/dist/kanzo.js.map +0 -1
package/README.md
CHANGED
|
@@ -13,11 +13,11 @@ installs it once so that its own agent and `@kanzo-tech/ai`'s components share o
|
|
|
13
13
|
## What it holds
|
|
14
14
|
|
|
15
15
|
```ts
|
|
16
|
-
import {
|
|
16
|
+
import { createGateway } from "@kanzo-tech/llm";
|
|
17
17
|
import { ToolLoopAgent, DirectChatTransport, tool, Output, streamText } from "@kanzo-tech/llm";
|
|
18
18
|
```
|
|
19
19
|
|
|
20
|
-
- **`
|
|
20
|
+
- **`createGateway({ baseURL })`** — the one door to a model. `gateway("chat")` is a model by
|
|
21
21
|
**alias**: which upstream answers it is the gateway's configuration, so a host's code is the same
|
|
22
22
|
in development (a local model) and in production. The gateway speaks OpenAI chat completions; its
|
|
23
23
|
key belongs to a server, so `baseURL` is normally the host's own authenticated proxy — keasy's is
|
|
@@ -27,7 +27,7 @@ import { ToolLoopAgent, DirectChatTransport, tool, Output, streamText } from "@k
|
|
|
27
27
|
asks the gateway for a JSON schema rather than prose to parse.
|
|
28
28
|
- **Re-exports** of the AI SDK surface a host needs — the agent, the transport, `tool`, `Output`,
|
|
29
29
|
`streamText`, and the message and part types — so a host never imports `ai` itself.
|
|
30
|
-
`@ai-sdk/openai-compatible` is not among them: `
|
|
30
|
+
`@ai-sdk/openai-compatible` is not among them: `createGateway` is the only way to a model.
|
|
31
31
|
|
|
32
32
|
## Why it is not part of `@kanzo-tech/ai`
|
|
33
33
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type LanguageModel } from "ai";
|
|
2
|
-
export interface
|
|
2
|
+
export interface GatewaySettings {
|
|
3
3
|
/**
|
|
4
4
|
* Where the gateway's OpenAI-compatible API is, as the browser reaches it. Behind a BFF that is
|
|
5
5
|
* the host's own proxy — keasy's is `/api/v1/ai` — because the key that opens the gateway must
|
|
@@ -12,9 +12,9 @@ export interface KanzoSettings {
|
|
|
12
12
|
fetch?: typeof globalThis.fetch;
|
|
13
13
|
}
|
|
14
14
|
/** A model behind the gateway, by alias. */
|
|
15
|
-
export type
|
|
15
|
+
export type Gateway = (alias: string) => LanguageModel;
|
|
16
16
|
/**
|
|
17
|
-
* The one door to a model: name an **alias** (`
|
|
17
|
+
* The one door to a model: name an **alias** (`chat`, `complete`), never a provider.
|
|
18
18
|
* Which upstream answers it is the gateway's configuration, so a host's code is the same in dev,
|
|
19
19
|
* where a local model answers, and in prod.
|
|
20
20
|
*
|
|
@@ -28,5 +28,5 @@ export type Kanzo = (alias: string) => LanguageModel;
|
|
|
28
28
|
* schema rather than prose the caller would parse — the "return ONLY JSON, no fences" prompt and
|
|
29
29
|
* its fence-stripping is what this ends.
|
|
30
30
|
*/
|
|
31
|
-
export declare function
|
|
32
|
-
//# sourceMappingURL=
|
|
31
|
+
export declare function createGateway(settings: GatewaySettings): Gateway;
|
|
32
|
+
//# sourceMappingURL=gateway.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gateway.d.ts","sourceRoot":"","sources":["../src/gateway.ts"],"names":[],"mappings":"AACA,OAAO,EAA8B,KAAK,aAAa,EAAqB,MAAM,IAAI,CAAC;AAEvF,MAAM,WAAW,eAAe;IAC9B;;;;OAIG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB,2EAA2E;IAC3E,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,2EAA2E;IAC3E,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;CACjC;AAED,4CAA4C;AAC5C,MAAM,MAAM,OAAO,GAAG,CAAC,KAAK,EAAE,MAAM,KAAK,aAAa,CAAC;AAEvD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,eAAe,GAAG,OAAO,CAWhE"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
|
|
2
2
|
import { extractReasoningMiddleware, wrapLanguageModel } from "ai";
|
|
3
3
|
/**
|
|
4
|
-
* The one door to a model: name an **alias** (`
|
|
4
|
+
* The one door to a model: name an **alias** (`chat`, `complete`), never a provider.
|
|
5
5
|
* Which upstream answers it is the gateway's configuration, so a host's code is the same in dev,
|
|
6
6
|
* where a local model answers, and in prod.
|
|
7
7
|
*
|
|
@@ -15,9 +15,9 @@ import { extractReasoningMiddleware, wrapLanguageModel } from "ai";
|
|
|
15
15
|
* schema rather than prose the caller would parse — the "return ONLY JSON, no fences" prompt and
|
|
16
16
|
* its fence-stripping is what this ends.
|
|
17
17
|
*/
|
|
18
|
-
export function
|
|
18
|
+
export function createGateway(settings) {
|
|
19
19
|
const provider = createOpenAICompatible({
|
|
20
|
-
name: "
|
|
20
|
+
name: "gateway",
|
|
21
21
|
baseURL: absolute(settings.baseURL),
|
|
22
22
|
headers: settings.headers,
|
|
23
23
|
fetch: settings.fetch,
|
|
@@ -36,4 +36,4 @@ function absolute(baseURL) {
|
|
|
36
36
|
const page = globalThis.location?.href;
|
|
37
37
|
return page ? new URL(baseURL, page).toString().replace(/\/$/, "") : baseURL;
|
|
38
38
|
}
|
|
39
|
-
//# sourceMappingURL=
|
|
39
|
+
//# sourceMappingURL=gateway.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gateway.js","sourceRoot":"","sources":["../src/gateway.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,EAAE,0BAA0B,EAAsB,iBAAiB,EAAE,MAAM,IAAI,CAAC;AAkBvF;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,aAAa,CAAC,QAAyB;IACrD,MAAM,QAAQ,GAAG,sBAAsB,CAAC;QACtC,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC;QACnC,OAAO,EAAE,QAAQ,CAAC,OAAO;QACzB,KAAK,EAAE,QAAQ,CAAC,KAAK;QACrB,YAAY,EAAE,IAAI;QAClB,yBAAyB,EAAE,IAAI;KAChC,CAAC,CAAC;IACH,MAAM,SAAS,GAAG,0BAA0B,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;IACnE,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,iBAAiB,CAAC,EAAE,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC,CAAC;AACzF,CAAC;AAED;;;;GAIG;AACH,SAAS,QAAQ,CAAC,OAAe;IAC/B,MAAM,IAAI,GAAG,UAAU,CAAC,QAAQ,EAAE,IAAI,CAAC;IACvC,OAAO,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;AAC/E,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Same standing as `@kanzo-tech/mosaic`: the third party — here the AI SDK — is a required peer, its
|
|
5
5
|
* surface is re-exported so a host never imports `ai` itself, and what is ours is the one door it
|
|
6
|
-
* does not have. A host reaches a model only through `
|
|
6
|
+
* does not have. A host reaches a model only through `createGateway`, an agent through
|
|
7
7
|
* `ToolLoopAgent`, and a conversation through `@kanzo-tech/ai`'s `useChat`, so one copy of the SDK
|
|
8
8
|
* is the easy outcome.
|
|
9
9
|
*/
|
|
10
10
|
export { DirectChatTransport, Output, ToolLoopAgent, getToolName, isToolUIPart, jsonSchema, stepCountIs, streamText, tool, type ChatStatus, type DynamicToolUIPart, type InferAgentUIMessage, type LanguageModel, type ReasoningUIPart, type ToolUIPart, type UIMessage, } from "ai";
|
|
11
11
|
/** Ours: the one door to a model. */
|
|
12
|
-
export {
|
|
12
|
+
export { createGateway, type Gateway, type GatewaySettings } from "./gateway.js";
|
|
13
13
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EACL,mBAAmB,EACnB,MAAM,EACN,aAAa,EACb,WAAW,EACX,YAAY,EACZ,UAAU,EACV,WAAW,EACX,UAAU,EACV,IAAI,EACJ,KAAK,UAAU,EACf,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACxB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,UAAU,EACf,KAAK,SAAS,GACf,MAAM,IAAI,CAAC;AAEZ,qCAAqC;AACrC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EACL,mBAAmB,EACnB,MAAM,EACN,aAAa,EACb,WAAW,EACX,YAAY,EACZ,UAAU,EACV,WAAW,EACX,UAAU,EACV,IAAI,EACJ,KAAK,UAAU,EACf,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACxB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,UAAU,EACf,KAAK,SAAS,GACf,MAAM,IAAI,CAAC;AAEZ,qCAAqC;AACrC,OAAO,EAAE,aAAa,EAAE,KAAK,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Same standing as `@kanzo-tech/mosaic`: the third party — here the AI SDK — is a required peer, its
|
|
5
5
|
* surface is re-exported so a host never imports `ai` itself, and what is ours is the one door it
|
|
6
|
-
* does not have. A host reaches a model only through `
|
|
6
|
+
* does not have. A host reaches a model only through `createGateway`, an agent through
|
|
7
7
|
* `ToolLoopAgent`, and a conversation through `@kanzo-tech/ai`'s `useChat`, so one copy of the SDK
|
|
8
8
|
* is the easy outcome.
|
|
9
9
|
*/
|
|
10
10
|
export { DirectChatTransport, Output, ToolLoopAgent, getToolName, isToolUIPart, jsonSchema, stepCountIs, streamText, tool, } from "ai";
|
|
11
11
|
/** Ours: the one door to a model. */
|
|
12
|
-
export {
|
|
12
|
+
export { createGateway } from "./gateway.js";
|
|
13
13
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EACL,mBAAmB,EACnB,MAAM,EACN,aAAa,EACb,WAAW,EACX,YAAY,EACZ,UAAU,EACV,WAAW,EACX,UAAU,EACV,IAAI,GAQL,MAAM,IAAI,CAAC;AAEZ,qCAAqC;AACrC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EACL,mBAAmB,EACnB,MAAM,EACN,aAAa,EACb,WAAW,EACX,YAAY,EACZ,UAAU,EACV,WAAW,EACX,UAAU,EACV,IAAI,GAQL,MAAM,IAAI,CAAC;AAEZ,qCAAqC;AACrC,OAAO,EAAE,aAAa,EAAsC,MAAM,cAAc,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kanzo-tech/llm",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "The model conversation, without React — the AI SDK re-exported as one surface, plus `
|
|
3
|
+
"version": "0.18.0",
|
|
4
|
+
"description": "The model conversation, without React — the AI SDK re-exported as one surface, plus `createGateway`, the one door to models behind a AI gateway.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"sideEffects": false,
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
},
|
|
19
19
|
"./package.json": "./package.json"
|
|
20
20
|
},
|
|
21
|
-
"//dependencies": "@ai-sdk/openai-compatible is a dependency, not a peer: it is how `
|
|
21
|
+
"//dependencies": "@ai-sdk/openai-compatible is a dependency, not a peer: it is how `createGateway` speaks to the gateway, and nothing outside this package names it — the same standing @duckdb/duckdb-wasm has in @kanzo-tech/mosaic, behind `engine()`.",
|
|
22
22
|
"//peers": "`ai` is REQUIRED, not optional, and that is the point of this package: there is nothing here without it, and a host installs it once so @kanzo-tech/ai's components and the host's own agent see the same UIMessage, the same ToolLoopAgent and the same transport. Two copies would be two type universes that do not assign to each other.",
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@ai-sdk/openai-compatible": "^3.0.62"
|
package/dist/kanzo.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"kanzo.d.ts","sourceRoot":"","sources":["../src/kanzo.ts"],"names":[],"mappings":"AACA,OAAO,EAA8B,KAAK,aAAa,EAAqB,MAAM,IAAI,CAAC;AAEvF,MAAM,WAAW,aAAa;IAC5B;;;;OAIG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB,2EAA2E;IAC3E,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,2EAA2E;IAC3E,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;CACjC;AAED,4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