@neon/ai-sdk-provider 1.0.1 → 1.1.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 +27 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/lib/neon-anthropic-language-model.d.ts.map +1 -1
- package/dist/lib/neon-capabilities.d.ts.map +1 -1
- package/dist/lib/neon-chat-language-model.d.ts.map +1 -1
- package/dist/lib/neon-chat-options.d.ts.map +1 -1
- package/dist/lib/neon-decision-model.d.ts +102 -0
- package/dist/lib/neon-decision-model.d.ts.map +1 -0
- package/dist/lib/neon-decision-model.js +116 -0
- package/dist/lib/neon-decision-model.js.map +1 -0
- package/dist/lib/neon-embedding-options.d.ts.map +1 -1
- package/dist/lib/neon-gateway-error.d.ts.map +1 -1
- package/dist/lib/neon-harmony-normalize.d.ts.map +1 -1
- package/dist/lib/neon-model-capabilities.d.ts.map +1 -1
- package/dist/lib/neon-openai-tools.d.ts.map +1 -1
- package/dist/lib/neon-responses-language-model.d.ts +1 -1
- package/dist/lib/neon-responses-language-model.d.ts.map +1 -1
- package/dist/lib/neon-responses-options.d.ts.map +1 -1
- package/dist/lib/provider.d.ts +6 -0
- package/dist/lib/provider.d.ts.map +1 -1
- package/dist/lib/provider.js +10 -1
- package/dist/lib/provider.js.map +1 -1
- package/dist/lib/version.d.ts.map +1 -1
- package/dist/package.js +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -130,6 +130,33 @@ const { embeddings } = await embedMany({
|
|
|
130
130
|
|
|
131
131
|
Both models return 1024-dimensional vectors. `qwen3-embedding-0-6b` honors `providerOptions.neon.dimensions` for shorter vectors; `gte-large-en` ignores it. The gateway accepts at most 150 inputs per request, so `embedMany()` splits larger lists into batches of 150. `NeonEmbeddingModelId` autocompletes the known ids; any other string is passed through to the gateway. `textEmbeddingModel()` is a deprecated alias.
|
|
132
132
|
|
|
133
|
+
## Decisions
|
|
134
|
+
|
|
135
|
+
`neon.decisionModel()` calls TypeSafe's System One decision models, such as Jev, on the gateway's `/typesafe/v1/systemone` endpoint with the same base URL and token. It works with AI SDK 7's `experimental_decide` and needs `ai@7.0.133` or newer; earlier 7.0 releases pass the decision state in a different shape.
|
|
136
|
+
|
|
137
|
+
```ts
|
|
138
|
+
import { neon } from "@neon/ai-sdk-provider";
|
|
139
|
+
import { experimental_decide as decide } from "ai";
|
|
140
|
+
|
|
141
|
+
const { answers } = await decide({
|
|
142
|
+
model: neon.decisionModel("typesafeai-jev-1-14-0"),
|
|
143
|
+
state: "I was charged twice this month.",
|
|
144
|
+
questions: {
|
|
145
|
+
billing: {
|
|
146
|
+
type: "boolean",
|
|
147
|
+
instructions: "Is the user asking about billing?",
|
|
148
|
+
criteria: { true: "Billing related", false: "Not billing" },
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
answers.billing; // { type: "boolean", probability: 0.97 }
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
A `boolean` question is sent as a System One `noul` question; `choice` and `score` questions are sent as they are. Probabilities and scores come back rounded to two decimals, and the per-answer `confidence` System One reports for `choice` and `score` is in `providerMetadata.neon.confidence`. State can be text or JSON; file parts throw `UnsupportedFunctionalityError`.
|
|
157
|
+
|
|
158
|
+
System One models are rolling out to the gateway. `GET $NEON_AI_GATEWAY_BASE_URL/v1/models` lists the ones your branch serves, with `dialects: ["systemone"]`. `NeonDecisionModelId` accepts any string.
|
|
159
|
+
|
|
133
160
|
## Image generation
|
|
134
161
|
|
|
135
162
|
Available on OpenAI models via the Responses `image_generation` tool (there is no `generateImage()` image-model endpoint). Use `streamText` — streaming returns the image as a `tool-result` part and avoids the gateway's non-streaming response-size cap and read timeout:
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { NeonAnthropicLanguageModel } from "./lib/neon-anthropic-language-model.js";
|
|
2
2
|
import { NeonChatLanguageModel } from "./lib/neon-chat-language-model.js";
|
|
3
3
|
import { NeonChatModelId, NeonKnownModelId } from "./lib/neon-chat-options.js";
|
|
4
|
+
import { NeonDecisionAnswer, NeonDecisionCallOptions, NeonDecisionModel, NeonDecisionModelId, NeonDecisionQuestion, NeonDecisionResult } from "./lib/neon-decision-model.js";
|
|
4
5
|
import { NeonEmbeddingModelId } from "./lib/neon-embedding-options.js";
|
|
5
6
|
import { NeonModelCapabilities, NeonModelFamily, NeonModelRoute, getNeonModelCapabilities, getNeonModelRoute } from "./lib/neon-model-capabilities.js";
|
|
6
7
|
import { NeonResponsesLanguageModel } from "./lib/neon-responses-language-model.js";
|
|
7
8
|
import { NeonErrorData, NeonProvider, NeonProviderSettings, createNeon, neon } from "./lib/provider.js";
|
|
8
|
-
export { NeonAnthropicLanguageModel, NeonChatLanguageModel, type NeonChatModelId, type NeonEmbeddingModelId, type NeonErrorData, type NeonKnownModelId, type NeonModelCapabilities, type NeonModelFamily, type NeonModelRoute, type NeonProvider, type NeonProviderSettings, NeonResponsesLanguageModel, createNeon, getNeonModelCapabilities, getNeonModelRoute, neon };
|
|
9
|
+
export { NeonAnthropicLanguageModel, NeonChatLanguageModel, type NeonChatModelId, type NeonDecisionAnswer, type NeonDecisionCallOptions, NeonDecisionModel, type NeonDecisionModelId, type NeonDecisionQuestion, type NeonDecisionResult, type NeonEmbeddingModelId, type NeonErrorData, type NeonKnownModelId, type NeonModelCapabilities, type NeonModelFamily, type NeonModelRoute, type NeonProvider, type NeonProviderSettings, NeonResponsesLanguageModel, createNeon, getNeonModelCapabilities, getNeonModelRoute, neon };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { getNeonModelCapabilities, getNeonModelRoute } from "./lib/neon-model-capabilities.js";
|
|
2
2
|
import { NeonAnthropicLanguageModel } from "./lib/neon-anthropic-language-model.js";
|
|
3
3
|
import { NeonChatLanguageModel } from "./lib/neon-chat-language-model.js";
|
|
4
|
+
import { NeonDecisionModel } from "./lib/neon-decision-model.js";
|
|
4
5
|
import { NeonResponsesLanguageModel } from "./lib/neon-responses-language-model.js";
|
|
5
6
|
import { createNeon, neon } from "./lib/provider.js";
|
|
6
|
-
export { NeonAnthropicLanguageModel, NeonChatLanguageModel, NeonResponsesLanguageModel, createNeon, getNeonModelCapabilities, getNeonModelRoute, neon };
|
|
7
|
+
export { NeonAnthropicLanguageModel, NeonChatLanguageModel, NeonDecisionModel, NeonResponsesLanguageModel, createNeon, getNeonModelCapabilities, getNeonModelRoute, neon };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"neon-anthropic-language-model.d.ts","names":[],"sources":["../../src/lib/neon-anthropic-language-model.ts"],"mappings":";;;;;;;AA+BA;AACC;
|
|
1
|
+
{"version":3,"file":"neon-anthropic-language-model.d.ts","names":["AnthropicMessagesLanguageModel","LanguageModelV3","LanguageModelV3CallOptions","LanguageModelV3GenerateResult","LanguageModelV3StreamResult","NeonAnthropicLanguageModel","Promise","AnthropicMessagesLanguageModel","LanguageModelV3","LanguageModelV3CallOptions","LanguageModelV3GenerateResult","LanguageModelV3StreamResult","NeonAnthropicLanguageModel","withGatewayCompat","doGenerate","options","Promise","doStream"],"sources":["../../src/lib/neon-anthropic-language-model.ts"],"mappings":";;;;;;;AA+BA;AACC;AA6BUE;AACCC;AAARG;AASOJ;AACCE;AAARE;AAxCKN;AACGC;AAAe;;;;;;cAFdI,0BAAAA,SACJL,8BAAAA,YACGC;;sBA4BDC,6BACPI,QAAQH;oBASDD,6BACPI,QAAQF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"neon-capabilities.d.ts","names":[],"sources":["../../src/lib/neon-capabilities.ts"],"mappings":";;;;;;AAoBA;AAAqC;
|
|
1
|
+
{"version":3,"file":"neon-capabilities.d.ts","names":["LanguageModelV3CallOptions","LanguageModelV3StreamPart","SharedV3Warning","applyNeonCapabilities","mergeStreamStartWarnings","TransformStream","LanguageModelV3CallOptions","LanguageModelV3StreamPart","SharedV3Warning","applyNeonCapabilities","modelId","options","warnings","mergeStreamStartWarnings","extra","TransformStream"],"sources":["../../src/lib/neon-capabilities.ts"],"mappings":";;;;;;AAoBA;AAAqC;AAE3BA;AACIA,iBAHEG,qBAAAA,CAGFH,OAAAA,EAAAA,MAAAA,EAAAA,OAAAA,EADJA,0BACIA,CAAAA,EAAAA;EAAsCE,OAAAA,EAAtCF,0BAAsCE;EAAeU,QAAA,EAAfV,eAAe,EAAA;AA6GnE,CAAA;AAAwC;AAAQA;AAAiBD;AAAAA,iBAAjDG,wBAAAA,CAAiDH,KAAAA,EAAjBC,eAAiBD,EAAAA,CAAAA,EAAAI,eAAAJ,CAAAA,yBAAAA,EAAAA,yBAAAA,CAAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"neon-chat-language-model.d.ts","names":[],"sources":["../../src/lib/neon-chat-language-model.ts"],"mappings":";;;;;;;AAqBA;AACC;
|
|
1
|
+
{"version":3,"file":"neon-chat-language-model.d.ts","names":["OpenAICompatibleChatLanguageModel","LanguageModelV3","LanguageModelV3CallOptions","LanguageModelV3GenerateResult","LanguageModelV3StreamResult","NeonChatLanguageModel","Promise","OpenAICompatibleChatLanguageModel","LanguageModelV3","LanguageModelV3CallOptions","LanguageModelV3GenerateResult","LanguageModelV3StreamResult","NeonChatLanguageModel","doGenerate","options","Promise","doStream"],"sources":["../../src/lib/neon-chat-language-model.ts"],"mappings":";;;;;;;AAqBA;AACC;AAIUE;AACCC;AAARG;AAYOJ;AACCE;AAARE,cAnBSD,qBAAAA,SACJL,iCAAAA,YACGC,eAiBRK,CAAAA;EAlBKN,UAAAA,CAAAA,OAAAA,EAIEE,0BAJFF,CAAAA,EAKLM,OALKN,CAKGG,6BALHH,CAAAA;EACGC,QAAAA,CAAAA,OAAAA,EAgBDC,0BAhBCD,CAAAA,EAiBRK,OAjBQL,CAiBAG,2BAjBAH,CAAAA;AAAe"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"neon-chat-options.d.ts","names":[],"sources":["../../src/lib/neon-chat-options.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"neon-chat-options.d.ts","names":["NEON_MODELS_DEV_IDS","NeonKnownModelId","NeonChatModelId","NEON_MODELS_DEV_IDS","NeonKnownModelId","NeonChatModelId"],"sources":["../../src/lib/neon-chat-options.ts"],"mappings":";;AAiBaA,cAAAA,mBA0DH,EAAA,SAAA,CAAA,gBAAA,EAAA,kBAAA,EAAA,kBAAA,EAAA,iBAAA,EAAA,iBAAA,EAAA,iBAAA,EAAA,iBAAA,EAAA,iBAAA,EAAA,eAAA,EAAA,iBAAA,EAAA,mBAAA,EAAA,mBAAA,EAAA,iBAAA,EAAA,OAAA,EAAA,SAAA,EAAA,SAAA,EAAA,eAAA,EAAA,SAAA,EAAA,cAAA,EAAA,cAAA,EAAA,SAAA,EAAA,aAAA,EAAA,cAAA,EAAA,aAAA,EAAA,eAAA,EAAA,YAAA,EAAA,YAAA,EAAA,aAAA,EAAA,cAAA,EAAA,aAAA,EAAA,uBAAA,EAAA,gBAAA,EAAA,kBAAA,EAAA,uBAAA,EAAA,kBAAA,EAAA,gBAAA,EAAA,aAAA,EAAA,kBAAA,EAAA,4BAAA,EAAA,6BAAA,EAAA,6BAAA,EAAA,kBAAA,EAAA,SAAA,EAAA,eAAA,EAAA,UAAA,EAAA,SAAA,EAAA,SAAA,CAAA;AAGV;AAOYE,KAPAD,gBAAAA,GAOe,CAAGA,OAPSD,mBAOO,CAAA,CAAA,MAAA,CAAA;;;;;;KAAlCE,eAAAA,GAAkBD"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { APICallError, SharedV3Headers, SharedV3ProviderMetadata, SharedV3Warning } from "@ai-sdk/provider";
|
|
2
|
+
import { FetchFunction, ResponseHandler } from "@ai-sdk/provider-utils";
|
|
3
|
+
|
|
4
|
+
//#region src/lib/neon-decision-model.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A System One decision model id, such as `typesafeai-jev-1-14-0`. Any string is
|
|
8
|
+
* accepted: `GET /v1/models` lists the ids a branch serves, with
|
|
9
|
+
* `dialects: ["systemone"]`.
|
|
10
|
+
*/
|
|
11
|
+
type NeonDecisionModelId = string;
|
|
12
|
+
type NeonDecisionInput = string | Readonly<Record<string, unknown>> | readonly unknown[];
|
|
13
|
+
type NeonDecisionQuestion = {
|
|
14
|
+
readonly type: "choice";
|
|
15
|
+
readonly instructions: NeonDecisionInput;
|
|
16
|
+
readonly criteria: Readonly<Record<string, NeonDecisionInput | null>>;
|
|
17
|
+
} | {
|
|
18
|
+
readonly type: "score";
|
|
19
|
+
readonly instructions: NeonDecisionInput;
|
|
20
|
+
readonly criteria: readonly (NeonDecisionInput | null)[];
|
|
21
|
+
} | {
|
|
22
|
+
readonly type: "boolean";
|
|
23
|
+
readonly instructions: NeonDecisionInput;
|
|
24
|
+
readonly criteria?: {
|
|
25
|
+
readonly true?: NeonDecisionInput | null;
|
|
26
|
+
readonly false?: NeonDecisionInput | null;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
type NeonDecisionStatePart = {
|
|
30
|
+
type: "text";
|
|
31
|
+
text: string;
|
|
32
|
+
} | {
|
|
33
|
+
type: "file";
|
|
34
|
+
mediaType: string;
|
|
35
|
+
data: unknown;
|
|
36
|
+
} | {
|
|
37
|
+
type: "json";
|
|
38
|
+
value: unknown;
|
|
39
|
+
};
|
|
40
|
+
interface NeonDecisionCallOptions {
|
|
41
|
+
state: readonly NeonDecisionStatePart[];
|
|
42
|
+
questions: Readonly<Record<string, NeonDecisionQuestion>>;
|
|
43
|
+
abortSignal?: AbortSignal;
|
|
44
|
+
headers?: SharedV3Headers;
|
|
45
|
+
}
|
|
46
|
+
type NeonDecisionAnswer = {
|
|
47
|
+
type: "choice";
|
|
48
|
+
choice: string;
|
|
49
|
+
probabilities?: Record<string, number>;
|
|
50
|
+
} | {
|
|
51
|
+
type: "score";
|
|
52
|
+
score: number;
|
|
53
|
+
probabilities?: Record<string, number>;
|
|
54
|
+
} | {
|
|
55
|
+
type: "boolean";
|
|
56
|
+
probability: number;
|
|
57
|
+
} | {
|
|
58
|
+
type: "refusal";
|
|
59
|
+
};
|
|
60
|
+
interface NeonDecisionResult {
|
|
61
|
+
answers: Record<string, NeonDecisionAnswer>;
|
|
62
|
+
rounding?: {
|
|
63
|
+
probabilityDecimals?: number;
|
|
64
|
+
scoreDecimals?: number;
|
|
65
|
+
};
|
|
66
|
+
usage?: {
|
|
67
|
+
inputTokens?: number;
|
|
68
|
+
outputTokens?: number;
|
|
69
|
+
};
|
|
70
|
+
warnings: SharedV3Warning[];
|
|
71
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
|
72
|
+
response?: {
|
|
73
|
+
modelId?: string;
|
|
74
|
+
headers?: SharedV3Headers;
|
|
75
|
+
body?: unknown;
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
interface NeonDecisionModelConfig {
|
|
79
|
+
provider: string;
|
|
80
|
+
url: () => string;
|
|
81
|
+
headers: () => Record<string, string | undefined>;
|
|
82
|
+
fetch?: FetchFunction;
|
|
83
|
+
failedResponseHandler: ResponseHandler<APICallError>;
|
|
84
|
+
}
|
|
85
|
+
/** TypeSafe's System One API, served by the gateway at `/typesafe/v1/systemone`. */
|
|
86
|
+
declare class NeonDecisionModel {
|
|
87
|
+
readonly specificationVersion = "v4";
|
|
88
|
+
readonly supportedQuestionTypes: readonly ["choice", "score", "boolean"];
|
|
89
|
+
readonly modelId: NeonDecisionModelId;
|
|
90
|
+
private readonly config;
|
|
91
|
+
constructor(modelId: NeonDecisionModelId, config: NeonDecisionModelConfig);
|
|
92
|
+
get provider(): string;
|
|
93
|
+
doDecide({
|
|
94
|
+
state,
|
|
95
|
+
questions,
|
|
96
|
+
abortSignal,
|
|
97
|
+
headers
|
|
98
|
+
}: NeonDecisionCallOptions): Promise<NeonDecisionResult>;
|
|
99
|
+
}
|
|
100
|
+
//#endregion
|
|
101
|
+
export { NeonDecisionAnswer, NeonDecisionCallOptions, NeonDecisionModel, NeonDecisionModelConfig, NeonDecisionModelId, NeonDecisionQuestion, NeonDecisionResult };
|
|
102
|
+
//# sourceMappingURL=neon-decision-model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"neon-decision-model.d.ts","names":["APICallError","SharedV3Headers","SharedV3ProviderMetadata","SharedV3Warning","FetchFunction","ResponseHandler","NeonDecisionModelId","NeonDecisionInput","Record","Readonly","NeonDecisionQuestion","NeonDecisionStatePart","NeonDecisionCallOptions","AbortSignal","NeonDecisionAnswer","NeonDecisionResult","NeonDecisionModelConfig","NeonDecisionModel","state","questions","abortSignal","headers","Promise","APICallError","SharedV3Headers","SharedV3ProviderMetadata","SharedV3Warning","FetchFunction","ResponseHandler","NeonDecisionModelId","NeonDecisionInput","Readonly","Record","NeonDecisionQuestion","type","instructions","criteria","true","false","NeonDecisionStatePart","text","mediaType","data","value","NeonDecisionCallOptions","state","questions","abortSignal","AbortSignal","headers","NeonDecisionAnswer","choice","probabilities","score","probability","NeonDecisionResult","answers","rounding","probabilityDecimals","scoreDecimals","usage","inputTokens","outputTokens","warnings","providerMetadata","response","modelId","body","NeonDecisionModelConfig","provider","url","fetch","failedResponseHandler","NeonDecisionModel","specificationVersion","supportedQuestionTypes","config","constructor","doDecide","Promise"],"sources":["../../src/lib/neon-decision-model.ts"],"mappings":";;;;;;;AAqBA;AAAyC;AAMnB;AAEVQ,KARAF,mBAAAA,GAQAE,MAAAA;AAATC,KAFEF,iBAAAA,GAEFE,MAAAA,GAAAA,QAAAA,CAASD,MAATC,CAAAA,MAAAA,EAAAA,OAAAA,CAAAA,CAAAA,GAAAA,SAAAA,OAAAA,EAAAA;AAAQ,KAGCC,oBAAAA,GAHD;EAGCA,SAAAA,IAAAA,EAAAA,QAAoB;EAAA,SAAAyB,YAAA,EAGN5B,iBAHM;EAGNA,SAAAA,QAAAA,EACJE,QADIF,CAEtBC,MAFsBD,CAAAA,MAAAA,EAEPA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AC+BJ,aAAAA,CAAAA,EAlBWQ,MAkBXR,CAAAA,MAAAA,EAAAA,MAAAA,CAAAA;AAAhBK,CAAAA,GAAAA;EAAe6B,IAAA,EAAA,SAAA;EAoC1BjB,WAAAA,EAAAA,MAAAA;AAAiB,CAAA,GAAA;EAGXX,IAAAA,EAAAA,SAAAA;AAGGA,CAAAA;AAA6BU,UAxDlCD,kBAAAA,CAwDkCC;EAUjDE,OAAAA,EAjEQV,MAiERU,CAAAA,MAAAA,EAjEuBJ,kBAiEvBI,CAAAA;EACAC,QAAAA,CAAAA,EAAAA;IACAC,mBAAAA,CAAAA,EAAAA,MAAAA;IACAC,aAAAA,CAAAA,EAAAA,MAAAA;EACET,CAAAA;EAAkCG,KAAAA,CAAAA,EAAAA;IAARO,WAAAA,CAAAA,EAAAA,MAAAA;IAAOwC,YAAA,CAAA,EAAA,MAAA;;YAlE1B3D;qBACSD;;;cACsBD;;;;UAGzBe,uBAAAA;;;iBAGDR;UACPJ;yBACeC,gBAAgBL;;;cAoC3BiB,iBAAAA;;;oBAGMX;;uBAGGA,6BAA6BU;;;;;;;KAc/CJ,0BAA0BU,QAAQP"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { UnsupportedFunctionalityError } from "@ai-sdk/provider";
|
|
2
|
+
import { combineHeaders, createJsonResponseHandler, postJsonToApi } from "@ai-sdk/provider-utils";
|
|
3
|
+
import { z } from "zod/v4";
|
|
4
|
+
//#region src/lib/neon-decision-model.ts
|
|
5
|
+
const systemOneResponseSchema = z.object({
|
|
6
|
+
model: z.string().nullish(),
|
|
7
|
+
answers: z.record(z.string(), z.discriminatedUnion("type", [
|
|
8
|
+
z.object({
|
|
9
|
+
type: z.literal("choice"),
|
|
10
|
+
choice: z.string(),
|
|
11
|
+
probabilities: z.record(z.string(), z.number()),
|
|
12
|
+
confidence: z.number().nullish()
|
|
13
|
+
}),
|
|
14
|
+
z.object({
|
|
15
|
+
type: z.literal("score"),
|
|
16
|
+
score: z.number(),
|
|
17
|
+
probabilities: z.record(z.string(), z.number()),
|
|
18
|
+
confidence: z.number().nullish()
|
|
19
|
+
}),
|
|
20
|
+
z.object({
|
|
21
|
+
type: z.literal("noul"),
|
|
22
|
+
noul: z.number()
|
|
23
|
+
})
|
|
24
|
+
])),
|
|
25
|
+
usage: z.object({
|
|
26
|
+
input_tokens: z.number().nullish(),
|
|
27
|
+
output_tokens: z.number().nullish()
|
|
28
|
+
}).nullish()
|
|
29
|
+
});
|
|
30
|
+
/** TypeSafe's System One API, served by the gateway at `/typesafe/v1/systemone`. */
|
|
31
|
+
var NeonDecisionModel = class {
|
|
32
|
+
specificationVersion = "v4";
|
|
33
|
+
supportedQuestionTypes = [
|
|
34
|
+
"choice",
|
|
35
|
+
"score",
|
|
36
|
+
"boolean"
|
|
37
|
+
];
|
|
38
|
+
modelId;
|
|
39
|
+
config;
|
|
40
|
+
constructor(modelId, config) {
|
|
41
|
+
this.modelId = modelId;
|
|
42
|
+
this.config = config;
|
|
43
|
+
}
|
|
44
|
+
get provider() {
|
|
45
|
+
return this.config.provider;
|
|
46
|
+
}
|
|
47
|
+
async doDecide({ state, questions, abortSignal, headers }) {
|
|
48
|
+
const { value: response, rawValue, responseHeaders } = await postJsonToApi({
|
|
49
|
+
url: this.config.url(),
|
|
50
|
+
headers: combineHeaders(this.config.headers(), headers),
|
|
51
|
+
body: {
|
|
52
|
+
model: this.modelId,
|
|
53
|
+
state: toSystemOneState(state),
|
|
54
|
+
questions: Object.fromEntries(Object.entries(questions).map(([id, question]) => [id, question.type === "boolean" ? {
|
|
55
|
+
...question,
|
|
56
|
+
type: "noul"
|
|
57
|
+
} : question]))
|
|
58
|
+
},
|
|
59
|
+
abortSignal,
|
|
60
|
+
fetch: this.config.fetch,
|
|
61
|
+
failedResponseHandler: this.config.failedResponseHandler,
|
|
62
|
+
successfulResponseHandler: createJsonResponseHandler(systemOneResponseSchema)
|
|
63
|
+
});
|
|
64
|
+
const confidence = {};
|
|
65
|
+
for (const [id, answer] of Object.entries(response.answers)) if (answer.type !== "noul" && answer.confidence != null) confidence[id] = answer.confidence;
|
|
66
|
+
return {
|
|
67
|
+
answers: Object.fromEntries(Object.entries(response.answers).map(([id, answer]) => [id, toDecisionAnswer(answer)])),
|
|
68
|
+
usage: {
|
|
69
|
+
inputTokens: response.usage?.input_tokens ?? void 0,
|
|
70
|
+
outputTokens: response.usage?.output_tokens ?? void 0
|
|
71
|
+
},
|
|
72
|
+
rounding: {
|
|
73
|
+
probabilityDecimals: 2,
|
|
74
|
+
scoreDecimals: 2
|
|
75
|
+
},
|
|
76
|
+
warnings: [],
|
|
77
|
+
providerMetadata: { neon: { confidence } },
|
|
78
|
+
response: {
|
|
79
|
+
modelId: response.model ?? this.modelId,
|
|
80
|
+
headers: responseHeaders,
|
|
81
|
+
body: rawValue
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
function toSystemOneState(state) {
|
|
87
|
+
if (!Array.isArray(state)) throw new UnsupportedFunctionalityError({ functionality: "decision state from ai versions before 7.0.133; upgrade ai to 7.0.133 or newer" });
|
|
88
|
+
const [only] = state;
|
|
89
|
+
if (state.length === 1 && only.type === "json") return only.value;
|
|
90
|
+
return state.map((part) => {
|
|
91
|
+
if (part.type === "file") throw new UnsupportedFunctionalityError({ functionality: "Neon AI Gateway decision file input" });
|
|
92
|
+
return part.type === "text" ? part.text : JSON.stringify(part.value);
|
|
93
|
+
}).join("\n");
|
|
94
|
+
}
|
|
95
|
+
function toDecisionAnswer(answer) {
|
|
96
|
+
switch (answer.type) {
|
|
97
|
+
case "noul": return {
|
|
98
|
+
type: "boolean",
|
|
99
|
+
probability: answer.noul
|
|
100
|
+
};
|
|
101
|
+
case "choice": return {
|
|
102
|
+
type: "choice",
|
|
103
|
+
choice: answer.choice,
|
|
104
|
+
probabilities: answer.probabilities
|
|
105
|
+
};
|
|
106
|
+
case "score": return {
|
|
107
|
+
type: "score",
|
|
108
|
+
score: answer.score,
|
|
109
|
+
probabilities: answer.probabilities
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
//#endregion
|
|
114
|
+
export { NeonDecisionModel };
|
|
115
|
+
|
|
116
|
+
//# sourceMappingURL=neon-decision-model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"neon-decision-model.js","names":[],"sources":["../../src/lib/neon-decision-model.ts"],"sourcesContent":["import {\n\ttype APICallError,\n\ttype SharedV3Headers,\n\ttype SharedV3ProviderMetadata,\n\ttype SharedV3Warning,\n\tUnsupportedFunctionalityError,\n} from \"@ai-sdk/provider\";\nimport {\n\tcombineHeaders,\n\tcreateJsonResponseHandler,\n\ttype FetchFunction,\n\tpostJsonToApi,\n\ttype ResponseHandler,\n} from \"@ai-sdk/provider-utils\";\nimport { z } from \"zod/v4\";\n\n/**\n * A System One decision model id, such as `typesafeai-jev-1-14-0`. Any string is\n * accepted: `GET /v1/models` lists the ids a branch serves, with\n * `dialects: [\"systemone\"]`.\n */\nexport type NeonDecisionModelId = string;\n\n// The AI SDK 7 decision contract (`Experimental_DecisionModelV4` in\n// `@ai-sdk/provider@4`), written out structurally: every v4 package requires\n// Node 22, while this package supports AI SDK 6 on Node 20. Inputs are only\n// forwarded, so they are typed as wide as v4's readonly JSON values.\ntype NeonDecisionInput =\n\t| string\n\t| Readonly<Record<string, unknown>>\n\t| readonly unknown[];\n\nexport type NeonDecisionQuestion =\n\t| {\n\t\t\treadonly type: \"choice\";\n\t\t\treadonly instructions: NeonDecisionInput;\n\t\t\treadonly criteria: Readonly<\n\t\t\t\tRecord<string, NeonDecisionInput | null>\n\t\t\t>;\n\t }\n\t| {\n\t\t\treadonly type: \"score\";\n\t\t\treadonly instructions: NeonDecisionInput;\n\t\t\treadonly criteria: readonly (NeonDecisionInput | null)[];\n\t }\n\t| {\n\t\t\treadonly type: \"boolean\";\n\t\t\treadonly instructions: NeonDecisionInput;\n\t\t\treadonly criteria?: {\n\t\t\t\treadonly true?: NeonDecisionInput | null;\n\t\t\t\treadonly false?: NeonDecisionInput | null;\n\t\t\t};\n\t };\n\ntype NeonDecisionStatePart =\n\t| { type: \"text\"; text: string }\n\t| { type: \"file\"; mediaType: string; data: unknown }\n\t| { type: \"json\"; value: unknown };\n\nexport interface NeonDecisionCallOptions {\n\tstate: readonly NeonDecisionStatePart[];\n\tquestions: Readonly<Record<string, NeonDecisionQuestion>>;\n\tabortSignal?: AbortSignal;\n\theaders?: SharedV3Headers;\n}\n\nexport type NeonDecisionAnswer =\n\t| { type: \"choice\"; choice: string; probabilities?: Record<string, number> }\n\t| { type: \"score\"; score: number; probabilities?: Record<string, number> }\n\t| { type: \"boolean\"; probability: number }\n\t| { type: \"refusal\" };\n\nexport interface NeonDecisionResult {\n\tanswers: Record<string, NeonDecisionAnswer>;\n\trounding?: { probabilityDecimals?: number; scoreDecimals?: number };\n\tusage?: { inputTokens?: number; outputTokens?: number };\n\twarnings: SharedV3Warning[];\n\tproviderMetadata?: SharedV3ProviderMetadata;\n\tresponse?: { modelId?: string; headers?: SharedV3Headers; body?: unknown };\n}\n\nexport interface NeonDecisionModelConfig {\n\tprovider: string;\n\turl: () => string;\n\theaders: () => Record<string, string | undefined>;\n\tfetch?: FetchFunction;\n\tfailedResponseHandler: ResponseHandler<APICallError>;\n}\n\nconst systemOneResponseSchema = z.object({\n\tmodel: z.string().nullish(),\n\tanswers: z.record(\n\t\tz.string(),\n\t\tz.discriminatedUnion(\"type\", [\n\t\t\tz.object({\n\t\t\t\ttype: z.literal(\"choice\"),\n\t\t\t\tchoice: z.string(),\n\t\t\t\tprobabilities: z.record(z.string(), z.number()),\n\t\t\t\tconfidence: z.number().nullish(),\n\t\t\t}),\n\t\t\tz.object({\n\t\t\t\ttype: z.literal(\"score\"),\n\t\t\t\tscore: z.number(),\n\t\t\t\tprobabilities: z.record(z.string(), z.number()),\n\t\t\t\tconfidence: z.number().nullish(),\n\t\t\t}),\n\t\t\tz.object({ type: z.literal(\"noul\"), noul: z.number() }),\n\t\t]),\n\t),\n\tusage: z\n\t\t.object({\n\t\t\tinput_tokens: z.number().nullish(),\n\t\t\toutput_tokens: z.number().nullish(),\n\t\t})\n\t\t.nullish(),\n});\n\ntype SystemOneAnswer = z.infer<\n\ttypeof systemOneResponseSchema\n>[\"answers\"][string];\n\n/** TypeSafe's System One API, served by the gateway at `/typesafe/v1/systemone`. */\nexport class NeonDecisionModel {\n\treadonly specificationVersion = \"v4\";\n\treadonly supportedQuestionTypes = [\"choice\", \"score\", \"boolean\"] as const;\n\treadonly modelId: NeonDecisionModelId;\n\tprivate readonly config: NeonDecisionModelConfig;\n\n\tconstructor(modelId: NeonDecisionModelId, config: NeonDecisionModelConfig) {\n\t\tthis.modelId = modelId;\n\t\tthis.config = config;\n\t}\n\n\tget provider(): string {\n\t\treturn this.config.provider;\n\t}\n\n\tasync doDecide({\n\t\tstate,\n\t\tquestions,\n\t\tabortSignal,\n\t\theaders,\n\t}: NeonDecisionCallOptions): Promise<NeonDecisionResult> {\n\t\tconst {\n\t\t\tvalue: response,\n\t\t\trawValue,\n\t\t\tresponseHeaders,\n\t\t} = await postJsonToApi({\n\t\t\turl: this.config.url(),\n\t\t\theaders: combineHeaders(this.config.headers(), headers),\n\t\t\tbody: {\n\t\t\t\tmodel: this.modelId,\n\t\t\t\tstate: toSystemOneState(state),\n\t\t\t\tquestions: Object.fromEntries(\n\t\t\t\t\tObject.entries(questions).map(([id, question]) => [\n\t\t\t\t\t\tid,\n\t\t\t\t\t\tquestion.type === \"boolean\"\n\t\t\t\t\t\t\t? { ...question, type: \"noul\" }\n\t\t\t\t\t\t\t: question,\n\t\t\t\t\t]),\n\t\t\t\t),\n\t\t\t},\n\t\t\tabortSignal,\n\t\t\tfetch: this.config.fetch,\n\t\t\tfailedResponseHandler: this.config.failedResponseHandler,\n\t\t\tsuccessfulResponseHandler: createJsonResponseHandler(\n\t\t\t\tsystemOneResponseSchema,\n\t\t\t),\n\t\t});\n\n\t\tconst confidence: Record<string, number> = {};\n\t\tfor (const [id, answer] of Object.entries(response.answers)) {\n\t\t\tif (answer.type !== \"noul\" && answer.confidence != null) {\n\t\t\t\tconfidence[id] = answer.confidence;\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tanswers: Object.fromEntries(\n\t\t\t\tObject.entries(response.answers).map(([id, answer]) => [\n\t\t\t\t\tid,\n\t\t\t\t\ttoDecisionAnswer(answer),\n\t\t\t\t]),\n\t\t\t),\n\t\t\tusage: {\n\t\t\t\tinputTokens: response.usage?.input_tokens ?? undefined,\n\t\t\t\toutputTokens: response.usage?.output_tokens ?? undefined,\n\t\t\t},\n\t\t\t// System One reports probabilities and scores to two decimals.\n\t\t\trounding: { probabilityDecimals: 2, scoreDecimals: 2 },\n\t\t\twarnings: [],\n\t\t\tproviderMetadata: { neon: { confidence } },\n\t\t\tresponse: {\n\t\t\t\tmodelId: response.model ?? this.modelId,\n\t\t\t\theaders: responseHeaders,\n\t\t\t\tbody: rawValue,\n\t\t\t},\n\t\t};\n\t}\n}\n\n// One JSON part goes as the JSON value itself; anything else is flattened into\n// the single string System One accepts.\nfunction toSystemOneState(state: readonly NeonDecisionStatePart[]): unknown {\n\t// ai@7.0.130-7.0.132 pass the caller's raw state instead of parts.\n\tif (!Array.isArray(state)) {\n\t\tthrow new UnsupportedFunctionalityError({\n\t\t\tfunctionality:\n\t\t\t\t\"decision state from ai versions before 7.0.133; upgrade ai to 7.0.133 or newer\",\n\t\t});\n\t}\n\tconst [only] = state;\n\tif (state.length === 1 && only.type === \"json\") {\n\t\treturn only.value;\n\t}\n\treturn state\n\t\t.map((part) => {\n\t\t\tif (part.type === \"file\") {\n\t\t\t\tthrow new UnsupportedFunctionalityError({\n\t\t\t\t\tfunctionality: \"Neon AI Gateway decision file input\",\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn part.type === \"text\"\n\t\t\t\t? part.text\n\t\t\t\t: JSON.stringify(part.value);\n\t\t})\n\t\t.join(\"\\n\");\n}\n\nfunction toDecisionAnswer(answer: SystemOneAnswer): NeonDecisionAnswer {\n\tswitch (answer.type) {\n\t\tcase \"noul\":\n\t\t\treturn { type: \"boolean\", probability: answer.noul };\n\t\tcase \"choice\":\n\t\t\treturn {\n\t\t\t\ttype: \"choice\",\n\t\t\t\tchoice: answer.choice,\n\t\t\t\tprobabilities: answer.probabilities,\n\t\t\t};\n\t\tcase \"score\":\n\t\t\treturn {\n\t\t\t\ttype: \"score\",\n\t\t\t\tscore: answer.score,\n\t\t\t\tprobabilities: answer.probabilities,\n\t\t\t};\n\t}\n}\n"],"mappings":";;;;AAyFA,MAAM,0BAA0B,EAAE,OAAO;CACxC,OAAO,EAAE,OAAO,CAAC,CAAC,QAAQ;CAC1B,SAAS,EAAE,OACV,EAAE,OAAO,GACT,EAAE,mBAAmB,QAAQ;EAC5B,EAAE,OAAO;GACR,MAAM,EAAE,QAAQ,QAAQ;GACxB,QAAQ,EAAE,OAAO;GACjB,eAAe,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC;GAC9C,YAAY,EAAE,OAAO,CAAC,CAAC,QAAQ;EAChC,CAAC;EACD,EAAE,OAAO;GACR,MAAM,EAAE,QAAQ,OAAO;GACvB,OAAO,EAAE,OAAO;GAChB,eAAe,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC;GAC9C,YAAY,EAAE,OAAO,CAAC,CAAC,QAAQ;EAChC,CAAC;EACD,EAAE,OAAO;GAAE,MAAM,EAAE,QAAQ,MAAM;GAAG,MAAM,EAAE,OAAO;EAAE,CAAC;CACvD,CAAC,CACF;CACA,OAAO,EACL,OAAO;EACP,cAAc,EAAE,OAAO,CAAC,CAAC,QAAQ;EACjC,eAAe,EAAE,OAAO,CAAC,CAAC,QAAQ;CACnC,CAAC,CAAC,CACD,QAAQ;AACX,CAAC;;AAOD,IAAa,oBAAb,MAA+B;CAC9B,uBAAgC;CAChC,yBAAkC;EAAC;EAAU;EAAS;CAAS;CAC/D;CACA;CAEA,YAAY,S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,GACvB,MAAM,IAAI,8BAA8B,EACvC,eACC,iFACF,CAAC;CAEF,MAAM,CAAC,QAAQ;CACf,IAAI,MAAM,WAAW,KAAK,KAAK,SAAS,QACvC,OAAO,KAAK;CAEb,OAAO,MACL,KAAK,SAAS;EACd,IAAI,KAAK,SAAS,QACjB,MAAM,IAAI,8BAA8B,EACvC,eAAe,sCAChB,CAAC;EAEF,OAAO,KAAK,SAAS,SAClB,KAAK,OACL,KAAK,UAAU,KAAK,KAAK;CAC7B,CAAC,CAAC,CACD,KAAK,IAAI;AACZ;AAEA,SAAS,iBAAiB,QAA6C;CACtE,QAAQ,OAAO,MAAf;EACC,KAAK,QACJ,OAAO;GAAE,MAAM;GAAW,aAAa,OAAO;EAAK;EACpD,KAAK,UACJ,OAAO;GACN,MAAM;GACN,QAAQ,OAAO;GACf,eAAe,OAAO;EACvB;EACD,KAAK,SACJ,OAAO;GACN,MAAM;GACN,OAAO,OAAO;GACd,eAAe,OAAO;EACvB;CACF;AACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"neon-embedding-options.d.ts","names":[],"sources":["../../src/lib/neon-embedding-options.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"neon-embedding-options.d.ts","names":["NEON_EMBEDDING_MODEL_IDS","NeonEmbeddingModelId","NEON_MAX_EMBEDDINGS_PER_CALL","NEON_EMBEDDING_MODEL_IDS","NeonEmbeddingModelId","NEON_MAX_EMBEDDINGS_PER_CALL"],"sources":["../../src/lib/neon-embedding-options.ts"],"mappings":";;AAMaA,cAAAA,wBAGH,EAAA,SAAA,CAAA,cAAA,EAAA,sBAAA,CAAA;AAMV;AAKA;;;KALYC,oBAAAA,WACDD;;cAIEE,4BAAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"neon-gateway-error.d.ts","names":[],"sources":["../../src/lib/neon-gateway-error.ts"],"mappings":";;;;;;AA4CA;AAqHA;AAiBA;AAAsD;
|
|
1
|
+
{"version":3,"file":"neon-gateway-error.d.ts","names":["FetchFunction","GatewayErrorDialect","normalizeGatewayErrorBody","wrapFetchWithGatewayErrorNormalization","FetchFunction","GatewayErrorDialect","normalizeGatewayErrorBody","body","dialect","wrapFetchWithGatewayErrorNormalization","baseFetch"],"sources":["../../src/lib/neon-gateway-error.ts"],"mappings":";;;;;;AA4CA;AAqHA;AAiBA;AAAsD;AAC1CA;AACFC;AACPD;AAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAzIJC,mBAAAA;;;;;iBAqHIC,yBAAAA,yBAEND;;iBAeME,sCAAAA,YACJH,oCACFC,sBACPD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"neon-harmony-normalize.d.ts","names":[],"sources":["../../src/lib/neon-harmony-normalize.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"neon-harmony-normalize.d.ts","names":["FetchFunction","ExtractedHarmony","NormalizeResult","extractHarmonyContent","normalizeCompletionBody","normalizeChunkBody","wrapFetchWithHarmonyNormalization","FetchFunction","ExtractedHarmony","text","reasoning","NormalizeResult","body","changed","extractHarmonyContent","content","normalizeCompletionBody","normalizeChunkBody","wrapFetchWithHarmonyNormalization","baseFetch"],"sources":["../../src/lib/neon-harmony-normalize.ts"],"mappings":";;;UAwCUC,gBAAAA;;EAAAA,SAAAA,EAAAA,MAAAA;AAAgB;AAgB1B;AAkDA,UA5DUC,eAAAA,CA4DME;EAkCAC,IAAAA,EAAAA,OAAAA;EAuGAC,OAAAA,EAAAA,OAAAA;AAAiC;AACpCN;AACVA;AAAa;;;iBA7LAG,qBAAAA,oBAEbF;;;;;iBAgDaG,uBAAAA,iBAAwCF;;;;;iBAkCxCG,kBAAAA,iBAAmCH;;;;;;;;;;iBAuGnCI,iCAAAA,aACHN,gBACVA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"neon-model-capabilities.d.ts","names":[],"sources":["../../src/lib/neon-model-capabilities.ts"],"mappings":";
|
|
1
|
+
{"version":3,"file":"neon-model-capabilities.d.ts","names":["NeonModelFamily","NeonModelRoute","getNeonModelRoute","NeonModelCapabilities","getNeonModelCapabilities","NeonModelFamily","NeonModelRoute","getNeonModelRoute","modelId","NeonModelCapabilities","family","supportsTemperature","supportsTopP","temperatureTopPMutuallyExclusive","supportsPenalties","supportsSeed","supportsStopSequences","supportsReasoningEffort","claudeSamplingUnrecognized","getNeonModelCapabilities"],"sources":["../../src/lib/neon-model-capabilities.ts"],"mappings":";KAAYA,eAAAA;AAAZ;AAiBA;AAEA;AAiBA;AAiGA;;;;;;KApHYC,cAAAA;iBAEIC,iBAAAA,mBAAoCD;UAiBnCE,qBAAAA;UACRH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAgGOI,wBAAAA,mBAEbD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"neon-openai-tools.d.ts","names":[],"sources":["../../src/lib/neon-openai-tools.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"neon-openai-tools.d.ts","names":["openai","openaiProvider","z","NeonImageGenerationArgs","imageGeneration","core","$strip","ZodObject","ZodString","NeonOpenAITools","tools","Omit","neonOpenAITools","openaiProvider","z","openai","NeonImageGenerationArgs","background","inputFidelity","inputImageMask","fileId","imageUrl","model","moderation","outputCompression","outputFormat","partialImages","quality","size","imageGeneration","args","type","id","inputSchema","ZodObject","core","$strip","outputSchema","result","ZodString","isProviderExecuted","NeonOpenAITools","Omit","tools","neonOpenAITools"],"sources":["../../src/lib/neon-openai-tools.ts"],"mappings":";;;;KAGYG,uBAAAA;;EAAAA,aAAAA,CAAAA,EAAAA,KAAAA,GAAAA,MAAuB;EA2BnBC,cAAAA,CAAAA,EAAAA;IAAegB,MAAA,CAAA,EAAA,MAAA;IAAOjB,QAAAA,CAAAA,EAAAA,MAAAA;;;;;;;EAe1BM,OAAAA,CAAAA,EAAAA,MAAAA,GAAe,KAAA,GAAA,QAAA,GAAA,MAAA;EAAAmB,IAAA,CAAA,EAAA,MAAA,GAAA,WAAA,GAAA,WAAA,GAAA,WAAA;AACnB3B,CAAAA;AADsBU;AAILP;AAAe;AAGxC;;;;;iBAtBgBA,eAAAA,QAAsBD;;;;;;;;;;;;;;;;;;;;;;;;KAe1BM,eAAAA,GAAkBE,YACtBV,MAAAA,CAAeS;0BAGEN;;cAGZQ,iBAAiBH"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { OpenAIResponsesLanguageModel } from "@ai-sdk/openai/internal";
|
|
2
1
|
import { LanguageModelV3, LanguageModelV3CallOptions, LanguageModelV3GenerateResult, LanguageModelV3StreamResult } from "@ai-sdk/provider";
|
|
2
|
+
import { OpenAIResponsesLanguageModel } from "@ai-sdk/openai/internal";
|
|
3
3
|
|
|
4
4
|
//#region src/lib/neon-responses-language-model.d.ts
|
|
5
5
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"neon-responses-language-model.d.ts","names":[],"sources":["../../src/lib/neon-responses-language-model.ts"],"mappings":";;;;;;;AAkBA;AACC;
|
|
1
|
+
{"version":3,"file":"neon-responses-language-model.d.ts","names":["OpenAIResponsesLanguageModel","LanguageModelV3","LanguageModelV3CallOptions","LanguageModelV3GenerateResult","LanguageModelV3StreamResult","NeonResponsesLanguageModel","Promise","LanguageModelV3","LanguageModelV3CallOptions","LanguageModelV3GenerateResult","LanguageModelV3StreamResult","OpenAIResponsesLanguageModel","NeonResponsesLanguageModel","doGenerate","options","Promise","doStream"],"sources":["../../src/lib/neon-responses-language-model.ts"],"mappings":";;;;;;;AAkBA;AACC;AAIUE;AACCC;AAARG;AAOOJ;AACCE;AAARE,cAdSD,0BAAAA,SACJL,4BAAAA,YACGC,eAYRK,CAAAA;EAbKN,UAAAA,CAAAA,OAAAA,EAIEE,0BAJFF,CAAAA,EAKLM,OALKN,CAKGG,6BALHH,CAAAA;EACGC,QAAAA,CAAAA,OAAAA,EAWDC,0BAXCD,CAAAA,EAYRK,OAZQL,CAYAG,2BAZAH,CAAAA;AAAe"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"neon-responses-options.d.ts","names":[],"sources":["../../src/lib/neon-responses-options.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"neon-responses-options.d.ts","names":["LanguageModelV3CallOptions","isReasoningModelId","withResponsesGatewayDefaults","LanguageModelV3CallOptions","isReasoningModelId","modelId","withResponsesGatewayDefaults","options"],"sources":["../../src/lib/neon-responses-options.ts"],"mappings":";;;;iBAmCgBC,kBAAAA;AAAhB;AASA;AAA4C;AAElCD;AACPA;AAA0B,iBAHbE,4BAAAA,CAGaG,OAAA,EAAA,MAAA,EAAAE,OAAA,EADnBP,0BACmB,CAAA,EAA1BA,0BAA0B"}
|
package/dist/lib/provider.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { NeonChatModelId } from "./neon-chat-options.js";
|
|
2
|
+
import { NeonDecisionModel, NeonDecisionModelId } from "./neon-decision-model.js";
|
|
2
3
|
import { NeonEmbeddingModelId } from "./neon-embedding-options.js";
|
|
3
4
|
import { neonOpenAITools } from "./neon-openai-tools.js";
|
|
4
5
|
import { EmbeddingModelV3, LanguageModelV3, ProviderV3 } from "@ai-sdk/provider";
|
|
@@ -48,6 +49,11 @@ interface NeonProvider extends ProviderV3 {
|
|
|
48
49
|
embeddingModel(modelId: NeonEmbeddingModelId): EmbeddingModelV3;
|
|
49
50
|
/** @deprecated Use `embeddingModel` instead. */
|
|
50
51
|
textEmbeddingModel(modelId: NeonEmbeddingModelId): EmbeddingModelV3;
|
|
52
|
+
/**
|
|
53
|
+
* Creates a Neon AI Gateway System One decision model for AI SDK 7's
|
|
54
|
+
* `experimental_decide` (`ai@7.0.133` and newer).
|
|
55
|
+
*/
|
|
56
|
+
decisionModel(modelId: NeonDecisionModelId): NeonDecisionModel;
|
|
51
57
|
}
|
|
52
58
|
declare function createNeon(options?: NeonProviderSettings): NeonProvider;
|
|
53
59
|
/** Default Neon provider instance (reads `NEON_AI_GATEWAY_*` env vars). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.d.ts","names":[],"sources":["../../src/lib/provider.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"provider.d.ts","names":["EmbeddingModelV3","LanguageModelV3","ProviderV3","FetchFunction","z","NeonChatModelId","NeonDecisionModel","NeonDecisionModelId","NeonEmbeddingModelId","neonOpenAITools","neonErrorSchema","ZodString","ZodNullable","ZodOptional","ZodUnknown","core","$strip","ZodObject","NeonErrorData","infer","NeonProviderSettings","Record","NeonProvider","createNeon","neon","NeonChatModelId","NeonDecisionModel","NeonDecisionModelId","NeonEmbeddingModelId","neonOpenAITools","EmbeddingModelV3","LanguageModelV3","ProviderV3","FetchFunction","z","neonErrorSchema","ZodObject","error","message","ZodString","type","ZodOptional","ZodNullable","param","ZodUnknown","code","core","$strip","NeonErrorData","infer","NeonProviderSettings","baseURL","apiKey","headers","Record","fetch","NeonProvider","modelId","languageModel","chat","tools","embeddingModel","textEmbeddingModel","decisionModel","createNeon","options","neon"],"sources":["../../src/lib/provider.ts"],"mappings":";;;;;;;;;cAkDMU,iBAAeN,CAAAA,CAAAa;;IAAfP,OAAAA,aAOJ;IAAA8B,IAAA,eAAA,cAAA,YAAA,CAAA,CAAA;;;;GAAApC,CAAAA,CAAAW,IAAAA,CAAAC;KAEUE,aAAAA,GAAgBd,CAAAA,CAAEe,aAAaT;UA4C1BU,oBAAAA;;;;;;;EA9CfhB;AAPmBA;AAAA;AASrB;EAAyBgD,MAAA,CAAA,EAAA,MAAA;EAAkB1C;EAAfN,OAAEe,CAAAA,EA2DnBE,MA3DmBF,CAAAA,MAAAA,EAAAA,MAAAA,CAAAA;EAAK;EA4ClBC,KAAAA,CAAAA,EAkBRjB,aAlBQiB;AAAoB;AAe1BC,UAMMC,YAAAA,SAAqBpB,UAN3BmB,CAAAA;EAGFlB;EAAa,CAAAsD,OAAA,EAKXpD,eALW,CAAA,EAKOJ,eALP;EAGLqB;EAAaoC,aAAA,CAAAD,OAAA,EAKNpD,eALM,CAAA,EAKYJ,eALZ;EAEnBI;EAAkBJ,IAAAA,CAAAA,OAAAA,EAMdI,eANcJ,CAAAA,EAMIA,eANJA;EAGLI;EAAkBJ,KAAAA,EAAAA,OAM3BQ,eAN2BR;EAG3BI;AAAkBJ;AAGlBQ;AAMUD;EAAuBR,cAAAA,CAAAA,OAAAA,EAAvBQ,oBAAuBR,CAAAA,EAAAA,gBAAAA;EAGnBQ;EAAuBR,kBAAAA,CAAAA,OAAAA,EAAvBQ,oBAAuBR,CAAAA,EAAAA,gBAAAA;EAM5BO;AAAsBD;AA1BRJ;AAAU;EA6BhCqB,aAAU,CAAAkC,OAAA,EAHFlD,mBAGE,CAAA,EAHoBD,iBAGpB;AAAA;AAAUc,iBAApBG,UAAAA,CAAoBH,OAAAA,CAAAA,EAAAA,oBAAAA,CAAAA,EAA4BE,YAA5BF;AAA4BE;AAAY,cA0I/DE,IA1I+D,EA0I3DF,YA1I2D"}
|
package/dist/lib/provider.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { getNeonModelRoute } from "./neon-model-capabilities.js";
|
|
2
2
|
import { NeonAnthropicLanguageModel } from "./neon-anthropic-language-model.js";
|
|
3
3
|
import { NeonChatLanguageModel } from "./neon-chat-language-model.js";
|
|
4
|
+
import { NeonDecisionModel } from "./neon-decision-model.js";
|
|
4
5
|
import { NeonResponsesLanguageModel } from "./neon-responses-language-model.js";
|
|
5
6
|
import "./neon-embedding-options.js";
|
|
6
7
|
import { wrapFetchWithGatewayErrorNormalization } from "./neon-gateway-error.js";
|
|
@@ -9,7 +10,7 @@ import { neonOpenAITools } from "./neon-openai-tools.js";
|
|
|
9
10
|
import { VERSION } from "./version.js";
|
|
10
11
|
import { OpenAICompatibleEmbeddingModel } from "@ai-sdk/openai-compatible";
|
|
11
12
|
import { NoSuchModelError } from "@ai-sdk/provider";
|
|
12
|
-
import { generateId, loadApiKey, loadSetting, withUserAgentSuffix, withoutTrailingSlash } from "@ai-sdk/provider-utils";
|
|
13
|
+
import { createJsonErrorResponseHandler, generateId, loadApiKey, loadSetting, withUserAgentSuffix, withoutTrailingSlash } from "@ai-sdk/provider-utils";
|
|
13
14
|
import { z } from "zod/v4";
|
|
14
15
|
//#region src/lib/provider.ts
|
|
15
16
|
/**
|
|
@@ -103,6 +104,13 @@ function createNeon(options = {}) {
|
|
|
103
104
|
errorStructure: neonErrorStructure,
|
|
104
105
|
maxEmbeddingsPerCall: 150
|
|
105
106
|
});
|
|
107
|
+
const createDecisionModel = (modelId) => new NeonDecisionModel(modelId, {
|
|
108
|
+
provider: "neon.decision",
|
|
109
|
+
url: () => `${getHost()}/typesafe/v1/systemone`,
|
|
110
|
+
headers: getHeaders,
|
|
111
|
+
fetch: wrapFetchWithGatewayErrorNormalization(options.fetch, "openai"),
|
|
112
|
+
failedResponseHandler: createJsonErrorResponseHandler(neonErrorStructure)
|
|
113
|
+
});
|
|
106
114
|
const createLanguageModel = (modelId) => {
|
|
107
115
|
switch (getNeonModelRoute(modelId)) {
|
|
108
116
|
case "anthropic": return createAnthropicModel(modelId);
|
|
@@ -117,6 +125,7 @@ function createNeon(options = {}) {
|
|
|
117
125
|
provider.tools = neonOpenAITools;
|
|
118
126
|
provider.embeddingModel = createEmbeddingModel;
|
|
119
127
|
provider.textEmbeddingModel = createEmbeddingModel;
|
|
128
|
+
provider.decisionModel = createDecisionModel;
|
|
120
129
|
provider.imageModel = (modelId) => {
|
|
121
130
|
throw new NoSuchModelError({
|
|
122
131
|
modelId,
|
package/dist/lib/provider.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.js","names":[],"sources":["../../src/lib/provider.ts"],"sourcesContent":["/**\n * Community Vercel AI SDK provider for the Neon AI Gateway.\n *\n * `createNeon()` returns a provider that routes each model to the best gateway\n * endpoint based on its id (Anthropic → native Messages, OpenAI → native\n * Responses incl. Codex, everything else → unified Chat Completions), so a single\n * `neon('claude-...')` call (same base URL + token) reaches the whole catalog.\n * Ids use the canonical Neon (unprefixed) form; the legacy `databricks-` prefix\n * is also accepted. Configure with the branch-scoped `NEON_AI_GATEWAY_BASE_URL` +\n * `NEON_AI_GATEWAY_TOKEN` emitted by `neonctl env pull` / `neon dev`, or pass\n * `baseURL` / `apiKey` explicitly.\n */\nimport {\n\tOpenAICompatibleEmbeddingModel,\n\ttype ProviderErrorStructure,\n} from \"@ai-sdk/openai-compatible\";\nimport {\n\ttype EmbeddingModelV3,\n\ttype LanguageModelV3,\n\tNoSuchModelError,\n\ttype ProviderV3,\n} from \"@ai-sdk/provider\";\nimport {\n\ttype FetchFunction,\n\tgenerateId,\n\tloadApiKey,\n\tloadSetting,\n\twithoutTrailingSlash,\n\twithUserAgentSuffix,\n} from \"@ai-sdk/provider-utils\";\nimport { z } from \"zod/v4\";\nimport { NeonAnthropicLanguageModel } from \"./neon-anthropic-language-model.js\";\nimport { NeonChatLanguageModel } from \"./neon-chat-language-model.js\";\nimport type { NeonChatModelId } from \"./neon-chat-options.js\";\nimport {\n\tNEON_MAX_EMBEDDINGS_PER_CALL,\n\ttype NeonEmbeddingModelId,\n} from \"./neon-embedding-options.js\";\nimport { wrapFetchWithGatewayErrorNormalization } from \"./neon-gateway-error.js\";\nimport { wrapFetchWithHarmonyNormalization } from \"./neon-harmony-normalize.js\";\nimport { getNeonModelRoute } from \"./neon-model-capabilities.js\";\nimport { neonOpenAITools } from \"./neon-openai-tools.js\";\nimport { NeonResponsesLanguageModel } from \"./neon-responses-language-model.js\";\nimport { VERSION } from \"./version.js\";\n\nconst neonErrorSchema = z.object({\n\terror: z.object({\n\t\tmessage: z.string(),\n\t\ttype: z.string().nullish(),\n\t\tparam: z.unknown().nullish(),\n\t\tcode: z.unknown().nullish(),\n\t}),\n});\n\nexport type NeonErrorData = z.infer<typeof neonErrorSchema>;\n\nconst neonErrorStructure: ProviderErrorStructure<NeonErrorData> = {\n\terrorSchema: neonErrorSchema,\n\terrorToMessage: (data) => data.error.message,\n};\n\n/**\n * Recursively remove the JSON Schema `$schema` marker, which some gateway\n * backends (notably Gemini) reject in tool/structured-output schemas. Other\n * backends ignore its absence, so stripping it everywhere is safe.\n */\nfunction stripJsonSchemaMarker(value: unknown): unknown {\n\tif (Array.isArray(value)) {\n\t\treturn value.map(stripJsonSchemaMarker);\n\t}\n\tif (value !== null && typeof value === \"object\") {\n\t\tconst result: Record<string, unknown> = {};\n\t\tfor (const [key, entry] of Object.entries(value)) {\n\t\t\tif (key === \"$schema\") {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tresult[key] = stripJsonSchemaMarker(entry);\n\t\t}\n\t\treturn result;\n\t}\n\treturn value;\n}\n\nfunction transformNeonRequestBody(\n\targs: Record<string, unknown>,\n): Record<string, unknown> {\n\tconst transformed = { ...args };\n\tif (transformed.tools != null) {\n\t\ttransformed.tools = stripJsonSchemaMarker(transformed.tools);\n\t}\n\tif (transformed.response_format != null) {\n\t\ttransformed.response_format = stripJsonSchemaMarker(\n\t\t\ttransformed.response_format,\n\t\t);\n\t}\n\treturn transformed;\n}\n\nexport interface NeonProviderSettings {\n\t/**\n\t * Neon AI Gateway base URL — the branch-scoped host root, e.g.\n\t * `https://<branch-id>-api.ai.<region>.aws.neon.tech`. The gateway paths are\n\t * appended internally. Falls back to the `NEON_AI_GATEWAY_BASE_URL` env var.\n\t */\n\tbaseURL?: string;\n\n\t/**\n\t * Neon AI Gateway platform token (the `nt_live_...` value). Falls back to the\n\t * `NEON_AI_GATEWAY_TOKEN` env var.\n\t */\n\tapiKey?: string;\n\n\t/** Custom headers to include in the requests. */\n\theaders?: Record<string, string>;\n\n\t/** Custom fetch implementation (e.g. for testing or middleware). */\n\tfetch?: FetchFunction;\n}\n\nexport interface NeonProvider extends ProviderV3 {\n\t/** Creates a Neon AI Gateway model for text generation. */\n\t(modelId: NeonChatModelId): LanguageModelV3;\n\n\t/** Creates a Neon AI Gateway model for text generation. */\n\tlanguageModel(modelId: NeonChatModelId): LanguageModelV3;\n\n\t/** Creates a Neon AI Gateway chat model for text generation. */\n\tchat(modelId: NeonChatModelId): LanguageModelV3;\n\n\t/** OpenAI Responses tools (e.g. `imageGeneration`) for OpenAI-routed models. */\n\ttools: typeof neonOpenAITools;\n\n\t/**\n\t * Creates a Neon AI Gateway embedding model for `embed()` and `embedMany()`.\n\t * Provider options go under `providerOptions.neon` (`dimensions`, `user`).\n\t */\n\tembeddingModel(modelId: NeonEmbeddingModelId): EmbeddingModelV3;\n\n\t/** @deprecated Use `embeddingModel` instead. */\n\ttextEmbeddingModel(modelId: NeonEmbeddingModelId): EmbeddingModelV3;\n}\n\nexport function createNeon(options: NeonProviderSettings = {}): NeonProvider {\n\t// Resolved lazily so that `createNeon()` and the default `neon` instance do\n\t// not throw at import time when configuration comes from the environment.\n\tconst getHost = () =>\n\t\twithoutTrailingSlash(\n\t\t\tloadSetting({\n\t\t\t\tsettingValue: options.baseURL,\n\t\t\t\tenvironmentVariableName: \"NEON_AI_GATEWAY_BASE_URL\",\n\t\t\t\tsettingName: \"baseURL\",\n\t\t\t\tdescription: \"Neon AI Gateway base URL\",\n\t\t\t}),\n\t\t);\n\n\tconst getHeaders = (extra?: Record<string, string>) =>\n\t\twithUserAgentSuffix(\n\t\t\t{\n\t\t\t\tAuthorization: `Bearer ${loadApiKey({\n\t\t\t\t\tapiKey: options.apiKey,\n\t\t\t\t\tenvironmentVariableName: \"NEON_AI_GATEWAY_TOKEN\",\n\t\t\t\t\tdescription: \"Neon AI Gateway token\",\n\t\t\t\t})}`,\n\t\t\t\t...extra,\n\t\t\t\t...options.headers,\n\t\t\t},\n\t\t\t`neondatabase/ai-sdk-provider/${VERSION}`,\n\t\t);\n\n\t// Anthropic models -> native Messages API.\n\tconst createAnthropicModel = (modelId: NeonChatModelId) =>\n\t\tnew NeonAnthropicLanguageModel(modelId, {\n\t\t\tprovider: \"neon.anthropic\",\n\t\t\tbaseURL: `${getHost()}/anthropic/v1`,\n\t\t\theaders: () => getHeaders({ \"anthropic-version\": \"2023-06-01\" }),\n\t\t\tfetch: wrapFetchWithGatewayErrorNormalization(\n\t\t\t\toptions.fetch,\n\t\t\t\t\"anthropic\",\n\t\t\t),\n\t\t\tgenerateId,\n\t\t});\n\n\t// OpenAI models (incl. Codex, only served natively) -> Responses API.\n\tconst createOpenAIModel = (modelId: NeonChatModelId) =>\n\t\tnew NeonResponsesLanguageModel(modelId, {\n\t\t\tprovider: \"neon.openai.responses\",\n\t\t\turl: ({ path }) => `${getHost()}/openai/v1${path}`,\n\t\t\theaders: getHeaders,\n\t\t\t// This route returns Databricks error envelopes the OpenAI schema\n\t\t\t// cannot read, which reach the caller as a bare \"Bad Request\".\n\t\t\t// `OpenAIConfig` has no error hook, so the rewrite rides on fetch.\n\t\t\tfetch: wrapFetchWithGatewayErrorNormalization(\n\t\t\t\toptions.fetch,\n\t\t\t\t\"openai\",\n\t\t\t),\n\t\t\tfileIdPrefixes: [\"file-\"],\n\t\t});\n\n\t// Everything else (Gemini, Llama, Qwen, gpt-oss, ...) -> unified Chat\n\t// Completions endpoint. Gemini is here because its native endpoint can't stream.\n\tconst createChatModel = (modelId: NeonChatModelId) =>\n\t\tnew NeonChatLanguageModel(modelId, {\n\t\t\tprovider: \"neon.chat\",\n\t\t\turl: ({ path }) => `${getHost()}/v1${path}`,\n\t\t\theaders: getHeaders,\n\t\t\t// Two wrappers, on disjoint halves of the response: the harmony one\n\t\t\t// rewrites successful gpt-oss bodies and returns early on any error,\n\t\t\t// the error one only touches non-2xx bodies. This route emits the\n\t\t\t// same flat `{ error_code, message }` Databricks envelope as the\n\t\t\t// Responses route (an out-of-range `temperature`, say), which\n\t\t\t// `errorStructure` below cannot read on its own.\n\t\t\t//\n\t\t\t// TODO(#308): Temporary workaround for gpt-oss. The gateway returns a\n\t\t\t// non-compliant \"harmony\" content-array shape; this wrapper normalizes it\n\t\t\t// to the Chat Completions contract and is a transparent pass-through for\n\t\t\t// every compliant response. Remove it (and neon-harmony-normalize.ts) once\n\t\t\t// the gateway returns spec-compliant gpt-oss responses.\n\t\t\tfetch: wrapFetchWithHarmonyNormalization(\n\t\t\t\twrapFetchWithGatewayErrorNormalization(options.fetch, \"openai\"),\n\t\t\t),\n\t\t\terrorStructure: neonErrorStructure,\n\t\t\ttransformRequestBody: transformNeonRequestBody,\n\t\t\tsupportsStructuredOutputs: true,\n\t\t});\n\n\tconst createEmbeddingModel = (modelId: NeonEmbeddingModelId) =>\n\t\tnew OpenAICompatibleEmbeddingModel(modelId, {\n\t\t\tprovider: \"neon.embedding\",\n\t\t\turl: ({ path }) => `${getHost()}/v1${path}`,\n\t\t\theaders: getHeaders,\n\t\t\tfetch: wrapFetchWithGatewayErrorNormalization(\n\t\t\t\toptions.fetch,\n\t\t\t\t\"openai\",\n\t\t\t),\n\t\t\terrorStructure: neonErrorStructure,\n\t\t\tmaxEmbeddingsPerCall: NEON_MAX_EMBEDDINGS_PER_CALL,\n\t\t});\n\n\tconst createLanguageModel = (modelId: NeonChatModelId): LanguageModelV3 => {\n\t\tswitch (getNeonModelRoute(modelId)) {\n\t\t\tcase \"anthropic\":\n\t\t\t\treturn createAnthropicModel(modelId);\n\t\t\tcase \"openai\":\n\t\t\t\treturn createOpenAIModel(modelId);\n\t\t\tdefault:\n\t\t\t\treturn createChatModel(modelId);\n\t\t}\n\t};\n\n\tconst provider = (modelId: NeonChatModelId) => createLanguageModel(modelId);\n\n\tprovider.specificationVersion = \"v3\" as const;\n\tprovider.languageModel = createLanguageModel;\n\tprovider.chat = createLanguageModel;\n\tprovider.tools = neonOpenAITools;\n\n\tprovider.embeddingModel = createEmbeddingModel;\n\tprovider.textEmbeddingModel = createEmbeddingModel;\n\tprovider.imageModel = (modelId: string) => {\n\t\tthrow new NoSuchModelError({ modelId, modelType: \"imageModel\" });\n\t};\n\n\treturn provider;\n}\n\n/** Default Neon provider instance (reads `NEON_AI_GATEWAY_*` env vars). */\nexport const neon = createNeon();\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAwDA,MAAM,qB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["/**\n * Community Vercel AI SDK provider for the Neon AI Gateway.\n *\n * `createNeon()` returns a provider that routes each model to the best gateway\n * endpoint based on its id (Anthropic → native Messages, OpenAI → native\n * Responses incl. Codex, everything else → unified Chat Completions), so a single\n * `neon('claude-...')` call (same base URL + token) reaches the whole catalog.\n * Ids use the canonical Neon (unprefixed) form; the legacy `databricks-` prefix\n * is also accepted. Configure with the branch-scoped `NEON_AI_GATEWAY_BASE_URL` +\n * `NEON_AI_GATEWAY_TOKEN` emitted by `neonctl env pull` / `neon dev`, or pass\n * `baseURL` / `apiKey` explicitly.\n */\nimport {\n\tOpenAICompatibleEmbeddingModel,\n\ttype ProviderErrorStructure,\n} from \"@ai-sdk/openai-compatible\";\nimport {\n\ttype EmbeddingModelV3,\n\ttype LanguageModelV3,\n\tNoSuchModelError,\n\ttype ProviderV3,\n} from \"@ai-sdk/provider\";\nimport {\n\tcreateJsonErrorResponseHandler,\n\ttype FetchFunction,\n\tgenerateId,\n\tloadApiKey,\n\tloadSetting,\n\twithoutTrailingSlash,\n\twithUserAgentSuffix,\n} from \"@ai-sdk/provider-utils\";\nimport { z } from \"zod/v4\";\nimport { NeonAnthropicLanguageModel } from \"./neon-anthropic-language-model.js\";\nimport { NeonChatLanguageModel } from \"./neon-chat-language-model.js\";\nimport type { NeonChatModelId } from \"./neon-chat-options.js\";\nimport {\n\tNeonDecisionModel,\n\ttype NeonDecisionModelId,\n} from \"./neon-decision-model.js\";\nimport {\n\tNEON_MAX_EMBEDDINGS_PER_CALL,\n\ttype NeonEmbeddingModelId,\n} from \"./neon-embedding-options.js\";\nimport { wrapFetchWithGatewayErrorNormalization } from \"./neon-gateway-error.js\";\nimport { wrapFetchWithHarmonyNormalization } from \"./neon-harmony-normalize.js\";\nimport { getNeonModelRoute } from \"./neon-model-capabilities.js\";\nimport { neonOpenAITools } from \"./neon-openai-tools.js\";\nimport { NeonResponsesLanguageModel } from \"./neon-responses-language-model.js\";\nimport { VERSION } from \"./version.js\";\n\nconst neonErrorSchema = z.object({\n\terror: z.object({\n\t\tmessage: z.string(),\n\t\ttype: z.string().nullish(),\n\t\tparam: z.unknown().nullish(),\n\t\tcode: z.unknown().nullish(),\n\t}),\n});\n\nexport type NeonErrorData = z.infer<typeof neonErrorSchema>;\n\nconst neonErrorStructure: ProviderErrorStructure<NeonErrorData> = {\n\terrorSchema: neonErrorSchema,\n\terrorToMessage: (data) => data.error.message,\n};\n\n/**\n * Recursively remove the JSON Schema `$schema` marker, which some gateway\n * backends (notably Gemini) reject in tool/structured-output schemas. Other\n * backends ignore its absence, so stripping it everywhere is safe.\n */\nfunction stripJsonSchemaMarker(value: unknown): unknown {\n\tif (Array.isArray(value)) {\n\t\treturn value.map(stripJsonSchemaMarker);\n\t}\n\tif (value !== null && typeof value === \"object\") {\n\t\tconst result: Record<string, unknown> = {};\n\t\tfor (const [key, entry] of Object.entries(value)) {\n\t\t\tif (key === \"$schema\") {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tresult[key] = stripJsonSchemaMarker(entry);\n\t\t}\n\t\treturn result;\n\t}\n\treturn value;\n}\n\nfunction transformNeonRequestBody(\n\targs: Record<string, unknown>,\n): Record<string, unknown> {\n\tconst transformed = { ...args };\n\tif (transformed.tools != null) {\n\t\ttransformed.tools = stripJsonSchemaMarker(transformed.tools);\n\t}\n\tif (transformed.response_format != null) {\n\t\ttransformed.response_format = stripJsonSchemaMarker(\n\t\t\ttransformed.response_format,\n\t\t);\n\t}\n\treturn transformed;\n}\n\nexport interface NeonProviderSettings {\n\t/**\n\t * Neon AI Gateway base URL — the branch-scoped host root, e.g.\n\t * `https://<branch-id>-api.ai.<region>.aws.neon.tech`. The gateway paths are\n\t * appended internally. Falls back to the `NEON_AI_GATEWAY_BASE_URL` env var.\n\t */\n\tbaseURL?: string;\n\n\t/**\n\t * Neon AI Gateway platform token (the `nt_live_...` value). Falls back to the\n\t * `NEON_AI_GATEWAY_TOKEN` env var.\n\t */\n\tapiKey?: string;\n\n\t/** Custom headers to include in the requests. */\n\theaders?: Record<string, string>;\n\n\t/** Custom fetch implementation (e.g. for testing or middleware). */\n\tfetch?: FetchFunction;\n}\n\nexport interface NeonProvider extends ProviderV3 {\n\t/** Creates a Neon AI Gateway model for text generation. */\n\t(modelId: NeonChatModelId): LanguageModelV3;\n\n\t/** Creates a Neon AI Gateway model for text generation. */\n\tlanguageModel(modelId: NeonChatModelId): LanguageModelV3;\n\n\t/** Creates a Neon AI Gateway chat model for text generation. */\n\tchat(modelId: NeonChatModelId): LanguageModelV3;\n\n\t/** OpenAI Responses tools (e.g. `imageGeneration`) for OpenAI-routed models. */\n\ttools: typeof neonOpenAITools;\n\n\t/**\n\t * Creates a Neon AI Gateway embedding model for `embed()` and `embedMany()`.\n\t * Provider options go under `providerOptions.neon` (`dimensions`, `user`).\n\t */\n\tembeddingModel(modelId: NeonEmbeddingModelId): EmbeddingModelV3;\n\n\t/** @deprecated Use `embeddingModel` instead. */\n\ttextEmbeddingModel(modelId: NeonEmbeddingModelId): EmbeddingModelV3;\n\n\t/**\n\t * Creates a Neon AI Gateway System One decision model for AI SDK 7's\n\t * `experimental_decide` (`ai@7.0.133` and newer).\n\t */\n\tdecisionModel(modelId: NeonDecisionModelId): NeonDecisionModel;\n}\n\nexport function createNeon(options: NeonProviderSettings = {}): NeonProvider {\n\t// Resolved lazily so that `createNeon()` and the default `neon` instance do\n\t// not throw at import time when configuration comes from the environment.\n\tconst getHost = () =>\n\t\twithoutTrailingSlash(\n\t\t\tloadSetting({\n\t\t\t\tsettingValue: options.baseURL,\n\t\t\t\tenvironmentVariableName: \"NEON_AI_GATEWAY_BASE_URL\",\n\t\t\t\tsettingName: \"baseURL\",\n\t\t\t\tdescription: \"Neon AI Gateway base URL\",\n\t\t\t}),\n\t\t);\n\n\tconst getHeaders = (extra?: Record<string, string>) =>\n\t\twithUserAgentSuffix(\n\t\t\t{\n\t\t\t\tAuthorization: `Bearer ${loadApiKey({\n\t\t\t\t\tapiKey: options.apiKey,\n\t\t\t\t\tenvironmentVariableName: \"NEON_AI_GATEWAY_TOKEN\",\n\t\t\t\t\tdescription: \"Neon AI Gateway token\",\n\t\t\t\t})}`,\n\t\t\t\t...extra,\n\t\t\t\t...options.headers,\n\t\t\t},\n\t\t\t`neondatabase/ai-sdk-provider/${VERSION}`,\n\t\t);\n\n\t// Anthropic models -> native Messages API.\n\tconst createAnthropicModel = (modelId: NeonChatModelId) =>\n\t\tnew NeonAnthropicLanguageModel(modelId, {\n\t\t\tprovider: \"neon.anthropic\",\n\t\t\tbaseURL: `${getHost()}/anthropic/v1`,\n\t\t\theaders: () => getHeaders({ \"anthropic-version\": \"2023-06-01\" }),\n\t\t\tfetch: wrapFetchWithGatewayErrorNormalization(\n\t\t\t\toptions.fetch,\n\t\t\t\t\"anthropic\",\n\t\t\t),\n\t\t\tgenerateId,\n\t\t});\n\n\t// OpenAI models (incl. Codex, only served natively) -> Responses API.\n\tconst createOpenAIModel = (modelId: NeonChatModelId) =>\n\t\tnew NeonResponsesLanguageModel(modelId, {\n\t\t\tprovider: \"neon.openai.responses\",\n\t\t\turl: ({ path }) => `${getHost()}/openai/v1${path}`,\n\t\t\theaders: getHeaders,\n\t\t\t// This route returns Databricks error envelopes the OpenAI schema\n\t\t\t// cannot read, which reach the caller as a bare \"Bad Request\".\n\t\t\t// `OpenAIConfig` has no error hook, so the rewrite rides on fetch.\n\t\t\tfetch: wrapFetchWithGatewayErrorNormalization(\n\t\t\t\toptions.fetch,\n\t\t\t\t\"openai\",\n\t\t\t),\n\t\t\tfileIdPrefixes: [\"file-\"],\n\t\t});\n\n\t// Everything else (Gemini, Llama, Qwen, gpt-oss, ...) -> unified Chat\n\t// Completions endpoint. Gemini is here because its native endpoint can't stream.\n\tconst createChatModel = (modelId: NeonChatModelId) =>\n\t\tnew NeonChatLanguageModel(modelId, {\n\t\t\tprovider: \"neon.chat\",\n\t\t\turl: ({ path }) => `${getHost()}/v1${path}`,\n\t\t\theaders: getHeaders,\n\t\t\t// Two wrappers, on disjoint halves of the response: the harmony one\n\t\t\t// rewrites successful gpt-oss bodies and returns early on any error,\n\t\t\t// the error one only touches non-2xx bodies. This route emits the\n\t\t\t// same flat `{ error_code, message }` Databricks envelope as the\n\t\t\t// Responses route (an out-of-range `temperature`, say), which\n\t\t\t// `errorStructure` below cannot read on its own.\n\t\t\t//\n\t\t\t// TODO(#308): Temporary workaround for gpt-oss. The gateway returns a\n\t\t\t// non-compliant \"harmony\" content-array shape; this wrapper normalizes it\n\t\t\t// to the Chat Completions contract and is a transparent pass-through for\n\t\t\t// every compliant response. Remove it (and neon-harmony-normalize.ts) once\n\t\t\t// the gateway returns spec-compliant gpt-oss responses.\n\t\t\tfetch: wrapFetchWithHarmonyNormalization(\n\t\t\t\twrapFetchWithGatewayErrorNormalization(options.fetch, \"openai\"),\n\t\t\t),\n\t\t\terrorStructure: neonErrorStructure,\n\t\t\ttransformRequestBody: transformNeonRequestBody,\n\t\t\tsupportsStructuredOutputs: true,\n\t\t});\n\n\tconst createEmbeddingModel = (modelId: NeonEmbeddingModelId) =>\n\t\tnew OpenAICompatibleEmbeddingModel(modelId, {\n\t\t\tprovider: \"neon.embedding\",\n\t\t\turl: ({ path }) => `${getHost()}/v1${path}`,\n\t\t\theaders: getHeaders,\n\t\t\tfetch: wrapFetchWithGatewayErrorNormalization(\n\t\t\t\toptions.fetch,\n\t\t\t\t\"openai\",\n\t\t\t),\n\t\t\terrorStructure: neonErrorStructure,\n\t\t\tmaxEmbeddingsPerCall: NEON_MAX_EMBEDDINGS_PER_CALL,\n\t\t});\n\n\tconst createDecisionModel = (modelId: NeonDecisionModelId) =>\n\t\tnew NeonDecisionModel(modelId, {\n\t\t\tprovider: \"neon.decision\",\n\t\t\turl: () => `${getHost()}/typesafe/v1/systemone`,\n\t\t\theaders: getHeaders,\n\t\t\tfetch: wrapFetchWithGatewayErrorNormalization(\n\t\t\t\toptions.fetch,\n\t\t\t\t\"openai\",\n\t\t\t),\n\t\t\tfailedResponseHandler:\n\t\t\t\tcreateJsonErrorResponseHandler(neonErrorStructure),\n\t\t});\n\n\tconst createLanguageModel = (modelId: NeonChatModelId): LanguageModelV3 => {\n\t\tswitch (getNeonModelRoute(modelId)) {\n\t\t\tcase \"anthropic\":\n\t\t\t\treturn createAnthropicModel(modelId);\n\t\t\tcase \"openai\":\n\t\t\t\treturn createOpenAIModel(modelId);\n\t\t\tdefault:\n\t\t\t\treturn createChatModel(modelId);\n\t\t}\n\t};\n\n\tconst provider = (modelId: NeonChatModelId) => createLanguageModel(modelId);\n\n\tprovider.specificationVersion = \"v3\" as const;\n\tprovider.languageModel = createLanguageModel;\n\tprovider.chat = createLanguageModel;\n\tprovider.tools = neonOpenAITools;\n\n\tprovider.embeddingModel = createEmbeddingModel;\n\tprovider.textEmbeddingModel = createEmbeddingModel;\n\tprovider.decisionModel = createDecisionModel;\n\tprovider.imageModel = (modelId: string) => {\n\t\tthrow new NoSuchModelError({ modelId, modelType: \"imageModel\" });\n\t};\n\n\treturn provider;\n}\n\n/** Default Neon provider instance (reads `NEON_AI_GATEWAY_*` env vars). */\nexport const neon = createNeon();\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA6DA,MAAM,qBAA4D;CACjE,aAZuB,EAAE,OAAO,EAChC,OAAO,EAAE,OAAO;EACf,SAAS,EAAE,OAAO;EAClB,MAAM,EAAE,OAAO,CAAC,CAAC,QAAQ;EACzB,OAAO,EAAE,QAAQ,CAAC,CAAC,QAAQ;EAC3B,MAAM,EAAE,QAAQ,CAAC,CAAC,QAAQ;CAC3B,CAAC,EACF,CAK4B;CAC3B,iBAAiB,SAAS,KAAK,MAAM;AACtC;;;;;;AAOA,SAAS,sBAAsB,OAAyB;CACvD,IAAI,MAAM,QAAQ,KAAK,GACtB,OAAO,MAAM,IAAI,qBAAqB;CAEvC,IAAI,UAAU,QAAQ,OAAO,UAAU,UAAU;EAChD,MAAM,SAAkC,CAAC;EACzC,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,KAAK,GAAG;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wBAAwB,YAC7B,IAAI,+BAA+B,SAAS;EAC3C,UAAU;EACV,MAAM,EAAE,WAAW,GAAG,QAAQ,EAAE,KAAK;EACrC,SAAS;EACT,OAAO,uCACN,QAAQ,OACR,QACD;EACA,gBAAgB;EAChB,sBAAA;CACD,CAAC;CAEF,MAAM,uBAAuB,YAC5B,IAAI,kBAAkB,SAAS;EAC9B,UAAU;EACV,WAAW,GAAG,QAAQ,EAAE;EACxB,SAAS;EACT,OAAO,uCACN,QAAQ,OACR,QACD;EACA,uBACC,+BAA+B,kBAAkB;CACnD,CAAC;CAEF,MAAM,uBAAuB,YAA8C;EAC1E,QAAQ,kBAAkB,OAAO,GAAjC;GACC,KAAK,aACJ,OAAO,qBAAqB,OAAO;GACpC,KAAK,UACJ,OAAO,kBAAkB,OAAO;GACjC,SACC,OAAO,gBAAgB,OAAO;EAChC;CACD;CAEA,MAAM,YAAY,YAA6B,oBAAoB,OAAO;CAE1E,SAAS,uBAAuB;CAChC,SAAS,gBAAgB;CACzB,SAAS,OAAO;CAChB,SAAS,QAAQ;CAEjB,SAAS,iBAAiB;CAC1B,SAAS,qBAAqB;CAC9B,SAAS,gBAAgB;CACzB,SAAS,cAAc,YAAoB;EAC1C,MAAM,IAAI,iBAAiB;GAAE;GAAS,WAAW;EAAa,CAAC;CAChE;CAEA,OAAO;AACR;;AAGA,MAAa,OAAO,WAAW"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.d.ts","names":[],"sources":["../../src/lib/version.ts"],"mappings":";
|
|
1
|
+
{"version":3,"file":"version.d.ts","names":["VERSION","VERSION"],"sources":["../../src/lib/version.ts"],"mappings":";cAIaA"}
|
package/dist/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neon/ai-sdk-provider",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Community Vercel AI SDK provider for the Neon AI Gateway.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"neon",
|
|
@@ -40,12 +40,12 @@
|
|
|
40
40
|
"@types/node": "^20.19.0",
|
|
41
41
|
"@vitest/coverage-v8": "^3.0.9",
|
|
42
42
|
"ai": "6.0.228",
|
|
43
|
-
"ai-v7": "npm:ai@7.0.
|
|
43
|
+
"ai-v7": "npm:ai@7.0.137",
|
|
44
44
|
"console-fail-test": "0.5.0",
|
|
45
45
|
"tsdown": "^0.14.1",
|
|
46
46
|
"typescript": "^5.9.0",
|
|
47
47
|
"vitest": "^3.0.9",
|
|
48
|
-
"zod": "^4.4
|
|
48
|
+
"zod": "^4.5.4",
|
|
49
49
|
"@neon/e2e-harness": "0.0.0"
|
|
50
50
|
},
|
|
51
51
|
"engines": {
|