@modelprofile.com/flexharness-providers 9.1.0 → 9.3.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/dist_ts_anthropic_messages/errors.d.ts +22 -0
- package/dist_ts_anthropic_messages/errors.js +100 -0
- package/dist_ts_anthropic_messages/index.d.ts +4 -0
- package/dist_ts_anthropic_messages/index.js +4 -0
- package/dist_ts_anthropic_messages/interfaces.d.ts +185 -0
- package/dist_ts_anthropic_messages/interfaces.js +2 -0
- package/dist_ts_anthropic_messages/openai.d.ts +19 -0
- package/dist_ts_anthropic_messages/openai.js +48 -0
- package/dist_ts_anthropic_messages/plugins.d.ts +4 -0
- package/dist_ts_anthropic_messages/plugins.js +4 -0
- package/dist_ts_anthropic_messages/request.d.ts +109 -0
- package/dist_ts_anthropic_messages/request.js +554 -0
- package/dist_ts_anthropic_messages/service.d.ts +8 -0
- package/dist_ts_anthropic_messages/service.js +274 -0
- package/dist_ts_anthropic_messages/signature.d.ts +16 -0
- package/dist_ts_anthropic_messages/signature.js +91 -0
- package/dist_ts_anthropic_messages/stream.d.ts +48 -0
- package/dist_ts_anthropic_messages/stream.js +220 -0
- package/dist_ts_anthropic_messages_node/index.d.ts +8 -0
- package/dist_ts_anthropic_messages_node/index.js +93 -0
- package/dist_ts_anthropic_messages_node/plugins.d.ts +6 -0
- package/dist_ts_anthropic_messages_node/plugins.js +4 -0
- package/dist_ts_media_openai/index.js +2 -3
- package/dist_ts_media_openai/plugins.d.ts +2 -0
- package/dist_ts_media_openai/plugins.js +5 -1
- package/dist_ts_openai_account/index.d.ts +1 -1
- package/dist_ts_openai_account/index.js +2 -2
- package/dist_ts_openai_account/plugins.d.ts +3 -0
- package/dist_ts_openai_account/plugins.js +3 -1
- package/dist_ts_openai_account/smartai.providers.credentials.d.ts +2 -2
- package/dist_ts_openai_account/smartai.providers.credentials.js +3 -4
- package/dist_ts_openai_account/smartai.providers.interfaces.d.ts +6 -7
- package/dist_ts_openai_account/smartai.providers.openai.js +15 -16
- package/dist_ts_openai_auth/index.d.ts +1 -1
- package/dist_ts_openai_auth/index.js +2 -2
- package/dist_ts_openai_auth/interfaces.d.ts +1 -1
- package/dist_ts_openai_auth/plugins.d.ts +3 -0
- package/dist_ts_openai_auth/plugins.js +4 -0
- package/dist_ts_openai_auth/smartai.auth.openai.d.ts +1 -2
- package/dist_ts_openai_auth/smartai.auth.openai.js +27 -27
- package/dist_ts_openai_auth/smartai.connection.openai.d.ts +3 -3
- package/dist_ts_openai_auth/smartai.connection.openai.js +6 -6
- package/dist_ts_openai_auth_files/index.d.ts +6 -6
- package/dist_ts_openai_auth_files/index.js +3 -4
- package/dist_ts_openai_auth_files/plugins.d.ts +3 -0
- package/dist_ts_openai_auth_files/plugins.js +4 -1
- package/dist_ts_providers/anthropic/index.d.ts +1 -1
- package/dist_ts_providers/anthropic/index.js +1 -1
- package/dist_ts_providers/anthropic/plugins.d.ts +4 -3
- package/dist_ts_providers/anthropic/plugins.js +3 -3
- package/dist_ts_providers/anthropic/smartai.middleware.anthropic.d.ts +2 -3
- package/dist_ts_providers/anthropic/smartai.middleware.anthropic.js +3 -3
- package/dist_ts_providers/google/index.d.ts +1 -1
- package/dist_ts_providers/google/index.js +1 -1
- package/dist_ts_providers/google/plugins.d.ts +1 -1
- package/dist_ts_providers/groq/index.d.ts +1 -1
- package/dist_ts_providers/groq/index.js +1 -1
- package/dist_ts_providers/groq/plugins.d.ts +1 -1
- package/dist_ts_providers/mistral/index.d.ts +1 -1
- package/dist_ts_providers/mistral/index.js +1 -1
- package/dist_ts_providers/mistral/plugins.d.ts +1 -1
- package/dist_ts_providers/ollama/index.d.ts +2 -2
- package/dist_ts_providers/ollama/index.js +1 -1
- package/dist_ts_providers/ollama/interfaces.d.ts +2 -2
- package/dist_ts_providers/ollama/plugins.d.ts +2 -0
- package/dist_ts_providers/ollama/plugins.js +2 -0
- package/dist_ts_providers/ollama/smartai.provider.ollama.d.ts +2 -2
- package/dist_ts_providers/ollama/smartai.provider.ollama.js +1 -1
- package/dist_ts_providers/openai/index.d.ts +1 -1
- package/dist_ts_providers/openai/index.js +1 -1
- package/dist_ts_providers/openai/plugins.d.ts +1 -1
- package/dist_ts_providers/openai/smartai.chatgpt.catalog.d.ts +2 -0
- package/dist_ts_providers/openai/smartai.chatgpt.catalog.js +8 -1
- package/dist_ts_providers/openai/smartai.chatgpt.middleware.d.ts +5 -1
- package/dist_ts_providers/openai/smartai.chatgpt.middleware.js +25 -12
- package/dist_ts_providers/openai/smartai.limits.openai.d.ts +4 -1
- package/dist_ts_providers/openai/smartai.limits.openai.js +10 -5
- package/dist_ts_providers/perplexity/index.d.ts +1 -1
- package/dist_ts_providers/perplexity/index.js +1 -1
- package/dist_ts_providers/perplexity/plugins.d.ts +1 -1
- package/dist_ts_providers/xai/index.d.ts +1 -1
- package/dist_ts_providers/xai/index.js +1 -1
- package/dist_ts_providers/xai/plugins.d.ts +1 -1
- package/package.json +23 -11
- package/readme.md +1 -0
- package/ts_anthropic_messages/errors.ts +124 -0
- package/ts_anthropic_messages/index.ts +24 -0
- package/ts_anthropic_messages/interfaces.ts +173 -0
- package/ts_anthropic_messages/openai.ts +58 -0
- package/ts_anthropic_messages/plugins.ts +26 -0
- package/ts_anthropic_messages/readme.md +129 -0
- package/ts_anthropic_messages/request.ts +652 -0
- package/ts_anthropic_messages/service.ts +312 -0
- package/ts_anthropic_messages/signature.ts +107 -0
- package/ts_anthropic_messages/stream.ts +260 -0
- package/ts_anthropic_messages_node/index.ts +99 -0
- package/ts_anthropic_messages_node/plugins.ts +7 -0
- package/ts_anthropic_messages_node/readme.md +50 -0
- package/ts_media_openai/index.ts +1 -2
- package/ts_media_openai/plugins.ts +6 -0
- package/ts_openai_account/index.ts +1 -1
- package/ts_openai_account/plugins.ts +37 -0
- package/ts_openai_account/smartai.providers.credentials.ts +3 -5
- package/ts_openai_account/smartai.providers.interfaces.ts +6 -12
- package/ts_openai_account/smartai.providers.openai.ts +18 -31
- package/ts_openai_auth/index.ts +1 -1
- package/ts_openai_auth/interfaces.ts +1 -1
- package/ts_openai_auth/plugins.ts +17 -0
- package/ts_openai_auth/smartai.auth.openai.ts +28 -33
- package/ts_openai_auth/smartai.connection.openai.ts +7 -11
- package/ts_openai_auth_files/index.ts +19 -28
- package/ts_openai_auth_files/plugins.ts +10 -0
- package/ts_providers/anthropic/index.ts +1 -1
- package/ts_providers/anthropic/plugins.ts +11 -1
- package/ts_providers/anthropic/smartai.middleware.anthropic.ts +3 -5
- package/ts_providers/google/index.ts +1 -1
- package/ts_providers/google/plugins.ts +1 -1
- package/ts_providers/groq/index.ts +1 -1
- package/ts_providers/groq/plugins.ts +1 -1
- package/ts_providers/mistral/index.ts +1 -1
- package/ts_providers/mistral/plugins.ts +1 -1
- package/ts_providers/ollama/index.ts +2 -2
- package/ts_providers/ollama/interfaces.ts +2 -2
- package/ts_providers/ollama/plugins.ts +12 -0
- package/ts_providers/ollama/smartai.provider.ollama.ts +11 -21
- package/ts_providers/openai/index.ts +1 -1
- package/ts_providers/openai/plugins.ts +1 -0
- package/ts_providers/openai/readme.md +9 -6
- package/ts_providers/openai/smartai.chatgpt.catalog.ts +11 -0
- package/ts_providers/openai/smartai.chatgpt.middleware.ts +27 -11
- package/ts_providers/openai/smartai.limits.openai.ts +12 -4
- package/ts_providers/perplexity/index.ts +1 -1
- package/ts_providers/perplexity/plugins.ts +1 -1
- package/ts_providers/readme.md +1 -0
- package/ts_providers/xai/index.ts +1 -1
- package/ts_providers/xai/plugins.ts +1 -1
|
@@ -14,18 +14,13 @@ import type {
|
|
|
14
14
|
IOpenAiChatGptTokenInfo,
|
|
15
15
|
TOpenAiChatGptBrowserCallback,
|
|
16
16
|
} from './interfaces.js';
|
|
17
|
-
import
|
|
18
|
-
OPENAI_CHATGPT_CODEX_BASE_URL,
|
|
19
|
-
OPENAI_CHATGPT_DEFAULT_ORIGINATOR,
|
|
20
|
-
OpenAiChatGptAuthError,
|
|
21
|
-
type TOpenAiChatGptRequestOutcome,
|
|
22
|
-
} from '@modelprofile.com/flexharness-providers/openai';
|
|
17
|
+
import * as plugins from './plugins.js';
|
|
23
18
|
|
|
24
19
|
export {
|
|
25
20
|
OPENAI_CHATGPT_CODEX_BASE_URL,
|
|
26
21
|
OPENAI_CHATGPT_DEFAULT_ORIGINATOR,
|
|
27
22
|
OpenAiChatGptAuthError,
|
|
28
|
-
};
|
|
23
|
+
} from './plugins.js';
|
|
29
24
|
|
|
30
25
|
export const OPENAI_CHATGPT_AUTH_ISSUER = 'https://auth.openai.com';
|
|
31
26
|
export const OPENAI_CHATGPT_CLIENT_ID = 'app_EMoamEEZ73f0CkXaXp7hrann';
|
|
@@ -65,7 +60,7 @@ interface IOpenAiChatGptTokenResponse {
|
|
|
65
60
|
function getFetch(options: IOpenAiChatGptAuthOptions): typeof fetch {
|
|
66
61
|
const fetchFunction = options.fetch ?? globalThis.fetch;
|
|
67
62
|
if (!fetchFunction) {
|
|
68
|
-
throw new OpenAiChatGptAuthError('fetch is not available for OpenAI ChatGPT authentication.');
|
|
63
|
+
throw new plugins.OpenAiChatGptAuthError('fetch is not available for OpenAI ChatGPT authentication.');
|
|
69
64
|
}
|
|
70
65
|
return fetchFunction;
|
|
71
66
|
}
|
|
@@ -74,8 +69,8 @@ function authError(
|
|
|
74
69
|
message: string,
|
|
75
70
|
options: IOpenAiChatGptAuthOptions,
|
|
76
71
|
details: { status?: number; body?: string } = {},
|
|
77
|
-
): OpenAiChatGptAuthError {
|
|
78
|
-
return new OpenAiChatGptAuthError(
|
|
72
|
+
): plugins.OpenAiChatGptAuthError {
|
|
73
|
+
return new plugins.OpenAiChatGptAuthError(
|
|
79
74
|
message,
|
|
80
75
|
usesSafeErrors(options)
|
|
81
76
|
? { ...(details.status === undefined ? {} : { status: details.status }) }
|
|
@@ -235,7 +230,7 @@ async function runFetch<TResult>(
|
|
|
235
230
|
timeoutMsArg = AUTH_REQUEST_TIMEOUT_MS,
|
|
236
231
|
): Promise<TResult> {
|
|
237
232
|
if (options.signal?.aborted) {
|
|
238
|
-
throw new OpenAiChatGptAuthError('OpenAI ChatGPT authentication was aborted.', {
|
|
233
|
+
throw new plugins.OpenAiChatGptAuthError('OpenAI ChatGPT authentication was aborted.', {
|
|
239
234
|
requestOutcome: 'notSent',
|
|
240
235
|
});
|
|
241
236
|
}
|
|
@@ -275,12 +270,12 @@ async function runFetch<TResult>(
|
|
|
275
270
|
aborted,
|
|
276
271
|
]);
|
|
277
272
|
} catch (error) {
|
|
278
|
-
const requestOutcome: TOpenAiChatGptRequestOutcome = requestStarted
|
|
273
|
+
const requestOutcome: plugins.TOpenAiChatGptRequestOutcome = requestStarted
|
|
279
274
|
? 'outcomeUnknown'
|
|
280
275
|
: 'notSent';
|
|
281
276
|
const retryAfterMs = response ? parseRetryAfterMs(response.headers.get('retry-after')) : undefined;
|
|
282
|
-
if (error instanceof OpenAiChatGptAuthError) {
|
|
283
|
-
throw new OpenAiChatGptAuthError(error.message, {
|
|
277
|
+
if (error instanceof plugins.OpenAiChatGptAuthError) {
|
|
278
|
+
throw new plugins.OpenAiChatGptAuthError(error.message, {
|
|
284
279
|
...(error.status !== undefined ? { status: error.status }
|
|
285
280
|
: response ? { status: response.status } : {}),
|
|
286
281
|
...(error.body !== undefined ? { body: error.body } : {}),
|
|
@@ -289,7 +284,7 @@ async function runFetch<TResult>(
|
|
|
289
284
|
});
|
|
290
285
|
}
|
|
291
286
|
if (!usesSafeErrors(options)) throw error;
|
|
292
|
-
throw new OpenAiChatGptAuthError(
|
|
287
|
+
throw new plugins.OpenAiChatGptAuthError(
|
|
293
288
|
options.signal?.aborted
|
|
294
289
|
? 'OpenAI ChatGPT authentication was aborted.'
|
|
295
290
|
: 'OpenAI ChatGPT authentication request failed.',
|
|
@@ -377,7 +372,7 @@ async function sleepWithAbort(
|
|
|
377
372
|
function parseJwtPayload(jwt: string): Record<string, unknown> {
|
|
378
373
|
const parts = jwt.split('.');
|
|
379
374
|
if (parts.length !== 3 || !parts[1]) {
|
|
380
|
-
throw new OpenAiChatGptAuthError('OpenAI ChatGPT auth returned an invalid token.');
|
|
375
|
+
throw new plugins.OpenAiChatGptAuthError('OpenAI ChatGPT auth returned an invalid token.');
|
|
381
376
|
}
|
|
382
377
|
|
|
383
378
|
try {
|
|
@@ -386,7 +381,7 @@ function parseJwtPayload(jwt: string): Record<string, unknown> {
|
|
|
386
381
|
const bytes = Uint8Array.from(binary, (character) => character.charCodeAt(0));
|
|
387
382
|
return JSON.parse(textDecoder.decode(bytes)) as Record<string, unknown>;
|
|
388
383
|
} catch (error) {
|
|
389
|
-
throw new OpenAiChatGptAuthError(`OpenAI ChatGPT token could not be parsed: ${(error as Error).message}`);
|
|
384
|
+
throw new plugins.OpenAiChatGptAuthError(`OpenAI ChatGPT token could not be parsed: ${(error as Error).message}`);
|
|
390
385
|
}
|
|
391
386
|
}
|
|
392
387
|
|
|
@@ -563,7 +558,7 @@ export function ensureOpenAiChatGptWorkspaceAllowed(
|
|
|
563
558
|
return;
|
|
564
559
|
}
|
|
565
560
|
if (tokenData.tokenInfo.chatgptAccountId !== forcedChatGptWorkspaceId) {
|
|
566
|
-
throw new OpenAiChatGptAuthError(`OpenAI ChatGPT login is restricted to workspace ${forcedChatGptWorkspaceId}.`);
|
|
561
|
+
throw new plugins.OpenAiChatGptAuthError(`OpenAI ChatGPT login is restricted to workspace ${forcedChatGptWorkspaceId}.`);
|
|
567
562
|
}
|
|
568
563
|
}
|
|
569
564
|
|
|
@@ -617,7 +612,7 @@ const requireBase64UrlValue = (
|
|
|
617
612
|
|| value.length < minimumBytes
|
|
618
613
|
|| value.length > maximumBytes
|
|
619
614
|
) {
|
|
620
|
-
throw new OpenAiChatGptAuthError(`OpenAI ChatGPT ${label} is invalid.`);
|
|
615
|
+
throw new plugins.OpenAiChatGptAuthError(`OpenAI ChatGPT ${label} is invalid.`);
|
|
621
616
|
}
|
|
622
617
|
return value;
|
|
623
618
|
};
|
|
@@ -642,7 +637,7 @@ export async function createOpenAiChatGptBrowserAuthorization(
|
|
|
642
637
|
const codeChallenge = encodeBase64Url(new Uint8Array(
|
|
643
638
|
await webCrypto.subtle.digest('SHA-256', textEncoder.encode(codeVerifier)),
|
|
644
639
|
));
|
|
645
|
-
const originator = options.originator ?? OPENAI_CHATGPT_DEFAULT_ORIGINATOR;
|
|
640
|
+
const originator = options.originator ?? plugins.OPENAI_CHATGPT_DEFAULT_ORIGINATOR;
|
|
646
641
|
if (
|
|
647
642
|
utf8ByteLength(originator) > 128
|
|
648
643
|
|| !/^[A-Za-z0-9._-]+$/.test(originator)
|
|
@@ -690,7 +685,7 @@ export function parseOpenAiChatGptBrowserCallback(
|
|
|
690
685
|
typeof callbackUrl !== 'string'
|
|
691
686
|
|| utf8ByteLength(callbackUrl) > SAFE_MAX_URL_BYTES
|
|
692
687
|
) {
|
|
693
|
-
throw new OpenAiChatGptAuthError('OpenAI ChatGPT browser callback is invalid.');
|
|
688
|
+
throw new plugins.OpenAiChatGptAuthError('OpenAI ChatGPT browser callback is invalid.');
|
|
694
689
|
}
|
|
695
690
|
const expectedRedirectUri = requireBrowserRedirectUri(options.expectedRedirectUri, {});
|
|
696
691
|
const expectedState = requireBase64UrlValue(options.expectedState, 'browser state', 32, 128);
|
|
@@ -698,11 +693,11 @@ export function parseOpenAiChatGptBrowserCallback(
|
|
|
698
693
|
try {
|
|
699
694
|
parsed = new URL(callbackUrl);
|
|
700
695
|
} catch {
|
|
701
|
-
throw new OpenAiChatGptAuthError('OpenAI ChatGPT browser callback is invalid.');
|
|
696
|
+
throw new plugins.OpenAiChatGptAuthError('OpenAI ChatGPT browser callback is invalid.');
|
|
702
697
|
}
|
|
703
698
|
const expectedUrl = new URL(expectedRedirectUri);
|
|
704
699
|
if (parsed.origin !== expectedUrl.origin || parsed.pathname !== expectedUrl.pathname) {
|
|
705
|
-
throw new OpenAiChatGptAuthError('OpenAI ChatGPT browser callback target is invalid.');
|
|
700
|
+
throw new plugins.OpenAiChatGptAuthError('OpenAI ChatGPT browser callback target is invalid.');
|
|
706
701
|
}
|
|
707
702
|
const allowedKeys = new Set(['code', 'state', 'error', 'error_description']);
|
|
708
703
|
const keys = [...parsed.searchParams.keys()];
|
|
@@ -711,16 +706,16 @@ export function parseOpenAiChatGptBrowserCallback(
|
|
|
711
706
|
|| keys.some((key) => !allowedKeys.has(key))
|
|
712
707
|
|| new Set(keys).size !== keys.length
|
|
713
708
|
) {
|
|
714
|
-
throw new OpenAiChatGptAuthError('OpenAI ChatGPT browser callback parameters are invalid.');
|
|
709
|
+
throw new plugins.OpenAiChatGptAuthError('OpenAI ChatGPT browser callback parameters are invalid.');
|
|
715
710
|
}
|
|
716
711
|
const state = parsed.searchParams.get('state');
|
|
717
712
|
if (state !== expectedState) {
|
|
718
|
-
throw new OpenAiChatGptAuthError('OpenAI ChatGPT browser callback state does not match.');
|
|
713
|
+
throw new plugins.OpenAiChatGptAuthError('OpenAI ChatGPT browser callback state does not match.');
|
|
719
714
|
}
|
|
720
715
|
const providerError = parsed.searchParams.get('error');
|
|
721
716
|
if (providerError !== null) {
|
|
722
717
|
if (!/^[A-Za-z0-9._-]{1,128}$/.test(providerError)) {
|
|
723
|
-
throw new OpenAiChatGptAuthError('OpenAI ChatGPT browser login was denied.');
|
|
718
|
+
throw new plugins.OpenAiChatGptAuthError('OpenAI ChatGPT browser login was denied.');
|
|
724
719
|
}
|
|
725
720
|
return { providerError };
|
|
726
721
|
}
|
|
@@ -729,7 +724,7 @@ export function parseOpenAiChatGptBrowserCallback(
|
|
|
729
724
|
!authorizationCode
|
|
730
725
|
|| utf8ByteLength(authorizationCode) > SAFE_MAX_AUTHORIZATION_CODE_BYTES
|
|
731
726
|
) {
|
|
732
|
-
throw new OpenAiChatGptAuthError('OpenAI ChatGPT browser callback has no valid code.');
|
|
727
|
+
throw new plugins.OpenAiChatGptAuthError('OpenAI ChatGPT browser callback has no valid code.');
|
|
733
728
|
}
|
|
734
729
|
return { authorizationCode };
|
|
735
730
|
}
|
|
@@ -799,14 +794,14 @@ export function createOpenAiChatGptProviderSettings(credentials: IOpenAiChatGptA
|
|
|
799
794
|
currentTokenInfo.expiresAt === undefined
|
|
800
795
|
|| Date.parse(currentTokenInfo.expiresAt) <= Date.now()
|
|
801
796
|
) {
|
|
802
|
-
throw new OpenAiChatGptAuthError('OpenAI ChatGPT access token has no valid future expiry.');
|
|
797
|
+
throw new plugins.OpenAiChatGptAuthError('OpenAI ChatGPT access token has no valid future expiry.');
|
|
803
798
|
}
|
|
804
799
|
const tokenAccountId = currentTokenInfo.chatgptAccountId;
|
|
805
800
|
if (
|
|
806
801
|
credentials.accountId !== undefined
|
|
807
802
|
&& credentials.accountId !== tokenAccountId
|
|
808
803
|
) {
|
|
809
|
-
throw new OpenAiChatGptAuthError('OpenAI ChatGPT account ID does not match the token claim.');
|
|
804
|
+
throw new plugins.OpenAiChatGptAuthError('OpenAI ChatGPT account ID does not match the token claim.');
|
|
810
805
|
}
|
|
811
806
|
if (
|
|
812
807
|
credentials.tokenInfo !== undefined
|
|
@@ -815,7 +810,7 @@ export function createOpenAiChatGptProviderSettings(credentials: IOpenAiChatGptA
|
|
|
815
810
|
|| credentials.tokenInfo.chatgptAccountIsFedramp !== currentTokenInfo.chatgptAccountIsFedramp
|
|
816
811
|
)
|
|
817
812
|
) {
|
|
818
|
-
throw new OpenAiChatGptAuthError('OpenAI ChatGPT token information does not match the current access token.');
|
|
813
|
+
throw new plugins.OpenAiChatGptAuthError('OpenAI ChatGPT token information does not match the current access token.');
|
|
819
814
|
}
|
|
820
815
|
if (
|
|
821
816
|
credentials.isFedrampAccount !== undefined
|
|
@@ -824,12 +819,12 @@ export function createOpenAiChatGptProviderSettings(credentials: IOpenAiChatGptA
|
|
|
824
819
|
|| credentials.isFedrampAccount !== currentTokenInfo.chatgptAccountIsFedramp
|
|
825
820
|
)
|
|
826
821
|
) {
|
|
827
|
-
throw new OpenAiChatGptAuthError('OpenAI ChatGPT FedRAMP status does not match the token claim.');
|
|
822
|
+
throw new plugins.OpenAiChatGptAuthError('OpenAI ChatGPT FedRAMP status does not match the token claim.');
|
|
828
823
|
}
|
|
829
824
|
const accountId = tokenAccountId;
|
|
830
825
|
const isFedrampAccount = currentTokenInfo.chatgptAccountIsFedramp;
|
|
831
826
|
const headers: Record<string, string> = {
|
|
832
|
-
originator: credentials.originator ?? OPENAI_CHATGPT_DEFAULT_ORIGINATOR,
|
|
827
|
+
originator: credentials.originator ?? plugins.OPENAI_CHATGPT_DEFAULT_ORIGINATOR,
|
|
833
828
|
};
|
|
834
829
|
|
|
835
830
|
if (accountId) {
|
|
@@ -841,7 +836,7 @@ export function createOpenAiChatGptProviderSettings(credentials: IOpenAiChatGptA
|
|
|
841
836
|
|
|
842
837
|
return {
|
|
843
838
|
apiKey: credentials.accessToken,
|
|
844
|
-
baseURL: OPENAI_CHATGPT_CODEX_BASE_URL,
|
|
839
|
+
baseURL: plugins.OPENAI_CHATGPT_CODEX_BASE_URL,
|
|
845
840
|
headers,
|
|
846
841
|
};
|
|
847
842
|
}
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
classifyOpenAiChatGptLimit,
|
|
3
|
-
createOpenAiChatGptInstructionsMiddleware,
|
|
4
|
-
type IOpenAiModelConnection,
|
|
5
|
-
} from '@modelprofile.com/flexharness-providers/openai';
|
|
1
|
+
import * as plugins from './plugins.js';
|
|
6
2
|
import type {
|
|
7
3
|
IOpenAiChatGptAuthCredentials,
|
|
8
4
|
IOpenAiChatGptDynamicModelConnectionOptions,
|
|
@@ -88,17 +84,17 @@ function applyAccessHeaders(
|
|
|
88
84
|
|
|
89
85
|
export const createOpenAiChatGptModelConnection = (
|
|
90
86
|
credentialsArg: IOpenAiChatGptAuthCredentials,
|
|
91
|
-
): IOpenAiModelConnection => ({
|
|
87
|
+
): plugins.IOpenAiModelConnection => ({
|
|
92
88
|
settings: createOpenAiChatGptProviderSettings(credentialsArg),
|
|
93
|
-
middleware: createOpenAiChatGptInstructionsMiddleware(),
|
|
89
|
+
middleware: plugins.createOpenAiChatGptInstructionsMiddleware(),
|
|
94
90
|
// the ChatGPT Codex backend serves the Responses API only
|
|
95
91
|
apis: ['responses'],
|
|
96
|
-
classifyLimit: classifyOpenAiChatGptLimit,
|
|
92
|
+
classifyLimit: plugins.classifyOpenAiChatGptLimit,
|
|
97
93
|
});
|
|
98
94
|
|
|
99
95
|
export const createOpenAiChatGptDynamicModelConnection = (
|
|
100
96
|
optionsArg: IOpenAiChatGptDynamicModelConnectionOptions,
|
|
101
|
-
): IOpenAiModelConnection => {
|
|
97
|
+
): plugins.IOpenAiModelConnection => {
|
|
102
98
|
if (!optionsArg || typeof optionsArg.resolveAccess !== 'function') {
|
|
103
99
|
throw new OpenAiChatGptAuthError('OpenAI ChatGPT access resolver is required.');
|
|
104
100
|
}
|
|
@@ -144,9 +140,9 @@ export const createOpenAiChatGptDynamicModelConnection = (
|
|
|
144
140
|
baseURL: OPENAI_CHATGPT_CODEX_BASE_URL,
|
|
145
141
|
fetch: fetchWithCurrentAccess,
|
|
146
142
|
},
|
|
147
|
-
middleware: createOpenAiChatGptInstructionsMiddleware(),
|
|
143
|
+
middleware: plugins.createOpenAiChatGptInstructionsMiddleware(),
|
|
148
144
|
// the ChatGPT Codex backend serves the Responses API only
|
|
149
145
|
apis: ['responses'],
|
|
150
|
-
classifyLimit: classifyOpenAiChatGptLimit,
|
|
146
|
+
classifyLimit: plugins.classifyOpenAiChatGptLimit,
|
|
151
147
|
};
|
|
152
148
|
};
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
import * as plugins from './plugins.js';
|
|
2
|
-
import {
|
|
3
|
-
parseOpenAiChatGptTokenInfo,
|
|
4
|
-
refreshOpenAiChatGptTokenData,
|
|
5
|
-
} from '@modelprofile.com/flexharness-providers/auth';
|
|
6
|
-
import type {
|
|
7
|
-
IOpenAiChatGptAuthOptions,
|
|
8
|
-
IOpenAiChatGptTokenData,
|
|
9
|
-
IOpenAiChatGptTokenInfo,
|
|
10
|
-
} from '@modelprofile.com/flexharness-providers/auth';
|
|
11
2
|
|
|
12
3
|
export type TOpenAiChatGptAuthSource = 'smartai' | 'opencode' | 'codex';
|
|
13
4
|
export type TOpenAiChatGptAuthFileFormat = TOpenAiChatGptAuthSource | 'auto';
|
|
@@ -41,13 +32,13 @@ export interface IInspectOpenAiChatGptAuthSourcesOptions {
|
|
|
41
32
|
export interface IResolveOpenAiChatGptAuthOptions extends IInspectOpenAiChatGptAuthSourcesOptions {
|
|
42
33
|
refresh?: 'ifNeeded' | false;
|
|
43
34
|
writeBack?: Partial<Record<TOpenAiChatGptAuthSource, boolean>>;
|
|
44
|
-
authOptions?: IOpenAiChatGptAuthOptions;
|
|
35
|
+
authOptions?: plugins.IOpenAiChatGptAuthOptions;
|
|
45
36
|
}
|
|
46
37
|
|
|
47
38
|
export interface IResolvedOpenAiChatGptAuth {
|
|
48
39
|
source: TOpenAiChatGptAuthSource;
|
|
49
40
|
filePath: string;
|
|
50
|
-
tokenData: IOpenAiChatGptTokenData;
|
|
41
|
+
tokenData: plugins.IOpenAiChatGptTokenData;
|
|
51
42
|
refreshed: boolean;
|
|
52
43
|
}
|
|
53
44
|
|
|
@@ -140,7 +131,7 @@ export const getDefaultOpenAiChatGptAuthPath = (
|
|
|
140
131
|
export const normalizeOpenAiChatGptAuth = (
|
|
141
132
|
input: unknown,
|
|
142
133
|
format: TOpenAiChatGptAuthFileFormat = 'auto',
|
|
143
|
-
): IOpenAiChatGptTokenData | undefined => {
|
|
134
|
+
): plugins.IOpenAiChatGptTokenData | undefined => {
|
|
144
135
|
if (format === 'auto') {
|
|
145
136
|
return normalizeOpenAiChatGptAuth(input, 'smartai')
|
|
146
137
|
?? normalizeOpenAiChatGptAuth(input, 'opencode')
|
|
@@ -188,7 +179,7 @@ const readBoundedAuthJson = async (filePathArg: string): Promise<unknown> =>
|
|
|
188
179
|
export const readOpenAiChatGptAuthFile = async (
|
|
189
180
|
filePath: string,
|
|
190
181
|
format: TOpenAiChatGptAuthFileFormat = 'auto',
|
|
191
|
-
): Promise<IOpenAiChatGptTokenData | undefined> => {
|
|
182
|
+
): Promise<plugins.IOpenAiChatGptTokenData | undefined> => {
|
|
192
183
|
const parsed = await readBoundedAuthJson(filePath);
|
|
193
184
|
return normalizeOpenAiChatGptAuth(parsed, format);
|
|
194
185
|
};
|
|
@@ -232,7 +223,7 @@ export const resolveOpenAiChatGptAuth = async (
|
|
|
232
223
|
const refresh = options.refresh ?? 'ifNeeded';
|
|
233
224
|
|
|
234
225
|
for (const sourceConfig of sourceConfigs) {
|
|
235
|
-
let tokenData: IOpenAiChatGptTokenData | undefined;
|
|
226
|
+
let tokenData: plugins.IOpenAiChatGptTokenData | undefined;
|
|
236
227
|
try {
|
|
237
228
|
tokenData = await readOpenAiChatGptAuthFile(sourceConfig.filePath!, sourceConfig.format ?? sourceConfig.source);
|
|
238
229
|
} catch (error) {
|
|
@@ -273,7 +264,7 @@ export const resolveOpenAiChatGptAuth = async (
|
|
|
273
264
|
refreshed: false,
|
|
274
265
|
};
|
|
275
266
|
}
|
|
276
|
-
const refreshed = await refreshOpenAiChatGptTokenData(
|
|
267
|
+
const refreshed = await plugins.refreshOpenAiChatGptTokenData(
|
|
277
268
|
latestTokenData,
|
|
278
269
|
options.authOptions ?? {},
|
|
279
270
|
);
|
|
@@ -300,7 +291,7 @@ export const resolveOpenAiChatGptAuth = async (
|
|
|
300
291
|
|
|
301
292
|
export const writeOpenAiChatGptAuthFile = async (
|
|
302
293
|
filePath: string,
|
|
303
|
-
tokenData: IOpenAiChatGptTokenData,
|
|
294
|
+
tokenData: plugins.IOpenAiChatGptTokenData,
|
|
304
295
|
format: TOpenAiChatGptAuthFileFormat = 'smartai',
|
|
305
296
|
): Promise<void> => {
|
|
306
297
|
if (format === 'auto') throw new Error('The auto auth-file format cannot be written.');
|
|
@@ -311,7 +302,7 @@ export const writeOpenAiChatGptAuthFile = async (
|
|
|
311
302
|
|
|
312
303
|
const writeOpenAiChatGptAuthFileUnlocked = async (
|
|
313
304
|
filePath: string,
|
|
314
|
-
tokenData: IOpenAiChatGptTokenData,
|
|
305
|
+
tokenData: plugins.IOpenAiChatGptTokenData,
|
|
315
306
|
format: TOpenAiChatGptAuthFileFormat,
|
|
316
307
|
): Promise<void> => {
|
|
317
308
|
const current = await readJsonFileIfExists(filePath);
|
|
@@ -341,7 +332,7 @@ const normalizeSourceConfigs = (
|
|
|
341
332
|
const toInspection = (
|
|
342
333
|
source: TOpenAiChatGptAuthSource,
|
|
343
334
|
filePath: string,
|
|
344
|
-
tokenData: IOpenAiChatGptTokenData,
|
|
335
|
+
tokenData: plugins.IOpenAiChatGptTokenData,
|
|
345
336
|
now: Date,
|
|
346
337
|
): IOpenAiChatGptAuthSourceInspection => {
|
|
347
338
|
const expired = isExpired(tokenData, now);
|
|
@@ -358,7 +349,7 @@ const toInspection = (
|
|
|
358
349
|
};
|
|
359
350
|
};
|
|
360
351
|
|
|
361
|
-
const normalizeTokenObject = (input: Record<string, unknown>): IOpenAiChatGptTokenData | undefined => {
|
|
352
|
+
const normalizeTokenObject = (input: Record<string, unknown>): plugins.IOpenAiChatGptTokenData | undefined => {
|
|
362
353
|
const accessToken = stringValue(input.accessToken) ?? stringValue(input.access_token);
|
|
363
354
|
const refreshToken = stringValue(input.refreshToken) ?? stringValue(input.refresh_token);
|
|
364
355
|
const idToken = stringValue(input.idToken) ?? stringValue(input.id_token);
|
|
@@ -366,7 +357,7 @@ const normalizeTokenObject = (input: Record<string, unknown>): IOpenAiChatGptTok
|
|
|
366
357
|
return createTokenDataFromValues({ accessToken, refreshToken, idToken, accountId });
|
|
367
358
|
};
|
|
368
359
|
|
|
369
|
-
const normalizeOpenCodeAuth = (input: Record<string, unknown>): IOpenAiChatGptTokenData | undefined => {
|
|
360
|
+
const normalizeOpenCodeAuth = (input: Record<string, unknown>): plugins.IOpenAiChatGptTokenData | undefined => {
|
|
370
361
|
if (!isRecord(input.openai)) return undefined;
|
|
371
362
|
const accessToken = stringValue(input.openai.access);
|
|
372
363
|
const refreshToken = stringValue(input.openai.refresh);
|
|
@@ -381,7 +372,7 @@ const createTokenDataFromValues = (input: {
|
|
|
381
372
|
idToken?: string;
|
|
382
373
|
accountId?: string;
|
|
383
374
|
fallbackExpiresAt?: string;
|
|
384
|
-
}): IOpenAiChatGptTokenData | undefined => {
|
|
375
|
+
}): plugins.IOpenAiChatGptTokenData | undefined => {
|
|
385
376
|
if (!input.accessToken || !input.refreshToken) return undefined;
|
|
386
377
|
const parseToken = input.idToken ?? input.accessToken;
|
|
387
378
|
const tokenInfo = parseTokenInfo(parseToken, input.accountId, input.fallbackExpiresAt);
|
|
@@ -402,9 +393,9 @@ const createTokenDataFromValues = (input: {
|
|
|
402
393
|
};
|
|
403
394
|
};
|
|
404
395
|
|
|
405
|
-
const parseTokenInfo = (token: string, accountId?: string, fallbackExpiresAt?: string): IOpenAiChatGptTokenInfo => {
|
|
396
|
+
const parseTokenInfo = (token: string, accountId?: string, fallbackExpiresAt?: string): plugins.IOpenAiChatGptTokenInfo => {
|
|
406
397
|
try {
|
|
407
|
-
const tokenInfo = parseOpenAiChatGptTokenInfo(token);
|
|
398
|
+
const tokenInfo = plugins.parseOpenAiChatGptTokenInfo(token);
|
|
408
399
|
return {
|
|
409
400
|
...tokenInfo,
|
|
410
401
|
chatgptAccountId: tokenInfo.chatgptAccountId ?? accountId,
|
|
@@ -420,7 +411,7 @@ const parseTokenInfo = (token: string, accountId?: string, fallbackExpiresAt?: s
|
|
|
420
411
|
}
|
|
421
412
|
};
|
|
422
413
|
|
|
423
|
-
const toSmartAiAuthFile = (tokenData: IOpenAiChatGptTokenData): Record<string, unknown> => ({
|
|
414
|
+
const toSmartAiAuthFile = (tokenData: plugins.IOpenAiChatGptTokenData): Record<string, unknown> => ({
|
|
424
415
|
accessToken: tokenData.accessToken,
|
|
425
416
|
refreshToken: tokenData.refreshToken,
|
|
426
417
|
idToken: tokenData.idToken,
|
|
@@ -428,7 +419,7 @@ const toSmartAiAuthFile = (tokenData: IOpenAiChatGptTokenData): Record<string, u
|
|
|
428
419
|
tokenInfo: tokenData.tokenInfo,
|
|
429
420
|
});
|
|
430
421
|
|
|
431
|
-
const toCodexAuthFile = (current: Record<string, unknown>, tokenData: IOpenAiChatGptTokenData): Record<string, unknown> => ({
|
|
422
|
+
const toCodexAuthFile = (current: Record<string, unknown>, tokenData: plugins.IOpenAiChatGptTokenData): Record<string, unknown> => ({
|
|
432
423
|
...current,
|
|
433
424
|
OPENAI_API_KEY: current.OPENAI_API_KEY ?? null,
|
|
434
425
|
tokens: {
|
|
@@ -441,7 +432,7 @@ const toCodexAuthFile = (current: Record<string, unknown>, tokenData: IOpenAiCha
|
|
|
441
432
|
last_refresh: new Date().toISOString(),
|
|
442
433
|
});
|
|
443
434
|
|
|
444
|
-
const toOpenCodeAuthFile = (current: Record<string, unknown>, tokenData: IOpenAiChatGptTokenData): Record<string, unknown> => ({
|
|
435
|
+
const toOpenCodeAuthFile = (current: Record<string, unknown>, tokenData: plugins.IOpenAiChatGptTokenData): Record<string, unknown> => ({
|
|
445
436
|
...current,
|
|
446
437
|
openai: {
|
|
447
438
|
...(isRecord(current.openai) ? current.openai : {}),
|
|
@@ -453,12 +444,12 @@ const toOpenCodeAuthFile = (current: Record<string, unknown>, tokenData: IOpenAi
|
|
|
453
444
|
},
|
|
454
445
|
});
|
|
455
446
|
|
|
456
|
-
const shouldRefreshToken = (tokenData: IOpenAiChatGptTokenData, now: Date): boolean => {
|
|
447
|
+
const shouldRefreshToken = (tokenData: plugins.IOpenAiChatGptTokenData, now: Date): boolean => {
|
|
457
448
|
if (!tokenData.tokenInfo.expiresAt) return false;
|
|
458
449
|
return Date.parse(tokenData.tokenInfo.expiresAt) - now.getTime() < refreshWindowMs;
|
|
459
450
|
};
|
|
460
451
|
|
|
461
|
-
const isExpired = (tokenData: IOpenAiChatGptTokenData, now: Date): boolean => {
|
|
452
|
+
const isExpired = (tokenData: plugins.IOpenAiChatGptTokenData, now: Date): boolean => {
|
|
462
453
|
if (!tokenData.tokenInfo.expiresAt) return false;
|
|
463
454
|
return Date.parse(tokenData.tokenInfo.expiresAt) <= now.getTime();
|
|
464
455
|
};
|
|
@@ -11,3 +11,13 @@ import * as properLockfile from 'proper-lockfile';
|
|
|
11
11
|
|
|
12
12
|
export { crypto, fs, fsConstants, os, path, properLockfile };
|
|
13
13
|
export type { FileHandle };
|
|
14
|
+
|
|
15
|
+
// @modelprofile.com scope
|
|
16
|
+
import { parseOpenAiChatGptTokenInfo, refreshOpenAiChatGptTokenData } from '@modelprofile.com/flexharness-providers/auth';
|
|
17
|
+
|
|
18
|
+
export { parseOpenAiChatGptTokenInfo, refreshOpenAiChatGptTokenData };
|
|
19
|
+
export type {
|
|
20
|
+
IOpenAiChatGptAuthOptions,
|
|
21
|
+
IOpenAiChatGptTokenData,
|
|
22
|
+
IOpenAiChatGptTokenInfo,
|
|
23
|
+
} from '@modelprofile.com/flexharness-providers/auth';
|
|
@@ -7,7 +7,7 @@ export interface IAnthropicModelOptions extends plugins.ISmartAiOptions {
|
|
|
7
7
|
promptCaching?: boolean | plugins.ISmartAiCacheOptions;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
export const createAnthropicModelProvider = (): plugins.IModelProvider<IAnthropicModelOptions> => ({
|
|
10
|
+
export const createAnthropicModelProvider = (): plugins.IModelProvider<IAnthropicModelOptions, plugins.LanguageModelV4> => ({
|
|
11
11
|
id: 'anthropic',
|
|
12
12
|
getModel: (options) => {
|
|
13
13
|
const model = plugins.createAnthropic({ apiKey: options.apiKey })(options.model);
|
|
@@ -2,14 +2,24 @@ import { createAnthropic } from '@ai-sdk/anthropic';
|
|
|
2
2
|
import { wrapLanguageModel } from 'ai';
|
|
3
3
|
import {
|
|
4
4
|
createModelLimitMiddleware,
|
|
5
|
+
createSmartAiCachingMiddleware,
|
|
5
6
|
readEpochSeconds,
|
|
6
7
|
readJsonRecord,
|
|
7
8
|
} from '@modelprofile.com/flexharness-models';
|
|
8
|
-
export {
|
|
9
|
+
export {
|
|
10
|
+
createAnthropic,
|
|
11
|
+
createModelLimitMiddleware,
|
|
12
|
+
createSmartAiCachingMiddleware,
|
|
13
|
+
readEpochSeconds,
|
|
14
|
+
readJsonRecord,
|
|
15
|
+
wrapLanguageModel,
|
|
16
|
+
};
|
|
17
|
+
export type { LanguageModelV4Middleware } from '@ai-sdk/provider';
|
|
9
18
|
export type {
|
|
10
19
|
IModelCallFailure,
|
|
11
20
|
IModelProvider,
|
|
12
21
|
ISmartAiCacheOptions,
|
|
13
22
|
ISmartAiOptions,
|
|
23
|
+
LanguageModelV4,
|
|
14
24
|
TModelLimitClassifier,
|
|
15
25
|
} from '@modelprofile.com/flexharness-models';
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { createSmartAiCachingMiddleware } from '@modelprofile.com/flexharness-models';
|
|
3
|
-
import type { ISmartAiCacheOptions } from '@modelprofile.com/flexharness-models';
|
|
1
|
+
import * as plugins from './plugins.js';
|
|
4
2
|
|
|
5
3
|
/**
|
|
6
4
|
* Creates middleware that adds Anthropic prompt caching directives.
|
|
7
5
|
* Marks the last system message and last user message with ephemeral cache control,
|
|
8
6
|
* reducing input token cost and latency on repeated calls.
|
|
9
7
|
*/
|
|
10
|
-
export function createAnthropicCachingMiddleware(options: ISmartAiCacheOptions = {}): LanguageModelV4Middleware {
|
|
11
|
-
return createSmartAiCachingMiddleware({ ...options, provider: 'anthropic' });
|
|
8
|
+
export function createAnthropicCachingMiddleware(options: plugins.ISmartAiCacheOptions = {}): plugins.LanguageModelV4Middleware {
|
|
9
|
+
return plugins.createSmartAiCachingMiddleware({ ...options, provider: 'anthropic' });
|
|
12
10
|
}
|
|
@@ -2,7 +2,7 @@ import * as plugins from './plugins.js';
|
|
|
2
2
|
|
|
3
3
|
export interface IGoogleModelOptions extends plugins.ISmartAiOptions { provider: 'google'; }
|
|
4
4
|
|
|
5
|
-
export const createGoogleModelProvider = (): plugins.IModelProvider<IGoogleModelOptions> => ({
|
|
5
|
+
export const createGoogleModelProvider = (): plugins.IModelProvider<IGoogleModelOptions, plugins.LanguageModelV4> => ({
|
|
6
6
|
id: 'google',
|
|
7
7
|
getModel: (options) => plugins.createGoogle({ apiKey: options.apiKey })(options.model),
|
|
8
8
|
});
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createGoogle } from '@ai-sdk/google';
|
|
2
2
|
export { createGoogle };
|
|
3
|
-
export type { IModelProvider, ISmartAiOptions } from '@modelprofile.com/flexharness-models';
|
|
3
|
+
export type { IModelProvider, ISmartAiOptions, LanguageModelV4 } from '@modelprofile.com/flexharness-models';
|
|
@@ -2,7 +2,7 @@ import * as plugins from './plugins.js';
|
|
|
2
2
|
|
|
3
3
|
export interface IGroqModelOptions extends plugins.ISmartAiOptions { provider: 'groq'; }
|
|
4
4
|
|
|
5
|
-
export const createGroqModelProvider = (): plugins.IModelProvider<IGroqModelOptions> => ({
|
|
5
|
+
export const createGroqModelProvider = (): plugins.IModelProvider<IGroqModelOptions, plugins.LanguageModelV4> => ({
|
|
6
6
|
id: 'groq',
|
|
7
7
|
getModel: (options) => plugins.createGroq({ apiKey: options.apiKey })(options.model),
|
|
8
8
|
});
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createGroq } from '@ai-sdk/groq';
|
|
2
2
|
export { createGroq };
|
|
3
|
-
export type { IModelProvider, ISmartAiOptions } from '@modelprofile.com/flexharness-models';
|
|
3
|
+
export type { IModelProvider, ISmartAiOptions, LanguageModelV4 } from '@modelprofile.com/flexharness-models';
|
|
@@ -2,7 +2,7 @@ import * as plugins from './plugins.js';
|
|
|
2
2
|
|
|
3
3
|
export interface IMistralModelOptions extends plugins.ISmartAiOptions { provider: 'mistral'; }
|
|
4
4
|
|
|
5
|
-
export const createMistralModelProvider = (): plugins.IModelProvider<IMistralModelOptions> => ({
|
|
5
|
+
export const createMistralModelProvider = (): plugins.IModelProvider<IMistralModelOptions, plugins.LanguageModelV4> => ({
|
|
6
6
|
id: 'mistral',
|
|
7
7
|
getModel: (options) => plugins.createMistral({ apiKey: options.apiKey })(options.model),
|
|
8
8
|
});
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createMistral } from '@ai-sdk/mistral';
|
|
2
2
|
export { createMistral };
|
|
3
|
-
export type { IModelProvider, ISmartAiOptions } from '@modelprofile.com/flexharness-models';
|
|
3
|
+
export type { IModelProvider, ISmartAiOptions, LanguageModelV4 } from '@modelprofile.com/flexharness-models';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type * as plugins from './plugins.js';
|
|
2
2
|
import type { IOllamaModelRequest } from './interfaces.js';
|
|
3
3
|
import { createOllamaModel } from './smartai.provider.ollama.js';
|
|
4
|
-
export const createOllamaModelProvider = (): IModelProvider<IOllamaModelRequest> => ({
|
|
4
|
+
export const createOllamaModelProvider = (): plugins.IModelProvider<IOllamaModelRequest> => ({
|
|
5
5
|
id: 'ollama', getModel: createOllamaModel,
|
|
6
6
|
});
|
|
7
7
|
export { createOllamaModel };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type * as plugins from './plugins.js';
|
|
2
2
|
|
|
3
|
-
export interface IOllamaModelRequest extends ISmartAiOptions {
|
|
3
|
+
export interface IOllamaModelRequest extends plugins.ISmartAiOptions {
|
|
4
4
|
provider: 'ollama';
|
|
5
5
|
ollamaOptions?: IOllamaModelOptions;
|
|
6
6
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type {
|
|
2
|
+
LanguageModelV3,
|
|
3
|
+
LanguageModelV3CallOptions,
|
|
4
|
+
LanguageModelV3Content,
|
|
5
|
+
LanguageModelV3FinishReason,
|
|
6
|
+
LanguageModelV3GenerateResult,
|
|
7
|
+
LanguageModelV3Prompt,
|
|
8
|
+
LanguageModelV3StreamPart,
|
|
9
|
+
LanguageModelV3StreamResult,
|
|
10
|
+
LanguageModelV3Usage,
|
|
11
|
+
} from '@ai-sdk/provider';
|
|
12
|
+
export type { IModelProvider, ISmartAiOptions } from '@modelprofile.com/flexharness-models';
|